This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 891f826143 fix(dashboard): Navigate to new dashboard when saved as a
new one (#35339)
891f826143 is described below
commit 891f8261433d49aa229c30e8de89b10f8266b93b
Author: Mehmet Salih Yavuz <[email protected]>
AuthorDate: Fri Oct 3 18:37:07 2025 +0300
fix(dashboard): Navigate to new dashboard when saved as a new one (#35339)
---
.../src/dashboard/actions/dashboardState.js | 3 +-
.../src/dashboard/actions/dashboardState.test.js | 36 ++++++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/src/dashboard/actions/dashboardState.js
b/superset-frontend/src/dashboard/actions/dashboardState.js
index d3305f2e6d..c92faa8ab3 100644
--- a/superset-frontend/src/dashboard/actions/dashboardState.js
+++ b/superset-frontend/src/dashboard/actions/dashboardState.js
@@ -58,7 +58,7 @@ import { safeStringify } from 'src/utils/safeStringify';
import { logEvent } from 'src/logger/actions';
import { LOG_ACTIONS_CONFIRM_OVERWRITE_DASHBOARD_METADATA } from
'src/logger/LogUtils';
import { isEqual } from 'lodash';
-import { navigateWithState } from 'src/utils/navigationUtils';
+import { navigateWithState, navigateTo } from 'src/utils/navigationUtils';
import { UPDATE_COMPONENTS_PARENTS_LIST } from './dashboardLayout';
import {
saveChartConfiguration,
@@ -368,6 +368,7 @@ export function saveDashboardRequest(data, id, saveType) {
}),
);
dispatch(saveDashboardFinished());
+ navigateTo(`/superset/dashboard/${response.json.result.id}/`);
dispatch(addSuccessToast(t('This dashboard was saved successfully.')));
return response;
};
diff --git a/superset-frontend/src/dashboard/actions/dashboardState.test.js
b/superset-frontend/src/dashboard/actions/dashboardState.test.js
index 390688a769..a305a12090 100644
--- a/superset-frontend/src/dashboard/actions/dashboardState.test.js
+++ b/superset-frontend/src/dashboard/actions/dashboardState.test.js
@@ -30,6 +30,7 @@ import {
DASHBOARD_GRID_ID,
SAVE_TYPE_OVERWRITE,
SAVE_TYPE_OVERWRITE_CONFIRMED,
+ SAVE_TYPE_NEWDASHBOARD,
} from 'src/dashboard/util/constants';
import {
filterId,
@@ -37,12 +38,18 @@ import {
} from 'spec/fixtures/mockSliceEntities';
import { emptyFilters } from 'spec/fixtures/mockDashboardFilters';
import mockDashboardData from 'spec/fixtures/mockDashboardData';
+import { navigateTo } from 'src/utils/navigationUtils';
jest.mock('@superset-ui/core', () => ({
...jest.requireActual('@superset-ui/core'),
isFeatureEnabled: jest.fn(),
}));
+jest.mock('src/utils/navigationUtils', () => ({
+ navigateTo: jest.fn(),
+ navigateWithState: jest.fn(),
+}));
+
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from
describe blocks
describe('dashboardState actions', () => {
const mockState = {
@@ -197,5 +204,34 @@ describe('dashboardState actions', () => {
expect(body).toBe(JSON.stringify(confirmedDashboardData));
});
});
+
+ test('should navigate to the new dashboard after Save As', async () => {
+ const newDashboardId = 999;
+ const { getState, dispatch } = setup({
+ dashboardState: { hasUnsavedChanges: true },
+ });
+
+ postStub.restore();
+ postStub = sinon.stub(SupersetClient, 'post').resolves({
+ json: {
+ result: {
+ ...mockDashboardData,
+ id: newDashboardId,
+ },
+ },
+ });
+
+ const thunk = saveDashboardRequest(
+ newDashboardData,
+ null,
+ SAVE_TYPE_NEWDASHBOARD,
+ );
+ await thunk(dispatch, getState);
+
+ await waitFor(() => expect(postStub.callCount).toBe(1));
+ expect(navigateTo).toHaveBeenCalledWith(
+ `/superset/dashboard/${newDashboardId}/`,
+ );
+ });
});
});