mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
feat(filter panel): hide filter panel on all dashboard by default. (#32870)
This commit is contained in:
@@ -45,6 +45,7 @@ export enum FeatureFlag {
|
||||
EnableTemplateProcessing = 'ENABLE_TEMPLATE_PROCESSING',
|
||||
EscapeMarkdownHtml = 'ESCAPE_MARKDOWN_HTML',
|
||||
EstimateQueryCost = 'ESTIMATE_QUERY_COST',
|
||||
FilterBarClosedByDefault = 'FILTERBAR_CLOSED_BY_DEFAULT',
|
||||
GlobalAsyncQueries = 'GLOBAL_ASYNC_QUERIES',
|
||||
ListviewsDefaultCardView = 'LISTVIEWS_DEFAULT_CARD_VIEW',
|
||||
ScheduledQueries = 'SCHEDULED_QUERIES',
|
||||
|
||||
@@ -23,6 +23,11 @@ import {
|
||||
within,
|
||||
screen,
|
||||
} from 'spec/helpers/testing-library';
|
||||
import { FeatureFlag } from '@superset-ui/core';
|
||||
import {
|
||||
OPEN_FILTER_BAR_WIDTH,
|
||||
CLOSED_FILTER_BAR_WIDTH,
|
||||
} from 'src/dashboard/constants';
|
||||
import DashboardBuilder from 'src/dashboard/components/DashboardBuilder/DashboardBuilder';
|
||||
import useStoredSidebarWidth from 'src/components/ResizableSidebar/useStoredSidebarWidth';
|
||||
import {
|
||||
@@ -268,6 +273,46 @@ describe('DashboardBuilder', () => {
|
||||
expect(filterbar).toHaveStyleRule('width', `${expectedValue}px`);
|
||||
});
|
||||
|
||||
it('filter panel state when featureflag is true', () => {
|
||||
window.featureFlags = {
|
||||
[FeatureFlag.FilterBarClosedByDefault]: true,
|
||||
};
|
||||
const setter = jest.fn();
|
||||
(useStoredSidebarWidth as jest.Mock).mockImplementation(() => [
|
||||
CLOSED_FILTER_BAR_WIDTH,
|
||||
setter,
|
||||
]);
|
||||
const { getByTestId } = setup({
|
||||
dashboardInfo: {
|
||||
...mockState.dashboardInfo,
|
||||
dash_edit_perm: true,
|
||||
},
|
||||
});
|
||||
|
||||
const filterbar = getByTestId('dashboard-filters-panel');
|
||||
expect(filterbar).toHaveStyleRule('width', `${CLOSED_FILTER_BAR_WIDTH}px`);
|
||||
});
|
||||
|
||||
it('filter panel state when featureflag is false', () => {
|
||||
window.featureFlags = {
|
||||
[FeatureFlag.FilterBarClosedByDefault]: false,
|
||||
};
|
||||
const setter = jest.fn();
|
||||
(useStoredSidebarWidth as jest.Mock).mockImplementation(() => [
|
||||
OPEN_FILTER_BAR_WIDTH,
|
||||
setter,
|
||||
]);
|
||||
const { getByTestId } = setup({
|
||||
dashboardInfo: {
|
||||
...mockState.dashboardInfo,
|
||||
dash_edit_perm: true,
|
||||
},
|
||||
});
|
||||
|
||||
const filterbar = getByTestId('dashboard-filters-panel');
|
||||
expect(filterbar).toHaveStyleRule('width', `${OPEN_FILTER_BAR_WIDTH}px`);
|
||||
});
|
||||
|
||||
it('should not render the filter bar when nativeFiltersEnabled is false', () => {
|
||||
jest.spyOn(useNativeFiltersModule, 'useNativeFilters').mockReturnValue({
|
||||
showDashboard: true,
|
||||
|
||||
@@ -21,6 +21,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { URL_PARAMS } from 'src/constants';
|
||||
import { getUrlParam } from 'src/utils/urlUtils';
|
||||
import { RootState } from 'src/dashboard/types';
|
||||
import { isFeatureEnabled, FeatureFlag } from '@superset-ui/core';
|
||||
import {
|
||||
useFilters,
|
||||
useNativeFiltersDataMask,
|
||||
@@ -71,6 +72,8 @@ export const useNativeFilters = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
(isFeatureEnabled(FeatureFlag.FilterBarClosedByDefault) &&
|
||||
expandFilters === null) ||
|
||||
expandFilters === false ||
|
||||
(filterValues.length === 0 && nativeFiltersEnabled)
|
||||
) {
|
||||
|
||||
@@ -531,6 +531,8 @@ DEFAULT_FEATURE_FLAGS: dict[str, bool] = {
|
||||
"DRILL_TO_DETAIL": True, # deprecated
|
||||
"DRILL_BY": True,
|
||||
"DATAPANEL_CLOSED_BY_DEFAULT": False,
|
||||
# When you open the dashboard, the filter panel will be closed
|
||||
"FILTERBAR_CLOSED_BY_DEFAULT": False,
|
||||
# The feature is off by default, and currently only supported in Presto and Postgres, # noqa: E501
|
||||
# and Bigquery.
|
||||
# It also needs to be enabled on a per-database basis, by adding the key/value pair
|
||||
|
||||
Reference in New Issue
Block a user