From 9b087e99dbbcb52f9b82bacc600aea5fa2f1a515 Mon Sep 17 00:00:00 2001 From: Stephen Smith Date: Thu, 24 Oct 2024 10:53:32 -0400 Subject: [PATCH] 22202: Navigate to home project when deleting currently open project Arvados-DCO-1.1-Signed-off-by: Stephen Smith --- .../src/store/processes/processes-actions.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/workbench2/src/store/processes/processes-actions.ts b/services/workbench2/src/store/processes/processes-actions.ts index 2d7bca846c..695b5d06bf 100644 --- a/services/workbench2/src/store/processes/processes-actions.ts +++ b/services/workbench2/src/store/processes/processes-actions.ts @@ -9,7 +9,7 @@ import { updateResources } from "store/resources/resources-actions"; import { dialogActions } from "store/dialog/dialog-actions"; import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions"; import { projectPanelRunActions } from "store/project-panel/project-panel-action-bind"; -import { navigateToRunProcess } from "store/navigation/navigation-action"; +import { navigateToRootProject, navigateToRunProcess } from "store/navigation/navigation-action"; import { goToStep, runProcessPanelActions } from "store/run-process-panel/run-process-panel-actions"; import { getResource } from "store/resources/resources"; import { initialize } from "redux-form"; @@ -26,6 +26,7 @@ import { selectedToArray } from "components/multiselect-toolbar/MultiselectToolb import { Resource, ResourceKind } from "models/resource"; import { ContextMenuResource } from "store/context-menu/context-menu-actions"; import { CommonResourceServiceError, getCommonResourceServiceError } from "services/common-service/common-resource-service"; +import { getProcessPanelCurrentUuid } from "store/process-panel/process-panel"; import { getProjectPanelCurrentUuid } from "store/project-panel/project-panel-action"; export const loadContainers = @@ -275,6 +276,7 @@ export const openRemoveProcessDialog = export const REMOVE_PROCESS_DIALOG = "removeProcessDialog"; export const removeProcessPermanently = (uuid: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const currentProcessPanelUuid = getProcessPanelCurrentUuid(getState().router); const currentProjectUuid = getProjectPanelCurrentUuid(getState()); const resource = getState().dialog.removeProcessDialog.data.resource; const checkedList = getState().multiselect.checkedList; @@ -324,6 +326,14 @@ export const removeProcessPermanently = (uuid: string) => async (dispatch: Dispa } } + // If currently viewing any of the deleted runs, navigate to home + if (currentProcessPanelUuid) { + const currentProcessDeleted = succeeded.find((promiseResult) => promiseResult.value.uuid === currentProcessPanelUuid); + if (currentProcessDeleted) { + dispatch(navigateToRootProject); + } + } + // If currently viewing the parent project of any of the deleted runs, refresh project runs tab if (currentProjectUuid && succeeded.find((promiseResult) => promiseResult.value.ownerUuid === currentProjectUuid)) { dispatch(projectPanelRunActions.REQUEST_ITEMS()); -- 2.30.2