kubevirt / web-ui

OpenShift Cluster Console UI
https://www.openshift.org
Apache License 2.0
26 stars 11 forks source link

Fix undefined namespace when NIC called from VmTemplateDetails #287

Closed yaacov closed 5 years ago

yaacov commented 5 years ago

In #265 I made a mistake resulting in undefined namespace when calling NIC from VmTemplateDetails page.

In: https://github.com/kubevirt/web-ui/blob/master/frontend/public/kubevirt/components/vm-template/vm-template-detail.jsx#L44 vm may be defined ( e.g. not undefined ) but missing a namespace label.

getNamespace(nic.vm || nic.vmTemplate) may result in undefined, while the expected result is the template namespace.

This PR use ~err to the side of safety by using~ the ~longer~ phrase: ~getNamespace(nic.vm) || getNamespace(nic.vmTemplate)~ getNamespace(nic.vmTemplate || nic.vm)

EDIT: getNamespace(nic.vmTemplate || nic.vm) is OK because vmTemplate is only defined when calling from the template details page, and undefined when calling from the vm page.