Skip to content

Commit

Permalink
Add selection to VM list screen
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Szwajkowski <[email protected]>
  • Loading branch information
rszwajko committed Dec 7, 2023
1 parent 649e95b commit f05bb8d
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { FC, useState } from 'react';
import { RouteComponentProps } from 'react-router-dom';
import StandardPage from 'src/components/page/StandardPage';
import { withIdBasedSelection } from 'src/components/page/withSelection';
import { ProviderData } from 'src/modules/Providers/utils';
import { useForkliftTranslation } from 'src/utils/i18n';

Expand Down Expand Up @@ -29,6 +29,11 @@ export interface ProviderVirtualMachinesListProps extends RouteComponentProps {
pageId: string;
}

const PageWithSelection = withIdBasedSelection<VmData>({
toId: (item: VmData) => (item.vm.providerType === 'openshift' ? item.vm.uid : item.vm.id),
canSelect: (item: VmData) => !!item,
});

export const ProviderVirtualMachinesList: FC<ProviderVirtualMachinesListProps> = ({
obj,
loaded,
Expand All @@ -44,7 +49,7 @@ export const ProviderVirtualMachinesList: FC<ProviderVirtualMachinesListProps> =
const [vmData, loading] = useInventoryVms(obj, loaded, loadError);

return (
<StandardPage<VmData>
<PageWithSelection
data-testid="vm-list"
dataSource={[vmData || [], !loading, null]}
CellMapper={cellMapper}
Expand Down

0 comments on commit f05bb8d

Please sign in to comment.