Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions superset-frontend/src/dashboard/actions/sliceEntities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,6 +57,14 @@ 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',
});
}

const cloneSlices = { ...slices };

return SupersetClient.get({
Expand Down
54 changes: 32 additions & 22 deletions superset-frontend/src/explore/components/SaveModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -69,6 +70,7 @@ type SaveModalState = {
action: SaveActionType;
isLoading: boolean;
saveStatus?: string | null;
vizType?: string;
};

export const StyledModal = styled(Modal)`
Expand All @@ -92,6 +94,7 @@ class SaveModal extends React.Component<SaveModalProps, SaveModalState> {
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);
Expand Down Expand Up @@ -339,27 +342,32 @@ class SaveModal extends React.Component<SaveModalProps, SaveModalState> {
/>
</FormItem>
)}
<FormItem
label={t('Add to dashboard')}
data-test="save-chart-modal-select-dashboard-form"
>
<Select
allowClear
allowNewOptions
ariaLabel={t('Select a dashboard')}
options={this.props.dashboards}
onChange={this.onDashboardSelectChange}
value={dashboardSelectValue || undefined}
placeholder={
<div>
<b>{t('Select')}</b>
{t(' a dashboard OR ')}
<b>{t('create')}</b>
{t(' a new one')}
</div>
}
/>
</FormItem>
{!(
isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS) &&
this.state.vizType === 'filter_box'
) && (
<FormItem
label={t('Add to dashboard')}
data-test="save-chart-modal-select-dashboard-form"
>
<Select
allowClear
allowNewOptions
ariaLabel={t('Select a dashboard')}
options={this.props.dashboards}
onChange={this.onDashboardSelectChange}
value={dashboardSelectValue || undefined}
placeholder={
<div>
<b>{t('Select')}</b>
{t(' a dashboard OR ')}
<b>{t('create')}</b>
{t(' a new one')}
</div>
}
/>
</FormItem>
)}
</Form>
);
};
Expand All @@ -376,7 +384,9 @@ class SaveModal extends React.Component<SaveModalProps, SaveModalState> {
!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)}
>
Expand Down
8 changes: 8 additions & 0 deletions superset-frontend/src/pages/ChartCreation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down