15768: fixed restore-from-trash icon, minor cleanup Arvados-DCO-1.1-Signed-off-by...
authorLisa Knox <lisaknox83@gmail.com>
Thu, 27 Jul 2023 16:04:25 +0000 (12:04 -0400)
committerLisa Knox <lisaknox83@gmail.com>
Thu, 27 Jul 2023 16:04:25 +0000 (12:04 -0400)
src/components/multiselectToolbar/MultiselectToolbar.tsx
src/store/processes/process-copy-actions.ts
src/store/processes/processes-actions.ts
src/views-components/dialog-copy/dialog-process-rerun.tsx
src/views-components/dialog-forms/copy-process-dialog.ts
src/views-components/process-remove-many-dialog/process-remove-many-dialog.tsx [deleted file]
src/views/workbench/workbench.tsx

index 0417422387e75eef992ab2ecee9e7a3923e250ef..309d3293491c10bfa269983bab2570fb940f803f 100644 (file)
@@ -9,21 +9,15 @@ import { ArvadosTheme } from 'common/custom-theme';
 import { RootState } from 'store/store';
 import { Dispatch } from 'redux';
 import { TCheckedList } from 'components/data-table/data-table';
-import { openRemoveProcessDialog, openRemoveManyProcessesDialog } from 'store/processes/processes-actions';
-import { processResourceActionSet } from '../../views-components/context-menu/action-sets/process-resource-action-set';
 import { ContextMenuResource } from 'store/context-menu/context-menu-actions';
 import { Resource, extractUuidKind } from 'models/resource';
-import { openMoveProcessDialog } from 'store/processes/process-move-actions';
-import { openCopyProcessDialog, openCopyManyProcessesDialog } from 'store/processes/process-copy-actions';
 import { getResource } from 'store/resources/resources';
 import { ResourcesState } from 'store/resources/resources';
-import { getProcess } from 'store/processes/process';
-import { CopyProcessDialog, CopyManyProcessesDialog } from 'views-components/dialog-forms/copy-process-dialog';
-import { collectionActionSet } from 'views-components/context-menu/action-sets/collection-action-set';
 import { ContextMenuAction, ContextMenuActionSet } from 'views-components/context-menu/context-menu-action-set';
-import { TrashIcon } from 'components/icon/icon';
-import { multiselectActionsFilters, TMultiselectActionsFilters, contextMenuActionConsts } from './ms-toolbar-action-filters';
+import { RestoreFromTrashIcon, TrashIcon } from 'components/icon/icon';
+import { multiselectActionsFilters, TMultiselectActionsFilters } from './ms-toolbar-action-filters';
 import { kindToActionSet, findActionByName } from './ms-kind-action-differentiator';
+import { toggleTrashAction } from 'views-components/context-menu/action-sets/project-action-set';
 
 type CssRules = 'root' | 'button';
 
@@ -36,7 +30,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         margin: '1rem auto auto 0.5rem',
         overflow: 'hidden',
         transition: 'width 150ms',
