From e74f34ad714398bc5cfaccbc9b3f1f6101d5a6a4 Mon Sep 17 00:00:00 2001 From: yuye-aws Date: Thu, 17 Aug 2023 11:37:16 +0800 Subject: [PATCH 1/3] only navigate to home page when delete and exit workspace successfully Signed-off-by: yuye-aws --- .../workspace_updater/workspace_updater.tsx | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) 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 972dc91d40c8..9d726a9cf35c 100644 --- a/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx +++ b/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx @@ -117,6 +117,16 @@ export const WorkspaceUpdater = () => { defaultMessage: 'Delete workspace successfully', }), }); + if (http && application) { + const homeUrl = application.getUrlForApp('home', { + path: '/', + absolute: false, + }); + const targetUrl = http.basePath.prepend(http.basePath.remove(homeUrl), { + withoutWorkspace: true, + }); + await application.navigateToUrl(targetUrl); + } } else { notifications?.toasts.addDanger({ title: i18n.translate('workspace.delete.failed', { @@ -127,16 +137,6 @@ export const WorkspaceUpdater = () => { } } setDeleteWorkspaceModalVisible(false); - if (http && application) { - const homeUrl = application.getUrlForApp('home', { - path: '/', - absolute: false, - }); - const targetUrl = http.basePath.prepend(http.basePath.remove(homeUrl), { - withoutWorkspace: true, - }); - await application.navigateToUrl(targetUrl); - } }; const exitWorkspace = async () => { @@ -152,7 +152,18 @@ export const WorkspaceUpdater = () => { }); return; } - if (!result?.success) { + if (result.success) { + if (http && application) { + const homeUrl = application.getUrlForApp('home', { + path: '/', + absolute: false, + }); + const targetUrl = http.basePath.prepend(http.basePath.remove(homeUrl), { + withoutWorkspace: true, + }); + await application.navigateToUrl(targetUrl); + } + } else { notifications?.toasts.addDanger({ title: i18n.translate('workspace.exit.failed', { defaultMessage: 'Failed to exit workspace', @@ -161,16 +172,6 @@ export const WorkspaceUpdater = () => { }); return; } - if (http && application) { - const homeUrl = application.getUrlForApp('home', { - path: '/', - absolute: false, - }); - const targetUrl = http.basePath.prepend(http.basePath.remove(homeUrl), { - withoutWorkspace: true, - }); - await application.navigateToUrl(targetUrl); - } }; return ( From f70c1cdeb12e03d56f1430ec4fdcfd9f9607a787 Mon Sep 17 00:00:00 2001 From: yuye-aws Date: Thu, 17 Aug 2023 11:38:30 +0800 Subject: [PATCH 2/3] unsubscribe workspaceEnabled when workspace service stop Signed-off-by: yuye-aws --- src/core/public/workspace/workspaces_service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/public/workspace/workspaces_service.ts b/src/core/public/workspace/workspaces_service.ts index edf4ec998731..142ac67fed38 100644 --- a/src/core/public/workspace/workspaces_service.ts +++ b/src/core/public/workspace/workspaces_service.ts @@ -55,5 +55,6 @@ export class WorkspaceService implements CoreService Date: Thu, 17 Aug 2023 12:11:41 +0800 Subject: [PATCH 3/3] only hide delete modal when delete workspace successfully Signed-off-by: yuye-aws --- .../public/components/workspace_updater/workspace_updater.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9d726a9cf35c..41a3e1216770 100644 --- a/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx +++ b/src/plugins/workspace/public/components/workspace_updater/workspace_updater.tsx @@ -117,6 +117,7 @@ export const WorkspaceUpdater = () => { defaultMessage: 'Delete workspace successfully', }), }); + setDeleteWorkspaceModalVisible(false); if (http && application) { const homeUrl = application.getUrlForApp('home', { path: '/', @@ -136,7 +137,6 @@ export const WorkspaceUpdater = () => { }); } } - setDeleteWorkspaceModalVisible(false); }; const exitWorkspace = async () => {