From 17f158d0b779cf8e708dae9e5c589b8b553f45af Mon Sep 17 00:00:00 2001 From: Karel Hala Date: Thu, 7 Nov 2024 13:45:24 +0100 Subject: [PATCH 1/2] fix(workspace): update parent id reference --- src/redux/reducers/workspaces-reducer.ts | 1 + src/smart-components/workspaces/workspaces.tsx | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/redux/reducers/workspaces-reducer.ts b/src/redux/reducers/workspaces-reducer.ts index 226716515..324d5002f 100644 --- a/src/redux/reducers/workspaces-reducer.ts +++ b/src/redux/reducers/workspaces-reducer.ts @@ -5,6 +5,7 @@ export interface Workspace { name: string; description: string; children?: Workspace[]; + parent_id?: string; } export interface WorkspacesStore { isLoading: boolean; diff --git a/src/smart-components/workspaces/workspaces.tsx b/src/smart-components/workspaces/workspaces.tsx index 74bddc419..7d4b39f82 100644 --- a/src/smart-components/workspaces/workspaces.tsx +++ b/src/smart-components/workspaces/workspaces.tsx @@ -22,12 +22,12 @@ const Workspaces = () => { dispatch(fetchWorkspaces()); }, [dispatch]); - const mapWorkspacesToHierarchy = (workspaceData: any[]): Workspace[] => { + const mapWorkspacesToHierarchy = (workspaceData: Workspace[]): Workspace[] => { const workspaceMap: { [key: string]: Workspace } = {}; workspaceData.forEach((ws) => { - workspaceMap[ws.uuid] = { - id: ws.uuid, + workspaceMap[ws.id] = { + id: ws.id, name: ws.name, description: ws.description, children: [], @@ -37,9 +37,9 @@ const Workspaces = () => { const hierarchy: Workspace[] = []; workspaceData.forEach((ws) => { if (ws.parent_id) { - workspaceMap[ws.parent_id]?.children?.push(workspaceMap[ws.uuid]); + workspaceMap[ws.parent_id]?.children?.push(workspaceMap[ws.id]); } else { - hierarchy.push(workspaceMap[ws.uuid]); + hierarchy.push(workspaceMap[ws.id]); } }); From ee50b668bd3de45b53c36d8ed3bec3dca715e644 Mon Sep 17 00:00:00 2001 From: Karel Hala Date: Thu, 7 Nov 2024 13:55:14 +0100 Subject: [PATCH 2/2] feat(workspaces): add bulk select to workspaces table --- .../workspaces/workspaces.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/smart-components/workspaces/workspaces.tsx b/src/smart-components/workspaces/workspaces.tsx index 7d4b39f82..a8556cad5 100644 --- a/src/smart-components/workspaces/workspaces.tsx +++ b/src/smart-components/workspaces/workspaces.tsx @@ -3,9 +3,9 @@ import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; import { fetchWorkspaces } from '../../redux/actions/workspaces-actions'; import messages from '../../Messages'; -import { ContentHeader } from '@patternfly/react-component-groups'; +import { BulkSelect, BulkSelectValue, ContentHeader } from '@patternfly/react-component-groups'; import { PageSection } from '@patternfly/react-core'; -import { DataView, DataViewTable, DataViewTh, DataViewTrTree, useDataViewSelection } from '@patternfly/react-data-view'; +import { DataView, DataViewTable, DataViewTh, DataViewToolbar, DataViewTrTree, useDataViewSelection } from '@patternfly/react-data-view'; import { Workspace } from '../../redux/reducers/workspaces-reducer'; import { RBACStore } from '../../redux/store'; @@ -67,6 +67,11 @@ const Workspaces = () => { const columns: DataViewTh[] = ['Name', 'Description']; + const handleBulkSelect = (value: BulkSelectValue) => { + value === BulkSelectValue.none && selection.onSelect(false); + value === BulkSelectValue.all && selection.onSelect(true, workspaces); + }; + return ( { {error &&

Error: {error}

} {!isLoading && !error && ( + + } + /> )}