-        borderBottom: '1px solid gray',
+        // borderBottom: '1px solid gray',
     },
     button: {
         width: '1rem',
@@ -59,16 +53,20 @@ export const MultiselectToolbar = connect(
         const { classes, checkedList } = props;
         const currentResourceKinds = Array.from(selectedToKindSet(checkedList));
 
-        const buttons = selectActionsByKind(currentResourceKinds, multiselectActionsFilters);
+        const currentPathIsTrash = window.location.pathname === '/trash';
+        const buttons =
+            currentPathIsTrash && selectedToKindSet(checkedList).size
+                ? [toggleTrashAction]
+                : selectActionsByKind(currentResourceKinds, multiselectActionsFilters);
 
         return (
             <Toolbar className={classes.root} style={{ width: `${buttons.length * 2.12}rem` }}>
                 {buttons.length ? (
                     buttons.map((btn, i) =>
                         btn.name === 'ToggleTrashAction' ? (
-                            <Tooltip className={classes.button} title={'Move to trash'} key={i} disableFocusListener>
+                            <Tooltip className={classes.button} title={currentPathIsTrash ? 'Restore' : 'Move to trash'} key={i} disableFocusListener>
                                 <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
-                                    <TrashIcon />
+                                    {currentPathIsTrash ? <RestoreFromTrashIcon /> : <TrashIcon />}
                                 </IconButton>
                             </Tooltip>
                         ) : (
@@ -167,7 +165,7 @@ function mapStateToProps(state: RootState) {
 
 function mapDispatchToProps(dispatch: Dispatch) {
     return {
-        executeMulti: (selectedAction: ContextMenuAction, checkedList: TCheckedList, resources: ResourcesState) => {
+        executeMulti: (selectedAction: ContextMenuAction, checkedList: TCheckedList, resources: ResourcesState): void => {
             const kindGroups = groupByKind(checkedList, resources);
             for (const kind in kindGroups) {
                 const actionSet = kindToActionSet[kind];
index d3c36b3f363afd9a0b4e545b751d901143215923..36d73940b13d0a873fac46d5f3df6db1f0d8948d 100644 (file)
@@ -9,50 +9,27 @@ import { resetPickerProjectTree } from 'store/project-tree-picker/project-tree-p
 import { RootState } from 'store/store';
 import { ServiceRepository } from 'services/services';
 import { CopyFormDialogData } from 'store/copy-dialog/copy-dialog';
-import { Process, getProcess } from 'store/processes/process';
+import { getProcess } from 'store/processes/process';
 import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
 import { initProjectsTreePicker } from 'store/tree-picker/tree-picker-actions';
-import { ContainerRequestResource, ContainerRequestState } from 'models/container-request';
+import { ContainerRequestState } from 'models/container-request';
 
 export const PROCESS_COPY_FORM_NAME = 'processCopyFormName';
 export const MULTI_PROCESS_COPY_FORM_NAME = 'multiProcessCopyFormName';
 
-export const openCopyProcessDialog = (resource: { name: string; uuid: string }) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-    const process = getProcess(resource.uuid)(getState().resources);
-    if (process) {
-        dispatch<any>(resetPickerProjectTree());
-        dispatch<any>(initProjectsTreePicker(PROCESS_COPY_FORM_NAME));
-        const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, uuid: resource.uuid, ownerUuid: '' };
-        dispatch<any>(initialize(PROCESS_COPY_FORM_NAME, initialData));
-        dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_COPY_FORM_NAME, data: {} }));
-    } else {
-        dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process not found', hideDuration: 2000, kind: SnackbarKind.ERROR }));
-    }
-};
-
-export const openCopyManyProcessesDialog = (list: Array<string>) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-    //need to test with undefined process array
-    const testList = ['tordo-xvhdp-f8ps1vs3s3c2u3v', 'foo'];
-    const processes = list.map((uuid) => {
-        // const processes = testList.map((uuid) => {
-        const process = getProcess(uuid)(getState().resources);
-        if (!process) {
-            dispatch(snackbarActions.OPEN_SNACKBAR({ message: `Process ${uuid} not found`, hideDuration: 2000, kind: SnackbarKind.ERROR }));
-            return undefined;
-        } else return process;
-    });
-    console.log(processes);
-
-    let initialData: CopyFormDialogData;
-    if (processes.every((process) => !!process)) {
-        const { name, uuid } = (processes[0] as Process).containerRequest;
-        dispatch<any>(resetPickerProjectTree());
-        dispatch<any>(initProjectsTreePicker(MULTI_PROCESS_COPY_FORM_NAME));
-        initialData = { name: `Copy of: ${name}`, uuid: uuid, ownerUuid: '' };
-        dispatch<any>(initialize(MULTI_PROCESS_COPY_FORM_NAME, initialData));
-        dispatch(dialogActions.OPEN_DIALOG({ id: MULTI_PROCESS_COPY_FORM_NAME, data: {} }));
-    }
-};
+export const openCopyProcessDialog =
+    (resource: { name: string; uuid: string }) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const process = getProcess(resource.uuid)(getState().resources);
+        if (process) {
+            dispatch<any>(resetPickerProjectTree());
+            dispatch<any>(initProjectsTreePicker(PROCESS_COPY_FORM_NAME));
+            const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, uuid: resource.uuid, ownerUuid: '' };
+            dispatch<any>(initialize(PROCESS_COPY_FORM_NAME, initialData));
+            dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_COPY_FORM_NAME, data: {} }));
+        } else {
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process not found', hideDuration: 2000, kind: SnackbarKind.ERROR }));
+        }
+    };
 
 export const copyProcess = (resource: CopyFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
     dispatch(startSubmit(PROCESS_COPY_FORM_NAME));
index 1d3be43533f52612b3e45e118bd36b8171339328..6d46efd08746a17046d91cab7072b9108efd4256 100644 (file)
@@ -158,40 +158,41 @@ export const startWorkflow = (uuid: string) => async (dispatch: Dispatch, getSta
     }
 };
 
-export const reRunProcess = (processUuid: string, workflowUuid: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-    const process = getResource<any>(processUuid)(getState().resources);
-    const workflows = getState().runProcessPanel.searchWorkflows;
-    const workflow = workflows.find((workflow) => workflow.uuid === workflowUuid);
-    if (workflow && process) {
-        const mainWf = getWorkflow(process.mounts[MOUNT_PATH_CWL_WORKFLOW]);
-        if (mainWf) {
-            mainWf.inputs = getInputs(process);
-        }
-        const stringifiedDefinition = JSON.stringify(process.mounts[MOUNT_PATH_CWL_WORKFLOW].content);
-        const newWorkflow = { ...workflow, definition: stringifiedDefinition };
+export const reRunProcess =
+    (processUuid: string, workflowUuid: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const process = getResource<any>(processUuid)(getState().resources);
+        const workflows = getState().runProcessPanel.searchWorkflows;
+        const workflow = workflows.find((workflow) => workflow.uuid === workflowUuid);
+        if (workflow && process) {
+            const mainWf = getWorkflow(process.mounts[MOUNT_PATH_CWL_WORKFLOW]);
+            if (mainWf) {
+                mainWf.inputs = getInputs(process);
+            }
+            const stringifiedDefinition = JSON.stringify(process.mounts[MOUNT_PATH_CWL_WORKFLOW].content);
+            const newWorkflow = { ...workflow, definition: stringifiedDefinition };
 
-        const owner = getResource<ProjectResource | UserResource>(workflow.ownerUuid)(getState().resources);
-        const basicInitialData: RunProcessBasicFormData = { name: `Copy of: ${process.name}`, description: process.description, owner };
-        dispatch<any>(initialize(RUN_PROCESS_BASIC_FORM, basicInitialData));
+            const owner = getResource<ProjectResource | UserResource>(workflow.ownerUuid)(getState().resources);
+            const basicInitialData: RunProcessBasicFormData = { name: `Copy of: ${process.name}`, description: process.description, owner };
+            dispatch<any>(initialize(RUN_PROCESS_BASIC_FORM, basicInitialData));
 
-        const advancedInitialData: RunProcessAdvancedFormData = {
-            output: process.outputName,
-            runtime: process.schedulingParameters.max_run_time,
-            ram: process.runtimeConstraints.ram,
-            vcpus: process.runtimeConstraints.vcpus,
-            keep_cache_ram: process.runtimeConstraints.keep_cache_ram,
-            acr_container_image: process.containerImage,
-        };
-        dispatch<any>(initialize(RUN_PROCESS_ADVANCED_FORM, advancedInitialData));
+            const advancedInitialData: RunProcessAdvancedFormData = {
+                output: process.outputName,
+                runtime: process.schedulingParameters.max_run_time,
+                ram: process.runtimeConstraints.ram,
+                vcpus: process.runtimeConstraints.vcpus,
+                keep_cache_ram: process.runtimeConstraints.keep_cache_ram,
+                acr_container_image: process.containerImage,
+            };
+            dispatch<any>(initialize(RUN_PROCESS_ADVANCED_FORM, advancedInitialData));
 
-        dispatch<any>(navigateToRunProcess);
-        dispatch<any>(goToStep(1));
-        dispatch(runProcessPanelActions.SET_STEP_CHANGED(true));
-        dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(newWorkflow));
-    } else {
-        dispatch<any>(snackbarActions.OPEN_SNACKBAR({ message: `You can't re-run this process`, kind: SnackbarKind.ERROR }));
-    }
-};
+            dispatch<any>(navigateToRunProcess);
+            dispatch<any>(goToStep(1));
+            dispatch(runProcessPanelActions.SET_STEP_CHANGED(true));
+            dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(newWorkflow));
+        } else {
+            dispatch<any>(snackbarActions.OPEN_SNACKBAR({ message: `You can't re-run this process`, kind: SnackbarKind.ERROR }));
+        }
+    };
 
 /*
  * Fetches raw inputs from containerRequest mounts with fallback to properties
@@ -296,22 +297,7 @@ export const openRemoveProcessDialog = (uuid: string) => (dispatch: Dispatch, ge
     );
 };
 
-export const openRemoveManyProcessesDialog = (list: Array<string>) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-    dispatch(
-        dialogActions.OPEN_DIALOG({
-            id: REMOVE_MANY_PROCESSES_DIALOG,
-            data: {
-                title: 'Remove processes permanently',
-                text: `Are you sure you want to remove these ${list.length} processes?`,
-                confirmButtonLabel: 'Remove',
-                list,
-            },
-        })
-    );
-};
-
 export const REMOVE_PROCESS_DIALOG = 'removeProcessDialog';
-export const REMOVE_MANY_PROCESSES_DIALOG = 'removeManyProcessesDialog';
 
 export const removeProcessPermanently = (uuid: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
     dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...', kind: SnackbarKind.INFO }));
index 2d34baf925570f0a067ee51f917a431ce9ba81be..a5d8f3a0f8abde8587f4ff3665c2addd5cb332c7 100644 (file)
@@ -25,14 +25,3 @@ const CopyDialogFields = memoize((pickerId: string) => () => (
         <Field name='ownerUuid' component={ProjectTreePickerField} validate={COPY_FILE_VALIDATION} pickerId={pickerId} />
     </>
 ));
-
-export const DialogManyProcessesRerun = (props: ProcessRerunFormDialogProps & PickerIdProp) => (
-    <FormDialog dialogTitle='Choose location for re-runs' formFields={CopyManyDialogFields(props.pickerId)} submitLabel='Copy' {...props} />
-);
-
-const CopyManyDialogFields = memoize((pickerId: string) => () => (
-    <>
-        {/* <Field name='name' component={TextField as any} validate={COPY_NAME_VALIDATION} label='Enter a new name for the copy' /> */}
-        <Field name='ownerUuid' component={ProjectTreePickerField} validate={COPY_FILE_VALIDATION} pickerId={pickerId} />
-    </>
-));
index 95db53a2a888410fec3594379021679330bff2e6..8afa58dde9583b3cee6f5a1c72651cd13fe952d3 100644 (file)
@@ -5,8 +5,8 @@
 import { compose } from 'redux';
 import { withDialog } from 'store/dialog/with-dialog';
 import { reduxForm } from 'redux-form';
