[arvados-workbench2] updated: 2.6.0-42-g1a3746a0

git repository hosting git at public.arvados.org
Thu May 25 20:15:50 UTC 2023


Summary of changes:
 src/components/data-explorer/data-explorer.tsx     |   2 -
 .../multiselectToolbar/MultiselectToolbar.tsx      |  83 ++++++----
 src/store/dialog/dialog-reducer.ts                 |  10 +-
 src/store/processes/process-copy-actions.ts        | 167 ++++++++++++---------
 .../dialog-copy/dialog-process-rerun.tsx           |  45 +++---
 .../dialog-forms/copy-process-dialog.ts            |  26 +++-
 src/views/workbench/workbench.tsx                  |   3 +-
 7 files changed, 199 insertions(+), 137 deletions(-)

       via  1a3746a005fb857cc6760fde34e78cbcbb7d11e5 (commit)
       via  1bde07ef5884a55bbb47aaf30a90b122a4810617 (commit)
      from  0486a1fe8e98fb613eceabfd745875ed2b0d4395 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 1a3746a005fb857cc6760fde34e78cbcbb7d11e5
Author: Lisa Knox <lisaknox83 at gmail.com>
Date:   Thu May 25 16:15:44 2023 -0400

    15768: new dialog box for multi-copy  Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>

diff --git a/src/components/multiselectToolbar/MultiselectToolbar.tsx b/src/components/multiselectToolbar/MultiselectToolbar.tsx
index 2d6b1889..d141afd9 100644
--- a/src/components/multiselectToolbar/MultiselectToolbar.tsx
+++ b/src/components/multiselectToolbar/MultiselectToolbar.tsx
@@ -15,13 +15,14 @@ import { processResourceActionSet } from '../../views-components/context-menu/ac
 import { ContextMenuResource } from 'store/context-menu/context-menu-actions';
 import { ResourceKind, extractUuidKind } from 'models/resource';
 import { openMoveProcessDialog } from 'store/processes/process-move-actions';
-import { openCopyProcessDialog } from 'store/processes/process-copy-actions';
+import { openCopyProcessDialog, openCopyManyProcessesDialog } from 'store/processes/process-copy-actions';
 import { getResource } from 'store/resources/resources';
 import { ResourceName } from 'views-components/data-explorer/renderers';
 import { ProcessResource } from 'models/process';
 import { ResourcesState } from 'store/resources/resources';
 import { Resource } from 'models/resource';
 import { getProcess } from 'store/processes/process';
+import { CopyProcessDialog, CopyManyProcessesDialog } from 'views-components/dialog-forms/copy-process-dialog';
 
 type CssRules = 'root' | 'button';
 
