15768: changed isSingle to fromContextMenu for clarity Arvados-DCO-1.1-Signed-off... 15768-multi-select-operations
authorLisa Knox <lisaknox83@gmail.com>
Tue, 17 Oct 2023 14:18:06 +0000 (10:18 -0400)
committerLisa Knox <lisaknox83@gmail.com>
Tue, 17 Oct 2023 14:18:06 +0000 (10:18 -0400)
src/store/collections/collection-copy-actions.ts
src/store/context-menu/context-menu-actions.ts
src/store/copy-dialog/copy-dialog.ts
src/store/move-to-dialog/move-to-dialog.ts
src/store/processes/processes-actions.ts
src/store/workbench/workbench-actions.ts
src/views-components/context-menu/action-sets/collection-action-set.ts
src/views-components/context-menu/context-menu.tsx
src/views-components/multiselect-toolbar/ms-collection-action-set.ts

index 9386fe3cf051633015c1ceca37d67e759c27fcdb..c332ef5faf2bb3496cbf3a8e57fc082c68b502b3 100644 (file)
@@ -19,25 +19,25 @@ import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions";
 export const COLLECTION_COPY_FORM_NAME = "collectionCopyFormName";
 export const COLLECTION_MULTI_COPY_FORM_NAME = "collectionMultiCopyFormName";
 
-export const openCollectionCopyDialog = (resource: { name: string; uuid: string; isSingle?: boolean }) => (dispatch: Dispatch) => {
+export const openCollectionCopyDialog = (resource: { name: string; uuid: string; fromContextMenu?: boolean }) => (dispatch: Dispatch) => {
     dispatch<any>(resetPickerProjectTree());
     dispatch<any>(initProjectsTreePicker(COLLECTION_COPY_FORM_NAME));
-    const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: "", uuid: resource.uuid, isSingle: resource.isSingle };
+    const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: "", uuid: resource.uuid, fromContextMenu: resource.fromContextMenu };
     dispatch<any>(initialize(COLLECTION_COPY_FORM_NAME, initialData));
     dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_COPY_FORM_NAME, data: {} }));
 };
 
