From 19151d1e4a6d735f4229a28eae2c6b00e1409227 Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Tue, 22 Oct 2024 23:07:40 +0300 Subject: [PATCH 01/14] fix: fixed Add Metrics to Tree Chart (#29158) --- .../plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx index 34d65a27d315..26fafbdc1b7f 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx @@ -89,9 +89,7 @@ const controlPanel: ControlPanelConfig = { { name: 'metric', config: { - ...optionalEntity, - type: 'DndMetricSelect', - label: t('Metric'), + ...sharedControls.metric, description: t('Metric for node values'), }, }, From 35aaeb66bf9d01a4e3f1cb7c9c92989b1503b25e Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Tue, 22 Oct 2024 23:45:27 +0300 Subject: [PATCH 02/14] fix: clear modal after CSS templates is added --- .../src/features/cssTemplates/CssTemplateModal.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx b/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx index 16af9e7039d3..74f0491543ea 100644 --- a/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx +++ b/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx @@ -131,7 +131,10 @@ const CssTemplateModal: FunctionComponent = ({ if (onCssTemplateAdd) { onCssTemplateAdd(); } - + setCurrentCssTemplate({ + template_name: '', + css: '', + }); hide(); }); } From db3afda17db52cf217af4f20b09a4d1e09848117 Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Wed, 23 Oct 2024 22:15:52 +0300 Subject: [PATCH 03/14] Revert "fix: clear modal after CSS templates is added" This reverts commit 35aaeb66bf9d01a4e3f1cb7c9c92989b1503b25e. --- .../src/features/cssTemplates/CssTemplateModal.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx b/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx index 74f0491543ea..16af9e7039d3 100644 --- a/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx +++ b/superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx @@ -131,10 +131,7 @@ const CssTemplateModal: FunctionComponent = ({ if (onCssTemplateAdd) { onCssTemplateAdd(); } - setCurrentCssTemplate({ - template_name: '', - css: '', - }); + hide(); }); } From 9eea2e6fd6ac5cf4f41ae91b2941a9bfea82718b Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Mon, 25 Nov 2024 21:45:32 +0300 Subject: [PATCH 04/14] fix: tree metrics exclude validator --- .../plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx index 26fafbdc1b7f..4d8b0fa978ee 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx @@ -90,6 +90,8 @@ const controlPanel: ControlPanelConfig = { name: 'metric', config: { ...sharedControls.metric, + clearable: true, + validators: [], description: t('Metric for node values'), }, }, From 368789af86b963b615b6348beb9a4fd9b40cd4af Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Tue, 25 Mar 2025 15:06:36 +0300 Subject: [PATCH 05/14] fix: revert #30679 --- .../plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx index 4d8b0fa978ee..34d65a27d315 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx @@ -89,9 +89,9 @@ const controlPanel: ControlPanelConfig = { { name: 'metric', config: { - ...sharedControls.metric, - clearable: true, - validators: [], + ...optionalEntity, + type: 'DndMetricSelect', + label: t('Metric'), description: t('Metric for node values'), }, }, From 18ea1e0e1f9b34ee17aabb0afe4b96c862cb5bde Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Tue, 25 Mar 2025 21:53:28 +0300 Subject: [PATCH 06/14] fix: add [#30679] --- .../plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx index 34d65a27d315..4d8b0fa978ee 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx @@ -89,9 +89,9 @@ const controlPanel: ControlPanelConfig = { { name: 'metric', config: { - ...optionalEntity, - type: 'DndMetricSelect', - label: t('Metric'), + ...sharedControls.metric, + clearable: true, + validators: [], description: t('Metric for node values'), }, }, From c96b2ca7d39845c2b350f9a9f52fd9fee26cc4fd Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Wed, 26 Mar 2025 23:02:19 +0300 Subject: [PATCH 07/14] feature: add flag FILTERBAR_CLOSED_BY_DEFAULT --- .../packages/superset-ui-core/src/utils/featureFlags.ts | 1 + .../src/dashboard/components/DashboardBuilder/state.ts | 8 ++++++-- superset/config.py | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts index 7890fd7c573c..1cd7eec5ad76 100644 --- a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts +++ b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts @@ -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', diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts b/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts index ec1cc0bc1f0f..68170e1ba946 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts @@ -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, @@ -68,8 +69,11 @@ export const useNativeFilters = () => { useEffect(() => { if ( - expandFilters === false || - (filterValues.length === 0 && nativeFiltersEnabled) + isFeatureEnabled(FeatureFlag.FilterBarClosedByDefault) && + expandFilters === null + ? true + : expandFilters === false || + (filterValues.length === 0 && nativeFiltersEnabled) ) { toggleDashboardFiltersOpen(false); } else { diff --git a/superset/config.py b/superset/config.py index 7d667ed699a2..03bfd886b597 100644 --- a/superset/config.py +++ b/superset/config.py @@ -527,6 +527,8 @@ class D3TimeFormat(TypedDict, total=False): "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": True, # 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 From 943b74b7c853242ccd52bfe1ee3ce3930dcc20c0 Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Wed, 26 Mar 2025 23:07:11 +0300 Subject: [PATCH 08/14] fix: revert metric control --- .../plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx index 4d8b0fa978ee..34d65a27d315 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Tree/controlPanel.tsx @@ -89,9 +89,9 @@ const controlPanel: ControlPanelConfig = { { name: 'metric', config: { - ...sharedControls.metric, - clearable: true, - validators: [], + ...optionalEntity, + type: 'DndMetricSelect', + label: t('Metric'), description: t('Metric for node values'), }, }, From 95adf44745d844900200f536e9150ed996b102c6 Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Wed, 26 Mar 2025 23:25:07 +0300 Subject: [PATCH 09/14] fix: simplified condition --- .../src/dashboard/components/DashboardBuilder/state.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts b/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts index 68170e1ba946..2aabec18aa13 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/state.ts @@ -69,11 +69,10 @@ export const useNativeFilters = () => { useEffect(() => { if ( - isFeatureEnabled(FeatureFlag.FilterBarClosedByDefault) && - expandFilters === null - ? true - : expandFilters === false || - (filterValues.length === 0 && nativeFiltersEnabled) + (isFeatureEnabled(FeatureFlag.FilterBarClosedByDefault) && + expandFilters === null) || + expandFilters === false || + (filterValues.length === 0 && nativeFiltersEnabled) ) { toggleDashboardFiltersOpen(false); } else { From d9c7ab7d984e66c6bf31c7a9231bc2eafcddc6b7 Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Thu, 27 Mar 2025 00:50:33 +0300 Subject: [PATCH 10/14] fix: add test --- .../DashboardBuilder.test.tsx | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx index 8a83e995475b..760c1d0a16ac 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx @@ -18,6 +18,11 @@ */ import fetchMock from 'fetch-mock'; import { fireEvent, render, within } 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 { @@ -262,4 +267,44 @@ describe('DashboardBuilder', () => { const filterbar = getByTestId('dashboard-filters-panel'); expect(filterbar).toHaveStyleRule('width', `${expectedValue}px`); }); + + it('filter panel state when featureflag is true', () => { + (global as any).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', () => { + (global as any).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`); + }); }); From 1d9754d04b67249afd4cb4d0bfce57c0b1270a25 Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Thu, 27 Mar 2025 23:48:33 +0300 Subject: [PATCH 11/14] fix: fix test feature flag --- .../components/DashboardBuilder/DashboardBuilder.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx index 760c1d0a16ac..acfb6c511d91 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx @@ -269,7 +269,7 @@ describe('DashboardBuilder', () => { }); it('filter panel state when featureflag is true', () => { - (global as any).featureFlags = { + window.featureFlags = { [FeatureFlag.FilterBarClosedByDefault]: true, }; const setter = jest.fn(); @@ -289,7 +289,7 @@ describe('DashboardBuilder', () => { }); it('filter panel state when featureflag is false', () => { - (global as any).featureFlags = { + window.featureFlags = { [FeatureFlag.FilterBarClosedByDefault]: false, }; const setter = jest.fn(); From 77a736b9ed11adaa57b5d5f3e82e71866f572c24 Mon Sep 17 00:00:00 2001 From: SBIN2010 Date: Fri, 28 Mar 2025 10:36:37 +0300 Subject: [PATCH 12/14] fix: flag default false --- superset/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/config.py b/superset/config.py index 03bfd886b597..a6eb3cd68f6a 100644 --- a/superset/config.py +++ b/superset/config.py @@ -528,7 +528,7 @@ class D3TimeFormat(TypedDict, total=False): "DRILL_BY": True, "DATAPANEL_CLOSED_BY_DEFAULT": False, # When you open the dashboard, the filter panel will be closed - "FILTERBAR_CLOSED_BY_DEFAULT": True, + "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 From 47af9a79c44c1a213e1402d9ac3386a709ba3eda Mon Sep 17 00:00:00 2001 From: SBIN2010 <132096459+SBIN2010@users.noreply.github.com> Date: Fri, 4 Apr 2025 11:23:10 +0300 Subject: [PATCH 13/14] Update DashboardBuilder.test.tsx --- .../DashboardBuilder.test.tsx | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx index acfb6c511d91..d1a44dd0a09f 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx @@ -37,6 +37,7 @@ import { import { storeWithState } from 'spec/fixtures/mockStore'; import mockState from 'spec/fixtures/mockState'; import { DASHBOARD_ROOT_ID } from 'src/dashboard/util/constants'; +import * as useNativeFiltersModule from './state'; fetchMock.get('glob:*/csstemplateasyncmodelview/api/read', {}); fetchMock.put('glob:*/api/v1/dashboard/*', {}); @@ -268,6 +269,47 @@ describe('DashboardBuilder', () => { expect(filterbar).toHaveStyleRule('width', `${expectedValue}px`); }); + it('should not render the filter bar when nativeFiltersEnabled is false', () => { + jest.spyOn(useNativeFiltersModule, 'useNativeFilters').mockReturnValue({ + showDashboard: true, + missingInitialFilters: [], + dashboardFiltersOpen: true, + toggleDashboardFiltersOpen: jest.fn(), + nativeFiltersEnabled: false, + }); + const { queryByTestId } = setup(); + + expect(queryByTestId('dashboard-filters-panel')).not.toBeInTheDocument(); + }); + + it('should render the filter bar when nativeFiltersEnabled is true and not in edit mode', () => { + jest.spyOn(useNativeFiltersModule, 'useNativeFilters').mockReturnValue({ + showDashboard: true, + missingInitialFilters: [], + dashboardFiltersOpen: true, + toggleDashboardFiltersOpen: jest.fn(), + nativeFiltersEnabled: true, + }); + const { queryByTestId } = setup(); + + expect(queryByTestId('dashboard-filters-panel')).toBeInTheDocument(); + }); + + it('should not render the filter bar when in edit mode even if nativeFiltersEnabled is true', () => { + jest.spyOn(useNativeFiltersModule, 'useNativeFilters').mockReturnValue({ + showDashboard: true, + missingInitialFilters: [], + dashboardFiltersOpen: true, + toggleDashboardFiltersOpen: jest.fn(), + nativeFiltersEnabled: true, + }); + const { queryByTestId } = setup({ + dashboardState: { ...mockState.dashboardState, editMode: true }, + }); + + expect(queryByTestId('dashboard-filters-panel')).not.toBeInTheDocument(); + }); + it('filter panel state when featureflag is true', () => { window.featureFlags = { [FeatureFlag.FilterBarClosedByDefault]: true, From 49d4d79e81adf349c16db215747cd9be67497489 Mon Sep 17 00:00:00 2001 From: SBIN2010 <132096459+SBIN2010@users.noreply.github.com> Date: Fri, 4 Apr 2025 11:35:25 +0300 Subject: [PATCH 14/14] Update DashboardBuilder.test.tsx --- .../DashboardBuilder.test.tsx | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx index d1a44dd0a09f..acfb6c511d91 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx @@ -37,7 +37,6 @@ import { import { storeWithState } from 'spec/fixtures/mockStore'; import mockState from 'spec/fixtures/mockState'; import { DASHBOARD_ROOT_ID } from 'src/dashboard/util/constants'; -import * as useNativeFiltersModule from './state'; fetchMock.get('glob:*/csstemplateasyncmodelview/api/read', {}); fetchMock.put('glob:*/api/v1/dashboard/*', {}); @@ -269,47 +268,6 @@ describe('DashboardBuilder', () => { expect(filterbar).toHaveStyleRule('width', `${expectedValue}px`); }); - it('should not render the filter bar when nativeFiltersEnabled is false', () => { - jest.spyOn(useNativeFiltersModule, 'useNativeFilters').mockReturnValue({ - showDashboard: true, - missingInitialFilters: [], - dashboardFiltersOpen: true, - toggleDashboardFiltersOpen: jest.fn(), - nativeFiltersEnabled: false, - }); - const { queryByTestId } = setup(); - - expect(queryByTestId('dashboard-filters-panel')).not.toBeInTheDocument(); - }); - - it('should render the filter bar when nativeFiltersEnabled is true and not in edit mode', () => { - jest.spyOn(useNativeFiltersModule, 'useNativeFilters').mockReturnValue({ - showDashboard: true, - missingInitialFilters: [], - dashboardFiltersOpen: true, - toggleDashboardFiltersOpen: jest.fn(), - nativeFiltersEnabled: true, - }); - const { queryByTestId } = setup(); - - expect(queryByTestId('dashboard-filters-panel')).toBeInTheDocument(); - }); - - it('should not render the filter bar when in edit mode even if nativeFiltersEnabled is true', () => { - jest.spyOn(useNativeFiltersModule, 'useNativeFilters').mockReturnValue({ - showDashboard: true, - missingInitialFilters: [], - dashboardFiltersOpen: true, - toggleDashboardFiltersOpen: jest.fn(), - nativeFiltersEnabled: true, - }); - const { queryByTestId } = setup({ - dashboardState: { ...mockState.dashboardState, editMode: true }, - }); - - expect(queryByTestId('dashboard-filters-panel')).not.toBeInTheDocument(); - }); - it('filter panel state when featureflag is true', () => { window.featureFlags = { [FeatureFlag.FilterBarClosedByDefault]: true,