chore: Remove the ability to add filter-box charts when DASHBOARD_NATIVE_FILTERS feature is enabled (#23142)

This commit is contained in:
John Bodley 2023-03-02 07:30:42 +13:00 committed by GitHub
parent 5f0c320415
commit 134acba99a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 22 deletions

View File

@ -22,6 +22,7 @@ import rison from 'rison';
import { addDangerToast } from 'src/components/MessageToasts/actions'; import { addDangerToast } from 'src/components/MessageToasts/actions';
import { getClientErrorObject } from 'src/utils/getClientErrorObject'; import { getClientErrorObject } from 'src/utils/getClientErrorObject';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
export const SET_ALL_SLICES = 'SET_ALL_SLICES'; export const SET_ALL_SLICES = 'SET_ALL_SLICES';
const FETCH_SLICES_PAGE_SIZE = 200; const FETCH_SLICES_PAGE_SIZE = 200;
@ -55,6 +56,14 @@ export function fetchSlices(
? [{ col: 'slice_name', opr: 'chart_all_text', value: filter_value }] ? [{ 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',
});
}
const cloneSlices = { ...slices }; const cloneSlices = { ...slices };
return SupersetClient.get({ return SupersetClient.get({

View File

@ -41,6 +41,7 @@ import { Select } from 'src/components';
import Loading from 'src/components/Loading'; import Loading from 'src/components/Loading';
import { setSaveChartModalVisibility } from 'src/explore/actions/saveModalActions'; import { setSaveChartModalVisibility } from 'src/explore/actions/saveModalActions';
import { SaveActionType } from 'src/explore/types'; import { SaveActionType } from 'src/explore/types';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
// Session storage key for recent dashboard // Session storage key for recent dashboard
const SK_DASHBOARD_ID = 'save_chart_recent_dashboard'; const SK_DASHBOARD_ID = 'save_chart_recent_dashboard';
@ -69,6 +70,7 @@ type SaveModalState = {
action: SaveActionType; action: SaveActionType;
isLoading: boolean; isLoading: boolean;
saveStatus?: string | null; saveStatus?: string | null;
vizType?: string;
}; };
export const StyledModal = styled(Modal)` export const StyledModal = styled(Modal)`
@ -92,6 +94,7 @@ class SaveModal extends React.Component<SaveModalProps, SaveModalState> {
alert: null, alert: null,
action: this.canOverwriteSlice() ? 'overwrite' : 'saveas', action: this.canOverwriteSlice() ? 'overwrite' : 'saveas',
isLoading: false, isLoading: false,
vizType: props.form_data?.viz_type,
}; };
this.onDashboardSelectChange = this.onDashboardSelectChange.bind(this); this.onDashboardSelectChange = this.onDashboardSelectChange.bind(this);
this.onSliceNameChange = this.onSliceNameChange.bind(this); this.onSliceNameChange = this.onSliceNameChange.bind(this);
@ -339,27 +342,32 @@ class SaveModal extends React.Component<SaveModalProps, SaveModalState> {
/> />
</FormItem> </FormItem>
)} )}
<FormItem {!(
label={t('Add to dashboard')} isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS) &&
data-test="save-chart-modal-select-dashboard-form" this.state.vizType === 'filter_box'
> ) && (
<Select <FormItem
allowClear label={t('Add to dashboard')}
allowNewOptions data-test="save-chart-modal-select-dashboard-form"
ariaLabel={t('Select a dashboard')} >
options={this.props.dashboards} <Select
onChange={this.onDashboardSelectChange} allowClear
value={dashboardSelectValue || undefined} allowNewOptions
placeholder={ ariaLabel={t('Select a dashboard')}
<div> options={this.props.dashboards}
<b>{t('Select')}</b> onChange={this.onDashboardSelectChange}
{t(' a dashboard OR ')} value={dashboardSelectValue || undefined}
<b>{t('create')}</b> placeholder={
{t(' a new one')} <div>
</div> <b>{t('Select')}</b>
} {t(' a dashboard OR ')}
/> <b>{t('create')}</b>
</FormItem> {t(' a new one')}
</div>
}
/>
</FormItem>
)}
</Form> </Form>
); );
}; };
@ -376,7 +384,9 @@ class SaveModal extends React.Component<SaveModalProps, SaveModalState> {
!this.state.newSliceName || !this.state.newSliceName ||
(!this.state.saveToDashboardId && !this.state.newDashboardName) || (!this.state.saveToDashboardId && !this.state.newDashboardName) ||
(this.props.datasource?.type !== DatasourceType.Table && (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)} onClick={() => this.saveOrOverwrite(true)}
> >

View File

@ -33,6 +33,7 @@ import Button from 'src/components/Button';
import { AsyncSelect, Steps } from 'src/components'; import { AsyncSelect, Steps } from 'src/components';
import { Tooltip } from 'src/components/Tooltip'; import { Tooltip } from 'src/components/Tooltip';
import withToasts from 'src/components/MessageToasts/withToasts'; import withToasts from 'src/components/MessageToasts/withToasts';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
import VizTypeGallery, { import VizTypeGallery, {
MAX_ADVISABLE_VIZ_GALLERY_WIDTH, MAX_ADVISABLE_VIZ_GALLERY_WIDTH,
@ -66,6 +67,13 @@ const ELEMENTS_EXCEPT_VIZ_GALLERY = ESTIMATED_NAV_HEIGHT + 250;
const bootstrapData = getBootstrapData(); const bootstrapData = getBootstrapData();
const denyList: string[] = bootstrapData.common.conf.VIZ_TYPE_DENYLIST || []; 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` const StyledContainer = styled.div`
${({ theme }) => ` ${({ theme }) => `
flex: 1 1 auto; flex: 1 1 auto;