-import { PROCESS_COPY_FORM_NAME, MULTI_PROCESS_COPY_FORM_NAME } from 'store/processes/process-copy-actions';
-import { DialogProcessRerun, DialogManyProcessesRerun } from 'views-components/dialog-copy/dialog-process-rerun';
+import { PROCESS_COPY_FORM_NAME } from 'store/processes/process-copy-actions';
+import { DialogProcessRerun } from 'views-components/dialog-copy/dialog-process-rerun';
 import { copyProcess } from 'store/workbench/workbench-actions';
 import { CopyFormDialogData } from 'store/copy-dialog/copy-dialog';
 import { pickerId } from 'store/tree-picker/picker-id';
@@ -16,21 +16,8 @@ export const CopyProcessDialog = compose(
     reduxForm<CopyFormDialogData>({
         form: PROCESS_COPY_FORM_NAME,
         onSubmit: (data, dispatch) => {
-            console.log('In CopyProcessDialog');
             dispatch(copyProcess(data));
         },
     }),
     pickerId(PROCESS_COPY_FORM_NAME)
 )(DialogProcessRerun);
-
-export const CopyManyProcessesDialog = compose(
-    withDialog(MULTI_PROCESS_COPY_FORM_NAME),
-    reduxForm<CopyFormDialogData>({
-        form: MULTI_PROCESS_COPY_FORM_NAME,
-        onSubmit: (data, dispatch) => {
-            console.log('COPYMANY', data);
-            dispatch(copyProcess(data));
-        },
-    }),
-    pickerId(MULTI_PROCESS_COPY_FORM_NAME)
-)(DialogManyProcessesRerun);
diff --git a/src/views-components/process-remove-many-dialog/process-remove-many-dialog.tsx b/src/views-components/process-remove-many-dialog/process-remove-many-dialog.tsx
deleted file mode 100644 (file)
index 4889418..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-//this file can probably be removed - lk
-
-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 { removeProcessPermanently, REMOVE_MANY_PROCESSES_DIALOG } from 'store/processes/processes-actions';
-
-const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<any>) => ({
-    onConfirm: () => {
-        props.closeDialog();
-        props.data.list.forEach((uuid: string) => dispatch<any>(removeProcessPermanently(uuid)));
-    },
-});
-
-export const RemoveManyProcessesDialog = compose(withDialog(REMOVE_MANY_PROCESSES_DIALOG), connect(null, mapDispatchToProps))(ConfirmationDialog);
index 74bccd0f741cc903b3c7b2ac9976566a5de5221c..445e86de66a03532044faec2f784632504140543 100644 (file)
@@ -24,7 +24,7 @@ import { ChangeWorkflowDialog } from 'views-components/run-process-dialog/change
 import { CreateProjectDialog } from 'views-components/dialog-forms/create-project-dialog';
 import { CreateCollectionDialog } from 'views-components/dialog-forms/create-collection-dialog';
 import { CopyCollectionDialog } from 'views-components/dialog-forms/copy-collection-dialog';
