From d1b1dea7d72c0654dcbd50a70100d364e44ffbf5 Mon Sep 17 00:00:00 2001 From: Lisa Knox Date: Wed, 15 Nov 2023 10:27:18 -0500 Subject: [PATCH] 21128: adjusted action menu types Arvados-DCO-1.1-Signed-off-by: Lisa Knox --- .../MultiselectToolbar.tsx | 26 +++++++++---------- .../ms-toolbar-action-filters.ts | 2 +- .../ms-collection-action-set.ts | 8 +++--- .../multiselect-toolbar/ms-menu-action-set.ts | 6 ++--- .../ms-process-action-set.ts | 8 +++--- .../ms-project-action-set.ts | 6 ++--- 6 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/src/components/multiselect-toolbar/MultiselectToolbar.tsx index 73454689b6..8112746555 100644 --- a/src/components/multiselect-toolbar/MultiselectToolbar.tsx +++ b/src/components/multiselect-toolbar/MultiselectToolbar.tsx @@ -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( - {buttons.length ? ( - buttons.map((btn, i) => - btn.isDefault ? ( + {actions.length ? ( + actions.map((action, i) => + action.isDefault ? ( - props.executeMulti(btn, checkedList, resources)}> - {btn.isDefault(selectedUuid, resources, favorites) ? btn.icon && btn.icon({}) : btn.altIcon && btn.altIcon({})} + props.executeMulti(action, checkedList, resources)}> + {action.isDefault(selectedUuid, resources, favorites) ? action.icon && action.icon({}) : action.altIcon && action.altIcon({})} ) : ( - props.executeMulti(btn, checkedList, resources)}>{btn.icon ? btn.icon({}) : <>} + props.executeMulti(action, checkedList, resources)}>{action.icon ? action.icon({}) : <>} ) ) @@ -153,14 +153,14 @@ function selectActionsByKind(currentResourceKinds: Array, filterSet: TMu }); const filteredNameSet = allFiltersArray.map(filterArray => { - const resultSet = new Set(); - filterArray.forEach(action => resultSet.add(action.name || "")); + const resultSet = new Set(); + 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; }); diff --git a/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts b/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts index 0ec5690e9f..8d8b6f0f7e 100644 --- a/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts +++ b/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts @@ -10,7 +10,7 @@ import { msProcessActionSet } from "views-components/multiselect-toolbar/ms-proc export type TMultiselectActionsFilters = Record]>; -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]); diff --git a/src/views-components/multiselect-toolbar/ms-collection-action-set.ts b/src/views-components/multiselect-toolbar/ms-collection-action-set.ts index 51e21592ae..b17a17e7df 100644 --- a/src/views-components/multiselect-toolbar/ms-collection-action-set.ts +++ b/src/views-components/multiselect-toolbar/ms-collection-action-set.ts @@ -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(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(openMoveCollectionDialog(resources[0])), }, { component: ToggleTrashAction, - name: "ToggleTrashAction", + name: MultiSelectMenuActionNames.ADD_TO_TRASH, isForMulti: true, execute: (dispatch, resources: ContextMenuResource[]) => { for (const resource of [...resources]) { diff --git a/src/views-components/multiselect-toolbar/ms-menu-action-set.ts b/src/views-components/multiselect-toolbar/ms-menu-action-set.ts index db184d266b..b31bea40dc 100644 --- a/src/views-components/multiselect-toolbar/ms-menu-action-set.ts +++ b/src/views-components/multiselect-toolbar/ms-menu-action-set.ts @@ -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>; +export type MultiSelectMenuActionSet = MultiSelectMenuAction[][]; diff --git a/src/views-components/multiselect-toolbar/ms-process-action-set.ts b/src/views-components/multiselect-toolbar/ms-process-action-set.ts index 28f97c42ca..57c8e5771f 100644 --- a/src/views-components/multiselect-toolbar/ms-process-action-set.ts +++ b/src/views-components/multiselect-toolbar/ms-process-action-set.ts @@ -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(openMoveProcessDialog(resources[0])); }, }, { - name: "Remove", + name: MultiSelectMenuActionNames.REMOVE, icon: RemoveIcon, isForMulti: true, execute: (dispatch, resources) => { diff --git a/src/views-components/multiselect-toolbar/ms-project-action-set.ts b/src/views-components/multiselect-toolbar/ms-project-action-set.ts index d3579e550a..d31fddddea 100644 --- a/src/views-components/multiselect-toolbar/ms-project-action-set.ts +++ b/src/views-components/multiselect-toolbar/ms-project-action-set.ts @@ -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, -- 2.30.2