From 636c54fb50139732c9c9ab46d12f8fd0fbc59e74 Mon Sep 17 00:00:00 2001 From: John Bodley Date: Wed, 22 Feb 2023 10:54:54 +1300 Subject: [PATCH 1/2] chore: Remove the ability to add filter-box charts when DASHBOARD_NATIVE_FILTERS feature is enabled --- .../src/dashboard/actions/sliceEntities.js | 11 ++++ .../src/explore/components/SaveModal.tsx | 54 +++++++++++-------- .../src/pages/ChartCreation/index.tsx | 8 +++ 3 files changed, 51 insertions(+), 22 deletions(-) diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.js b/superset-frontend/src/dashboard/actions/sliceEntities.js index 74fd8fd7f2520..e2ea646128742 100644 --- a/superset-frontend/src/dashboard/actions/sliceEntities.js +++ b/superset-frontend/src/dashboard/actions/sliceEntities.js @@ -22,6 +22,7 @@ import rison from 'rison'; import { addDangerToast } from 'src/components/MessageToasts/actions'; import { getClientErrorObject } from 'src/utils/getClientErrorObject'; +import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; export const SET_ALL_SLICES = 'SET_ALL_SLICES'; const FETCH_SLICES_PAGE_SIZE = 200; @@ -56,6 +57,16 @@ export function fetchSlices( ? [{ col: 'slice_name', opr: 'chart_all_text', value: filter_value }] : []; + if (isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS)) { + additional_filters.push({ + col: 'viz_type', + opr: 'neq', + value: 'filter_box', + }); + } + + isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS); + const cloneSlices = { ...slices }; return SupersetClient.get({ diff --git a/superset-frontend/src/explore/components/SaveModal.tsx b/superset-frontend/src/explore/components/SaveModal.tsx index d62cb4d898c6c..8d7bd2d895547 100644 --- a/superset-frontend/src/explore/components/SaveModal.tsx +++ b/superset-frontend/src/explore/components/SaveModal.tsx @@ -41,6 +41,7 @@ import { Select } from 'src/components'; import Loading from 'src/components/Loading'; import { setSaveChartModalVisibility } from 'src/explore/actions/saveModalActions'; import { SaveActionType } from 'src/explore/types'; +import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; // Session storage key for recent dashboard const SK_DASHBOARD_ID = 'save_chart_recent_dashboard'; @@ -69,6 +70,7 @@ type SaveModalState = { action: SaveActionType; isLoading: boolean; saveStatus?: string | null; + vizType?: string; }; export const StyledModal = styled(Modal)` @@ -92,6 +94,7 @@ class SaveModal extends React.Component { alert: null, action: this.canOverwriteSlice() ? 'overwrite' : 'saveas', isLoading: false, + vizType: props.form_data?.viz_type, }; this.onDashboardSelectChange = this.onDashboardSelectChange.bind(this); this.onSliceNameChange = this.onSliceNameChange.bind(this); @@ -339,27 +342,32 @@ class SaveModal extends React.Component { /> )} - - + {t('Select')} + {t(' a dashboard OR ')} + {t('create')} + {t(' a new one')} + + } + /> + + )} ); }; @@ -376,7 +384,9 @@ class SaveModal extends React.Component { !this.state.newSliceName || (!this.state.saveToDashboardId && !this.state.newDashboardName) || (this.props.datasource?.type !== DatasourceType.Table && - !this.state.datasetName) + !this.state.datasetName) || + (isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS) && + this.state.vizType === 'filter_box') } onClick={() => this.saveOrOverwrite(true)} > diff --git a/superset-frontend/src/pages/ChartCreation/index.tsx b/superset-frontend/src/pages/ChartCreation/index.tsx index 2a01a9123af12..baa0c78f1a08d 100644 --- a/superset-frontend/src/pages/ChartCreation/index.tsx +++ b/superset-frontend/src/pages/ChartCreation/index.tsx @@ -33,6 +33,7 @@ import Button from 'src/components/Button'; import { AsyncSelect, Steps } from 'src/components'; import { Tooltip } from 'src/components/Tooltip'; import withToasts from 'src/components/MessageToasts/withToasts'; +import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; import VizTypeGallery, { MAX_ADVISABLE_VIZ_GALLERY_WIDTH, @@ -66,6 +67,13 @@ const ELEMENTS_EXCEPT_VIZ_GALLERY = ESTIMATED_NAV_HEIGHT + 250; const bootstrapData = getBootstrapData(); const denyList: string[] = bootstrapData.common.conf.VIZ_TYPE_DENYLIST || []; +if ( + isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS) && + !('filter_box' in denyList) +) { + denyList.push('filter_box'); +} + const StyledContainer = styled.div` ${({ theme }) => ` flex: 1 1 auto; From 32ff91cc8b2b035c18421a5234ce68f46dcb2eef Mon Sep 17 00:00:00 2001 From: John Bodley <4567245+john-bodley@users.noreply.github.com> Date: Fri, 24 Feb 2023 06:21:58 +1300 Subject: [PATCH 2/2] Update sliceEntities.js --- superset-frontend/src/dashboard/actions/sliceEntities.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.js b/superset-frontend/src/dashboard/actions/sliceEntities.js index e2ea646128742..a40dc5de91088 100644 --- a/superset-frontend/src/dashboard/actions/sliceEntities.js +++ b/superset-frontend/src/dashboard/actions/sliceEntities.js @@ -65,8 +65,6 @@ export function fetchSlices( }); } - isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS); - const cloneSlices = { ...slices }; return SupersetClient.get({