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

View File

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