-import { CopyProcessDialog, CopyManyProcessesDialog } from 'views-components/dialog-forms/copy-process-dialog';
+import { CopyProcessDialog } from 'views-components/dialog-forms/copy-process-dialog';
 import { UpdateCollectionDialog } from 'views-components/dialog-forms/update-collection-dialog';
 import { UpdateProcessDialog } from 'views-components/dialog-forms/update-process-dialog';
 import { UpdateProjectDialog } from 'views-components/dialog-forms/update-project-dialog';
@@ -34,7 +34,6 @@ import { MoveCollectionDialog } from 'views-components/dialog-forms/move-collect
 import { FilesUploadCollectionDialog } from 'views-components/dialog-forms/files-upload-collection-dialog';
 import { PartialCopyCollectionDialog } from 'views-components/dialog-forms/partial-copy-collection-dialog';
 import { RemoveProcessDialog } from 'views-components/process-remove-dialog/process-remove-dialog';
-import { RemoveManyProcessesDialog } from 'views-components/process-remove-many-dialog/process-remove-many-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';
@@ -194,7 +193,11 @@ let routes = (
 
 const reduceRoutesFn: (a: React.ReactElement[], b: ElementListReducer) => React.ReactElement[] = (a, b) => b(a);
 
-routes = React.createElement(React.Fragment, null, pluginConfig.centerPanelList.reduce(reduceRoutesFn, React.Children.toArray(routes.props.children)));
+routes = React.createElement(
+    React.Fragment,
+    null,
+    pluginConfig.centerPanelList.reduce(reduceRoutesFn, React.Children.toArray(routes.props.children))
+);
 
 const applyCollapsedState = (isCollapsed) => {
     const rightPanel: Element = document.getElementsByClassName('layout-pane')[1];
@@ -255,7 +258,6 @@ export const WorkbenchPanel = withStyles(styles)((props: WorkbenchPanelProps) =>
             <ContextMenu />
             <CopyCollectionDialog />
             <CopyProcessDialog />
-            <CopyManyProcessesDialog />
             <CreateCollectionDialog />
             <CreateProjectDialog />
             <CreateRepositoryDialog />
@@ -282,7 +284,6 @@ export const WorkbenchPanel = withStyles(styles)((props: WorkbenchPanelProps) =>
             <RemoveKeepServiceDialog />
             <RemoveLinkDialog />
             <RemoveProcessDialog />
-            <RemoveManyProcessesDialog />
             <RemoveRepositoryDialog />
             <RemoveSshKeyDialog />
             <RemoveVirtualMachineDialog />