-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1528 from DanaOrr/fixing-hardware-devices-table
CNV-32568: Fixing Hardware Devices table in Compute -> Hardware devices
- Loading branch information
Showing
8 changed files
with
127 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 19 additions & 6 deletions
25
src/utils/components/HardwareDevices/HardwareDevicesPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/utils/components/HardwareDevices/HardwareDevicesPageRow.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { NO_DATA_DASH } from '@kubevirt-utils/resources/vm/utils/constants'; | ||
import { RowProps, TableData } from '@openshift-console/dynamic-plugin-sdk'; | ||
|
||
import { HardwareDevicePageRow } from './utils/constants'; | ||
|
||
const HardwareDevicesPageRow: FC<RowProps<HardwareDevicePageRow>> = ({ | ||
activeColumnIDs, | ||
obj: device, | ||
}) => { | ||
return ( | ||
<> | ||
<TableData activeColumnIDs={activeColumnIDs} id="resourceName"> | ||
{device?.resourceName || NO_DATA_DASH} | ||
</TableData> | ||
<TableData activeColumnIDs={activeColumnIDs} id="selector"> | ||
{device?.selector || NO_DATA_DASH} | ||
</TableData> | ||
</> | ||
); | ||
}; | ||
|
||
export default HardwareDevicesPageRow; |
39 changes: 39 additions & 0 deletions
39
src/utils/components/HardwareDevices/HardwareDevicesPageTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; | ||
import { VirtualizedTable } from '@openshift-console/dynamic-plugin-sdk'; | ||
|
||
import MutedTextSpan from '../MutedTextSpan/MutedTextSpan'; | ||
|
||
import useHardwareDevicesPageColumns from './list/hooks/useHardwareDevicesPageColumns '; | ||
import { HardwareDevicePageRow } from './utils/constants'; | ||
import HardwareDevicesPageRow from './HardwareDevicesPageRow'; | ||
|
||
type HardwareDevicesPageTableProps = { | ||
devices: HardwareDevicePageRow[]; | ||
error: Error; | ||
loaded: boolean; | ||
}; | ||
|
||
const HardwareDevicesPageTable: FC<HardwareDevicesPageTableProps> = ({ | ||
devices, | ||
error, | ||
loaded, | ||
}) => { | ||
const { t } = useKubevirtTranslation(); | ||
const columns = useHardwareDevicesPageColumns(); | ||
|
||
return ( | ||
<VirtualizedTable | ||
columns={columns} | ||
data={devices} | ||
EmptyMsg={() => <MutedTextSpan text={t('Not available')} />} | ||
loaded={loaded} | ||
loadError={error} | ||
Row={HardwareDevicesPageRow} | ||
unfilteredData={devices} | ||
/> | ||
); | ||
}; | ||
|
||
export default HardwareDevicesPageTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/utils/components/HardwareDevices/list/hooks/useHardwareDevicesPageColumns .tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useMemo } from 'react'; | ||
|
||
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; | ||
import { TableColumn } from '@openshift-console/dynamic-plugin-sdk'; | ||
|
||
import { HardwareDevicePageRow } from '../../utils/constants'; | ||
|
||
const useHardwareDevicesPageColumns = () => { | ||
const { t } = useKubevirtTranslation(); | ||
|
||
const columns: TableColumn<HardwareDevicePageRow>[] = useMemo( | ||
() => [ | ||
{ | ||
id: 'resourceName', | ||
props: { className: 'pf-m-width-20' }, | ||
title: t('Resource name'), | ||
}, | ||
{ | ||
id: 'selector', | ||
props: { className: 'pf-m-width-20' }, | ||
title: t('Selector'), | ||
}, | ||
], | ||
[t], | ||
); | ||
return columns; | ||
}; | ||
|
||
export default useHardwareDevicesPageColumns; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters