diff --git a/frontend/packages/kubevirt-plugin/src/components/flavor-text.tsx b/frontend/packages/kubevirt-plugin/src/components/flavor-text.tsx index a27149fedb..2d5c97e56b 100644 --- a/frontend/packages/kubevirt-plugin/src/components/flavor-text.tsx +++ b/frontend/packages/kubevirt-plugin/src/components/flavor-text.tsx @@ -1,11 +1,9 @@ -import * as React from 'react'; import * as _ from 'lodash'; import { convertToBaseValue, humanizeDecimalBytes } from '@console/internal/components/utils'; import { getFlavor, vCPUCount, getCPU, getMemory, asVM } from '../selectors/vm'; import { VMLikeEntityKind } from '../types'; -export const FlavorText: React.FC = (props) => { - const { vmLike } = props; +export const getFlavorText = (vmLike: VMLikeEntityKind) => { const vm = asVM(vmLike); const flavor = _.capitalize(getFlavor(vmLike)); @@ -16,9 +14,5 @@ export const FlavorText: React.FC = (props) => { const memoryBase = convertToBaseValue(getMemory(vm)); const memoryText = humanizeDecimalBytes(memoryBase).string; - return <>{`${flavor || ''}${flavor ? ': ' : ''}${vcpusText}, ${memoryText} Memory`}; -}; - -type FlavorTextProps = { - vmLike: VMLikeEntityKind; + return `${flavor || ''}${flavor ? ': ' : ''}${vcpusText}, ${memoryText} Memory`; }; diff --git a/frontend/packages/kubevirt-plugin/src/components/vm-templates/vm-template-resource.tsx b/frontend/packages/kubevirt-plugin/src/components/vm-templates/vm-template-resource.tsx index 057f435c81..f5bd0b9cc1 100644 --- a/frontend/packages/kubevirt-plugin/src/components/vm-templates/vm-template-resource.tsx +++ b/frontend/packages/kubevirt-plugin/src/components/vm-templates/vm-template-resource.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import * as _ from 'lodash'; import { getOperatingSystemName, getOperatingSystem, @@ -7,16 +8,17 @@ import { BootOrder, getBootableDevicesInOrder, TemplateSource, + getTemplateProvisionSource, } from 'kubevirt-web-ui-components'; import { ResourceSummary } from '@console/internal/components/utils'; -import { DASH } from '@console/shared'; import { TemplateKind, K8sResourceKind } from '@console/internal/module/k8s'; import { getBasicID, prefixedID } from '../../utils'; import { vmDescriptionModal } from '../modals/vm-description-modal'; import { getDescription } from '../../selectors/selectors'; import { vmFlavorModal } from '../modals'; -import { FlavorText } from '../flavor-text'; +import { getFlavorText } from '../flavor-text'; import { EditButton } from '../edit-button'; +import { VMDetailsItem } from '../vms/vm-resource'; import { VMTemplateLink } from './vm-template-link'; import './_vm-template-resource.scss'; @@ -28,29 +30,45 @@ export const VMTemplateResourceSummary: React.FC const id = getBasicID(template); const base = getVmTemplate(template); - const description = getDescription(template) || DASH; + const description = getDescription(template); + const os = getOperatingSystemName(template) || getOperatingSystem(template); + const workloadProfile = getWorkloadProfile(template); return ( -
Description
-
+ vmDescriptionModal({ vmLikeEntity: template })} > {description} -
-
Operating System
-
- {getOperatingSystemName(template) || getOperatingSystem(template) || DASH} -
-
Workload Profile
-
{getWorkloadProfile(template) || DASH}
-
Base Template
-
- {base ? : DASH} -
+ + + + {os} + + + + {workloadProfile} + + + + {base && } +
); }; @@ -62,31 +80,33 @@ export const VMTemplateDetailsList: React.FC = ({ }) => { const id = getBasicID(template); const sortedBootableDevices = getBootableDevicesInOrder(template); + const flavorText = getFlavorText(template); + const isProvisionSource = + dataVolumes && !!_.get(getTemplateProvisionSource(template, dataVolumes), 'type'); return (
-
Boot Order
-
- {sortedBootableDevices.length > 0 ? ( - - ) : ( - DASH - )} -
-
Flavor
-
+ + + + + vmFlavorModal({ vmLike: template })}> - + {flavorText} -
-
Provision Source
-
- {dataVolumes ? ( - - ) : ( - DASH - )} -
+ + + + {dataVolumes && } +
); }; diff --git a/frontend/packages/kubevirt-plugin/src/components/vms/vm-resource.tsx b/frontend/packages/kubevirt-plugin/src/components/vms/vm-resource.tsx index 0acf54eb61..1640e6036f 100644 --- a/frontend/packages/kubevirt-plugin/src/components/vms/vm-resource.tsx +++ b/frontend/packages/kubevirt-plugin/src/components/vms/vm-resource.tsx @@ -11,7 +11,7 @@ import { } from 'kubevirt-web-ui-components'; import { ResourceSummary, NodeLink, ResourceLink } from '@console/internal/components/utils'; import { PodKind } from '@console/internal/module/k8s'; -import { getName, getNamespace, DASH } from '@console/shared'; +import { getName, getNamespace } from '@console/shared'; import { PodModel } from '@console/internal/models'; import { VMKind, VMIKind } from '../../types'; import { VMTemplateLink } from '../vm-templates/vm-template-link'; @@ -19,34 +19,56 @@ import { getBasicID, prefixedID } from '../../utils'; import { vmDescriptionModal, vmFlavorModal } from '../modals'; import { getDescription } from '../../selectors/selectors'; import { getVMStatus } from '../../statuses/vm/vm'; -import { FlavorText } from '../flavor-text'; +import { getFlavorText } from '../flavor-text'; import { EditButton } from '../edit-button'; import { getVmiIpAddressesString } from '../ip-addresses'; import './_vm-resource.scss'; +export const VMDetailsItem: React.FC = ({ + title, + idValue, + isNotAvail = false, + valueClassName, + children, +}) => { + return ( + <> +
{title}
+
+ {isNotAvail ? Not available : children} +
+ + ); +}; + export const VMResourceSummary: React.FC = ({ vm, canUpdateVM }) => { const template = getVmTemplate(vm); const id = getBasicID(vm); - const description = getDescription(vm) || DASH; + const description = getDescription(vm); + const os = getOperatingSystemName(vm) || getOperatingSystem(vm); return ( -
Description
-
+ vmDescriptionModal({ vmLikeEntity: vm })}> {description} -
-
Operating System
-
- {getOperatingSystemName(vm) || getOperatingSystem(vm) || DASH} -
-
Template
-
- {template ? : DASH} -
+ + + + {os} + + + + {template && } +
); }; @@ -63,49 +85,71 @@ export const VMDetailsList: React.FC = ({ const { launcherPod } = vmStatus; const sortedBootableDevices = getBootableDevicesInOrder(vm); const nodeName = getNodeName(launcherPod); + const ipAddrs = getVmiIpAddressesString(vmi, vmStatus); + const workloadProfile = getWorkloadProfile(vm); + const flavorText = getFlavorText(vm); return (
-
Status
-
+ -
-
Pod
-
- {launcherPod ? ( + + + + {launcherPod && ( - ) : ( - DASH - )} -
-
Boot Order
-
- {sortedBootableDevices.length > 0 ? ( - - ) : ( - DASH )} -
-
IP Address
-
{getVmiIpAddressesString(vmi, vmStatus) || DASH}
-
Node
-
{}
-
Flavor
-
+ + + + + + + + {ipAddrs} + + + + {nodeName && } + + + vmFlavorModal({ vmLike: vm })}> - + {flavorText} -
-
Workload Profile
-
{getWorkloadProfile(vm) || DASH}
+ + + + {workloadProfile} +
); }; +type VMDetailsItemProps = { + title: string; + idValue?: string; + isNotAvail?: boolean; + valueClassName?: string; + children: React.ReactNode; +}; + type VMResourceSummaryProps = { vm: VMKind; canUpdateVM: boolean;