From 9357b8b80868d200d4f7e8091034279f094bc58d Mon Sep 17 00:00:00 2001 From: Lisa Knox Date: Tue, 28 Nov 2023 11:52:00 -0500 Subject: [PATCH] 21128: redesign of action sets Arvados-DCO-1.1-Signed-off-by: Lisa Knox --- .../ms-toolbar-action-filters.ts | 48 +---- .../multiselect-toolbar/ms-menu-actions.ts | 148 +++++++++++--- .../ms-project-action-set.ts | 184 ++++-------------- .../ms-workflow-action-set.ts | 16 +- 4 files changed, 184 insertions(+), 212 deletions(-) diff --git a/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts b/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts index 950996a7..e494d802 100644 --- a/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts +++ b/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts @@ -4,30 +4,15 @@ import { MultiSelectMenuActionSet, MultiSelectMenuActionNames } from 'views-components/multiselect-toolbar/ms-menu-actions'; import { msCollectionActionSet } from 'views-components/multiselect-toolbar/ms-collection-action-set'; -import { msProjectActionSet, msReadOnlyProjectActionSet, msFilterGroupActionSet, msFrozenActionSet } from 'views-components/multiselect-toolbar/ms-project-action-set'; +import { msProjectActionSet, msProjectActionFilter, msReadOnlyProjectActionFilter, msFilterGroupActionFilter, msFrozenActionFilter } from 'views-components/multiselect-toolbar/ms-project-action-set'; import { msProcessActionSet } from 'views-components/multiselect-toolbar/ms-process-action-set'; -import { msWorkflowActionSet } from 'views-components/multiselect-toolbar/ms-workflow-action-set'; +import { msWorkflowActionSet, msWorkflowActionFilter } from 'views-components/multiselect-toolbar/ms-workflow-action-set'; export type TMultiselectActionsFilters = Record]>; const { - ADD_TO_FAVORITES, - ADD_TO_TRASH, - API_DETAILS, - COPY_AND_RERUN_PROCESS, - COPY_TO_CLIPBOARD, - DELETE_WORKFLOW, - EDIT_PPROJECT, - FREEZE_PROJECT, - MAKE_A_COPY, MOVE_TO, - NEW_PROJECT, - OPEN_IN_NEW_TAB, - OPEN_W_3RD_PARTY_CLIENT, REMOVE, - RUN_WORKFLOW, - SHARE, - VIEW_DETAILS, } = MultiSelectMenuActionNames; const allActionNames = (actionSet: MultiSelectMenuActionSet): Set => new Set(actionSet[0].map((action) => action.name)); @@ -35,24 +20,7 @@ const allActionNames = (actionSet: MultiSelectMenuActionSet): Set => new //use allActionNames or filter manually below const processResourceMSActionsFilter = new Set([MOVE_TO, REMOVE]); -const projectMSActionsFilter = new Set([ - ADD_TO_FAVORITES, - ADD_TO_TRASH, - API_DETAILS, - COPY_AND_RERUN_PROCESS, - COPY_TO_CLIPBOARD, - EDIT_PPROJECT, - FREEZE_PROJECT, - MAKE_A_COPY, - MOVE_TO, - NEW_PROJECT, - OPEN_IN_NEW_TAB, - OPEN_W_3RD_PARTY_CLIENT, - REMOVE, - SHARE, - VIEW_DETAILS, -]); -const workflowMSActionFilter = new Set([OPEN_IN_NEW_TAB, COPY_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, RUN_WORKFLOW, DELETE_WORKFLOW]); + export enum msResourceKind { @@ -82,10 +50,10 @@ const { COLLECTION, PROCESS, PROJECT, PROJECT_FROZEN, PROJECT_READONLY,PROJECT_F export const multiselectActionsFilters: TMultiselectActionsFilters = { [COLLECTION]: [msCollectionActionSet, allActionNames(msCollectionActionSet)], [PROCESS]: [msProcessActionSet, processResourceMSActionsFilter], - [PROJECT]: [msProjectActionSet, projectMSActionsFilter], - [PROJECT_FROZEN]: [msProjectActionSet, allActionNames(msFrozenActionSet)], - [PROJECT_READONLY]: [msProjectActionSet, allActionNames(msReadOnlyProjectActionSet)], - [PROJECT_FILTER]: [msProjectActionSet, allActionNames(msFilterGroupActionSet)], - [WORKFLOW]: [msWorkflowActionSet, workflowMSActionFilter] + [PROJECT]: [msProjectActionSet, msProjectActionFilter], + [PROJECT_FROZEN]: [msProjectActionSet, msFrozenActionFilter], + [PROJECT_READONLY]: [msProjectActionSet, msReadOnlyProjectActionFilter], + [PROJECT_FILTER]: [msProjectActionSet, msFilterGroupActionFilter], + [WORKFLOW]: [msWorkflowActionSet, msWorkflowActionFilter] }; diff --git a/src/views-components/multiselect-toolbar/ms-menu-actions.ts b/src/views-components/multiselect-toolbar/ms-menu-actions.ts index 7f3bb475..2e54a698 100644 --- a/src/views-components/multiselect-toolbar/ms-menu-actions.ts +++ b/src/views-components/multiselect-toolbar/ms-menu-actions.ts @@ -2,30 +2,39 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { Dispatch } from "redux"; -import { IconType } from "components/icon/icon"; -import { ResourcesState } from "store/resources/resources"; -import { FavoritesState } from "store/favorites/favorites-reducer"; -import { ContextMenuResource } from "store/context-menu/context-menu-actions"; - -export const MultiSelectMenuActionNames = { - ADD_TO_FAVORITES: "Add to Favorites", - ADD_TO_TRASH: "Add to Trash", - API_DETAILS: 'API Details', - COPY_AND_RERUN_PROCESS: "Copy and re-run process", - COPY_TO_CLIPBOARD: "Copy to clipboard", - DELETE_WORKFLOW: 'DELETE_WORKFLOW', - EDIT_PPROJECT: 'Edit project', - FREEZE_PROJECT: 'Freeze Project', - MAKE_A_COPY: "Make a copy", - MOVE_TO: "Move to", - NEW_PROJECT: 'New project', - OPEN_IN_NEW_TAB: 'Open in new tab', - OPEN_W_3RD_PARTY_CLIENT: 'Open with 3rd party client', - REMOVE: "Remove", - RUN_WORKFLOW: 'RUN_WORKFLOW', - SHARE: 'Share', - VIEW_DETAILS: 'View details', +import { Dispatch } from 'redux'; +import { IconType } from 'components/icon/icon'; +import { ResourcesState } from 'store/resources/resources'; +import { FavoritesState } from 'store/favorites/favorites-reducer'; +import { ContextMenuResource } from 'store/context-menu/context-menu-actions'; +import { AddFavoriteIcon, AdvancedIcon, DetailsIcon, FolderSharedIcon, Link, OpenIcon, RemoveFavoriteIcon, ShareIcon } from 'components/icon/icon'; +import { checkFavorite } from 'store/favorites/favorites-reducer'; +import { toggleFavorite } from 'store/favorites/favorites-actions'; +import { favoritePanelActions } from 'store/favorite-panel/favorite-panel-action'; +import { copyToClipboardAction, openInNewTabAction } from 'store/open-in-new-tab/open-in-new-tab.actions'; +import { toggleDetailsPanel } from 'store/details-panel/details-panel-action'; +import { openAdvancedTabDialog } from 'store/advanced-tab/advanced-tab'; +import { openWebDavS3InfoDialog } from 'store/collections/collection-info-actions'; +import { openSharingDialog } from 'store/sharing-dialog/sharing-dialog-actions'; + +export const MultiSelectMenuActionNames: Record = { + ADD_TO_FAVORITES: 'Add to Favorites', + ADD_TO_TRASH: 'Add to Trash', + API_DETAILS: 'API Details', + COPY_AND_RERUN_PROCESS: 'Copy and re-run process', + COPY_TO_CLIPBOARD: 'Copy to clipboard', + DELETE_WORKFLOW: 'DELETE_WORKFLOW', + EDIT_PPROJECT: 'Edit project', + FREEZE_PROJECT: 'Freeze Project', + MAKE_A_COPY: 'Make a copy', + MOVE_TO: 'Move to', + NEW_PROJECT: 'New project', + OPEN_IN_NEW_TAB: 'Open in new tab', + OPEN_W_3RD_PARTY_CLIENT: 'Open with 3rd party client', + REMOVE: 'Remove', + RUN_WORKFLOW: 'RUN_WORKFLOW', + SHARE: 'Share', + VIEW_DETAILS: 'View details', }; export type MultiSelectMenuAction = { @@ -35,9 +44,98 @@ export type MultiSelectMenuAction = { altName?: string; altIcon?: IconType; isForMulti: boolean; - useAlts?: (uuid: string | null, resources: ResourcesState, favorites: FavoritesState) => boolean; + useAlts?: (uuid: string, iconProps: {resources: ResourcesState, favorites: FavoritesState}) => boolean; execute(dispatch: Dispatch, resources: ContextMenuResource[], state?: any): void; adminOnly?: boolean; }; export type MultiSelectMenuActionSet = MultiSelectMenuAction[][]; + +const { ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, COPY_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, OPEN_W_3RD_PARTY_CLIENT, SHARE } = MultiSelectMenuActionNames; + +const msToggleFavoriteAction: MultiSelectMenuAction = { + name: ADD_TO_FAVORITES, + icon: AddFavoriteIcon, + hasAlts: true, + altName: 'Remove from Favorites', + altIcon: RemoveFavoriteIcon, + isForMulti: false, + useAlts: (uuid, iconProps) => { + return checkFavorite(uuid, iconProps.favorites); + }, + execute: (dispatch, resources) => { + dispatch(toggleFavorite(resources[0])).then(() => { + dispatch(favoritePanelActions.REQUEST_ITEMS()); + }); + }, +}; + +const msOpenInNewTabMenuAction: MultiSelectMenuAction = { + name: OPEN_IN_NEW_TAB, + icon: OpenIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(openInNewTabAction(resources[0])); + }, +}; + +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, + hasAlts: false, + isForMulti: false, + execute: (dispatch) => { + dispatch(toggleDetailsPanel()); + }, +}; + +const msAdvancedAction: MultiSelectMenuAction = { + name: API_DETAILS, + icon: AdvancedIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(openAdvancedTabDialog(resources[0].uuid)); + }, +}; + +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, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(openSharingDialog(resources[0].uuid)); + }, +}; + +export const msCommonActionSet = [ + msToggleFavoriteAction, + msOpenInNewTabMenuAction, + msCopyToClipboardMenuAction, + msViewDetailsAction, + msAdvancedAction, + msOpenWith3rdPartyClientAction, + msShareAction, +]; 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 5d16da91..d5076ba7 100644 --- a/src/views-components/multiselect-toolbar/ms-project-action-set.ts +++ b/src/views-components/multiselect-toolbar/ms-project-action-set.ts @@ -2,107 +2,39 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { MultiSelectMenuActionSet, MultiSelectMenuActionNames } from 'views-components/multiselect-toolbar/ms-menu-actions'; +import { 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 { copyToClipboardAction, openInNewTabAction } from 'store/open-in-new-tab/open-in-new-tab.actions'; -import { toggleFavorite } from 'store/favorites/favorites-actions'; -import { favoritePanelActions } from 'store/favorite-panel/favorite-panel-action'; import { - AddFavoriteIcon, - AdvancedIcon, - DetailsIcon, FreezeIcon, - FolderSharedIcon, - Link, MoveToIcon, NewProjectIcon, - OpenIcon, - RemoveFavoriteIcon, RenameIcon, - ShareIcon, UnfreezeIcon, } from 'components/icon/icon'; import { RestoreFromTrashIcon, TrashIcon } from 'components/icon/icon'; import { getResource } from 'store/resources/resources'; -import { checkFavorite } from 'store/favorites/favorites-reducer'; -import { toggleDetailsPanel } from 'store/details-panel/details-panel-action'; -import { openAdvancedTabDialog } from 'store/advanced-tab/advanced-tab'; -import { openWebDavS3InfoDialog } from 'store/collections/collection-info-actions'; -import { openSharingDialog } from 'store/sharing-dialog/sharing-dialog-actions'; 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'; -export const msToggleFavoriteAction = { - name: MultiSelectMenuActionNames.ADD_TO_FAVORITES, - icon: AddFavoriteIcon, - hasAlts: true, - altName: 'Remove from Favorites', - altIcon: RemoveFavoriteIcon, - isForMulti: false, - useAlts: (uuid, iconProps) => { - return checkFavorite(uuid, iconProps.favorites); - }, - execute: (dispatch, resources) => { - dispatch(toggleFavorite(resources[0])).then(() => { - dispatch(favoritePanelActions.REQUEST_ITEMS()); - }); - }, -}; - -export const msOpenInNewTabMenuAction = { - name: MultiSelectMenuActionNames.OPEN_IN_NEW_TAB, - icon: OpenIcon, - hasAlts: false, - isForMulti: false, - execute: (dispatch, resources) => { - dispatch(openInNewTabAction(resources[0])); - }, -}; - -export const msCopyToClipboardMenuAction = { - name: MultiSelectMenuActionNames.COPY_TO_CLIPBOARD, - icon: Link, - hasAlts: false, - isForMulti: false, - execute: (dispatch, resources) => { - dispatch(copyToClipboardAction(resources)); - }, -}; - -export const msViewDetailsAction = { - name: MultiSelectMenuActionNames.VIEW_DETAILS, - icon: DetailsIcon, - hasAlts: false, - isForMulti: false, - execute: (dispatch) => { - dispatch(toggleDetailsPanel()); - }, -}; - -export const msAdvancedAction = { - name: MultiSelectMenuActionNames.API_DETAILS, - icon: AdvancedIcon, - hasAlts: false, - isForMulti: false, - execute: (dispatch, resources) => { - dispatch(openAdvancedTabDialog(resources[0].uuid)); - }, -}; - -export const msOpenWith3rdPartyClientAction = { - name: MultiSelectMenuActionNames.OPEN_W_3RD_PARTY_CLIENT, - icon: FolderSharedIcon, - hasAlts: false, - isForMulti: false, - execute: (dispatch, resources) => { - dispatch(openWebDavS3InfoDialog(resources[0].uuid)); - }, -}; - -export const msEditProjectAction = { - name: MultiSelectMenuActionNames.EDIT_PPROJECT, +const { + ADD_TO_FAVORITES, + OPEN_IN_NEW_TAB, + COPY_TO_CLIPBOARD, + VIEW_DETAILS, + API_DETAILS, + OPEN_W_3RD_PARTY_CLIENT, + EDIT_PPROJECT, + SHARE, + MOVE_TO, + ADD_TO_TRASH, + FREEZE_PROJECT, + NEW_PROJECT, +} = MultiSelectMenuActionNames; + +const msEditProjectAction = { + name: EDIT_PPROJECT, icon: RenameIcon, hasAlts: false, isForMulti: false, @@ -111,18 +43,8 @@ export const msEditProjectAction = { }, }; -export const msShareAction = { - name: MultiSelectMenuActionNames.SHARE, - icon: ShareIcon, - hasAlts: false, - isForMulti: false, - execute: (dispatch, resources) => { - dispatch(openSharingDialog(resources[0].uuid)); - }, -}; - -export const msMoveToAction = { - name: MultiSelectMenuActionNames.MOVE_TO, +const msMoveToAction = { + name: MOVE_TO, icon: MoveToIcon, hasAlts: false, isForMulti: true, @@ -132,7 +54,7 @@ export const msMoveToAction = { }; export const msToggleTrashAction = { - name: MultiSelectMenuActionNames.ADD_TO_TRASH, + name: ADD_TO_TRASH, icon: TrashIcon, hasAlts: true, altName: 'Restore from Trash', @@ -148,8 +70,8 @@ export const msToggleTrashAction = { }, }; -export const msFreezeProjectAction = { - name: MultiSelectMenuActionNames.FREEZE_PROJECT, +const msFreezeProjectAction = { + name: FREEZE_PROJECT, icon: FreezeIcon, hasAlts: true, altName: 'Unfreeze Project', @@ -167,8 +89,8 @@ export const msFreezeProjectAction = { }, }; -export const msNewProjectAction: any = { - name: MultiSelectMenuActionNames.NEW_PROJECT, +const msNewProjectAction: any = { + name: NEW_PROJECT, icon: NewProjectIcon, hasAlts: false, isForMulti: false, @@ -179,14 +101,8 @@ export const msNewProjectAction: any = { export const msProjectActionSet: MultiSelectMenuActionSet = [ [ - msToggleFavoriteAction, - msOpenInNewTabMenuAction, - msCopyToClipboardMenuAction, - msViewDetailsAction, - msAdvancedAction, - msOpenWith3rdPartyClientAction, + ...msCommonActionSet, msEditProjectAction, - msShareAction, msMoveToAction, msToggleTrashAction, msNewProjectAction, @@ -194,34 +110,20 @@ export const msProjectActionSet: MultiSelectMenuActionSet = [ ], ]; -export const msReadOnlyProjectActionSet: MultiSelectMenuActionSet = [ - [msToggleFavoriteAction, msOpenInNewTabMenuAction, msCopyToClipboardMenuAction, msViewDetailsAction, msAdvancedAction, msOpenWith3rdPartyClientAction], -]; - -export const msFilterGroupActionSet: MultiSelectMenuActionSet = [ - [ - msToggleFavoriteAction, - msOpenInNewTabMenuAction, - msCopyToClipboardMenuAction, - msViewDetailsAction, - msAdvancedAction, - msOpenWith3rdPartyClientAction, - msEditProjectAction, - msShareAction, - msMoveToAction, - msToggleTrashAction, - ], -]; - -export const msFrozenActionSet: MultiSelectMenuActionSet = [ - [ - msShareAction, - msToggleFavoriteAction, - msOpenInNewTabMenuAction, - msCopyToClipboardMenuAction, - msViewDetailsAction, - msAdvancedAction, - msOpenWith3rdPartyClientAction, - msFreezeProjectAction, - ], -]; \ No newline at end of file +export const msProjectActionFilter = new Set([ + ADD_TO_FAVORITES, + ADD_TO_TRASH, + API_DETAILS, + COPY_TO_CLIPBOARD, + EDIT_PPROJECT, + FREEZE_PROJECT, + MOVE_TO, + NEW_PROJECT, + OPEN_IN_NEW_TAB, + OPEN_W_3RD_PARTY_CLIENT, + SHARE, + VIEW_DETAILS, +]); +export const msReadOnlyProjectActionFilter = new Set([ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, COPY_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, OPEN_W_3RD_PARTY_CLIENT]); +export const msFrozenActionFilter = new Set([ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, COPY_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, OPEN_W_3RD_PARTY_CLIENT, SHARE, FREEZE_PROJECT]) +export const msFilterGroupActionFilter = new Set([ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, COPY_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, OPEN_W_3RD_PARTY_CLIENT, EDIT_PPROJECT, SHARE, MOVE_TO, ADD_TO_TRASH]) diff --git a/src/views-components/multiselect-toolbar/ms-workflow-action-set.ts b/src/views-components/multiselect-toolbar/ms-workflow-action-set.ts index 00210aad..5b38c2aa 100644 --- a/src/views-components/multiselect-toolbar/ms-workflow-action-set.ts +++ b/src/views-components/multiselect-toolbar/ms-workflow-action-set.ts @@ -9,10 +9,12 @@ import { toggleDetailsPanel } from 'store/details-panel/details-panel-action'; import { openAdvancedTabDialog } from 'store/advanced-tab/advanced-tab'; import { MultiSelectMenuActionSet, MultiSelectMenuActionNames } from './ms-menu-actions'; +const { OPEN_IN_NEW_TAB, COPY_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, RUN_WORKFLOW, DELETE_WORKFLOW } = MultiSelectMenuActionNames; + export const msReadOnlyWorkflowActionSet: MultiSelectMenuActionSet = [ [ { - name: MultiSelectMenuActionNames.OPEN_IN_NEW_TAB, + name: OPEN_IN_NEW_TAB, icon: OpenIcon, hasAlts: false, isForMulti: false, @@ -21,7 +23,7 @@ export const msReadOnlyWorkflowActionSet: MultiSelectMenuActionSet = [ }, }, { - name: MultiSelectMenuActionNames.COPY_TO_CLIPBOARD, + name: COPY_TO_CLIPBOARD, icon: Link, hasAlts: false, @@ -31,7 +33,7 @@ export const msReadOnlyWorkflowActionSet: MultiSelectMenuActionSet = [ }, }, { - name: MultiSelectMenuActionNames.VIEW_DETAILS, + name: VIEW_DETAILS, icon: DetailsIcon, hasAlts: false, isForMulti: false, @@ -40,7 +42,7 @@ export const msReadOnlyWorkflowActionSet: MultiSelectMenuActionSet = [ }, }, { - name: MultiSelectMenuActionNames.API_DETAILS, + name: API_DETAILS, icon: AdvancedIcon, hasAlts: false, isForMulti: false, @@ -49,7 +51,7 @@ export const msReadOnlyWorkflowActionSet: MultiSelectMenuActionSet = [ }, }, { - name: MultiSelectMenuActionNames.RUN_WORKFLOW, + name: RUN_WORKFLOW, icon: StartIcon, hasAlts: false, isForMulti: false, @@ -64,7 +66,7 @@ export const msWorkflowActionSet: MultiSelectMenuActionSet = [ [ ...msReadOnlyWorkflowActionSet[0], { - name: MultiSelectMenuActionNames.DELETE_WORKFLOW, + name: DELETE_WORKFLOW, icon: TrashIcon, hasAlts: false, isForMulti: false, @@ -74,3 +76,5 @@ export const msWorkflowActionSet: MultiSelectMenuActionSet = [ }, ], ]; + +export const msWorkflowActionFilter = new Set([OPEN_IN_NEW_TAB, COPY_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, RUN_WORKFLOW, DELETE_WORKFLOW]); -- 2.30.2