@@ -101,7 +102,8 @@ export const MultiselectToolbar = connect(
             <Toolbar className={classes.root} style={{ width: `${buttons.length * 5.5}rem` }}>
                 {buttons.length ? (
                     buttons.map((btn) => (
-                        <Button key={btn.name} className={classes.button} onClick={() => props[btn.funcName](checkedList, resources)}>
+                        <Button key={btn.name} className={classes.button} onClick={() => props[btn.funcName](checkedList)}>
+                            {/* {<CopyProcessDialog>{btn.name}</CopyProcessDialog>} */}
                             {btn.name}
                         </Button>
                     ))
@@ -134,8 +136,6 @@ function selectedToKindSet(checkedList: TCheckedList): Set<string> {
 }
 
 function mapStateToProps(state: RootState) {
-    // console.log(state);
-    // console.log(getResource<ProcessResource>('tordo-dz642-0p7xefqdr4nw4pw')(state.resources));
     const { isVisible, checkedList } = state.multiselect;
     return {
         isVisible: isVisible,
@@ -146,20 +146,18 @@ function mapStateToProps(state: RootState) {
 
 function mapDispatchToProps(dispatch: Dispatch) {
     return {
-        copySelected: (checkedList: TCheckedList, resources: ResourcesState) => copyMoveMulti(dispatch, checkedList, resources),
+        copySelected: (checkedList: TCheckedList, resources: ResourcesState) => copyMoveMany(dispatch, checkedList),
         moveSelected: (checkedList: TCheckedList) => {},
         barSelected: () => {},
         removeSelected: (checkedList: TCheckedList) => removeMultiProcesses(dispatch, checkedList),
     };
 }
 
-function copyMoveMulti(dispatch: Dispatch, checkedList: TCheckedList, resources: ResourcesState) {
+function copyMoveMany(dispatch: Dispatch, checkedList: TCheckedList) {
     const selectedList: Array<string> = selectedToArray(checkedList);
-    const single = getProcess(selectedList[0])(resources)?.containerRequest;
-    console.log(single);
-    const { name, uuid } = single as any;
-    console.log(name, uuid);
-    dispatch<any>(openCopyProcessDialog({ name, uuid }));
+    const uuid = selectedList[0];
+    // dispatch<any>(openCopyManyProcessesDialog(uuid));
+    dispatch<any>(openCopyManyProcessesDialog(selectedList));
 }
 
 function moveMultiProcesses(dispatch: Dispatch, checkedList: TCheckedList): void {
diff --git a/src/store/dialog/dialog-reducer.ts b/src/store/dialog/dialog-reducer.ts
index 30368685..548d0a78 100644
--- a/src/store/dialog/dialog-reducer.ts
+++ b/src/store/dialog/dialog-reducer.ts
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { DialogAction, dialogActions } from "./dialog-actions";
+import { DialogAction, dialogActions } from './dialog-actions';
 
 export type DialogState = Record<string, Dialog<any>>;
 
@@ -12,16 +12,14 @@ export interface Dialog<T> {
 }
 
 export const dialogReducer = (state: DialogState = {}, action: DialogAction) =>
-
     dialogActions.match(action, {
         OPEN_DIALOG: ({ id, data }) => ({ ...state, [id]: { open: true, data } }),
         CLOSE_DIALOG: ({ id }) => ({
             ...state,
-            [id]: state[id] ? { ...state[id], open: false } : { open: false, data: {} }
+            [id]: state[id] ? { ...state[id], open: false } : { open: false, data: {} },
         }),
-        CLOSE_ALL_DIALOGS: () => ({ }),
+        CLOSE_ALL_DIALOGS: () => ({}),
         default: () => state,
     });
 
-export const getDialog = <T>(state: DialogState, id: string) =>
-    state[id] ? state[id] as Dialog<T> : undefined;
+export const getDialog = <T>(state: DialogState, id: string) => (state[id] ? (state[id] as Dialog<T>) : undefined);
diff --git a/src/store/processes/process-copy-actions.ts b/src/store/processes/process-copy-actions.ts
index d8e1eb09..d3c36b3f 100644
--- a/src/store/processes/process-copy-actions.ts
+++ b/src/store/processes/process-copy-actions.ts
@@ -9,15 +9,15 @@ 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 { getProcess } from 'store/processes/process';
+import { Process, getProcess } from 'store/processes/process';
 import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
 import { initProjectsTreePicker } from 'store/tree-picker/tree-picker-actions';
-import { ContainerRequestState } from 'models/container-request';
+import { ContainerRequestResource, 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) => {
-    console.log(resource);
     const process = getProcess(resource.uuid)(getState().resources);
     if (process) {
         dispatch<any>(resetPickerProjectTree());
@@ -30,6 +30,30 @@ export const openCopyProcessDialog = (resource: { name: string; uuid: string })
     }
 };
 
+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 copyProcess = (resource: CopyFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
     dispatch(startSubmit(PROCESS_COPY_FORM_NAME));
     try {
diff --git a/src/views-components/dialog-copy/dialog-process-rerun.tsx b/src/views-components/dialog-copy/dialog-process-rerun.tsx
index 9f97b1ac..2d34baf9 100644
--- a/src/views-components/dialog-copy/dialog-process-rerun.tsx
+++ b/src/views-components/dialog-copy/dialog-process-rerun.tsx
@@ -2,38 +2,37 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import React from "react";
+import React from 'react';
 import { memoize } from 'lodash/fp';
 import { InjectedFormProps, Field } from 'redux-form';
 import { WithDialogProps } from 'store/dialog/with-dialog';
 import { FormDialog } from 'components/form-dialog/form-dialog';
 import { ProjectTreePickerField } from 'views-components/projects-tree-picker/tree-picker-field';
 import { COPY_NAME_VALIDATION, COPY_FILE_VALIDATION } from 'validators/validators';
-import { TextField } from "components/text-field/text-field";
+import { TextField } from 'components/text-field/text-field';
 import { CopyFormDialogData } from 'store/copy-dialog/copy-dialog';
 import { PickerIdProp } from 'store/tree-picker/picker-id';
 
 type ProcessRerunFormDialogProps = WithDialogProps<string> & InjectedFormProps<CopyFormDialogData>;
 
-export const DialogProcessRerun = (props: ProcessRerunFormDialogProps & PickerIdProp) =>
-    <FormDialog
-        dialogTitle='Choose location for re-run'
-        formFields={CopyDialogFields(props.pickerId)}
-        submitLabel='Copy'
-        {...props}
-    />;
+export const DialogProcessRerun = (props: ProcessRerunFormDialogProps & PickerIdProp) => (
+    <FormDialog dialogTitle='Choose location for re-run' formFields={CopyDialogFields(props.pickerId)} submitLabel='Copy' {...props} />
+);
 
-const CopyDialogFields = 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}/>
-        </>);
+const CopyDialogFields = 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} />
+    </>
+));
+
+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} />
+    </>
+));
diff --git a/src/views-components/dialog-forms/copy-process-dialog.ts b/src/views-components/dialog-forms/copy-process-dialog.ts
index 6a79b626..b3454428 100644
--- a/src/views-components/dialog-forms/copy-process-dialog.ts
+++ b/src/views-components/dialog-forms/copy-process-dialog.ts
@@ -2,14 +2,14 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { compose } from "redux";
-import { withDialog } from "store/dialog/with-dialog";
+import { compose } from 'redux';
+import { withDialog } from 'store/dialog/with-dialog';
 import { reduxForm } from 'redux-form';
-import { PROCESS_COPY_FORM_NAME } from 'store/processes/process-copy-actions';
-import { DialogProcessRerun } from "views-components/dialog-copy/dialog-process-rerun";
+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 { copyProcess } from 'store/workbench/workbench-actions';
 import { CopyFormDialogData } from 'store/copy-dialog/copy-dialog';
-import { pickerId } from "store/tree-picker/picker-id";
+import { pickerId } from 'store/tree-picker/picker-id';
 
 export const CopyProcessDialog = compose(
     withDialog(PROCESS_COPY_FORM_NAME),
@@ -17,7 +17,19 @@ export const CopyProcessDialog = compose(
         form: PROCESS_COPY_FORM_NAME,
         onSubmit: (data, dispatch) => {
             dispatch(copyProcess(data));
-        }
+        },
     }),
-    pickerId(PROCESS_COPY_FORM_NAME),
+    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/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 7be3c8ba..74bccd0f 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -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 } from 'views-components/dialog-forms/copy-process-dialog';
+import { CopyProcessDialog, CopyManyProcessesDialog } 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';
@@ -255,6 +255,7 @@ export const WorkbenchPanel = withStyles(styles)((props: WorkbenchPanelProps) =>
             <ContextMenu />
             <CopyCollectionDialog />
             <CopyProcessDialog />
+            <CopyManyProcessesDialog />
             <CreateCollectionDialog />
             <CreateProjectDialog />
             <CreateRepositoryDialog />

commit 1bde07ef5884a55bbb47aaf30a90b122a4810617
Author: Lisa Knox <lisaknox83 at gmail.com>
Date:   Wed May 24 16:14:00 2023 -0400

    one process copies Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>

diff --git a/src/components/data-explorer/data-explorer.tsx b/src/components/data-explorer/data-explorer.tsx
index 67c6e748..b1d4605f 100644
--- a/src/components/data-explorer/data-explorer.tsx
+++ b/src/components/data-explorer/data-explorer.tsx
@@ -186,7 +186,6 @@ export const DataExplorer = withStyles(styles)(
                 panelName,
                 panelMaximized,
                 elementPath,
-                isMSToolbarVisible,
                 toggleMSToolbar,
                 setCheckedListOnStore,
             } = this.props;
@@ -231,7 +230,6 @@ export const DataExplorer = withStyles(styles)(
                                             </Tooltip>
                                         )}
                                     </Toolbar>
