From: Lisa Knox Date: Tue, 5 Dec 2023 15:39:53 +0000 (-0500) Subject: 21128: moved 2 actions from common to specific sets Arvados-DCO-1.1-Signed-off-by... X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/578c6026645cda9432f3386f29521075b8526609 21128: moved 2 actions from common to specific sets Arvados-DCO-1.1-Signed-off-by: Lisa Knox --- diff --git a/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/src/components/multiselect-toolbar/MultiselectToolbar.tsx index 56c363af..438b5e99 100644 --- a/src/components/multiselect-toolbar/MultiselectToolbar.tsx +++ b/src/components/multiselect-toolbar/MultiselectToolbar.tsx @@ -92,17 +92,18 @@ export const MultiselectToolbar = connect( style={{ width: `${(actions.length * 2.5) + 1}rem` }} > {actions.length ? ( - actions.map((action, i) => - action.hasAlts ? ( + actions.map((action, i) =>{ + const { hasAlts, useAlts, name, altName, icon, altIcon } = action; + return hasAlts ? ( - props.executeMulti(action, checkedList, iconProps.resources)}> - {currentPathIsTrash || action.useAlts(singleSelectedUuid, iconProps) ? action.altIcon && action.altIcon({}) : action.icon({})} + props.executeMulti(action, checkedList, iconProps.resources)}> + {currentPathIsTrash || useAlts && useAlts(singleSelectedUuid, iconProps) ? altIcon && altIcon({}) : icon({})} @@ -118,7 +119,7 @@ export const MultiselectToolbar = connect( ) - ) + }) ) : ( <> )} diff --git a/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts b/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts index cf848580..c0f8c021 100644 --- a/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts +++ b/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts @@ -11,17 +11,10 @@ import { msFilterGroupActionFilter, msFrozenProjectActionFilter, } from 'views-components/multiselect-toolbar/ms-project-action-set'; -import { msProcessActionSet } from 'views-components/multiselect-toolbar/ms-process-action-set'; +import { msProcessActionSet, processResourceMSActionsFilter } from 'views-components/multiselect-toolbar/ms-process-action-set'; import { msWorkflowActionSet, msWorkflowActionFilter, msReadOnlyWorkflowActionFilter } from 'views-components/multiselect-toolbar/ms-workflow-action-set'; import { ResourceKind } from 'models/resource'; - -const { MOVE_TO, REMOVE } = MultiSelectMenuActionNames; - -const allActionNames = (actionSet: MultiSelectMenuActionSet): Set => new Set(actionSet[0].map((action) => action.name)); - -const processResourceMSActionsFilter = new Set([MOVE_TO, REMOVE]); - export enum msMenuResourceKind { API_CLIENT_AUTHORIZATION = 'ApiClientAuthorization', ROOT_PROJECT = 'RootProject', @@ -74,6 +67,8 @@ const { COLLECTION, COLLECTION_ADMIN, READONLY_COLLECTION, PROCESS, PROCESS_ADMI export type TMultiselectActionsFilters = Record]>; +const allActionNames = (actionSet: MultiSelectMenuActionSet): Set => new Set(actionSet[0].map((action) => action.name)); + export const multiselectActionsFilters: TMultiselectActionsFilters = { [COLLECTION]: [msCollectionActionSet, msCommonCollectionActionFilter], [READONLY_COLLECTION]: [msCollectionActionSet, msReadOnlyCollectionActionFilter], 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 44a0bc6e..821ffef2 100644 --- a/src/views-components/multiselect-toolbar/ms-collection-action-set.ts +++ b/src/views-components/multiselect-toolbar/ms-collection-action-set.ts @@ -8,8 +8,10 @@ import { openCollectionCopyDialog, openMultiCollectionCopyDialog } from "store/c import { toggleCollectionTrashed } from "store/trash/trash-actions"; import { ContextMenuResource } from "store/context-menu/context-menu-actions"; import { msCommonActionSet, MultiSelectMenuActionSet, MultiSelectMenuActionNames, MultiSelectMenuAction } from "./ms-menu-actions"; -import { TrashIcon } from "components/icon/icon"; +import { TrashIcon, Link, FolderSharedIcon } from "components/icon/icon"; import { openCollectionUpdateDialog } from "store/collections/collection-update-actions"; +import { copyToClipboardAction } from "store/open-in-new-tab/open-in-new-tab.actions"; +import { openWebDavS3InfoDialog } from "store/collections/collection-info-actions"; const { MAKE_A_COPY, MOVE_TO, ADD_TO_TRASH, EDIT_COLLECTION, OPEN_IN_NEW_TAB, OPEN_W_3RD_PARTY_CLIENT, COPY_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, ADD_TO_FAVORITES, SHARE} = MultiSelectMenuActionNames; @@ -54,13 +56,35 @@ const msEditCollection: MultiSelectMenuAction = { }, } +const msCopyToClipboardMenuAction: MultiSelectMenuAction = { + name: COPY_TO_CLIPBOARD, + icon: Link, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(copyToClipboardAction(resources)); + }, +}; + +const msOpenWith3rdPartyClientAction: MultiSelectMenuAction = { + name: OPEN_W_3RD_PARTY_CLIENT, + icon: FolderSharedIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(openWebDavS3InfoDialog(resources[0].uuid)); + }, +}; + export const msCollectionActionSet: MultiSelectMenuActionSet = [ [ ...msCommonActionSet, msCopyCollection, msMoveCollection, msToggleTrashAction, - msEditCollection + msEditCollection, + msCopyToClipboardMenuAction, + msOpenWith3rdPartyClientAction ], ]; diff --git a/src/views-components/multiselect-toolbar/ms-menu-actions.ts b/src/views-components/multiselect-toolbar/ms-menu-actions.ts index 1734644c..c01b431e 100644 --- a/src/views-components/multiselect-toolbar/ms-menu-actions.ts +++ b/src/views-components/multiselect-toolbar/ms-menu-actions.ts @@ -49,7 +49,7 @@ export type MultiSelectMenuAction = { altName?: string; altIcon?: IconType; isForMulti: boolean; - useAlts?: (uuid: string, iconProps: {resources: ResourcesState, favorites: FavoritesState, publicFavorites: PublicFavoritesState}) => boolean; + useAlts?: (uuid: string | null, iconProps: {resources: ResourcesState, favorites: FavoritesState, publicFavorites: PublicFavoritesState}) => boolean; execute(dispatch: Dispatch, resources: ContextMenuResource[], state?: any): void; adminOnly?: boolean; }; @@ -65,7 +65,7 @@ const msToggleFavoriteAction: MultiSelectMenuAction = { altName: 'Remove from Favorites', altIcon: RemoveFavoriteIcon, isForMulti: false, - useAlts: (uuid, iconProps) => { + useAlts: (uuid: string, iconProps) => { return checkFavorite(uuid, iconProps.favorites); }, execute: (dispatch, resources) => { @@ -85,16 +85,6 @@ const msOpenInNewTabMenuAction: MultiSelectMenuAction = { }, }; -const msCopyToClipboardMenuAction: MultiSelectMenuAction = { - name: COPY_TO_CLIPBOARD, - icon: Link, - hasAlts: false, - isForMulti: false, - execute: (dispatch, resources) => { - dispatch(copyToClipboardAction(resources)); - }, -}; - const msViewDetailsAction: MultiSelectMenuAction = { name: VIEW_DETAILS, icon: DetailsIcon, @@ -115,16 +105,6 @@ const msAdvancedAction: MultiSelectMenuAction = { }, }; -const msOpenWith3rdPartyClientAction: MultiSelectMenuAction = { - name: OPEN_W_3RD_PARTY_CLIENT, - icon: FolderSharedIcon, - hasAlts: false, - isForMulti: false, - execute: (dispatch, resources) => { - dispatch(openWebDavS3InfoDialog(resources[0].uuid)); - }, -}; - const msShareAction: MultiSelectMenuAction = { name: SHARE, icon: ShareIcon, @@ -155,10 +135,8 @@ const msTogglePublicFavoriteAction: MultiSelectMenuAction = { export const msCommonActionSet = [ msToggleFavoriteAction, msOpenInNewTabMenuAction, - msCopyToClipboardMenuAction, msViewDetailsAction, msAdvancedAction, - msOpenWith3rdPartyClientAction, msShareAction, msTogglePublicFavoriteAction ]; 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 de906244..f8ab66d9 100644 --- a/src/views-components/multiselect-toolbar/ms-process-action-set.ts +++ b/src/views-components/multiselect-toolbar/ms-process-action-set.ts @@ -6,38 +6,48 @@ 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, MultiSelectMenuActionNames } from "./ms-menu-actions"; +import { MultiSelectMenuAction, MultiSelectMenuActionSet, MultiSelectMenuActionNames } from "./ms-menu-actions"; + +const msCopyAndRerunProcess: MultiSelectMenuAction = { + name: MultiSelectMenuActionNames.COPY_AND_RERUN_PROCESS, + icon: ReRunProcessIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + for (const resource of [...resources]) { + dispatch(openCopyProcessDialog(resource)); + } + }, +} + +const msRemoveProcess: MultiSelectMenuAction = { + name: MultiSelectMenuActionNames.REMOVE, + icon: RemoveIcon, + hasAlts: false, + isForMulti: true, + execute: (dispatch, resources) => { + dispatch(openRemoveProcessDialog(resources[0], resources.length)); + }, +} + +const msMoveTo: MultiSelectMenuAction = { + name: MultiSelectMenuActionNames.MOVE_TO, + icon: MoveToIcon, + hasAlts: false, + isForMulti: true, + execute: (dispatch, resources) => { + dispatch(openMoveProcessDialog(resources[0])); + }, +} export const msProcessActionSet: MultiSelectMenuActionSet = [ [ - { - name: MultiSelectMenuActionNames.COPY_AND_RERUN_PROCESS, - icon: ReRunProcessIcon, - hasAlts: false, - isForMulti: false, - execute: (dispatch, resources) => { - for (const resource of [...resources]) { - dispatch(openCopyProcessDialog(resource)); - } - }, - }, - { - name: MultiSelectMenuActionNames.MOVE_TO, - icon: MoveToIcon, - hasAlts: false, - isForMulti: true, - execute: (dispatch, resources) => { - dispatch(openMoveProcessDialog(resources[0])); - }, - }, - { - name: MultiSelectMenuActionNames.REMOVE, - icon: RemoveIcon, - hasAlts: false, - isForMulti: true, - execute: (dispatch, resources) => { - dispatch(openRemoveProcessDialog(resources[0], resources.length)); - }, - }, - ], + msCopyAndRerunProcess, + msRemoveProcess, + msMoveTo + ] ]; + +const { MOVE_TO, REMOVE, COPY_AND_RERUN_PROCESS } = MultiSelectMenuActionNames + +export const processResourceMSActionsFilter = new Set([MOVE_TO, REMOVE, COPY_AND_RERUN_PROCESS ]); 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 221b3cf0..9c0a4d88 100644 --- a/src/views-components/multiselect-toolbar/ms-project-action-set.ts +++ b/src/views-components/multiselect-toolbar/ms-project-action-set.ts @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { MultiSelectMenuActionSet, MultiSelectMenuActionNames, msCommonActionSet } from 'views-components/multiselect-toolbar/ms-menu-actions'; +import { MultiSelectMenuAction, MultiSelectMenuActionSet, MultiSelectMenuActionNames, msCommonActionSet } from 'views-components/multiselect-toolbar/ms-menu-actions'; import { openMoveProjectDialog } from 'store/projects/project-move-actions'; import { toggleProjectTrashed } from 'store/trash/trash-actions'; import { @@ -12,11 +12,13 @@ import { RenameIcon, UnfreezeIcon, } from 'components/icon/icon'; -import { RestoreFromTrashIcon, TrashIcon } from 'components/icon/icon'; +import { RestoreFromTrashIcon, TrashIcon, FolderSharedIcon, Link } from 'components/icon/icon'; import { getResource } from 'store/resources/resources'; import { openProjectCreateDialog } from 'store/projects/project-create-actions'; import { openProjectUpdateDialog } from 'store/projects/project-update-actions'; import { freezeProject, unfreezeProject } from 'store/projects/project-lock-actions'; +import { openWebDavS3InfoDialog } from 'store/collections/collection-info-actions'; +import { copyToClipboardAction } from 'store/open-in-new-tab/open-in-new-tab.actions'; const { ADD_TO_FAVORITES, @@ -33,27 +35,47 @@ const { NEW_PROJECT, } = MultiSelectMenuActionNames; -const msEditProjectAction = { +const msCopyToClipboardMenuAction: MultiSelectMenuAction = { + name: COPY_TO_CLIPBOARD, + icon: Link, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(copyToClipboardAction(resources)); + }, +}; + +const msEditProjectAction: MultiSelectMenuAction = { name: EDIT_PROJECT, icon: RenameIcon, hasAlts: false, isForMulti: false, execute: (dispatch, resources) => { - dispatch(openProjectUpdateDialog(resources[0])); + dispatch(openProjectUpdateDialog(resources[0])); }, }; -const msMoveToAction = { +const msMoveToAction: MultiSelectMenuAction = { name: MOVE_TO, icon: MoveToIcon, hasAlts: false, isForMulti: true, execute: (dispatch, resource) => { - dispatch(openMoveProjectDialog(resource[0])); + dispatch(openMoveProjectDialog(resource[0])); + }, +}; + +const msOpenWith3rdPartyClientAction: MultiSelectMenuAction = { + name: OPEN_W_3RD_PARTY_CLIENT, + icon: FolderSharedIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(openWebDavS3InfoDialog(resources[0].uuid)); }, }; -export const msToggleTrashAction = { +export const msToggleTrashAction: MultiSelectMenuAction = { name: ADD_TO_TRASH, icon: TrashIcon, hasAlts: true, @@ -65,12 +87,12 @@ export const msToggleTrashAction = { }, execute: (dispatch, resources) => { for (const resource of [...resources]) { - dispatch(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!, resources.length > 1)); + dispatch(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!, resources.length > 1)); } }, }; -const msFreezeProjectAction = { +const msFreezeProjectAction: MultiSelectMenuAction = { name: FREEZE_PROJECT, icon: FreezeIcon, hasAlts: true, @@ -81,21 +103,21 @@ const msFreezeProjectAction = { return uuid ? !!(getResource(uuid)(iconProps.resources) as any).frozenByUuid : false; }, execute: (dispatch, resources) => { - if (resources[0].frozenByUuid) { - dispatch(unfreezeProject(resources[0].uuid)); + if ((resources[0] as any).frozenByUuid) { + dispatch(unfreezeProject(resources[0].uuid)); } else { - dispatch(freezeProject(resources[0].uuid)); + dispatch(freezeProject(resources[0].uuid)); } }, }; -const msNewProjectAction: any = { +const msNewProjectAction: MultiSelectMenuAction = { name: NEW_PROJECT, icon: NewProjectIcon, hasAlts: false, isForMulti: false, - execute: (dispatch, resource): void => { - dispatch(openProjectCreateDialog(resource.uuid)); + execute: (dispatch, resources): void => { + dispatch(openProjectCreateDialog(resources[0].uuid)); }, }; @@ -107,6 +129,8 @@ export const msProjectActionSet: MultiSelectMenuActionSet = [ msToggleTrashAction, msNewProjectAction, msFreezeProjectAction, + msOpenWith3rdPartyClientAction, + msCopyToClipboardMenuAction ], ];