Skip to content

Commit

Permalink
Remove export CSV in old filter box (#16592)
Browse files Browse the repository at this point in the history
  • Loading branch information
duynguyenhoang authored Sep 6, 2021
1 parent 7cbced8 commit 3fe2e6e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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: '',
Expand Down Expand Up @@ -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,
Expand All @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 && (
Expand Down

0 comments on commit 3fe2e6e

Please sign in to comment.