-                                    {/* {isMSToolbarVisible && <MultiselectToolbar buttons={defaultActions} />} */}
                                     <MultiselectToolbar actions={defaultActions} />
                                 </Grid>
                             )}
diff --git a/src/components/multiselectToolbar/MultiselectToolbar.tsx b/src/components/multiselectToolbar/MultiselectToolbar.tsx
index fc036b29..2d6b1889 100644
--- a/src/components/multiselectToolbar/MultiselectToolbar.tsx
+++ b/src/components/multiselectToolbar/MultiselectToolbar.tsx
@@ -13,10 +13,17 @@ 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 { toggleTrashed } from 'store/trash/trash-actions';
 import { ResourceKind, extractUuidKind } from 'models/resource';
+import { openMoveProcessDialog } from 'store/processes/process-move-actions';
+import { openCopyProcessDialog } from 'store/processes/process-copy-actions';
+import { getResource } from 'store/resources/resources';
+import { ResourceName } from 'views-components/data-explorer/renderers';
+import { ProcessResource } from 'models/process';
+import { ResourcesState } from 'store/resources/resources';
+import { Resource } from 'models/resource';
+import { getProcess } from 'store/processes/process';
 
-type CssRules = 'root' | 'expanded' | 'button';
+type CssRules = 'root' | 'button';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     root: {
@@ -26,8 +33,6 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         padding: 0,
         margin: '1rem auto auto 0.5rem',
         overflow: 'hidden',
-    },
-    expanded: {
         transition: 'width 150ms',
     },
     button: {
@@ -42,30 +47,31 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 
 type MultiselectToolbarAction = {
     name: string;
-    action: string;
+    funcName: string;
     relevantKinds: Set<ResourceKind>;
 };
 
+//gleaned from src/views-components/context-menu/action-sets
 export const defaultActions: Array<MultiselectToolbarAction> = [
     {
-        name: 'copy',
-        action: 'copySelected',
-        relevantKinds: new Set([ResourceKind.COLLECTION]),
+        name: 'copy and re-run',
+        funcName: 'copySelected',
+        relevantKinds: new Set([ResourceKind.PROCESS]),
     },
     {
         name: 'move',
-        action: 'moveSelected',
-        relevantKinds: new Set([ResourceKind.COLLECTION, ResourceKind.PROCESS]),
+        funcName: 'moveSelected',
+        relevantKinds: new Set([ResourceKind.PROCESS, ResourceKind.PROJECT]),
     },
     {
         name: 'remove',
-        action: 'removeSelected',
-        relevantKinds: new Set([ResourceKind.COLLECTION, ResourceKind.PROCESS, ResourceKind.PROJECT]),
+        funcName: 'removeSelected',
+        relevantKinds: new Set([ResourceKind.PROCESS, ResourceKind.COLLECTION]),
     },
     {
-        name: 'foo',
-        action: 'barSelected',
-        relevantKinds: new Set([ResourceKind.COLLECTION, ResourceKind.PROJECT]),
+        name: 'favorite',
+        funcName: 'favoriteSelected',
+        relevantKinds: new Set([ResourceKind.PROCESS, ResourceKind.PROJECT, ResourceKind.COLLECTION]),
     },
 ];
 
@@ -73,10 +79,11 @@ export type MultiselectToolbarProps = {
     actions: Array<MultiselectToolbarAction>;
     isVisible: boolean;
     checkedList: TCheckedList;
-    copySelected: () => void;
-    moveSelected: () => void;
+    resources: ResourcesState;
+    copySelected: (checkedList: TCheckedList, resources: ResourcesState) => void;
+    moveSelected: (resource) => void;
     barSelected: () => void;
-    removeSelected: (selectedList: TCheckedList) => void;
+    removeSelected: (checkedList: TCheckedList) => void;
 };
 
 export const MultiselectToolbar = connect(
@@ -85,16 +92,16 @@ export const MultiselectToolbar = connect(
 )(
     withStyles(styles)((props: MultiselectToolbarProps & WithStyles<CssRules>) => {
         // console.log(props);
-        const { classes, actions, isVisible, checkedList } = props;
+        const { classes, actions, isVisible, checkedList, resources } = props;
 
         const currentResourceKinds = Array.from(selectedToKindSet(checkedList));
         const buttons = actions.filter((action) => currentResourceKinds.length && currentResourceKinds.every((kind) => action.relevantKinds.has(kind as ResourceKind)));
 
         return (
-            <Toolbar className={isVisible && buttons.length ? `${classes.root} ${classes.expanded}` : classes.root} style={{ width: `${buttons.length * 5.5}rem` }}>
+            <Toolbar className={classes.root} style={{ width: `${buttons.length * 5.5}rem` }}>
                 {buttons.length ? (
                     buttons.map((btn) => (
-                        <Button key={btn.name} className={`${classes.button} ${classes.expanded}`} onClick={() => props[btn.action](checkedList)}>
+                        <Button key={btn.name} className={classes.button} onClick={() => props[btn.funcName](checkedList, resources)}>
                             {btn.name}
                         </Button>
                     ))
@@ -127,23 +134,49 @@ function selectedToKindSet(checkedList: TCheckedList): Set<string> {
 }
 
 function mapStateToProps(state: RootState) {
+    // console.log(state);
+    // console.log(getResource<ProcessResource>('tordo-dz642-0p7xefqdr4nw4pw')(state.resources));
     const { isVisible, checkedList } = state.multiselect;
     return {
         isVisible: isVisible,
         checkedList: checkedList as TCheckedList,
+        resources: state.resources,
     };
 }
 
 function mapDispatchToProps(dispatch: Dispatch) {
     return {
-        copySelected: () => {},
-        moveSelected: () => {},
+        copySelected: (checkedList: TCheckedList, resources: ResourcesState) => copyMoveMulti(dispatch, checkedList, resources),
+        moveSelected: (checkedList: TCheckedList) => {},
         barSelected: () => {},
-        removeSelected: (checkedList: TCheckedList) => removeMulti(dispatch, checkedList),
+        removeSelected: (checkedList: TCheckedList) => removeMultiProcesses(dispatch, checkedList),
     };
 }
 
-function removeMulti(dispatch: Dispatch, checkedList: TCheckedList): void {
+function copyMoveMulti(dispatch: Dispatch, checkedList: TCheckedList, resources: ResourcesState) {
+    const selectedList: Array<string> = selectedToArray(checkedList);
+    const single = getProcess(selectedList[0])(resources)?.containerRequest;
+    console.log(single);
+    const { name, uuid } = single as any;
+    console.log(name, uuid);
+    dispatch<any>(openCopyProcessDialog({ name, uuid }));
+}
+
+function moveMultiProcesses(dispatch: Dispatch, checkedList: TCheckedList): void {
+    const selectedList: Array<string> = selectedToArray(checkedList);
+    // if (selectedList.length === 1) dispatch<any>(openMoveProcessDialog(selectedList[0]));
+}
+
+const RemoveFunctions = {
+    ONE_PROCESS: (uuid: string) => openRemoveProcessDialog(uuid),
+    MANY_PROCESSES: (list: Array<string>) => openRemoveManyProcessesDialog(list),
+};
+
+function removeMultiProcesses(dispatch: Dispatch, checkedList: TCheckedList): void {
     const selectedList: Array<string> = selectedToArray(checkedList);
-    dispatch<any>(selectedList.length === 1 ? openRemoveProcessDialog(selectedList[0]) : openRemoveManyProcessesDialog(selectedList));
+    dispatch<any>(selectedList.length === 1 ? RemoveFunctions.ONE_PROCESS(selectedList[0]) : RemoveFunctions.MANY_PROCESSES(selectedList));
 }
+
+//onRemove
+//go through the array of selected and choose the appropriate removal function
+//have a constant with [ResourceKind]: different removal methods
diff --git a/src/store/processes/process-copy-actions.ts b/src/store/processes/process-copy-actions.ts
index 3c55a9ad..d8e1eb09 100644
--- a/src/store/processes/process-copy-actions.ts
+++ b/src/store/processes/process-copy-actions.ts
@@ -2,85 +2,84 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { Dispatch } from "redux";
-import { dialogActions } from "store/dialog/dialog-actions";
+import { Dispatch } from 'redux';
+import { dialogActions } from 'store/dialog/dialog-actions';
 import { initialize, startSubmit } from 'redux-form';
 import { resetPickerProjectTree } from 'store/project-tree-picker/project-tree-picker-actions';
 import { RootState } from 'store/store';
 import { ServiceRepository } from 'services/services';
 import { CopyFormDialogData } from 'store/copy-dialog/copy-dialog';
 import { getProcess } from 'store/processes/process';
-import {snackbarActions, SnackbarKind} from 'store/snackbar/snackbar-actions';
+import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
 import { initProjectsTreePicker } from 'store/tree-picker/tree-picker-actions';
-import { ContainerRequestState } from "models/container-request";
+import { ContainerRequestState } from 'models/container-request';
 
 export const PROCESS_COPY_FORM_NAME = 'processCopyFormName';
 
-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 openCopyProcessDialog = (resource: { name: string; uuid: string }) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+    console.log(resource);
+    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));
-        try {
-            const process = await services.containerRequestService.get(resource.uuid);
-            const {
-                command,
-                containerCountMax,
-                containerImage,
-                cwd,
-                description,
-                environment,
-                kind,
-                mounts,
-                outputName,
-                outputPath,
-                outputProperties,
-                outputStorageClasses,
-                outputTtl,
-                properties,
-                runtimeConstraints,
-                schedulingParameters,
-                useExisting,
-            } = process;
-            const newProcess = await services.containerRequestService.create({
-                command,
-                containerCountMax,
-                containerImage,
-                cwd,
-                description,
-                environment,
-                kind,
-                mounts,
-                name: resource.name,
-                outputName,
-                outputPath,
-                outputProperties,
-                outputStorageClasses,
-                outputTtl,
-                ownerUuid: resource.ownerUuid,
-                priority: 500,
-                properties,
-                runtimeConstraints,
-                schedulingParameters,
-                state: ContainerRequestState.UNCOMMITTED,
-                useExisting,
-            });
-            dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_COPY_FORM_NAME }));
-            return newProcess;
-        } catch (e) {
-            dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_COPY_FORM_NAME }));
-            throw new Error('Could not copy the process.');
-        }
-    };
+export const copyProcess = (resource: CopyFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+    dispatch(startSubmit(PROCESS_COPY_FORM_NAME));
+    try {
+        const process = await services.containerRequestService.get(resource.uuid);
+        const {
+            command,
+            containerCountMax,
+            containerImage,
+            cwd,
+            description,
+            environment,
+            kind,
+            mounts,
+            outputName,
+            outputPath,
+            outputProperties,
+            outputStorageClasses,
+            outputTtl,
+            properties,
+            runtimeConstraints,
+            schedulingParameters,
+            useExisting,
+        } = process;
+        const newProcess = await services.containerRequestService.create({
+            command,
+            containerCountMax,
+            containerImage,
+            cwd,
+            description,
+            environment,
+            kind,
+            mounts,
+            name: resource.name,
+            outputName,
+            outputPath,
+            outputProperties,
+            outputStorageClasses,
+            outputTtl,
+            ownerUuid: resource.ownerUuid,
+            priority: 500,
+            properties,
+            runtimeConstraints,
+            schedulingParameters,
+            state: ContainerRequestState.UNCOMMITTED,
+            useExisting,
+        });
+        dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_COPY_FORM_NAME }));
+        return newProcess;
+    } catch (e) {
+        dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_COPY_FORM_NAME }));
+        throw new Error('Could not copy the process.');
+    }
+};

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list