From fb10daa75864def53d1f0ffa7da3cece8cebe9d0 Mon Sep 17 00:00:00 2001 From: Lisa Knox Date: Fri, 23 Jun 2023 12:52:40 -0400 Subject: [PATCH] 15768: made new filters.ts file Arvados-DCO-1.1-Signed-off-by: Lisa Knox --- .../multiselectToolbar/MultiselectToolbar.tsx | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/components/multiselectToolbar/MultiselectToolbar.tsx b/src/components/multiselectToolbar/MultiselectToolbar.tsx index d2796322..e6e8c62e 100644 --- a/src/components/multiselectToolbar/MultiselectToolbar.tsx +++ b/src/components/multiselectToolbar/MultiselectToolbar.tsx @@ -22,6 +22,7 @@ import { CopyProcessDialog, CopyManyProcessesDialog } from 'views-components/dia import { collectionActionSet } from 'views-components/context-menu/action-sets/collection-action-set'; import { ContextMenuAction, ContextMenuActionSet } from 'views-components/context-menu/context-menu-action-set'; import { TrashIcon } from 'components/icon/icon'; +import { multiselectActionsFilters, TMultiselectActionsFilters } from './ms-toolbar-action-filters'; type CssRules = 'root' | 'button'; @@ -52,22 +53,12 @@ export type MultiselectToolbarProps = { executeMulti: (fn, checkedList: TCheckedList, resources: ResourcesState) => void; }; -const collectionMSActionsFilter = { - MAKE_A_COPY: 'Make a copy', - MOVE_TO: 'Move to', - TOGGLE_TRASH_ACTION: 'ToggleTrashAction', -}; - -const multiselectActionsFilters = { - 'arvados#collection': [collectionActionSet, collectionMSActionsFilter], -}; - export const MultiselectToolbar = connect( mapStateToProps, mapDispatchToProps )( withStyles(styles)((props: MultiselectToolbarProps & WithStyles) => { - const { classes, isVisible, checkedList, resources } = props; + const { classes, checkedList } = props; const currentResourceKinds = Array.from(selectedToKindSet(checkedList)); const buttons = selectActionsByKind(currentResourceKinds, multiselectActionsFilters); @@ -117,13 +108,15 @@ function selectedToKindSet(checkedList: TCheckedList): Set { return setifiedList; } -function filterActions(actionArray: ContextMenuActionSet, filters: Record): Array { - return actionArray[0].filter((action) => Object.values(filters).includes(action.name as string)); +function filterActions(actionArray: ContextMenuActionSet, filters: Array): Array { + return actionArray[0].filter((action) => filters.includes(action.name as string)); } -function selectActionsByKind(resourceKinds: Array, filterSet: any) { +function selectActionsByKind(resourceKinds: Array, filterSet: TMultiselectActionsFilters) { const result: Array = []; - resourceKinds.forEach((kind) => result.push(...filterActions(filterSet[kind][0], filterSet[kind][1]))); + resourceKinds.forEach((kind) => { + if (filterSet[kind]) result.push(...filterActions(...filterSet[kind])); + }); return result; } @@ -142,7 +135,6 @@ function mapDispatchToProps(dispatch: Dispatch) { return { executeMulti: (fn, checkedList: TCheckedList, resources: ResourcesState) => selectedToArray(checkedList).forEach((uuid) => { - console.log(uuid); fn(dispatch, getResource(uuid)(resources)); }), }; -- 2.30.2