mirror of
https://github.com/apache/superset.git
synced 2024-09-16 10:39:55 -04:00
fix: Fixed saved query export (#14086)
* Fixed saved query export * Te sting implemented
This commit is contained in:
parent
4b23d0ecca
commit
6392d41ac9
@ -26,6 +26,7 @@ import { render, screen, cleanup } from 'spec/helpers/testing-library';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { QueryParamProvider } from 'use-query-params';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { handleBulkSavedQueryExport } from 'src/views/CRUD/utils';
|
||||
import * as featureFlags from 'src/featureFlags';
|
||||
import SavedQueryList from 'src/views/CRUD/data/savedquery/SavedQueryList';
|
||||
import SubMenu from 'src/components/Menu/SubMenu';
|
||||
@ -95,6 +96,9 @@ fetchMock.get(queriesDistinctEndpoint, {
|
||||
result: [],
|
||||
});
|
||||
|
||||
// Mock utils module
|
||||
jest.mock('src/views/CRUD/utils');
|
||||
|
||||
describe('SavedQueryList', () => {
|
||||
const wrapper = mount(
|
||||
<Provider store={store}>
|
||||
@ -245,4 +249,12 @@ describe('RTL', () => {
|
||||
});
|
||||
expect(exportTooltip).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('runs handleBulkSavedQueryExport when export is clicked', () => {
|
||||
// Grab Export action button and mock mouse clicking it
|
||||
const exportActionButton = screen.getAllByRole('button')[17];
|
||||
userEvent.click(exportActionButton);
|
||||
|
||||
expect(handleBulkSavedQueryExport).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
@ -25,7 +25,7 @@ import {
|
||||
createFetchRelated,
|
||||
createFetchDistinct,
|
||||
createErrorHandler,
|
||||
handleBulkDashboardExport,
|
||||
handleBulkSavedQueryExport,
|
||||
} from 'src/views/CRUD/utils';
|
||||
import Popover from 'src/components/Popover';
|
||||
import withToasts from 'src/messageToasts/enhancers/withToasts';
|
||||
@ -306,7 +306,7 @@ function SavedQueryList({
|
||||
};
|
||||
const handleEdit = () => openInSqlLab(original.id);
|
||||
const handleCopy = () => copyQueryLink(original.id);
|
||||
const handleExport = () => handleBulkDashboardExport([original]);
|
||||
const handleExport = () => handleBulkSavedQueryExport([original]);
|
||||
const handleDelete = () => setQueryCurrentlyDeleting(original);
|
||||
|
||||
const actions = [
|
||||
@ -454,7 +454,7 @@ function SavedQueryList({
|
||||
key: 'export',
|
||||
name: t('Export'),
|
||||
type: 'primary',
|
||||
onSelect: handleBulkDashboardExport,
|
||||
onSelect: handleBulkSavedQueryExport,
|
||||
});
|
||||
}
|
||||
return (
|
||||
|
@ -27,7 +27,7 @@ import Chart from 'src/types/Chart';
|
||||
import rison from 'rison';
|
||||
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
|
||||
import { FetchDataConfig } from 'src/components/ListView';
|
||||
import { Dashboard, Filters } from './types';
|
||||
import { Dashboard, Filters, SavedQueryObject } from './types';
|
||||
|
||||
const createFetchResourceMethod = (method: string) => (
|
||||
resource: string,
|
||||
@ -218,6 +218,16 @@ export function handleBulkDashboardExport(dashboardsToExport: Dashboard[]) {
|
||||
);
|
||||
}
|
||||
|
||||
export function handleBulkSavedQueryExport(
|
||||
savedQueriesToExport: SavedQueryObject[],
|
||||
) {
|
||||
return window.location.assign(
|
||||
`/api/v1/saved_query/export/?q=${rison.encode(
|
||||
savedQueriesToExport.map(({ id }) => id),
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
|
||||
export function handleDashboardDelete(
|
||||
{ id, dashboard_title: dashboardTitle }: Dashboard,
|
||||
refreshData: (config?: FetchDataConfig | null) => void,
|
||||
|
Loading…
Reference in New Issue
Block a user