21128: adjusted action menu types Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa...
authorLisa Knox <lisaknox83@gmail.com>
Wed, 15 Nov 2023 15:27:18 +0000 (10:27 -0500)
committerLisa Knox <lisaknox83@gmail.com>
Wed, 15 Nov 2023 15:27:18 +0000 (10:27 -0500)
src/components/multiselect-toolbar/MultiselectToolbar.tsx
src/components/multiselect-toolbar/ms-toolbar-action-filters.ts
src/views-components/multiselect-toolbar/ms-collection-action-set.ts
src/views-components/multiselect-toolbar/ms-menu-action-set.ts
src/views-components/multiselect-toolbar/ms-process-action-set.ts
src/views-components/multiselect-toolbar/ms-project-action-set.ts

index 73454689b65aafb6bbc3240d52ddbe723e48e3b2..8112746555296fd9e3d84447118a6e0e67329629 100644 (file)
@@ -57,7 +57,7 @@ export const MultiselectToolbar = connect(
 
         const currentPathIsTrash = window.location.pathname === "/trash";
 
-        const buttons =
+        const actions =
             currentPathIsTrash && selectedToKindSet(checkedList).size 
             ? [msToggleTrashAction] 
             : selectActionsByKind(currentResourceKinds, multiselectActionsFilters);
@@ -66,29 +66,29 @@ export const MultiselectToolbar = connect(
             <React.Fragment>
                 <Toolbar
                     className={classes.root}
-                    style={{ width: `${buttons.length * 2.5}rem` }}
+                    style={{ width: `${actions.length * 2.5}rem` }}
                 >
-                    {buttons.length ? (
-                        buttons.map((btn, i) =>
-                            btn.isDefault ? (
+                    {actions.length ? (
+                        actions.map((action, i) =>
+                            action.isDefault ? (
                                 <Tooltip
                                     className={classes.button}
-                                    title={btn.isDefault(selectedUuid, resources, favorites) ? btn.defaultText : btn.altText}
+                                    title={action.isDefault(selectedUuid, resources, favorites) ? action.name : action.altText}
                                     key={i}
                                     disableFocusListener
                                 >
-                                    <IconButton onClick={() => props.executeMulti(btn, checkedList, resources)}>
-                                        {btn.isDefault(selectedUuid, resources, favorites) ? btn.icon && btn.icon({}) : btn.altIcon && btn.altIcon({})}
+                                    <IconButton onClick={() => props.executeMulti(action, checkedList, resources)}>
+                                        {action.isDefault(selectedUuid, resources, favorites) ? action.icon && action.icon({}) : action.altIcon && action.altIcon({})}
                                     </IconButton>
                                 </Tooltip>
                             ) : (
                                 <Tooltip
                                     className={classes.button}
-                                    title={btn.name}
+                                    title={action.name}
                                     key={i}
                                     disableFocusListener
                                 >
-                                    <IconButton onClick={() => props.executeMulti(btn, checkedList, resources)}>{btn.icon ? btn.icon({}) : <></>}</IconButton>
+                                    <IconButton onClick={() => props.executeMulti(action, checkedList, resources)}>{action.icon ? action.icon({}) : <></>}</IconButton>
                                 </Tooltip>
                             )
                         )
@@ -153,14 +153,14 @@ function selectActionsByKind(currentResourceKinds: Array<string>, filterSet: TMu
     });
 
     const filteredNameSet = allFiltersArray.map(filterArray => {
-        const resultSet = new Set();
-        filterArray.forEach(action => resultSet.add(action.name || ""));
+        const resultSet = new Set<string>();
+        filterArray.forEach(action => resultSet.add(action.name as string || ""));
         return resultSet;
     });
 
     const filteredResult = Array.from(rawResult).filter(action => {
         for (let i = 0; i < filteredNameSet.length; i++) {
-            if (!filteredNameSet[i].has(action.name)) return false;
+            if (!filteredNameSet[i].has(action.name as string)) return false;
         }
         return true;
     });
index 0ec5690e9fb0fe464ecfa2e74874f33d4e1beae9..8d8b6f0f7ef83ff2087d6d69669a78e0b464d650 100644 (file)
@@ -10,7 +10,7 @@ import { msProcessActionSet } from "views-components/multiselect-toolbar/ms-proc
 
 export type TMultiselectActionsFilters = Record<string, [MultiSelectMenuActionSet, Set<string>]>;
 
-const { MOVE_TO, TOGGLE_TRASH_ACTION, TOGGLE_FAVORITE_ACTION, REMOVE, MAKE_A_COPY } = MultiSelectMenuActionNames;
+const { MOVE_TO, ADD_TO_TRASH: TOGGLE_TRASH_ACTION, ADD_TO_FAVORITES: TOGGLE_FAVORITE_ACTION, REMOVE, MAKE_A_COPY } = MultiSelectMenuActionNames;
 
 //these sets govern what actions are on the ms toolbar for each resource kind
 const projectMSActionsFilter = new Set([MOVE_TO, TOGGLE_TRASH_ACTION, TOGGLE_FAVORITE_ACTION]);
index 51e21592aec26ecf284998b3cc03825c1affc690..b17a17e7df93fc73d5bb635dba3141dcea42a291 100644 (file)
@@ -8,13 +8,13 @@ import { openCollectionCopyDialog, openMultiCollectionCopyDialog } from "store/c
 import { ToggleTrashAction } from "views-components/context-menu/actions/trash-action";
 import { toggleCollectionTrashed } from "store/trash/trash-actions";
 import { ContextMenuResource } from "store/context-menu/context-menu-actions";
-import { MultiSelectMenuActionSet } from "./ms-menu-action-set";
+import { MultiSelectMenuActionSet, MultiSelectMenuActionNames } from "./ms-menu-action-set";
 
 export const msCollectionActionSet: MultiSelectMenuActionSet = [
     [
         {
             icon: CopyIcon,
-            name: "Make a copy",
+            name: MultiSelectMenuActionNames.MAKE_A_COPY,
             isForMulti: true,
             execute: (dispatch, [...resources]) => {
                 if (resources[0].fromContextMenu || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
@@ -23,13 +23,13 @@ export const msCollectionActionSet: MultiSelectMenuActionSet = [
         },
         {
             icon: MoveToIcon,
-            name: "Move to",
+            name: MultiSelectMenuActionNames.MOVE_TO,
             isForMulti: true,
             execute: (dispatch, resources) => dispatch<any>(openMoveCollectionDialog(resources[0])),
         },
         {
             component: ToggleTrashAction,
-            name: "ToggleTrashAction",
+            name: MultiSelectMenuActionNames.ADD_TO_TRASH,
             isForMulti: true,
             execute: (dispatch, resources: ContextMenuResource[]) => {
                 for (const resource of [...resources]) {
index db184d266b3086fa40e3b131d03d84c2828db5e0..b31bea40dc898eb15f9fbb81b099e6f2b6674dd9 100644 (file)
@@ -9,8 +9,8 @@ import { ResourcesState } from "store/resources/resources";
 export const MultiSelectMenuActionNames = {
   MAKE_A_COPY: "Make a copy",
   MOVE_TO: "Move to",
-  TOGGLE_TRASH_ACTION: "ToggleTrashAction",
-  TOGGLE_FAVORITE_ACTION: "ToggleFavoriteAction",
+  ADD_TO_TRASH: "Add to Trash",
+  ADD_TO_FAVORITES: "Add to Favorites",
   COPY_TO_CLIPBOARD: "Copy to clipboard",
   COPY_AND_RERUN_PROCESS: "Copy and re-run process",
   REMOVE: "Remove",
@@ -24,4 +24,4 @@ export interface MultiSelectMenuAction extends ContextMenuAction {
     isForMulti: boolean;
 }
 
-export type MultiSelectMenuActionSet = Array<Array<MultiSelectMenuAction>>;
+export type MultiSelectMenuActionSet = MultiSelectMenuAction[][];
index 28f97c42cac7a1d15fdc7efb269d494f34a57621..57c8e5771f2256c314d65ebed34e6cef172bb04a 100644 (file)
@@ -6,13 +6,13 @@ import { MoveToIcon, RemoveIcon, ReRunProcessIcon } from "components/icon/icon";
 import { openMoveProcessDialog } from "store/processes/process-move-actions";
 import { openCopyProcessDialog } from "store/processes/process-copy-actions";
 import { openRemoveProcessDialog } from "store/processes/processes-actions";
-import { MultiSelectMenuActionSet } from "./ms-menu-action-set";
+import { MultiSelectMenuActionSet, MultiSelectMenuActionNames } from "./ms-menu-action-set";
 
 export const msProcessActionSet: MultiSelectMenuActionSet = [
     [
         {
             icon: ReRunProcessIcon,
-            name: "Copy and re-run process",
+            name: MultiSelectMenuActionNames.COPY_AND_RERUN_PROCESS,
             isForMulti: true,
             execute: (dispatch, resources) => {
                 for (const resource of [...resources]) {
@@ -22,14 +22,14 @@ export const msProcessActionSet: MultiSelectMenuActionSet = [
         },
         {
             icon: MoveToIcon,
-            name: "Move to",
+            name: MultiSelectMenuActionNames.MOVE_TO,
             isForMulti: true,
             execute: (dispatch, resources) => {
                 dispatch<any>(openMoveProcessDialog(resources[0]));
             },
         },
         {
-            name: "Remove",
+            name: MultiSelectMenuActionNames.REMOVE,
             icon: RemoveIcon,
             isForMulti: true,
             execute: (dispatch, resources) => {
index d3579e550a1a98d903b062fce53eb521b7121048..d31fddddea61989a9b249d45d566a876951191b9 100644 (file)
@@ -15,8 +15,7 @@ import { getResource } from "store/resources/resources";
 import { checkFavorite } from "store/favorites/favorites-reducer";
 
 export const msToggleFavoriteAction = {
-    name: MultiSelectMenuActionNames.TOGGLE_FAVORITE_ACTION,
-    defaultText: 'Add to Favorites',
+    name: MultiSelectMenuActionNames.ADD_TO_FAVORITES,
     altText: 'Remove from Favorites',
     icon: AddFavoriteIcon,
     altIcon: RemoveFavoriteIcon,
@@ -50,8 +49,7 @@ export const msMoveToAction = {
 };
 
 export const msToggleTrashAction = {
-    name: MultiSelectMenuActionNames.TOGGLE_TRASH_ACTION,
-    defaultText: 'Add to Trash',
+    name: MultiSelectMenuActionNames.ADD_TO_TRASH,
     altText: 'Restore from Trash',
     icon: TrashIcon,
     altIcon: RestoreFromTrashIcon,