From 932e5a45dd95501b137673367c34dc5987083df8 Mon Sep 17 00:00:00 2001 From: Lisa Knox Date: Mon, 12 Aug 2024 12:00:25 -0400 Subject: [PATCH] 21900: fixed multiple select toolbar display for Groups Arvados-DCO-1.1-Signed-off-by: Lisa Knox --- .../data-explorer/data-explorer.tsx | 13 +++++----- .../MultiselectToolbar.tsx | 26 +++++++++++-------- .../data-explorer/data-explorer.tsx | 5 +++- .../ms-group-action-set.ts | 4 +-- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/services/workbench2/src/components/data-explorer/data-explorer.tsx b/services/workbench2/src/components/data-explorer/data-explorer.tsx index 9af3410e49..dfe8c68cda 100644 --- a/services/workbench2/src/components/data-explorer/data-explorer.tsx +++ b/services/workbench2/src/components/data-explorer/data-explorer.tsx @@ -121,7 +121,7 @@ interface DataExplorerDataProps { hideSearchInput?: boolean; title?: React.ReactNode; progressBar?: React.ReactNode; - paperKey?: string; + path?: string; currentRouteUuid: string; selectedResourceUuid: string; elementPath?: string; @@ -149,6 +149,7 @@ interface DataExplorerActionProps { toggleMSToolbar: (isVisible: boolean) => void; setCheckedListOnStore: (checkedList: TCheckedList) => void; setSelectedUuid: (uuid: string) => void; + usesDetailsCard: (uuid: string) => boolean; } type DataExplorerProps = DataExplorerDataProps & DataExplorerActionProps & WithStyles & MPVPanelProps; @@ -169,10 +170,10 @@ export const DataExplorer = withStyles(styles)( } componentDidUpdate( prevProps: Readonly>, prevState: Readonly<{}>, snapshot?: any ): void { - const { selectedResourceUuid, currentRouteUuid } = this.props; + const { selectedResourceUuid, currentRouteUuid, path, usesDetailsCard } = this.props; if(selectedResourceUuid !== prevProps.selectedResourceUuid || currentRouteUuid !== prevProps.currentRouteUuid) { this.setState({ - hideToolbar: selectedResourceUuid === this.props.currentRouteUuid, + hideToolbar: usesDetailsCard(path || '') ? selectedResourceUuid === this.props.currentRouteUuid : false, }) } if (this.props.itemsAvailable !== prevProps.itemsAvailable) { @@ -207,7 +208,7 @@ export const DataExplorer = withStyles(styles)( actions, paperProps, hideSearchInput, - paperKey, + path, fetchMode, selectedResourceUuid, title, @@ -229,7 +230,7 @@ export const DataExplorer = withStyles(styles)( { - return disallowedPaths.some(path => location.includes(path)) +export const usesDetailsCard = (location: string): boolean => { + return detailsCardPaths.some(path => location.includes(path)) } export const MultiselectToolbar = connect( @@ -103,9 +100,10 @@ export const MultiselectToolbar = connect( )( withStyles(styles)((props: MultiselectToolbarProps & WithStyles) => { const { classes, checkedList, iconProps, user, disabledButtons, location, forceMultiSelectMode, injectedStyles } = props; - const selectedResourceUuid = isPathDisallowed(location) ? null : props.selectedResourceUuid; + const selectedResourceArray = selectedToArray(checkedList); + const selectedResourceUuid = usesDetailsCard(location) ? props.selectedResourceUuid : selectedResourceArray.length === 1 ? selectedResourceArray[0] : null; const singleResourceKind = selectedResourceUuid && !forceMultiSelectMode ? [resourceToMsResourceKind(selectedResourceUuid, iconProps.resources, user)] : null - const currentResourceKinds = singleResourceKind ? singleResourceKind : Array.from(selectedToKindSet(checkedList)); + const currentResourceKinds = singleResourceKind ? singleResourceKind : Array.from(selectedToKindSet(checkedList, iconProps.resources)); const currentPathIsTrash = window.location.pathname === "/trash"; const rawActions = @@ -204,16 +202,22 @@ export function selectedToArray(checkedList: TCheckedList): Array { return arrayifiedSelectedList; } -export function selectedToKindSet(checkedList: TCheckedList): Set { +export function selectedToKindSet(checkedList: TCheckedList, resources: ResourcesState = {}): Set { const setifiedList = new Set(); for (const [key, value] of Object.entries(checkedList)) { if (value === true) { - setifiedList.add(extractUuidKind(key) as string); + isGroupResource(key, resources) ? setifiedList.add(ContextMenuKind.GROUPS) : setifiedList.add(extractUuidKind(key) as string); } } return setifiedList; } +const isGroupResource = (uuid: string, resources: ResourcesState): boolean => { + const resource = getResource(uuid)(resources); + if(!resource) return false; + return resource.kind === ResourceKind.PROJECT && (resource as GroupResource).groupClass === GroupClass.ROLE; +}; + function groupByKind(checkedList: TCheckedList, resources: ResourcesState): Record { const result = {}; selectedToArray(checkedList).forEach(uuid => { diff --git a/services/workbench2/src/views-components/data-explorer/data-explorer.tsx b/services/workbench2/src/views-components/data-explorer/data-explorer.tsx index dc03454829..ce0a79a35d 100644 --- a/services/workbench2/src/views-components/data-explorer/data-explorer.tsx +++ b/services/workbench2/src/views-components/data-explorer/data-explorer.tsx @@ -13,6 +13,7 @@ import { DataColumns, TCheckedList } from "components/data-table/data-table"; import { DataTableFilters } from "components/data-table-filters/data-table-filters-tree"; import { toggleMSToolbar, setCheckedListOnStore } from "store/multiselect/multiselect-actions"; import { setSelectedResourceUuid } from "store/selected-resource/selected-resource-actions"; +import { usesDetailsCard } from "components/multiselect-toolbar/MultiselectToolbar"; interface Props { id: string; @@ -30,7 +31,7 @@ const mapStateToProps = ({ progressIndicator, dataExplorer, router, multiselect, const isMSToolbarVisible = multiselect.isVisible; return { ...dataExplorerState, - paperKey: currentRoute, + path: currentRoute, currentRouteUuid: properties.currentRouteUuid, isMSToolbarVisible, selectedResourceUuid, @@ -91,6 +92,8 @@ const mapDispatchToProps = () => { onRowDoubleClick, onContextMenu, + + usesDetailsCard, }); }; 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 index 3f2e147249..3e2a0a38e6 100644 --- 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 @@ -43,9 +43,9 @@ const msRemoveGroupAction: MultiSelectMenuAction = { name: ContextMenuActionNames.REMOVE, icon: RemoveIcon, hasAlts: false, - isForMulti: false, + isForMulti: true, execute: (dispatch, resources) => { - dispatch(openRemoveGroupDialog(resources[0].uuid)); + resources.forEach(resource => dispatch(openRemoveGroupDialog(resource.uuid))); }, }; -- 2.39.5