-
Notifications
You must be signed in to change notification settings - Fork 22
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 #708 from rszwajko/providersVm
Display more columns in Providers VM table
- Loading branch information
Showing
16 changed files
with
821 additions
and
136 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
106 changes: 106 additions & 0 deletions
106
...gin/src/modules/Providers/views/details/tabs/VirtualMachines/OVirtVirtualMachinesList.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,106 @@ | ||
import React from 'react'; | ||
|
||
import { EnumToTuple, ResourceFieldFactory } from '@kubev2v/common'; | ||
|
||
import { ProviderVirtualMachinesList } from './components/ProviderVirtualMachinesList'; | ||
import { OVirtVirtualMachinesRow } from './OVirtVirtualMachinesRow'; | ||
import { ProviderVirtualMachinesProps } from './ProviderVirtualMachines'; | ||
|
||
export const oVirtVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [ | ||
{ | ||
resourceFieldId: 'name', | ||
jsonPath: '$.name', | ||
label: t('Name'), | ||
isVisible: true, | ||
isIdentity: true, // Name is sufficient ID when Namespace is pre-selected | ||
filter: { | ||
type: 'freetext', | ||
placeholderLabel: t('Filter by name'), | ||
}, | ||
sortable: true, | ||
}, | ||
{ | ||
resourceFieldId: 'concerns', | ||
jsonPath: '$.concerns', | ||
label: t('Concerns'), | ||
isVisible: true, | ||
sortable: true, | ||
filter: { | ||
type: 'enum', | ||
primary: true, | ||
placeholderLabel: t('Concerns'), | ||
values: EnumToTuple({ Critical: 'Critical', Warning: 'Warning', Information: 'Information' }), | ||
}, | ||
}, | ||
{ | ||
resourceFieldId: 'cluster', | ||
jsonPath: '$.vm.cluster', | ||
label: t('Cluster'), | ||
isVisible: true, | ||
isIdentity: false, | ||
filter: { | ||
type: 'freetext', | ||
placeholderLabel: t('Filter by cluster'), | ||
}, | ||
sortable: true, | ||
}, | ||
{ | ||
resourceFieldId: 'host', | ||
jsonPath: '$.vm.host', | ||
label: t('Host'), | ||
isVisible: true, | ||
isIdentity: false, | ||
filter: { | ||
type: 'freetext', | ||
placeholderLabel: t('Filter by host'), | ||
}, | ||
sortable: true, | ||
}, | ||
{ | ||
resourceFieldId: 'path', | ||
jsonPath: '$.vm.path', | ||
label: t('Path'), | ||
isVisible: true, | ||
isIdentity: false, | ||
filter: { | ||
type: 'freetext', | ||
placeholderLabel: t('Filter by path'), | ||
}, | ||
sortable: true, | ||
}, | ||
{ | ||
resourceFieldId: 'status', | ||
jsonPath: '$.vm.status', | ||
label: t('Status'), | ||
isVisible: true, | ||
isIdentity: false, | ||
filter: { | ||
type: 'freetext', | ||
placeholderLabel: t('Filter by status'), | ||
}, | ||
sortable: true, | ||
}, | ||
{ | ||
resourceFieldId: 'description', | ||
jsonPath: '$.vm.description', | ||
label: t('Description'), | ||
isVisible: true, | ||
isIdentity: false, | ||
sortable: false, | ||
}, | ||
]; | ||
|
||
export const OVirtVirtualMachinesList: React.FC<ProviderVirtualMachinesProps> = ({ | ||
obj, | ||
loaded, | ||
loadError, | ||
}) => ( | ||
<ProviderVirtualMachinesList | ||
obj={obj} | ||
loaded={loaded} | ||
loadError={loadError} | ||
rowMapper={OVirtVirtualMachinesRow} | ||
fieldsMetadataFactory={oVirtVmFieldsMetadataFactory} | ||
pageId="OVirtVirtualMachinesList" | ||
/> | ||
); |
54 changes: 54 additions & 0 deletions
54
...ugin/src/modules/Providers/views/details/tabs/VirtualMachines/OVirtVirtualMachinesRow.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,54 @@ | ||
import React from 'react'; | ||
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 { VMCellProps, VMConcernsCellRenderer, VMNameCellRenderer } from './components'; | ||
|
||
export interface VmData { | ||
vm: OVirtVM; | ||
name: string; | ||
concerns: string; | ||
} | ||
|
||
const renderTd = ({ resourceData, resourceFieldId, resourceFields }: RenderTdProps) => { | ||
const fieldId = resourceFieldId; | ||
|
||
const CellRenderer = cellRenderers?.[fieldId] ?? (() => <></>); | ||
return ( | ||
<Td key={fieldId} dataLabel={fieldId}> | ||
<CellRenderer data={resourceData} fieldId={fieldId} fields={resourceFields} /> | ||
</Td> | ||
); | ||
}; | ||
|
||
interface RenderTdProps { | ||
resourceData: VmData; | ||
resourceFieldId: string; | ||
resourceFields: ResourceField[]; | ||
} | ||
|
||
const cellRenderers: Record<string, React.FC<VMCellProps>> = { | ||
name: VMNameCellRenderer, | ||
concerns: VMConcernsCellRenderer, | ||
host: ({ data }) => <TableCell>{(data?.vm as OVirtVM)?.host}</TableCell>, | ||
cluster: ({ data }) => <TableCell>{(data?.vm as OVirtVM)?.cluster}</TableCell>, | ||
path: ({ data }) => <TableCell>{(data?.vm as OVirtVM)?.path}</TableCell>, | ||
status: ({ data }) => <TableCell>{(data?.vm as OVirtVM)?.status}</TableCell>, | ||
description: ({ data }) => <TableCell>{(data?.vm as OVirtVM)?.description}</TableCell>, | ||
}; | ||
|
||
export const OVirtVirtualMachinesRow: React.FC<RowProps<VmData>> = ({ | ||
resourceFields, | ||
resourceData, | ||
}) => { | ||
return ( | ||
<Tr> | ||
{resourceFields?.map(({ resourceFieldId }) => | ||
renderTd({ resourceData, resourceFieldId, resourceFields }), | ||
)} | ||
</Tr> | ||
); | ||
}; |
50 changes: 50 additions & 0 deletions
50
...src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesList.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,50 @@ | ||
import React from 'react'; | ||
|
||
import { EnumToTuple, ResourceFieldFactory } from '@kubev2v/common'; | ||
|
||
import { ProviderVirtualMachinesList } from './components/ProviderVirtualMachinesList'; | ||
import { OpenShiftVirtualMachinesRow } from './OpenShiftVirtualMachinesRow'; | ||
import { ProviderVirtualMachinesProps } from './ProviderVirtualMachines'; | ||
|
||
const openShiftVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [ | ||
{ | ||
resourceFieldId: 'name', | ||
jsonPath: '$.name', | ||
label: t('Name'), | ||
isVisible: true, | ||
isIdentity: true, // Name is sufficient ID when Namespace is pre-selected | ||
filter: { | ||
type: 'freetext', | ||
placeholderLabel: t('Filter by name'), | ||
}, | ||
sortable: true, | ||
}, | ||
{ | ||
resourceFieldId: 'concerns', | ||
jsonPath: '$.concerns', | ||
label: t('Concerns'), | ||
isVisible: true, | ||
sortable: true, | ||
filter: { | ||
type: 'enum', | ||
primary: true, | ||
placeholderLabel: t('Concerns'), | ||
values: EnumToTuple({ Critical: 'Critical', Warning: 'Warning', Information: 'Information' }), | ||
}, | ||
}, | ||
]; | ||
|
||
export const OpenShiftVirtualMachinesList: React.FC<ProviderVirtualMachinesProps> = ({ | ||
obj, | ||
loaded, | ||
loadError, | ||
}) => ( | ||
<ProviderVirtualMachinesList | ||
obj={obj} | ||
loaded={loaded} | ||
loadError={loadError} | ||
rowMapper={OpenShiftVirtualMachinesRow} | ||
fieldsMetadataFactory={openShiftVmFieldsMetadataFactory} | ||
pageId="OpenShiftVirtualMachinesList" | ||
/> | ||
); |
41 changes: 41 additions & 0 deletions
41
.../src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesRow.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,41 @@ | ||
import React from 'react'; | ||
|
||
import { ResourceField, RowProps } from '@kubev2v/common'; | ||
import { Td, Tr } from '@patternfly/react-table'; | ||
|
||
import { VMCellProps, VMConcernsCellRenderer, VmData, VMNameCellRenderer } from './components'; | ||
|
||
const cellRenderers: Record<string, React.FC<VMCellProps>> = { | ||
name: VMNameCellRenderer, | ||
concerns: VMConcernsCellRenderer, | ||
}; | ||
|
||
const renderTd = ({ resourceData, resourceFieldId, resourceFields }: RenderTdProps) => { | ||
const fieldId = resourceFieldId; | ||
|
||
const CellRenderer = cellRenderers?.[fieldId] ?? (() => <></>); | ||
return ( | ||
<Td key={fieldId} dataLabel={fieldId}> | ||
<CellRenderer data={resourceData} fieldId={fieldId} fields={resourceFields} /> | ||
</Td> | ||
); | ||
}; | ||
|
||
interface RenderTdProps { | ||
resourceData: VmData; | ||
resourceFieldId: string; | ||
resourceFields: ResourceField[]; | ||
} | ||
|
||
export const OpenShiftVirtualMachinesRow: React.FC<RowProps<VmData>> = ({ | ||
resourceFields, | ||
resourceData, | ||
}) => { | ||
return ( | ||
<Tr> | ||
{resourceFields?.map(({ resourceFieldId }) => | ||
renderTd({ resourceData, resourceFieldId, resourceFields }), | ||
)} | ||
</Tr> | ||
); | ||
}; |
Oops, something went wrong.