diff --git a/src/core/public/http/types.ts b/src/core/public/http/types.ts index 4c81dbdd7a5f..4b720cbacc18 100644 --- a/src/core/public/http/types.ts +++ b/src/core/public/http/types.ts @@ -105,7 +105,7 @@ export interface IBasePath { /** * Prepends `path` with the basePath + workspace. */ - prepend: (url: string) => string; + prepend: (url: string, withoutWorkspace?: boolean) => string; /** * Removes the prepended basePath + workspace from the `path`. diff --git a/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx b/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx index d599fc1e457f..e5de1ec3c5d4 100644 --- a/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx +++ b/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx @@ -25,7 +25,7 @@ import { DeleteWorkspaceModal } from '../delete_workspace_modal'; export const WorkspaceUpdater = () => { const { - services: { application, workspaces, notifications }, + services: { application, workspaces, notifications, http }, } = useOpenSearchDashboards<{ application: ApplicationStart }>(); const currentWorkspace = useObservable( @@ -127,14 +127,13 @@ export const WorkspaceUpdater = () => { } } setDeleteWorkspaceModalVisible(false); - if (workspaces) { - window.location.href = workspaces.formatUrlWithWorkspaceId( - application.getUrlForApp('home', { - path: '/', - absolute: true, - }), - '' - ); + if (http) { + const homeUrl = application.getUrlForApp('home', { + path: '/', + absolute: false, + }); + const targetUrl = http.basePath.prepend(http.basePath.remove(homeUrl), true); + await application.navigateToUrl(targetUrl); } }; @@ -160,14 +159,13 @@ export const WorkspaceUpdater = () => { }); return; } - if (workspaces) { - window.location.href = workspaces.formatUrlWithWorkspaceId( - application.getUrlForApp('home', { - path: '/', - absolute: true, - }), - '' - ); + if (http) { + const homeUrl = application.getUrlForApp('home', { + path: '/', + absolute: false, + }); + const targetUrl = http.basePath.prepend(http.basePath.remove(homeUrl), true); + await application.navigateToUrl(targetUrl); } };