21128: created ms-menu-action-set and moved name consts into it Arvados-DCO-1.1-Signe...
authorLisa Knox <lisaknox83@gmail.com>
Tue, 14 Nov 2023 17:22:21 +0000 (12:22 -0500)
committerLisa Knox <lisaknox83@gmail.com>
Tue, 14 Nov 2023 17:22:21 +0000 (12:22 -0500)
src/components/multiselect-toolbar/MultiselectToolbar.tsx
src/components/multiselect-toolbar/ms-kind-action-differentiator.ts
src/components/multiselect-toolbar/ms-toolbar-action-filters.ts
src/views-components/context-menu/context-menu-action-set.ts
src/views-components/multiselect-toolbar/ms-menu-action-set.ts [new file with mode: 0644]
src/views-components/multiselect-toolbar/ms-project-action-set.ts

index 4ba9e25da6a8c65bff88dba5c1a1504256369929..185f8e0f4ad5b6f0aa2cf829a32e545ac40f9595 100644 (file)
@@ -13,8 +13,9 @@ import { ContextMenuResource } from "store/context-menu/context-menu-actions";
 import { Resource, extractUuidKind } from "models/resource";
 import { getResource } from "store/resources/resources";
 import { ResourcesState } from "store/resources/resources";
-import { ContextMenuAction, ContextMenuActionSet, MultiSelectMenuAction } from "views-components/context-menu/context-menu-action-set";
-import { multiselectActionsFilters, TMultiselectActionsFilters, contextMenuActionConsts } from "./ms-toolbar-action-filters";
+import { MultiSelectMenuAction, MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-action-set";
+import { ContextMenuAction, ContextMenuActionSet } from "views-components/context-menu/context-menu-action-set";
+import { multiselectActionsFilters, TMultiselectActionsFilters } from "./ms-toolbar-action-filters";
 import { kindToActionSet, findActionByName } from "./ms-kind-action-differentiator";
 import { msToggleTrashAction } from "views-components/multiselect-toolbar/ms-project-action-set";
 import { copyToClipboardAction } from "store/open-in-new-tab/open-in-new-tab.actions";
@@ -74,7 +75,7 @@ export const MultiselectToolbar = connect(
                                     disableFocusListener
                                 >
                                     <IconButton onClick={() => props.executeMulti(btn, checkedList, props.resources)}>
-                                        {!currentPathIsTrash ? btn.defaultIcon && btn.defaultIcon({}) : btn.altIcon && btn.altIcon({})}
+                                        {!currentPathIsTrash ? btn.icon({}) : btn.altIcon({})}
                                     </IconButton>
                                 </Tooltip>
                             ) : (
@@ -188,13 +189,13 @@ function mapDispatchToProps(dispatch: Dispatch) {
         executeMulti: (selectedAction: ContextMenuAction, checkedList: TCheckedList, resources: ResourcesState): void => {
             const kindGroups = groupByKind(checkedList, resources);
             switch (selectedAction.name) {
-                case contextMenuActionConsts.MOVE_TO:
-                case contextMenuActionConsts.REMOVE:
+                case MultiSelectMenuActionNames.MOVE_TO:
+                case MultiSelectMenuActionNames.REMOVE:
                     const firstResource = getResource(selectedToArray(checkedList)[0])(resources) as ContainerRequestResource | Resource;
                     const action = findActionByName(selectedAction.name as string, kindToActionSet[firstResource.kind]);
                     if (action) action.execute(dispatch, kindGroups[firstResource.kind]);
                     break;
-                case contextMenuActionConsts.COPY_TO_CLIPBOARD:
+                case MultiSelectMenuActionNames.COPY_TO_CLIPBOARD:
                     const selectedResources = selectedToArray(checkedList).map(uuid => getResource(uuid)(resources));
                     dispatch<any>(copyToClipboardAction(selectedResources));
                     break;
index 2c617fdb7339863359a2cfeec3e2880a2052eefb..f514a078fa141bef80bf7410473d04a0cddad25d 100644 (file)
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { ResourceKind } from "models/resource";
-import { MultiSelectMenuActionSet } from "views-components/context-menu/context-menu-action-set";
+import { MultiSelectMenuAction , MultiSelectMenuActionSet} from "views-components/multiselect-toolbar/ms-menu-action-set";
 import { msCollectionActionSet } from "views-components/multiselect-toolbar/ms-collection-action-set";
 import { msProjectActionSet } from "views-components/multiselect-toolbar/ms-project-action-set";
 import { msProcessActionSet } from "views-components/multiselect-toolbar/ms-process-action-set";
index eb968e0ffc93d20a013229f26971c79db7e6f021..0ec5690e9fb0fe464ecfa2e74874f33d4e1beae9 100644 (file)
@@ -3,24 +3,14 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { ResourceKind } from "models/resource";
-import { MultiSelectMenuActionSet } from "views-components/context-menu/context-menu-action-set";
+import { MultiSelectMenuActionSet, MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-action-set";
 import { msCollectionActionSet } from "views-components/multiselect-toolbar/ms-collection-action-set";
 import { msProjectActionSet } from "views-components/multiselect-toolbar/ms-project-action-set";
 import { msProcessActionSet } from "views-components/multiselect-toolbar/ms-process-action-set";
 
 export type TMultiselectActionsFilters = Record<string, [MultiSelectMenuActionSet, Set<string>]>;
 
-export const contextMenuActionConsts = {
-    MAKE_A_COPY: "Make a copy",
-    MOVE_TO: "Move to",
-    TOGGLE_TRASH_ACTION: "ToggleTrashAction",
-    TOGGLE_FAVORITE_ACTION: "ToggleFavoriteAction",
-    COPY_TO_CLIPBOARD: "Copy to clipboard",
-    COPY_AND_RERUN_PROCESS: "Copy and re-run process",
-    REMOVE: "Remove",
-};
-
-const { MOVE_TO, TOGGLE_TRASH_ACTION, TOGGLE_FAVORITE_ACTION, REMOVE, MAKE_A_COPY } = contextMenuActionConsts;
+const { MOVE_TO, TOGGLE_TRASH_ACTION, 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 ba3eac1be3ee08197b155ab5e37a496a1cabd537..a953500b3ae7a49f9216bce9544b24b3771a9982 100644 (file)
@@ -5,18 +5,9 @@
 import { Dispatch } from "redux";
 import { ContextMenuItem } from "components/context-menu/context-menu";
 import { ContextMenuResource } from "store/context-menu/context-menu-actions";
-import { IconType } from "components/icon/icon";
 
 export interface ContextMenuAction extends ContextMenuItem {
     execute(dispatch: Dispatch, resources: ContextMenuResource[], state?: any): void;
 }
 
-export interface MultiSelectMenuAction extends ContextMenuAction {
-    defaultText?: string
-    defaultIcon?: IconType
-    altText?: string
-    altIcon?: IconType
-}
-
 export type ContextMenuActionSet = Array<Array<ContextMenuAction>>;
-export type MultiSelectMenuActionSet = Array<Array<MultiSelectMenuAction>>;
diff --git a/src/views-components/multiselect-toolbar/ms-menu-action-set.ts b/src/views-components/multiselect-toolbar/ms-menu-action-set.ts
new file mode 100644 (file)
index 0000000..c34df02
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { IconType } from "components/icon/icon";
+import { ContextMenuAction } from "../context-menu/context-menu-action-set";
+
+export const MultiSelectMenuActionNames = {
+  MAKE_A_COPY: "Make a copy",
+  MOVE_TO: "Move to",
+  TOGGLE_TRASH_ACTION: "ToggleTrashAction",
+  TOGGLE_FAVORITE_ACTION: "ToggleFavoriteAction",
+  COPY_TO_CLIPBOARD: "Copy to clipboard",
+  COPY_AND_RERUN_PROCESS: "Copy and re-run process",
+  REMOVE: "Remove",
+};
+
+export interface MultiSelectMenuAction extends ContextMenuAction {
+    defaultText?: string;
+    altText?: string;
+    altIcon?: IconType;
+    isDefault?: () => boolean;
+}
+
+export type MultiSelectMenuActionSet = Array<Array<MultiSelectMenuAction>>;
index 4e8c6f144db3b228bbcdc7ba33c3ea097964719b..61e89b1c63918e304b613ec158302b6b7ec5be02 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { MultiSelectMenuAction } from "views-components/context-menu/context-menu-action-set";
+import { MultiSelectMenuAction, MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-action-set";
 import { MoveToIcon, Link } from "components/icon/icon";
 import { openMoveProjectDialog } from "store/projects/project-move-actions";
 import { toggleProjectTrashed } from "store/trash/trash-actions";
@@ -13,11 +13,12 @@ import { AddFavoriteIcon, RemoveFavoriteIcon } from "components/icon/icon";
 import { RestoreFromTrashIcon, TrashIcon } from "components/icon/icon";
 
 
+
 export const msToggleFavoriteAction = {
-    name: "ToggleFavoriteAction",
+    name: MultiSelectMenuActionNames.TOGGLE_FAVORITE_ACTION,
     defaultText: 'Add to Favorites',
     altText: 'Remove from Favorites',
-    defaultIcon: AddFavoriteIcon,
+    icon: AddFavoriteIcon,
     altIcon: RemoveFavoriteIcon,
     execute: (dispatch, resources) => {
         dispatch(toggleFavorite(resources[0])).then(() => {
@@ -28,7 +29,7 @@ export const msToggleFavoriteAction = {
 
 export const msCopyToClipboardMenuAction = {
     icon: Link,
-    name: "Copy to clipboard",
+    name: MultiSelectMenuActionNames.COPY_TO_CLIPBOARD,
     execute: (dispatch, resources) => {
         dispatch(copyToClipboardAction(resources));
     },
@@ -36,17 +37,17 @@ export const msCopyToClipboardMenuAction = {
 
 export const msMoveToAction = {
     icon: MoveToIcon,
-    name: "Move to",
+    name: MultiSelectMenuActionNames.MOVE_TO,
     execute: (dispatch, resource) => {
         dispatch(openMoveProjectDialog(resource[0]));
     },
 };
 
 export const msToggleTrashAction = {
-    name: "ToggleTrashAction",
+    name: MultiSelectMenuActionNames.TOGGLE_TRASH_ACTION,
     defaultText: 'Add to Trash',
     altText: 'Restore from Trash',
-    defaultIcon: TrashIcon,
+    icon: TrashIcon,
     altIcon: RestoreFromTrashIcon,
     execute: (dispatch, resources) => {
         for (const resource of [...resources]) {