diff --git a/packages/common/src/components/TableView/index.ts b/packages/common/src/components/TableView/index.ts index 268b50701..1e423245a 100644 --- a/packages/common/src/components/TableView/index.ts +++ b/packages/common/src/components/TableView/index.ts @@ -6,4 +6,5 @@ export * from './ManageColumnsToolbarItem'; export * from './sort'; export * from './TableView'; export * from './types'; +export * from './withTr'; // @endindex diff --git a/packages/common/src/components/TableView/withTr.tsx b/packages/common/src/components/TableView/withTr.tsx new file mode 100644 index 000000000..171c2eb8d --- /dev/null +++ b/packages/common/src/components/TableView/withTr.tsx @@ -0,0 +1,15 @@ +import React from 'react'; + +import { Tr } from '@patternfly/react-table'; + +import { RowProps } from './types'; + +export function withTr(Component: React.FC>) { + const Enhanced = (props: RowProps) => ( + + + + ); + Enhanced.displayName = `${Component.displayName || 'Component'}WithTr`; + return Enhanced; +} diff --git a/packages/forklift-console-plugin/src/components/page/StandardPage.tsx b/packages/forklift-console-plugin/src/components/page/StandardPage.tsx index 25482165d..11c605645 100644 --- a/packages/forklift-console-plugin/src/components/page/StandardPage.tsx +++ b/packages/forklift-console-plugin/src/components/page/StandardPage.tsx @@ -4,28 +4,31 @@ import { useForkliftTranslation } from 'src/utils/i18n'; import { AttributeValueFilter, createMetaMatcher, + DEFAULT_PER_PAGE, + DefaultHeader, + DefaultRow, defaultSupportedFilters, defaultValueMatchers, + ErrorState, FilterGroup, FilterRenderer, GlobalActionToolbarProps, - toFieldFilter, - useUrlFilters, - ValueMatcher, -} from '@kubev2v/common'; -import { - DEFAULT_PER_PAGE, - ErrorState, Loading, NoResultsFound, NoResultsMatchFilter, + ResourceField, + RowProps, + TableView, + TableViewHeaderProps, + toFieldFilter, useFields, usePagination, UserSettings, + useSort, + useUrlFilters, + ValueMatcher, + withTr, } from '@kubev2v/common'; -import { DefaultHeader, RowProps, TableView, TableViewHeaderProps, useSort } from '@kubev2v/common'; -import { ResourceField } from '@kubev2v/common'; -import { DefaultRow } from '@kubev2v/common'; import { Level, LevelItem, @@ -98,6 +101,12 @@ export interface StandardPageProps { */ RowMapper?: FC>; + /** + * (optional) Maps entity to a list of cells (without wrapping them in ). + * If present, it is used instead of RowMapper. + */ + CellMapper?: FC>; + /** * (optional) Maps field list to table header. * Defaults to all visible fields. @@ -166,6 +175,7 @@ export function StandardPage({ namespace, dataSource: [flatData, loaded, error], RowMapper = DefaultRow, + CellMapper, title, addButton, fieldsMetadata, @@ -298,7 +308,7 @@ export function StandardPage({ entities={showPagination ? pageData : filteredData} visibleColumns={fields.filter(({ isVisible, isHidden }) => isVisible && !isHidden)} aria-label={title} - Row={RowMapper} + Row={CellMapper ? withTr(CellMapper) : RowMapper} Header={HeaderMapper} activeSort={activeSort} setActiveSort={setActiveSort} diff --git a/packages/forklift-console-plugin/src/components/page/withSelection.tsx b/packages/forklift-console-plugin/src/components/page/withSelection.tsx index e4b140303..9f8e90d32 100644 --- a/packages/forklift-console-plugin/src/components/page/withSelection.tsx +++ b/packages/forklift-console-plugin/src/components/page/withSelection.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { FC, useState } from 'react'; import { DefaultHeader, @@ -6,21 +6,25 @@ import { RowProps, TableViewHeaderProps, } from '@kubev2v/common'; -import { Th } from '@patternfly/react-table'; +import { Td, Th } from '@patternfly/react-table'; import StandardPage, { StandardPageProps } from './StandardPage'; -export function withRowSelection({ RowMapper, isSelected, toggleSelectFor }) { +export function withRowSelection({ CellMapper, isSelected, toggleSelectFor, canSelect }) { const Enhanced = (props: RowProps) => ( - toggleSelectFor([props.resourceData])} - /> + <> + toggleSelectFor([props.resourceData]), + isSelected: isSelected(props.resourceData), + disable: !canSelect(props.resourceData), + }} + /> + + ); - Enhanced.displayName = `${RowMapper.displayName || 'RowMapper'}WithSelection`; + Enhanced.displayName = `${CellMapper.displayName || 'CellMapper'}WithSelection`; return Enhanced; } @@ -55,21 +59,19 @@ export interface IdBasedSelectionProps { * @returns true if items can be selected, false otherwise */ canSelect: (item: T) => boolean; - - /** - * global toolbar actions - */ - actions: React.FC & { selectedIds: string[] }>[]; } +export type GlobalActionWithSelection = GlobalActionToolbarProps & { + selectedIds: string[]; +}; + /** * Adds ID based multi selection to StandardPage component. * Contract: - * 1. provided row mapper renders check boxes when needed - * 2. IDs provided with toId() function are unique and constant in time - * 3. check box status at row level does not depend from other rows and can be calculated from the item via canSelect() function + * 1. IDs provided with toId() function are unique and constant in time + * 2. check box status at row level does not depend from other rows and can be calculated from the item via canSelect() function */ -export function withIdBasedSelection({ toId, canSelect, actions }: IdBasedSelectionProps) { +export function withIdBasedSelection({ toId, canSelect }: IdBasedSelectionProps) { const Enhanced = (props: StandardPageProps) => { const [selectedIds, setSelectedIds]: [string[], (selected: string[]) => void] = useState([]); const isSelected = (item: T) => selectedIds.includes(toId(item)); @@ -84,8 +86,9 @@ export function withIdBasedSelection({ toId, canSelect, actions }: IdBasedSel return ( ({ toId, canSelect, actions }: IdBasedSel isSelected, toggleSelectFor, })} - GlobalActionToolbarItems={actions.map((Action) => { - const ActionWithSelection = (props) => ; - ActionWithSelection.displayName = `${Action.displayName || 'Action'}WithSelection`; - return ActionWithSelection; - })} + GlobalActionToolbarItems={props.GlobalActionToolbarItems?.map( + (Action: FC>) => { + const ActionWithSelection = (props) => ; + ActionWithSelection.displayName = `${Action.displayName || 'Action'}WithSelection`; + return ActionWithSelection; + }, + )} /> ); }; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Hosts/VSphereHostsList.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Hosts/VSphereHostsList.tsx index db11b77af..c1fb8d91f 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Hosts/VSphereHostsList.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Hosts/VSphereHostsList.tsx @@ -1,6 +1,6 @@ -import React, { useState } from 'react'; +import React, { FC, useState } from 'react'; import StandardPage from 'src/components/page/StandardPage'; -import { withIdBasedSelection } from 'src/components/page/withSelection'; +import { GlobalActionWithSelection, withIdBasedSelection } from 'src/components/page/withSelection'; import { useProviderInventory } from 'src/modules/Providers/hooks'; import { useModal } from 'src/modules/Providers/modals'; import { useForkliftTranslation } from 'src/utils/i18n'; @@ -18,7 +18,7 @@ import { Button, ToolbarItem } from '@patternfly/react-core'; import { VSphereNetworkModal } from './modals/VSphereNetworkModal'; import { InventoryHostPair, matchHostsToInventory } from './utils/helpers'; import { ProviderHostsProps } from './ProviderHosts'; -import { VSphereHostsRow } from './VSphereHostsRow'; +import { VSphereHostsCells } from './VSphereHostsRow'; export const hostsFieldsMetadataFactory: ResourceFieldFactory = (t) => [ { @@ -60,7 +60,12 @@ export const hostsFieldsMetadataFactory: ResourceFieldFactory = (t) => [ }, ]; -export const VSphereHostsList: React.FC = ({ obj }) => { +const PageWithSelection = withIdBasedSelection({ + toId: (item: InventoryHostPair) => item.inventory.id, + canSelect: (item: InventoryHostPair) => item?.inventory?.networkAdapters?.length > 0, +}); + +export const VSphereHostsList: FC = ({ obj }) => { const { t } = useForkliftTranslation(); const [userSettings] = useState(() => loadUserSettings({ pageId: 'ProviderHosts' })); @@ -86,30 +91,26 @@ export const VSphereHostsList: React.FC = ({ obj }) => { const hostsData = matchHostsToInventory(hostsInventory, hosts, provider); - const Page = permissions?.canPatch - ? withIdBasedSelection({ - toId: (item: InventoryHostPair) => item.inventory.id, - canSelect: (item: InventoryHostPair) => item?.inventory?.networkAdapters?.length > 0, - actions: [ - ({ selectedIds }) => , - ], - }) - : StandardPage; + const Page = permissions?.canPatch ? PageWithSelection : StandardPage; + const actions: FC>[] = permissions?.canPatch + ? [({ selectedIds }) => ] + : []; return ( ); }; -const SelectNetworkBtn: React.FC<{ +const SelectNetworkBtn: FC<{ selectedIds: string[]; provider: V1beta1Provider; hostsData: InventoryHostPair[]; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Hosts/VSphereHostsRow.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Hosts/VSphereHostsRow.tsx index 7a0d267cb..1b16f9649 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Hosts/VSphereHostsRow.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Hosts/VSphereHostsRow.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { ResourceField, RowProps } from '@kubev2v/common'; -import { Td, Tr } from '@patternfly/react-table'; +import { Td } from '@patternfly/react-table'; import { NameCellRenderer } from './components/NameCellRenderer'; import { InventoryHostPair } from './utils/helpers'; @@ -12,31 +12,16 @@ import { NetworkCellRenderer, } from './components'; -export const VSphereHostsRow: React.FC> = ({ +export const VSphereHostsCells: React.FC> = ({ resourceFields, resourceData, - isSelected, - toggleSelect, - resourceIndex: rowIndex, }) => { return ( - - {!!toggleSelect && ( - - )} + <> {resourceFields?.map(({ resourceFieldId }) => renderTd({ resourceData, resourceFieldId, resourceFields }), )} - + ); }; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OVirtVirtualMachinesList.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OVirtVirtualMachinesList.tsx index 00edf8c18..bbea1420c 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OVirtVirtualMachinesList.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OVirtVirtualMachinesList.tsx @@ -4,7 +4,7 @@ import { EnumToTuple, ResourceFieldFactory } from '@kubev2v/common'; import { concernFilter } from './utils/concernFilter'; import { ProviderVirtualMachinesList, VmData } from './components'; -import { OVirtVirtualMachinesRow } from './OVirtVirtualMachinesRow'; +import { OVirtVirtualMachinesCells } from './OVirtVirtualMachinesRow'; import { ProviderVirtualMachinesProps } from './ProviderVirtualMachines'; import { getVmPowerState } from './utils'; @@ -97,7 +97,7 @@ export const OVirtVirtualMachinesList: React.FC = obj={obj} loaded={loaded} loadError={loadError} - rowMapper={OVirtVirtualMachinesRow} + cellMapper={OVirtVirtualMachinesCells} fieldsMetadataFactory={oVirtVmFieldsMetadataFactory} pageId="OVirtVirtualMachinesList" /> diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OVirtVirtualMachinesRow.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OVirtVirtualMachinesRow.tsx index 084862cde..e47eab05d 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OVirtVirtualMachinesRow.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OVirtVirtualMachinesRow.tsx @@ -3,7 +3,7 @@ import { TableCell } from 'src/modules/Providers/utils'; import { ResourceField, RowProps } from '@kubev2v/common'; import { OVirtVM } from '@kubev2v/types'; -import { Td, Tr } from '@patternfly/react-table'; +import { Td } from '@patternfly/react-table'; import { PowerStateCellRenderer } from './components/PowerStateCellRenderer'; import { VMCellProps, VMConcernsCellRenderer, VMNameCellRenderer } from './components'; @@ -41,15 +41,15 @@ const cellRenderers: Record> = { description: ({ data }) => {(data?.vm as OVirtVM)?.description}, }; -export const OVirtVirtualMachinesRow: React.FC> = ({ +export const OVirtVirtualMachinesCells: React.FC> = ({ resourceFields, resourceData, }) => { return ( - + <> {resourceFields?.map(({ resourceFieldId }) => renderTd({ resourceData, resourceFieldId, resourceFields }), )} - + ); }; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesList.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesList.tsx index ccacf9a0b..bdbbe6c98 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesList.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesList.tsx @@ -4,7 +4,7 @@ import { EnumToTuple, ResourceFieldFactory } from '@kubev2v/common'; import { toVmFeatureEnum } from './utils/helpers/toVmFeatureEnum'; import { ProviderVirtualMachinesList, VmData } from './components'; -import { OpenShiftVirtualMachinesRow } from './OpenShiftVirtualMachinesRow'; +import { OpenShiftVirtualMachinesCells } from './OpenShiftVirtualMachinesRow'; import { ProviderVirtualMachinesProps } from './ProviderVirtualMachines'; import { getOpenShiftFeatureMap, getVmPowerState } from './utils'; @@ -70,7 +70,7 @@ export const OpenShiftVirtualMachinesList: React.FC diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesRow.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesRow.tsx index 1c0583392..0c4e4c29d 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesRow.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesRow.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { TableCell } from 'src/modules/Providers/utils'; import { ResourceField, RowProps } from '@kubev2v/common'; -import { Td, Tr } from '@patternfly/react-table'; +import { Td } from '@patternfly/react-table'; import { PowerStateCellRenderer } from './components/PowerStateCellRenderer'; import { VmResourceLinkRenderer } from './components/VmResourceLinkRenderer'; @@ -33,15 +33,15 @@ interface RenderTdProps { resourceFields: ResourceField[]; } -export const OpenShiftVirtualMachinesRow: React.FC> = ({ +export const OpenShiftVirtualMachinesCells: React.FC> = ({ resourceFields, resourceData, }) => { return ( - + <> {resourceFields?.map(({ resourceFieldId }) => renderTd({ resourceData, resourceFieldId, resourceFields }), )} - + ); }; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenStackVirtualMachinesList.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenStackVirtualMachinesList.tsx index 9751935d0..9c3d2e65d 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenStackVirtualMachinesList.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenStackVirtualMachinesList.tsx @@ -5,7 +5,7 @@ import { EnumToTuple, ResourceFieldFactory } from '@kubev2v/common'; import { concernFilter } from './utils/concernFilter'; import { getVmPowerState } from './utils/helpers/getVmPowerState'; import { ProviderVirtualMachinesList, VmData } from './components'; -import { OpenStackVirtualMachinesRow } from './OpenStackVirtualMachinesRow'; +import { OpenStackVirtualMachinesCells } from './OpenStackVirtualMachinesRow'; import { ProviderVirtualMachinesProps } from './ProviderVirtualMachines'; export const openStackVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [ @@ -113,7 +113,7 @@ export const OpenStackVirtualMachinesList: React.FC diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenStackVirtualMachinesRow.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenStackVirtualMachinesRow.tsx index a07b3d51d..7c002511d 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenStackVirtualMachinesRow.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenStackVirtualMachinesRow.tsx @@ -3,7 +3,7 @@ import { TableCell } from 'src/modules/Providers/utils'; import { ResourceField, RowProps } from '@kubev2v/common'; import { OpenstackVM } from '@kubev2v/types'; -import { Td, Tr } from '@patternfly/react-table'; +import { Td } from '@patternfly/react-table'; import { VMCellProps, VMConcernsCellRenderer, VmData, VMNameCellRenderer } from './components'; @@ -35,15 +35,15 @@ const cellRenderers: Record> = { flavorID: ({ data }) => {(data?.vm as OpenstackVM)?.flavorID}, }; -export const OpenStackVirtualMachinesRow: React.FC> = ({ +export const OpenStackVirtualMachinesCells: React.FC> = ({ resourceFields, resourceData, }) => { return ( - + <> {resourceFields?.map(({ resourceFieldId }) => renderTd({ resourceData, resourceFieldId, resourceFields }), )} - + ); }; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OvaVirtualMachinesList.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OvaVirtualMachinesList.tsx index 744b8e933..41f314e6e 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OvaVirtualMachinesList.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OvaVirtualMachinesList.tsx @@ -4,7 +4,7 @@ import { ResourceFieldFactory } from '@kubev2v/common'; import { concernFilter } from './utils/concernFilter'; import { ProviderVirtualMachinesList } from './components'; -import { OvaVirtualMachinesRow } from './OvaVirtualMachinesRow'; +import { OvaVirtualMachinesCells } from './OvaVirtualMachinesRow'; import { ProviderVirtualMachinesProps } from './ProviderVirtualMachines'; export const ovaVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [ @@ -51,7 +51,7 @@ export const OvaVirtualMachinesList: React.FC = ({ obj={obj} loaded={loaded} loadError={loadError} - rowMapper={OvaVirtualMachinesRow} + cellMapper={OvaVirtualMachinesCells} fieldsMetadataFactory={ovaVmFieldsMetadataFactory} pageId="OvaVirtualMachinesList" /> diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OvaVirtualMachinesRow.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OvaVirtualMachinesRow.tsx index 45bb65ebb..daac9f7d1 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OvaVirtualMachinesRow.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OvaVirtualMachinesRow.tsx @@ -3,7 +3,7 @@ import { TableCell } from 'src/modules/Providers/utils'; import { ResourceField, RowProps } from '@kubev2v/common'; import { OvaVM } from '@kubev2v/types'; -import { Td, Tr } from '@patternfly/react-table'; +import { Td } from '@patternfly/react-table'; import { VMCellProps, VMConcernsCellRenderer, VMNameCellRenderer } from './components'; @@ -35,15 +35,15 @@ const cellRenderers: Record> = { ovaPath: ({ data }) => {(data?.vm as OvaVM)?.OvaPath}, }; -export const OvaVirtualMachinesRow: React.FC> = ({ +export const OvaVirtualMachinesCells: React.FC> = ({ resourceFields, resourceData, }) => { return ( - + <> {resourceFields?.map(({ resourceFieldId }) => renderTd({ resourceData, resourceFieldId, resourceFields }), )} - + ); }; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/VSphereVirtualMachinesList.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/VSphereVirtualMachinesList.tsx index 473d72c9f..e141791dc 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/VSphereVirtualMachinesList.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/VSphereVirtualMachinesList.tsx @@ -6,7 +6,7 @@ import { concernFilter } from './utils/concernFilter'; import { ProviderVirtualMachinesList, VmData } from './components'; import { ProviderVirtualMachinesProps } from './ProviderVirtualMachines'; import { getVmPowerState } from './utils'; -import { VSphereVirtualMachinesRow } from './VSphereVirtualMachinesRow'; +import { VSphereVirtualMachinesCells } from './VSphereVirtualMachinesRow'; export const vSphereVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [ { @@ -85,7 +85,7 @@ export const VSphereVirtualMachinesList: React.FC obj={obj} loaded={loaded} loadError={loadError} - rowMapper={VSphereVirtualMachinesRow} + cellMapper={VSphereVirtualMachinesCells} fieldsMetadataFactory={vSphereVmFieldsMetadataFactory} pageId="VSphereVirtualMachinesList" /> diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/VSphereVirtualMachinesRow.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/VSphereVirtualMachinesRow.tsx index 936dcbd40..23cb0af34 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/VSphereVirtualMachinesRow.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/VSphereVirtualMachinesRow.tsx @@ -3,7 +3,7 @@ import { TableCell } from 'src/modules/Providers/utils'; import { ResourceField, RowProps } from '@kubev2v/common'; import { VSphereVM } from '@kubev2v/types'; -import { Td, Tr } from '@patternfly/react-table'; +import { Td } from '@patternfly/react-table'; import { PowerStateCellRenderer, @@ -46,15 +46,15 @@ const cellRenderers: Record> = { powerState: PowerStateCellRenderer, }; -export const VSphereVirtualMachinesRow: React.FC> = ({ +export const VSphereVirtualMachinesCells: React.FC> = ({ resourceFields, resourceData, }) => { return ( - + <> {resourceFields?.map(({ resourceFieldId }) => renderTd({ resourceData, resourceFieldId, resourceFields }), )} - + ); }; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/components/ProviderVirtualMachinesList.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/components/ProviderVirtualMachinesList.tsx index 44954c681..3408107b7 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/components/ProviderVirtualMachinesList.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/components/ProviderVirtualMachinesList.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { FC, useState } from 'react'; import { RouteComponentProps } from 'react-router-dom'; import StandardPage from 'src/components/page/StandardPage'; import { ProviderData } from 'src/modules/Providers/utils'; @@ -24,16 +24,16 @@ export interface ProviderVirtualMachinesListProps extends RouteComponentProps { name?: string; loaded?: boolean; loadError?: unknown; - rowMapper: React.FunctionComponent>; + cellMapper: FC>; fieldsMetadataFactory: ResourceFieldFactory; pageId: string; } -export const ProviderVirtualMachinesList: React.FC = ({ +export const ProviderVirtualMachinesList: FC = ({ obj, loaded, loadError, - rowMapper, + cellMapper, fieldsMetadataFactory, pageId, }) => { @@ -47,7 +47,7 @@ export const ProviderVirtualMachinesList: React.FC data-testid="vm-list" dataSource={[vmData || [], !loading, null]} - RowMapper={rowMapper} + CellMapper={cellMapper} fieldsMetadata={fieldsMetadataFactory(t)} namespace={obj?.provider?.metadata?.namespace} title={t('Virtual Machines')}