Skip to content

Commit

Permalink
change navigation method
Browse files Browse the repository at this point in the history
Signed-off-by: yuye-aws <yuyezhu@amazon.com>
  • Loading branch information
yuye-aws committed Jul 21, 2023
1 parent 13c58e7 commit 12ac2db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/core/public/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
}
};

Expand All @@ -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);
}
};

Expand Down

0 comments on commit 12ac2db

Please sign in to comment.