mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
feat: Improves key expiration handling in Explore (#18624)
* feat: Improves key expiration handling in Explore * Sets use_slice_data equals true * Shows toast when recovering
This commit is contained in:
committed by
GitHub
parent
bcad1acec2
commit
f03b4dbedb
@@ -28,6 +28,7 @@ const reduxState = {
|
||||
common: { conf: { SUPERSET_WEBSERVER_TIMEOUT: 60 } },
|
||||
controls: { datasource: { value: '1__table' } },
|
||||
datasource: {
|
||||
id: 1,
|
||||
type: 'table',
|
||||
columns: [{ is_dttm: false }],
|
||||
metrics: [{ id: 1, metric_name: 'count' }],
|
||||
@@ -65,7 +66,7 @@ fetchMock.get('glob:*/api/v1/explore/form_data*', {});
|
||||
|
||||
const renderWithRouter = (withKey?: boolean) => {
|
||||
const path = '/superset/explore/';
|
||||
const search = withKey ? `?form_data_key=${key}` : '';
|
||||
const search = withKey ? `?form_data_key=${key}&dataset_id=1` : '';
|
||||
return render(
|
||||
<MemoryRouter initialEntries={[`${path}${search}`]}>
|
||||
<Route path={path}>
|
||||
@@ -82,7 +83,12 @@ test('generates a new form_data param when none is available', async () => {
|
||||
expect(replaceState).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
undefined,
|
||||
expect.stringMatching('form_data'),
|
||||
expect.stringMatching('form_data_key'),
|
||||
);
|
||||
expect(replaceState).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
undefined,
|
||||
expect.stringMatching('dataset_id'),
|
||||
);
|
||||
replaceState.mockRestore();
|
||||
});
|
||||
@@ -96,6 +102,11 @@ test('generates a different form_data param when one is provided and is mounting
|
||||
undefined,
|
||||
expect.stringMatching(key),
|
||||
);
|
||||
expect(replaceState).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
undefined,
|
||||
expect.stringMatching('dataset_id'),
|
||||
);
|
||||
replaceState.mockRestore();
|
||||
});
|
||||
|
||||
|
||||
@@ -167,6 +167,12 @@ const updateHistory = debounce(
|
||||
async (formData, datasetId, isReplace, standalone, force, title) => {
|
||||
const payload = { ...formData };
|
||||
const chartId = formData.slice_id;
|
||||
const additionalParam = {};
|
||||
if (chartId) {
|
||||
additionalParam[URL_PARAMS.sliceId.name] = chartId;
|
||||
} else {
|
||||
additionalParam[URL_PARAMS.datasetId.name] = datasetId;
|
||||
}
|
||||
|
||||
try {
|
||||
let key;
|
||||
@@ -183,6 +189,7 @@ const updateHistory = debounce(
|
||||
standalone ? URL_PARAMS.standalone.name : null,
|
||||
{
|
||||
[URL_PARAMS.formDataKey.name]: key,
|
||||
...additionalParam,
|
||||
},
|
||||
force,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user