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..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'; @@ -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]); } }); @@ -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 && ( + + } + /> )}