From 82a1e18daed6998b2a5e13a1fd64cb0e104ddf09 Mon Sep 17 00:00:00 2001 From: Lisa Knox Date: Mon, 12 Aug 2024 09:02:19 -0400 Subject: [PATCH] 21900: * single selection shows proper toolbar Arvados-DCO-1.1-Signed-off-by: Lisa Knox --- .../MultiselectToolbar.tsx | 18 ++++-- .../ms-toolbar-action-filters.ts | 4 ++ .../ms-group-action-set.ts | 59 +++++++++++++++++++ 3 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 services/workbench2/src/views-components/multiselect-toolbar/ms-group-action-set.ts diff --git a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx index 222e960ea9..1c797461f9 100644 --- a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx +++ b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx @@ -90,7 +90,7 @@ const disallowedPaths = [ "/favorites", "/public-favorites", "/trash", - "/group", + "/group/", ] const isPathDisallowed = (location: string): boolean => { @@ -243,11 +243,17 @@ const resourceToMsResourceKind = (uuid: string, resources: ResourcesState, user: return isAdmin ? ContextMenuKind.FROZEN_PROJECT_ADMIN : ContextMenuKind.FROZEN_PROJECT; } - return isAdmin && !readonly - ? resource && resource.groupClass !== GroupClass.FILTER - ? ContextMenuKind.PROJECT_ADMIN - : ContextMenuKind.FILTER_GROUP_ADMIN - : isEditable + if (isAdmin && !readonly) { + if (resource?.groupClass === GroupClass.FILTER) { + return ContextMenuKind.FILTER_GROUP_ADMIN; + } + if (resource?.groupClass === GroupClass.ROLE) { + return ContextMenuKind.GROUPS; + } + return ContextMenuKind.PROJECT_ADMIN; + } + + return isEditable ? resource && resource.groupClass !== GroupClass.FILTER ? ContextMenuKind.PROJECT : ContextMenuKind.FILTER_GROUP diff --git a/services/workbench2/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts b/services/workbench2/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts index 998977a600..35237b8817 100644 --- a/services/workbench2/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts +++ b/services/workbench2/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts @@ -16,6 +16,7 @@ import { import { msProcessActionSet, msCommonProcessActionFilter, msAdminProcessActionFilter, msRunningProcessActionFilter } from 'views-components/multiselect-toolbar/ms-process-action-set'; import { msWorkflowActionSet, msWorkflowActionFilter, msReadOnlyWorkflowActionFilter } from 'views-components/multiselect-toolbar/ms-workflow-action-set'; import { UserDetailsActionSet } from 'views-components/multiselect-toolbar/ms-user-details-action-set'; +import { msGroupActionSet } from 'views-components/multiselect-toolbar/ms-group-action-set'; import { ResourceKind } from 'models/resource'; import { ContextMenuKind } from 'views-components/context-menu/menu-item-sort'; @@ -36,6 +37,7 @@ const { READONLY_PROJECT, FILTER_GROUP, FILTER_GROUP_ADMIN, + GROUPS, WORKFLOW, READONLY_WORKFLOW, } = ContextMenuKind; @@ -65,6 +67,8 @@ export const multiselectActionsFilters: TMultiselectActionsFilters = { [FILTER_GROUP]: [msProjectActionSet, msFilterGroupActionFilter], [FILTER_GROUP_ADMIN]: [msProjectActionSet, msAdminFilterGroupActionFilter], + + [GROUPS]: [msGroupActionSet, allActionNames(msGroupActionSet)], [WORKFLOW]: [msWorkflowActionSet, msWorkflowActionFilter], [READONLY_WORKFLOW]: [msWorkflowActionSet, msReadOnlyWorkflowActionFilter], diff --git a/services/workbench2/src/views-components/multiselect-toolbar/ms-group-action-set.ts b/services/workbench2/src/views-components/multiselect-toolbar/ms-group-action-set.ts new file mode 100644 index 0000000000..3f2e147249 --- /dev/null +++ b/services/workbench2/src/views-components/multiselect-toolbar/ms-group-action-set.ts @@ -0,0 +1,59 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { ContextMenuActionNames } from 'views-components/context-menu/context-menu-action-set'; +import { RenameIcon, AdvancedIcon, RemoveIcon, DetailsIcon } from 'components/icon/icon'; +import { openAdvancedTabDialog } from 'store/advanced-tab/advanced-tab'; +import { openRemoveGroupDialog, openGroupUpdateDialog } from 'store/groups-panel/groups-panel-actions'; +import { MultiSelectMenuAction, MultiSelectMenuActionSet } from 'views-components/multiselect-toolbar/ms-menu-actions'; +import { toggleDetailsPanel } from 'store/details-panel/details-panel-action'; + +const msRenameGroupAction: MultiSelectMenuAction = { + name: ContextMenuActionNames.RENAME, + icon: RenameIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(openGroupUpdateDialog(resources[0])) + }, +}; + +const msAdvancedAction: MultiSelectMenuAction = { + name: ContextMenuActionNames.API_DETAILS, + icon: AdvancedIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(openAdvancedTabDialog(resources[0].uuid)); + }, +}; + +const msViewDetailsAction: MultiSelectMenuAction = { + name: ContextMenuActionNames.VIEW_DETAILS, + icon: DetailsIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(toggleDetailsPanel(resources[0].uuid)); + }, +}; + +const msRemoveGroupAction: MultiSelectMenuAction = { + name: ContextMenuActionNames.REMOVE, + icon: RemoveIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(openRemoveGroupDialog(resources[0].uuid)); + }, +}; + +export const msGroupActionSet: MultiSelectMenuActionSet = [ + [ + msRenameGroupAction, + msAdvancedAction, + msRemoveGroupAction, + msViewDetailsAction, + ] +] \ No newline at end of file -- 2.30.2