-export const openMultiCollectionCopyDialog = (resource: { name: string; uuid: string; isSingle?: boolean }) => (dispatch: Dispatch) => {
+export const openMultiCollectionCopyDialog = (resource: { name: string; uuid: string; fromContextMenu?: boolean }) => (dispatch: Dispatch) => {
     dispatch<any>(resetPickerProjectTree());
     dispatch<any>(initProjectsTreePicker(COLLECTION_MULTI_COPY_FORM_NAME));
-    const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: "", uuid: resource.uuid, isSingle: resource.isSingle };
+    const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: "", uuid: resource.uuid, fromContextMenu: resource.fromContextMenu };
     dispatch<any>(initialize(COLLECTION_MULTI_COPY_FORM_NAME, initialData));
     dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_MULTI_COPY_FORM_NAME, data: {} }));
 };
 
 export const copyCollection =
     (resource: CopyFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        const formName = resource.isSingle ? COLLECTION_COPY_FORM_NAME : COLLECTION_MULTI_COPY_FORM_NAME;
+        const formName = resource.fromContextMenu ? COLLECTION_COPY_FORM_NAME : COLLECTION_MULTI_COPY_FORM_NAME;
         dispatch(startSubmit(formName));
         let collection = getResource<CollectionResource>(resource.uuid)(getState().resources);
         try {
index da6dac5db0006ca68f3cc3aaab0fdf6254bb58ee..f846d25ba5089b8abfa859edfecd72d4ff07581f 100644 (file)
@@ -48,7 +48,7 @@ export type ContextMenuResource = {
     storageClassesDesired?: string[];
     properties?: { [key: string]: string | string[] };
     isMulti?: boolean;
-    isSingle?: boolean;
+    fromContextMenu?: boolean;
 };
 
 export const isKeyboardClick = (event: React.MouseEvent<HTMLElement>) => event.nativeEvent.detail === 0;
index af4d7ace95944915b99182b93a0b0e367fcd5662..dfae5c2cf0101eb5bd0dad71504568f1168309e7 100644 (file)
@@ -6,5 +6,5 @@ export interface CopyFormDialogData {
     name: string;
     uuid: string;
     ownerUuid: string;
-    isSingle?: boolean;
+    fromContextMenu?: boolean;
 }
index 12f2e858235877dbbb988e7f597fb49fd95cc621..e58f3984766cbb0f60989c1fdfe1da14af361308 100644 (file)
@@ -6,5 +6,5 @@ export interface MoveToFormDialogData {
     name: string;
     uuid: string;
     ownerUuid: string;
-    isSingle?: boolean;
+    fromContextMenu?: boolean;
 }
index 1b9d725ef0c49a08b6a76fa30b558fd12bd316c9..eadb05e5e1460ff47db6b12d687b36394a9c624e 100644 (file)
@@ -316,7 +316,7 @@ export const removeProcessPermanently = (uuid: string) => async (dispatch: Dispa
     const resource = getState().dialog.removeProcessDialog.data.resource;
     const checkedList = getState().multiselect.checkedList;
 
-    const uuidsToRemove: string[] = resource.isSingle ? [resource.uuid] : selectedToArray(checkedList);
+    const uuidsToRemove: string[] = resource.fromContextMenu ? [resource.uuid] : selectedToArray(checkedList);
 
     //if no items in checkedlist, default to normal context menu behavior
     if (!uuidsToRemove.length) uuidsToRemove.push(uuid);
index bf21bd3fee018c61b4d8886d62137841af14e423..956fa3d9a24a05379f45b1ef0c697b6097dea4f3 100644 (file)
@@ -279,7 +279,7 @@ export const moveProject =
     (data: MoveToFormDialogData, isSecondaryMove = false) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const checkedList = getState().multiselect.checkedList;
-        const uuidsToMove: string[] = data.isSingle ? [data.uuid] : selectedToArray(checkedList);
+        const uuidsToMove: string[] = data.fromContextMenu ? [data.uuid] : selectedToArray(checkedList);
 
         //if no items in checkedlist default to normal context menu behavior
         if (!isSecondaryMove && !uuidsToMove.length) uuidsToMove.push(data.uuid);
@@ -423,7 +423,7 @@ export const createCollection = (data: collectionCreateActions.CollectionCreateF
 
 export const copyCollection = (data: CopyFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
     const checkedList = getState().multiselect.checkedList;
-    const uuidsToCopy: string[] = data.isSingle ? [data.uuid] : selectedToArray(checkedList);
+    const uuidsToCopy: string[] = data.fromContextMenu ? [data.uuid] : selectedToArray(checkedList);
 
     //if no items in checkedlist && no items passed in, default to normal context menu behavior
     if (!uuidsToCopy.length) uuidsToCopy.push(data.uuid);
@@ -437,13 +437,13 @@ export const copyCollection = (data: CopyFormDialogData) => async (dispatch: Dis
     }
 
     async function copySingleCollection(copyToProject: CollectionCopyResource) {
-        const newName = data.isSingle || collectionsToCopy.length === 1 ? data.name : `Copy of: ${copyToProject.name}`;
+        const newName = data.fromContextMenu || collectionsToCopy.length === 1 ? data.name : `Copy of: ${copyToProject.name}`;
         try {
             const collection = await dispatch<any>(
                 collectionCopyActions.copyCollection({
                     ...copyToProject,
                     name: newName,
-                    isSingle: collectionsToCopy.length === 1 ? true : data.isSingle,
+                    fromContextMenu: collectionsToCopy.length === 1 ? true : data.fromContextMenu,
                 })
             );
             if (copyToProject && collection) {
@@ -475,7 +475,7 @@ export const moveCollection =
     (data: MoveToFormDialogData, isSecondaryMove = false) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const checkedList = getState().multiselect.checkedList;
-        const uuidsToMove: string[] = data.isSingle ? [data.uuid] : selectedToArray(checkedList);
+        const uuidsToMove: string[] = data.fromContextMenu ? [data.uuid] : selectedToArray(checkedList);
 
         //if no items in checkedlist && no items passed in, default to normal context menu behavior
         if (!isSecondaryMove && !uuidsToMove.length) uuidsToMove.push(data.uuid);
@@ -597,7 +597,7 @@ export const moveProcess =
     (data: MoveToFormDialogData, isSecondaryMove = false) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const checkedList = getState().multiselect.checkedList;
-        const uuidsToMove: string[] = data.isSingle ? [data.uuid] : selectedToArray(checkedList);
+        const uuidsToMove: string[] = data.fromContextMenu ? [data.uuid] : selectedToArray(checkedList);
 
         //if no items in checkedlist && no items passed in, default to normal context menu behavior
         if (!isSecondaryMove && !uuidsToMove.length) uuidsToMove.push(data.uuid);
@@ -831,7 +831,7 @@ const groupContentsHandlers = unionize(groupContentsHandlersRecord);
 
 type GroupContentsHandler = UnionOf<typeof groupContentsHandlers>;
 
-type CollectionCopyResource = Resource & { name: string; isSingle: boolean };
+type CollectionCopyResource = Resource & { name: string; fromContextMenu: boolean };
 
 type MoveableResource = Resource & { name: string };
 
index 2b343001a8006265c5ff5ce1aa9e1593920fd1d3..95aec9c7c94f476be3de1aa2f595040211b8d6b6 100644 (file)
@@ -65,7 +65,7 @@ const commonActionSet: ContextMenuActionSet = [
             icon: CopyIcon,
             name: "Make a copy",
             execute: (dispatch, resources) => {
-                if (resources[0].isSingle || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
+                if (resources[0].fromContextMenu || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
                 else dispatch<any>(openMultiCollectionCopyDialog(resources[0]));
             },
         },
index 8cb3394a23a8752a9b9c8bd5888267083217b7bc..157d4a728f6b1f44027766410c2ebb7d9b6efffe 100644 (file)
@@ -52,7 +52,7 @@ const mapDispatchToProps = (dispatch: Dispatch): ActionProps => ({
 const handleItemClick = memoize(
     (resource: DataProps["resource"], onItemClick: ActionProps["onItemClick"]): ContextMenuProps["onItemClick"] =>
         item => {
-            onItemClick(item, { ...resource, isSingle: true } as ContextMenuResource);
+            onItemClick(item, { ...resource, fromContextMenu: true } as ContextMenuResource);
         }
 );
 
index 3f6b2c3875d0480f6a3a2af1228a7b3260331cf3..b0a2a1b024793aafc8e86d269f468c7a49324862 100644 (file)
@@ -16,7 +16,7 @@ export const msCollectionActionSet: ContextMenuActionSet = [
             icon: CopyIcon,
             name: "Make a copy",
             execute: (dispatch, [...resources]) => {
-                if (resources[0].isSingle || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
+                if (resources[0].fromContextMenu || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
                 else dispatch<any>(openMultiCollectionCopyDialog(resources[0]));
             },
         },