Skip to content

Commit

Permalink
Adding template link in single VM overview details card
Browse files Browse the repository at this point in the history
Signed-off-by: Dana Orr <dorr@redhat.com>
  • Loading branch information
DanaOrr committed Jun 14, 2022
1 parent 25280fe commit b03cec9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 46 deletions.
68 changes: 23 additions & 45 deletions locales/en/plugin__kubevirt-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"(default) | ": "(default) | ",
"(requires login) and copy the download link URL of the KVM guest image (expires quickly)": "(requires login) and copy the download link URL of the KVM guest image (expires quickly)",
"{{annotationsCount}} Annotations": "{{annotationsCount}} Annotations",
"{{count}} Affinity rules": "{{count}} Affinity rules",
"{{count}} Affinity rules_plural": "{{count}} Affinity rules",
"{{count}} Annotations": "{{count}} Annotations",
"{{count}} Annotations_plural": "{{count}} Annotations",
"{{count}} Toleration rules": "{{count}} Toleration rules",
"{{count}} Toleration rules_plural": "{{count}} Toleration rules",
"{{count}} Tolerations rules": "{{count}} Tolerations rules",
"{{count}} Tolerations rules_plural": "{{count}} Tolerations rules",
"{{count}} Affinity rules_one": "{{count}} Affinity rules",
"{{count}} Affinity rules_other": "{{count}} Affinity rules",
"{{count}} Annotations_one": "{{count}} Annotations",
"{{count}} Annotations_other": "{{count}} Annotations",
"{{count}} Toleration rules_one": "{{count}} Toleration rules",
"{{count}} Toleration rules_other": "{{count}} Toleration rules",
"{{count}} Tolerations rules_one": "{{count}} Tolerations rules",
"{{count}} Tolerations rules_other": "{{count}} Tolerations rules",
"{{cpu}} CPU | {{memory}} Memory": "{{cpu}} CPU | {{memory}} Memory",
"{{cpuCount}} CPU | {{memory}} Memory": "{{cpuCount}} CPU | {{memory}} Memory",
"{{dsLabel}} name": "{{dsLabel}} name",
Expand Down Expand Up @@ -251,10 +251,10 @@
"Disk Source represents the source for our Disk, this can be HTTP, Registry or an existing PVC": "Disk Source represents the source for our Disk, this can be HTTP, Registry or an existing PVC",
"Disk Type": "Disk Type",
"Disks": "Disks",
"Disks ({{count}})": "Disks ({{count}})",
"Disks ({{count}})_plural": "Disks ({{count}})",
"Disks included in this snapshot ({{count}})": "Disks included in this snapshot ({{count}})",
"Disks included in this snapshot ({{count}})_plural": "Disks included in this snapshot ({{count}})",
"Disks ({{count}})_one": "Disks ({{count}})",
"Disks ({{count}})_other": "Disks ({{count}})",
"Disks included in this snapshot ({{count}})_one": "Disks included in this snapshot ({{count}})",
"Disks included in this snapshot ({{count}})_other": "Disks included in this snapshot ({{count}})",
"Disks tab": "Disks tab",
"Display name": "Display name",
"display name text area": "display name text area",
Expand Down Expand Up @@ -282,8 +282,8 @@
"Edit Labels": "Edit Labels",
"Edit Network Interface": "Edit Network Interface",
"Edit template": "Edit template",
"Edit the disk or contact your cluster admin for further details.": "Edit the disk or contact your cluster admin for further details.",
"Edit the disk or contact your cluster admin for further details._plural": "Edit the disk or contact your cluster admin for further details.",
"Edit the disk or contact your cluster admin for further details._one": "Edit the disk or contact your cluster admin for further details.",
"Edit the disk or contact your cluster admin for further details._other": "Edit the disk or contact your cluster admin for further details.",
"Editing the DataSource will affect <2><0> all templates</0></2> that are currently using this DataSource.": "Editing the DataSource will affect <2><0> all templates</0></2> that are currently using this DataSource.",
"Effect": "Effect",
"Elapsed time since login": "Elapsed time since login",
Expand Down Expand Up @@ -335,8 +335,8 @@
"Hardware Device Name": "Hardware Device Name",
"Hardware devices": "Hardware devices",
"Hardware Devices": "Hardware Devices",
"Hardware Devices ({{count}})": "Hardware Devices ({{count}})",
"Hardware Devices ({{count}})_plural": "Hardware Devices ({{count}})",
"Hardware Devices ({{count}})_one": "Hardware Devices ({{count}})",
"Hardware Devices ({{count}})_other": "Hardware Devices ({{count}})",
"Help": "Help",
"Hide from view": "Hide from view",
"High performance": "High performance",
Expand Down Expand Up @@ -431,8 +431,8 @@
"Network Interface": "Network Interface",
"Network interfaces": "Network interfaces",
"Network Interfaces": "Network Interfaces",
"Network interfaces ({{count}})": "Network interfaces ({{count}})",
"Network interfaces ({{count}})_plural": "Network interfaces ({{count}})",
"Network interfaces ({{count}})_one": "Network interfaces ({{count}})",
"Network interfaces ({{count}})_other": "Network interfaces ({{count}})",
"Network Transfer": "Network Transfer",
"Networks misconfigured": "Networks misconfigured",
"NICs": "NICs",
Expand Down Expand Up @@ -605,8 +605,8 @@
"Single user (RWO)": "Single user (RWO)",
"Size": "Size",
"Snapshots": "Snapshots",
"Snapshots ({{count}})": "Snapshots ({{count}})",
"Snapshots ({{count}})_plural": "Snapshots ({{count}})",
"Snapshots ({{count}})_one": "Snapshots ({{count}})",
"Snapshots ({{count}})_other": "Snapshots ({{count}})",
"Sockets": "Sockets",
"Some fields may not be supported.": "Some fields may not be supported.",
"Source": "Source",
Expand Down Expand Up @@ -661,8 +661,8 @@
"The Descheduler can be used to evict a running VirtualMachine so that the VirtualMachine can be rescheduled onto a more suitable Node via a live migration.": "The Descheduler can be used to evict a running VirtualMachine so that the VirtualMachine can be rescheduled onto a more suitable Node via a live migration.",
"The following areas have pending changes that will be applied when this VirtualMachine is restarted.": "The following areas have pending changes that will be applied when this VirtualMachine is restarted.",
"The following credentials for this operating system were created via cloud-init. If unsuccessful, cloud-init could be improperly configured. Please contact the image provider for more information.": "The following credentials for this operating system were created via cloud-init. If unsuccessful, cloud-init could be improperly configured. Please contact the image provider for more information.",
"The following disk will not be included in the snapshot": "The following disk will not be included in the snapshot",
"The following disk will not be included in the snapshot_plural": "The following disk will not be included in the snapshot",
"The following disk will not be included in the snapshot_one": "The following disk will not be included in the snapshot",
"The following disk will not be included in the snapshot_other": "The following disk will not be included in the snapshot",
"The following information is provided by the OpenShift Virtualization operator.": "The following information is provided by the OpenShift Virtualization operator.",
"The following information regarding how the disks are partitioned is provided by the guest agent.": "The following information regarding how the disks are partitioned is provided by the guest agent.",
"The following resources will be deleted along with this VirtualMachine. Unchecked items will not be deleted.": "The following resources will be deleted along with this VirtualMachine. Unchecked items will not be deleted.",
Expand Down Expand Up @@ -796,27 +796,5 @@
"You can customize the Templates storage by overriding the original parameters": "You can customize the Templates storage by overriding the original parameters",
"You can edit the boot order in the <1>{t('Disks tab')}</1>": "You can edit the boot order in the <1>{t('Disks tab')}</1>",
"You can select the boot source in the <2>Disks</2> tab.": "You can select the boot source in the <2>Disks</2> tab.",
"You can use Cloudinit for post installation configuration of the guest operating system.": "You can use Cloudinit for post installation configuration of the guest operating system.",
"{{count}} Affinity rules_one": "{{count}} Affinity rules",
"{{count}} Affinity rules_other": "{{count}} Affinity rules",
"{{count}} Annotations_one": "{{count}} Annotations",
"{{count}} Annotations_other": "{{count}} Annotations",
"{{count}} Toleration rules_one": "{{count}} Toleration rules",
"{{count}} Toleration rules_other": "{{count}} Toleration rules",
"{{count}} Tolerations rules_one": "{{count}} Tolerations rules",
"{{count}} Tolerations rules_other": "{{count}} Tolerations rules",
"Disks ({{count}})_one": "Disks ({{count}})",
"Disks ({{count}})_other": "Disks ({{count}})",
"Disks included in this snapshot ({{count}})_one": "Disks included in this snapshot ({{count}})",
"Disks included in this snapshot ({{count}})_other": "Disks included in this snapshot ({{count}})",
"Edit the disk or contact your cluster admin for further details._one": "Edit the disk or contact your cluster admin for further details.",
"Edit the disk or contact your cluster admin for further details._other": "Edit the disk or contact your cluster admin for further details.",
"Hardware Devices ({{count}})_one": "Hardware Devices ({{count}})",
"Hardware Devices ({{count}})_other": "Hardware Devices ({{count}})",
"Network interfaces ({{count}})_one": "Network interfaces ({{count}})",
"Network interfaces ({{count}})_other": "Network interfaces ({{count}})",
"Snapshots ({{count}})_one": "Snapshots ({{count}})",
"Snapshots ({{count}})_other": "Snapshots ({{count}})",
"The following disk will not be included in the snapshot_one": "The following disk will not be included in the snapshot",
"The following disk will not be included in the snapshot_other": "The following disk will not be included in the snapshot"
"You can use Cloudinit for post installation configuration of the guest operating system.": "You can use Cloudinit for post installation configuration of the guest operating system."
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import * as React from 'react';
import { useHistory } from 'react-router-dom';

