Remove export CSV in old filter box (#16592)

This commit is contained in:
Duy Nguyen Hoang 2021-09-06 18:40:24 +07:00 committed by GitHub
parent 7cbced8833
commit 3fe2e6ec73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 11 deletions

View File

@ -36,7 +36,7 @@ jest.mock('src/common/components', () => {
};
});
const createProps = () => ({
const createProps = (viz_type = 'sunburst') => ({
addDangerToast: jest.fn(),
addSuccessToast: jest.fn(),
exploreChart: jest.fn(),
@ -67,9 +67,9 @@ const createProps = () => ({
time_range: 'No filter',
time_range_endpoints: ['inclusive', 'exclusive'],
url_params: {},
viz_type: 'sunburst',
viz_type,
},
viz_type: 'sunburst',
viz_type,
datasource: '58__table',
description: 'test-description',
description_markeddown: '',
@ -152,25 +152,30 @@ test('Should "export to CSV"', () => {
expect(props.exportCSV).toBeCalledWith(371);
});
test('Should not show "Export to CSV" if slice is filter box', () => {
const props = createProps('filter_box');
render(<SliceHeaderControls {...props} />, { useRedux: true });
expect(screen.queryByRole('menuitem', { name: 'Export CSV' })).toBe(null);
});
test('Export full CSV is under featureflag', () => {
// @ts-ignore
global.featureFlags = {
[FeatureFlag.ALLOW_FULL_CSV_EXPORT]: false,
};
const props = createProps();
props.slice.viz_type = 'table';
const props = createProps('table');
render(<SliceHeaderControls {...props} />, { useRedux: true });
expect(screen.queryByRole('menuitem', { name: 'Export full CSV' })).toBe(
null,
);
});
test('Should "export full CSV"', () => {
// @ts-ignore
global.featureFlags = {
[FeatureFlag.ALLOW_FULL_CSV_EXPORT]: true,
};
const props = createProps();
props.slice.viz_type = 'table';
const props = createProps('table');
render(<SliceHeaderControls {...props} />, { useRedux: true });
expect(screen.queryByRole('menuitem', { name: 'Export full CSV' })).not.toBe(
null,
@ -193,6 +198,18 @@ test('Should not show export full CSV if report is not table', () => {
);
});
test('Should not show export full CSV if slice is filter box', () => {
// @ts-ignore
global.featureFlags = {
[FeatureFlag.ALLOW_FULL_CSV_EXPORT]: true,
};
const props = createProps('filter_box');
render(<SliceHeaderControls {...props} />, { useRedux: true });
expect(screen.queryByRole('menuitem', { name: 'Export full CSV' })).toBe(
null,
);
});
test('Should "Toggle chart description"', () => {
const props = createProps();
render(<SliceHeaderControls {...props} />, { useRedux: true });

View File

@ -328,16 +328,20 @@ class SliceHeaderControls extends React.PureComponent<
{t('Download as image')}
</Menu.Item>
{this.props.supersetCanCSV && (
<Menu.Item key={MENU_KEYS.EXPORT_CSV}>{t('Export CSV')}</Menu.Item>
)}
{isFeatureEnabled(FeatureFlag.ALLOW_FULL_CSV_EXPORT) &&
{this.props.slice.viz_type !== 'filter_box' &&
this.props.supersetCanCSV && (
<Menu.Item key={MENU_KEYS.EXPORT_CSV}>{t('Export CSV')}</Menu.Item>
)}
{this.props.slice.viz_type !== 'filter_box' &&
isFeatureEnabled(FeatureFlag.ALLOW_FULL_CSV_EXPORT) &&
this.props.supersetCanCSV &&
isTable && (
<Menu.Item key={MENU_KEYS.EXPORT_FULL_CSV}>
{t('Export full CSV')}
</Menu.Item>
)}
{isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS) &&
isCrossFilter &&
canEmitCrossFilter && (