From caf20343bd8d7a9b065e1708dcd4e946224847ed Mon Sep 17 00:00:00 2001 From: Lisa Knox Date: Mon, 13 May 2024 15:25:12 -0400 Subject: [PATCH] 21535: added wf delete dialog Arvados-DCO-1.1-Signed-off-by: Lisa Knox --- .../workflow-panel/workflow-panel-actions.ts | 26 +++++++++++++++++++ .../ms-workflow-action-set.ts | 4 +-- .../workflow-remove-dialog.tsx | 22 ++++++++++++++++ .../src/views/workbench/workbench.tsx | 2 ++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 services/workbench2/src/views-components/workflow-remove-dialog/workflow-remove-dialog.tsx diff --git a/services/workbench2/src/store/workflow-panel/workflow-panel-actions.ts b/services/workbench2/src/store/workflow-panel/workflow-panel-actions.ts index ef1f23ec1f..5079c01dd0 100644 --- a/services/workbench2/src/store/workflow-panel/workflow-panel-actions.ts +++ b/services/workbench2/src/store/workflow-panel/workflow-panel-actions.ts @@ -24,6 +24,8 @@ import { getResource } from 'store/resources/resources'; import { ProjectResource } from 'models/project'; import { UserResource } from 'models/user'; import { getWorkflowInputs, parseWorkflowDefinition } from 'models/workflow'; +import { ContextMenuResource } from 'store/context-menu/context-menu-actions'; +import { dialogActions } from 'store/dialog/dialog-actions'; export const WORKFLOW_PANEL_ID = "workflowPanel"; const UUID_PREFIX_PROPERTY_NAME = 'uuidPrefix'; @@ -127,3 +129,27 @@ export const deleteWorkflow = (workflowUuid: string, ownerUuid?: string) => await services.workflowService.delete(workflowUuid); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removed.', hideDuration: 2000, kind: SnackbarKind.SUCCESS })); }; + +export const openRemoveWorkflowDialog = +(resource: ContextMenuResource, numOfWorkflows: Number) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const confirmationText = + numOfWorkflows === 1 + ? "Are you sure you want to remove this workflow?" + : `Are you sure you want to remove these ${numOfWorkflows} workflows?`; + const titleText = numOfWorkflows === 1 ? "Remove workflow permanently" : "Remove workflows permanently"; + + dispatch( + dialogActions.OPEN_DIALOG({ + id: REMOVE_WORKFLOW_DIALOG, + data: { + title: titleText, + text: confirmationText, + confirmButtonLabel: "Remove", + uuid: resource.uuid, + resource, + }, + }) + ); +}; + +export const REMOVE_WORKFLOW_DIALOG = "removeWorkflowDialog"; \ No newline at end of file diff --git a/services/workbench2/src/views-components/multiselect-toolbar/ms-workflow-action-set.ts b/services/workbench2/src/views-components/multiselect-toolbar/ms-workflow-action-set.ts index e0f46bf6ee..945aea13f1 100644 --- a/services/workbench2/src/views-components/multiselect-toolbar/ms-workflow-action-set.ts +++ b/services/workbench2/src/views-components/multiselect-toolbar/ms-workflow-action-set.ts @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { openRunProcess, deleteWorkflow } from 'store/workflow-panel/workflow-panel-actions'; +import { openRunProcess, openRemoveWorkflowDialog } from 'store/workflow-panel/workflow-panel-actions'; import { StartIcon, DeleteForever, Link } from 'components/icon/icon'; import { MultiSelectMenuAction, MultiSelectMenuActionSet, msCommonActionSet } from './ms-menu-actions'; import { MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-actions"; @@ -27,7 +27,7 @@ const msDeleteWorkflow: MultiSelectMenuAction = { isForMulti: true, execute: (dispatch, resources) => { for (const resource of [...resources]){ - dispatch(deleteWorkflow(resource.uuid)); + dispatch(openRemoveWorkflowDialog(resource, resources.length)); } }, }; diff --git a/services/workbench2/src/views-components/workflow-remove-dialog/workflow-remove-dialog.tsx b/services/workbench2/src/views-components/workflow-remove-dialog/workflow-remove-dialog.tsx new file mode 100644 index 0000000000..7eb2f5e9e0 --- /dev/null +++ b/services/workbench2/src/views-components/workflow-remove-dialog/workflow-remove-dialog.tsx @@ -0,0 +1,22 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { Dispatch, compose } from 'redux'; +import { connect } from "react-redux"; +import { ConfirmationDialog } from "components/confirmation-dialog/confirmation-dialog"; +import { withDialog, WithDialogProps } from "store/dialog/with-dialog"; +import { REMOVE_WORKFLOW_DIALOG } from 'store/workflow-panel/workflow-panel-actions'; +import { deleteWorkflow } from 'store/workflow-panel/workflow-panel-actions'; + +const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps) => ({ + onConfirm: () => { + props.closeDialog(); + dispatch(deleteWorkflow(props.data.uuid)); + } +}); + +export const RemoveWorkflowDialog = compose( + withDialog(REMOVE_WORKFLOW_DIALOG), + connect(null, mapDispatchToProps) +)(ConfirmationDialog); diff --git a/services/workbench2/src/views/workbench/workbench.tsx b/services/workbench2/src/views/workbench/workbench.tsx index 3020e0d298..3da00e492a 100644 --- a/services/workbench2/src/views/workbench/workbench.tsx +++ b/services/workbench2/src/views/workbench/workbench.tsx @@ -39,6 +39,7 @@ import { PartialMoveToNewCollectionDialog } from "views-components/dialog-forms/ import { PartialMoveToExistingCollectionDialog } from "views-components/dialog-forms/partial-move-to-existing-collection-dialog"; import { PartialMoveToSeparateCollectionsDialog } from "views-components/dialog-forms/partial-move-to-separate-collections-dialog"; import { RemoveProcessDialog } from "views-components/process-remove-dialog/process-remove-dialog"; +import { RemoveWorkflowDialog } from "views-components/workflow-remove-dialog/workflow-remove-dialog"; import { MainContentBar } from "views-components/main-content-bar/main-content-bar"; import { Grid } from "@material-ui/core"; import { TrashPanel } from "views/trash-panel/trash-panel"; @@ -435,6 +436,7 @@ const { classes, sidePanelIsCollapsed, isNotLinking, isTransitioning, isUserActi + -- 2.30.2