import { modelToGroupVersionKind, TemplateModel } from '@kubevirt-ui/kubevirt-api/console';
import { V1VirtualMachine } from '@kubevirt-ui/kubevirt-api/kubevirt';
import MutedTextSpan from '@kubevirt-utils/components/MutedTextSpan/MutedTextSpan';
import { timestampFor } from '@kubevirt-utils/components/Timestamp/utils/datetime';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import { getLabel } from '@kubevirt-utils/resources/shared';
import { LABEL_USED_TEMPLATE_NAMESPACE } from '@kubevirt-utils/resources/template';
import { useVMIAndPodsForVM } from '@kubevirt-utils/resources/vm';
import { VM_TEMPLATE_ANNOTATION } from '@kubevirt-utils/resources/vm';
import { useGuestOS } from '@kubevirt-utils/resources/vmi';
import { ResourceLink } from '@openshift-console/dynamic-plugin-sdk';
import {
Card,
CardBody,
Expand Down Expand Up @@ -40,6 +46,10 @@ const VirtualMachinesOverviewTabDetails: React.FC<VirtualMachinesOverviewTabDeta
const { vmi } = useVMIAndPodsForVM(vm?.metadata?.name, vm?.metadata?.namespace);
const [guestAgentData, loaded] = useGuestOS(vmi);
const Icon = getVMStatusIcon(vm?.status?.printableStatus);
const history = useHistory();
const templateName = getLabel(vm, VM_TEMPLATE_ANNOTATION);
const templateNamespace = getLabel(vm, LABEL_USED_TEMPLATE_NAMESPACE);
const None = <MutedTextSpan text={t('None')} />;

const timestamp = timestampFor(
new Date(vm?.metadata?.creationTimestamp),
Expand Down Expand Up @@ -115,7 +125,18 @@ const VirtualMachinesOverviewTabDetails: React.FC<VirtualMachinesOverviewTabDeta
<DescriptionListGroup>
<DescriptionListTerm>{t('Template')}</DescriptionListTerm>
<DescriptionListDescription data-test-id="virtual-machine-overview-details-template">
{vm?.metadata?.labels?.['vm.kubevirt.io/template'] || '-'}
{templateName && templateNamespace ? (
<ResourceLink
groupVersionKind={modelToGroupVersionKind(TemplateModel)}
name={templateName}
namespace={templateNamespace}
onClick={() =>
history.push(`/k8s/ns/${templateNamespace}/templates/${templateName}`)
}
/>
) : (
None
)}
</DescriptionListDescription>
</DescriptionListGroup>
</DescriptionList>
Expand Down

0 comments on commit b03cec9

Please sign in to comment.