From 43a209cdfdf2bf288ae90f903e1cb8c91f974a6e Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Date: Fri, 8 May 2026 09:35:18 -0400 Subject: [PATCH] CONSOLE-5284: Put new node inventory items behind tech-preview --- .../console-app/locales/en/console-app.json | 6 +-- .../nodes/node-dashboard/InventoryCard.tsx | 43 ++++----------- .../VirtualMachinesInventoryItems.tsx | 54 +++++++++++++++++++ 3 files changed, 67 insertions(+), 36 deletions(-) create mode 100644 frontend/packages/console-app/src/components/nodes/node-dashboard/VirtualMachinesInventoryItems.tsx diff --git a/frontend/packages/console-app/locales/en/console-app.json b/frontend/packages/console-app/locales/en/console-app.json index ce594b3c6a8..7e2d9ce2039 100644 --- a/frontend/packages/console-app/locales/en/console-app.json +++ b/frontend/packages/console-app/locales/en/console-app.json @@ -392,9 +392,6 @@ "Inventory": "Inventory", "Images": "Images", "Image": "Image", - "Virtual machines": "Virtual machines", - "This count reflects your access permissions and might not include all virtual machines.": "This count reflects your access permissions and might not include all virtual machines.", - "Virtual machine": "Virtual machine", "Health checks": "Health checks", "See details": "See details", "{{ cpuMessage }}": "{{ cpuMessage }}", @@ -412,6 +409,9 @@ "Utilization": "Utilization", "Network transfer": "Network transfer", "Pod count": "Pod count", + "Virtual machines": "Virtual machines", + "This count reflects your access permissions and might not include all virtual machines.": "This count reflects your access permissions and might not include all virtual machines.", + "Virtual machine": "Virtual machine", "Node conditions": "Node conditions", "Reason": "Reason", "Updated": "Updated", diff --git a/frontend/packages/console-app/src/components/nodes/node-dashboard/InventoryCard.tsx b/frontend/packages/console-app/src/components/nodes/node-dashboard/InventoryCard.tsx index 6a2331c5961..d41b50da57b 100644 --- a/frontend/packages/console-app/src/components/nodes/node-dashboard/InventoryCard.tsx +++ b/frontend/packages/console-app/src/components/nodes/node-dashboard/InventoryCard.tsx @@ -11,8 +11,9 @@ import { DescriptionListTerm, } from '@patternfly/react-core'; import { useTranslation } from 'react-i18next'; -import { Link } from 'react-router'; import BareMetalInventoryItems from '@console/app/src/components/nodes/node-dashboard/BareMetalInventoryItems'; +import VirtualMachinesInventoryItems from '@console/app/src/components/nodes/node-dashboard/VirtualMachinesInventoryItems'; +import { FLAG_NODE_MGMT_V1 } from '@console/app/src/consts'; import { useK8sWatchResource } from '@console/internal/components/utils/k8s-watch-hook'; import { resourcePathFromModel } from '@console/internal/components/utils/resource-link'; import { PodModel, NodeModel } from '@console/internal/models'; @@ -24,9 +25,7 @@ import { ResourceInventoryItem, } from '@console/shared/src/components/dashboard/inventory-card/InventoryItem'; import { getPodStatusGroups } from '@console/shared/src/components/dashboard/inventory-card/utils'; -import { DescriptionListTermHelp } from '@console/shared/src/components/description-list/DescriptionListTermHelp'; -import { useIsKubevirtPluginActive } from '../../../utils/kubevirt'; -import { useWatchVirtualMachineInstances, VirtualMachineModel } from '../NodeVmUtils'; +import { useFlag } from '@console/shared/src/hooks/useFlag'; import { NodeDashboardContext } from './NodeDashboardContext'; export const NodeInventoryItem: FC = ({ nodeName, model, mapper }) => { @@ -56,9 +55,7 @@ export const NodeInventoryItem: FC = ({ nodeName, model, const InventoryCard: FC = () => { const { obj } = useContext(NodeDashboardContext); const { t } = useTranslation(); - - const showVms = useIsKubevirtPluginActive(); - const [vms, vmsLoaded, vmsLoadError] = useWatchVirtualMachineInstances(obj.metadata.name); + const nodeMgmtV1Enabled = useFlag(FLAG_NODE_MGMT_V1); return ( @@ -89,32 +86,12 @@ const InventoryCard: FC = () => { /> - - {showVms ? ( - - - - - - - - - ) : null} + {nodeMgmtV1Enabled && ( + <> + + + + )} diff --git a/frontend/packages/console-app/src/components/nodes/node-dashboard/VirtualMachinesInventoryItems.tsx b/frontend/packages/console-app/src/components/nodes/node-dashboard/VirtualMachinesInventoryItems.tsx new file mode 100644 index 00000000000..ae2a915c8c1 --- /dev/null +++ b/frontend/packages/console-app/src/components/nodes/node-dashboard/VirtualMachinesInventoryItems.tsx @@ -0,0 +1,54 @@ +import type { FC } from 'react'; +import { useContext } from 'react'; +import { DescriptionListDescription, DescriptionListGroup } from '@patternfly/react-core'; +import { useTranslation } from 'react-i18next'; +import { Link } from 'react-router'; +import { + useWatchVirtualMachineInstances, + VirtualMachineModel, +} from '@console/app/src/components/nodes/NodeVmUtils'; +import { useIsKubevirtPluginActive } from '@console/app/src/utils/kubevirt'; +import { resourcePathFromModel } from '@console/internal/components/utils/resource-link'; +import { InventoryItem } from '@console/shared/src/components/dashboard/inventory-card/InventoryItem'; +import { DescriptionListTermHelp } from '@console/shared/src/components/description-list/DescriptionListTermHelp'; +import { NodeDashboardContext } from './NodeDashboardContext'; + +const VirtualMachinesInventoryItems: FC = () => { + const { obj } = useContext(NodeDashboardContext); + const { t } = useTranslation(); + const showVms = useIsKubevirtPluginActive(); + + const [vms, vmsLoaded, vmsLoadError] = useWatchVirtualMachineInstances(obj.metadata.name); + + if (!showVms) { + return null; + } + + return ( + + + + + + + + + ); +}; + +export default VirtualMachinesInventoryItems;