Skip to content

OCPNETUI-38: Virtual Machines tab on NAD/UDN/CUDN detail pages - #442

Open
Parthivk100 wants to merge 12 commits into
openshift:mainfrom
Parthivk100:vm-tab
Open

OCPNETUI-38: Virtual Machines tab on NAD/UDN/CUDN detail pages#442
Parthivk100 wants to merge 12 commits into
openshift:mainfrom
Parthivk100:vm-tab

Conversation

@Parthivk100

@Parthivk100 Parthivk100 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Virtual Machines tab on NAD/UDN/CUDN detail pages

Screenshare.-.2026-07-30.4_35_11.PM.mp4

Summary by CodeRabbit

  • New Features
    • Added dedicated details pages for NetworkAttachmentDefinitions and user-defined networks, including resource summaries, YAML views, tabs, actions, and navigation.
    • Added Virtual Machines lists with filtering/sorting/pagination, table column management, and row actions.
    • Added connect/remove workflows for Virtual Machines with confirmation and improved failure feedback.
  • Bug Fixes
    • Improved Virtual Machine matching/removal logic and made VM memory sorting more consistent.
    • Improved modal/type rendering and ensured confirm buttons support configurable variants.
  • Localization
    • Added new UI translations and pluralized annotation keys for the Virtual Machines workflows and status messaging.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci
openshift-ci Bot requested review from adamviktora and lkladnit July 10, 2026 15:25
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Walkthrough

Changes

The plugin adds NAD and UDN details pages with YAML and virtual-machine tabs, VM association management, resource lookup utilities, configurable table columns, updated confirmation dialogs, manifest wiring, and localization strings.

Network details and VM workflows

Layer / File(s) Summary
VM resource selectors and lookup foundations
src/utils/resources/vm/*, src/utils/hooks/useVMResourceLookups.ts, src/utils/components/VMNetworkTable/*, src/utils/utils/units.js
Adds VM CPU/memory resolution, selectors, unit conversion, and reusable VM network table column definitions.
NAD and UDN matching and attachment operations
src/utils/resources/udns/*, src/utils/resources/nads/types/types.ts, src/utils/resources/vm/utils.ts
Adds UDN/NAD matching helpers and updates VM interface attach, reconnect, hot-unplug, removal, and orphan cleanup behavior.
NAD and UDN details page integration
src/views/nads/details/*, src/views/udns/details/*, src/views/nads/manifest.ts, src/views/udns/manifest.ts
Adds resource details pages, titles, tabs, YAML views, VM derivation hooks, and manifest extensions.
VM tables, selection, and add/remove actions
src/views/nads/details/tabs/virtualMachines/*, src/views/udns/details/tabs/virtualMachines/*
Adds filtered and paginated VM tables, selection hooks, add modals with partial-failure handling, and remove-from-network actions.
Shared UI and localization
src/utils/components/ConfirmModal/ConfirmModal.tsx, locales/*, package.json
Adds configurable confirmation button variants, VM workflow translations, and the PatternFly DataView development dependency.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Suggested reviewers: adamviktora

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

@Parthivk100 Parthivk100 changed the title Virtual Machines tab on NAD/UDN/CUDN detail pages OCPNETUI-38: Virtual Machines tab on NAD/UDN/CUDN detail pages Jul 13, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 13, 2026

Copy link
Copy Markdown

@Parthivk100: This pull request references OCPNETUI-38 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Virtual Machines tab on NAD/UDN/CUDN detail pages

Summary by CodeRabbit

  • New Features
  • Added a dedicated NetworkAttachmentDefinition details page with summary information, YAML editing, and tabbed navigation.
  • Added NetworkAttachmentDefinition Virtual Machines view with search, sorting, pagination, status/interface details, and VM counts.
  • Added workflows to add or remove Virtual Machines from both NADs and UDNs (including bulk add and confirmations).
  • Refactor
  • Consolidated NetworkAttachmentDefinition and UDN details into the unified resource-details page experience.
  • Style
  • Made confirmation modals support configurable submit button styling.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 13, 2026
@lkladnit

Copy link
Copy Markdown

/retest

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 13, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@lkladnit

Copy link
Copy Markdown

/lgtm

@lkladnit lkladnit removed their assignment Jul 13, 2026
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 13, 2026
@openshift-ci

openshift-ci Bot commented Jul 13, 2026

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

🧹 Nitpick comments (3)
src/views/nads/details/tabs/virtualMachines/NADVirtualMachines.tsx (1)

46-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract inline prop type for consistency.

Other new files in this PR (NADYAML.tsx, NADDescriptionDetails.tsx) define a named Props type; this component uses an inline object type instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/views/nads/details/tabs/virtualMachines/NADVirtualMachines.tsx` at line
46, Extract the inline prop object type from the NADVirtualMachines component
into a named Props type, matching the pattern used by NADYAML and
NADDescriptionDetails, then update the component declaration to use Props while
preserving the optional obj property and its NetworkAttachmentDefinitionKind
type.
src/utils/components/VMNetworkTable/vmNetworkDataViewContent.tsx (1)

86-100: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate getVMStatusLabelColor helper across two files. Both files define an identical function to map VM status to a Label color; extract to a shared util once.

  • src/utils/components/VMNetworkTable/vmNetworkDataViewContent.tsx#L86-L100: remove the local copy and import the shared helper.
  • src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx#L60-L74: remove the local copy and import the shared helper.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/components/VMNetworkTable/vmNetworkDataViewContent.tsx` around
lines 86 - 100, Extract the identical getVMStatusLabelColor logic into a shared
utility, then remove the local definitions and import the shared helper in
src/utils/components/VMNetworkTable/vmNetworkDataViewContent.tsx (lines 86-100)
and
src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx
(lines 60-74). Preserve the existing status-to-color behavior at both call
sites.
src/views/udns/details/tabs/details/UDNDetailsTab.tsx (1)

2-2: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer named lodash import for tree-shaking.

import * as _ from 'lodash' pulls the entire library. Only _.size is used. A named import enables bundler tree-shaking.

-import * as _ from 'lodash';
+import { size } from 'lodash';

Then replace _.size(...) with size(...) on lines 103 and 108.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/views/udns/details/tabs/details/UDNDetailsTab.tsx` at line 2, Replace the
namespace lodash import in UDNDetailsTab with a named size import, then update
both _.size usages in the component to call size directly. Leave all other
lodash usage unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Line 44: Update the `@patternfly/react-data-view` dependency in package.json
from the tilde range to the exact version 6.5.0, matching the file’s existing
exact-version dependency convention.

In `@src/utils/components/VMNetworkTable/vmNetworkDataViewContent.tsx`:
- Around line 57-84: The MEMORY branch of getVMNetworkTableSortValue currently
returns the display quantity string from getVMMemory, causing lexicographic
ordering; normalize that value to its numeric quantity before returning it for
sorting, while leaving the displayed memory formatting unchanged.

In `@src/utils/resources/vm/utils.ts`:
- Around line 219-223: Update findNADForUDN to resolve and return the matching
watched NAD from _nads instead of calling buildNADReferenceForUDN to fabricate
one. Derive the namespace and candidate NAD names using the existing
CUDN-generated prefix handling, then search _nads and return the matched
resource; preserve undefined when no candidate exists.
- Around line 471-492: Update the single-pair reconnect logic in patchVM to
clone pairToReconnect.network and pairToReconnect.iface rather than constructing
new objects. Override only multus.networkName on the network, and remove only
the interface’s state: 'absent' while preserving all other NIC configuration
fields.

In `@src/views/nads/actions/NADActions.tsx`:
- Around line 8-22: Update NADsRow to pass its isKebabToggle value through the
NADsActions component when rendering it, ensuring the ActionsDropdown receives
the intended kebab-toggle state instead of relying on the optional default.

In
`@src/views/nads/details/tabs/virtualMachines/components/AddNADVirtualMachinesModal.tsx`:
- Around line 378-390: Update handleAdd to await all addVMToNAD operations to
completion using per-VM outcome collection rather than fail-fast Promise.all.
Keep the modal open when any VM fails, identify and display the failed VM names,
and only clear isSubmitting after every patch has settled; preserve onClose only
when all selected VMs succeed.

In `@src/views/nads/manifest.ts`:
- Around line 80-86: Gate the NetworkAttachmentDefinition details extension
containing NADDetailsPage behind the appropriate KubeVirt feature flag from
src/utils/flags/consts.ts, using the manifest’s required flags mechanism. Ensure
the page cannot mount and start its VirtualMachine watch when KubeVirt is
unavailable.

In `@src/views/udns/details/tabs/details/UDNDetailsTab.tsx`:
- Around line 102-109: Update both annotation translation calls in UDNDetailsTab
to use i18next pluralization with the count value, referencing the pluralized
annotation key rather than the singular key. Add matching annotation_one and
annotation_other entries to every locale file that defines this translation.

In
`@src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx`:
- Around line 379-403: Surface user-facing failures for both VM network mutation
flows: in AddUDNVirtualMachinesModal.handleAdd, use Promise.allSettled to detect
rejected addVMToNAD operations and show an appropriate toast or alert while
preserving submission cleanup; in UDNVirtualMachineRowActions, handle
removeVMFromNAD rejection inside the ConfirmModal executeFn flow and show the
failure to the user even though the modal closes immediately. Update both listed
files and retain networkConsole logging as appropriate.
- Around line 194-241: Update getSortParams so sortBy.direction is provided only
when the current column matches the active sort key (sortBy ===
SORT_COLUMN_KEYS[columnIndex]); otherwise leave the direction unset while
preserving each column’s index.

---

Nitpick comments:
In `@src/utils/components/VMNetworkTable/vmNetworkDataViewContent.tsx`:
- Around line 86-100: Extract the identical getVMStatusLabelColor logic into a
shared utility, then remove the local definitions and import the shared helper
in src/utils/components/VMNetworkTable/vmNetworkDataViewContent.tsx (lines
86-100) and
src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx
(lines 60-74). Preserve the existing status-to-color behavior at both call
sites.

In `@src/views/nads/details/tabs/virtualMachines/NADVirtualMachines.tsx`:
- Line 46: Extract the inline prop object type from the NADVirtualMachines
component into a named Props type, matching the pattern used by NADYAML and
NADDescriptionDetails, then update the component declaration to use Props while
preserving the optional obj property and its NetworkAttachmentDefinitionKind
type.

In `@src/views/udns/details/tabs/details/UDNDetailsTab.tsx`:
- Line 2: Replace the namespace lodash import in UDNDetailsTab with a named size
import, then update both _.size usages in the component to call size directly.
Leave all other lodash usage unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b9ba4197-28d9-458c-bfa5-efefdd84701b

📥 Commits

Reviewing files that changed from the base of the PR and between 35f8ec7 and 86e8b1f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (39)
  • locales/en/plugin__networking-console-plugin.json
  • locales/es/plugin__networking-console-plugin.json
  • locales/fr/plugin__networking-console-plugin.json
  • locales/ja/plugin__networking-console-plugin.json
  • locales/ko/plugin__networking-console-plugin.json
  • locales/zh/plugin__networking-console-plugin.json
  • package.json
  • src/utils/components/ConfirmModal/ConfirmModal.tsx
  • src/utils/components/VMNetworkTable/VMNetworkColumnManagement.tsx
  • src/utils/components/VMNetworkTable/constants.ts
  • src/utils/components/VMNetworkTable/useVMNetworkTableColumns.ts
  • src/utils/components/VMNetworkTable/vmNetworkDataViewContent.tsx
  • src/utils/hooks/useVMResourceLookups.ts
  • src/utils/resources/vm/selectors.ts
  • src/utils/resources/vm/utils.ts
  • src/utils/resources/vm/vmResourceLookups.ts
  • src/views/nads/actions/NADActions.tsx
  • src/views/nads/details/NADDetailsPage.tsx
  • src/views/nads/details/components/NADDetailsPageTitle.tsx
  • src/views/nads/details/hooks/useNADTabs.tsx
  • src/views/nads/details/hooks/useNADVirtualMachines.ts
  • src/views/nads/details/tabs/details/NADDescriptionDetails.tsx
  • src/views/nads/details/tabs/details/NADDetails.tsx
  • src/views/nads/details/tabs/details/NADTypeDetails.tsx
  • src/views/nads/details/tabs/virtualMachines/NADVirtualMachines.tsx
  • src/views/nads/details/tabs/virtualMachines/components/AddNADVirtualMachinesModal.tsx
  • src/views/nads/details/tabs/virtualMachines/components/NADVirtualMachineRowActions.tsx
  • src/views/nads/details/tabs/yaml/NADYAML.tsx
  • src/views/nads/manifest.ts
  • src/views/udns/details/UDNDetailsPage.tsx
  • src/views/udns/details/components/UDNDetailsPageTitle.tsx
  • src/views/udns/details/hooks/useUDNTabs.tsx
  • src/views/udns/details/hooks/useUDNVirtualMachines.ts
  • src/views/udns/details/tabs/details/UDNDetailsTab.tsx
  • src/views/udns/details/tabs/virtualMachines/UDNVirtualMachines.tsx
  • src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx
  • src/views/udns/details/tabs/virtualMachines/components/UDNVirtualMachineRowActions.tsx
  • src/views/udns/details/tabs/yaml/UDNYAML.tsx
  • src/views/udns/manifest.ts

Comment thread package.json Outdated
Comment thread src/utils/components/VMNetworkTable/vmNetworkDataViewContent.tsx
Comment thread src/utils/resources/vm/utils.ts Outdated
Comment thread src/utils/resources/vm/utils.ts
Comment thread src/views/nads/actions/NADActions.tsx
Comment thread src/views/nads/manifest.ts
Comment thread src/views/udns/details/tabs/details/UDNDetailsTab.tsx Outdated

@pcbailey pcbailey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check CodeRabbit comments and squash smaller commits where it makes sense.

Comment thread src/utils/resources/vm/utils.ts Outdated
Comment thread src/utils/resources/vm/utils.ts Outdated
Comment thread src/utils/resources/vm/utils.ts
Comment thread src/views/nads/details/hooks/useNADVirtualMachines.ts Outdated
Comment thread src/views/nads/details/hooks/useNADVirtualMachines/utils/utils.ts
virtualMachines: UDNVirtualMachine[];
};

const networkUsesUDN = (network: V1Network, udn: UDNResource, vm: V1VirtualMachine): boolean => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions should be in a utils file for the hook.

@@ -0,0 +1,136 @@
import React, { FC } from 'react';
import * as _ from 'lodash';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import only needed functions.


const UDNDetailsTab: FC<UDNDetailsTabProps> = ({ obj: udn }) => {
const { t } = useNetworkingTranslation();
const metadata = udn?.metadata;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the VM version. Remove this and create variables for fields used multiple times.

[direction, onSort],
);

const columns = useMemo(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look for candidates to become custom hooks.

obj?: ClusterUserDefinedNetworkKind | UserDefinedNetworkKind;
};

const UDNYAML: FC<UDNYAMLProps> = ({ obj: udn }) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spell out NAD to save our eyes. 🙏🏼

@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lkladnit, Parthivk100

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [Parthivk100,lkladnit]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 30, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/utils/units.js`:
- Around line 208-218: Update validate.split to parse the complete value with an
anchored numeric-and-unit pattern, allowing an optional exponent in the numeric
portion so inputs such as 1e3 produce 1000 with no unit while preserving unit
extraction for values that include one.

In
`@src/views/nads/details/tabs/virtualMachines/components/AddNADVirtualMachinesModal.tsx`:
- Around line 397-398: Update the failed-VM label construction around
getName(selected[index]) to include each VM’s namespace, formatting labels as
namespace/name. Preserve the existing fallback of returning an empty list when
the selected VM lacks a usable name, and use the VM’s existing namespace field.

In
`@src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx`:
- Around line 408-429: Update the partial-failure handling around failedNames so
selected contains only the rejected virtual machines before displaying the
error. Derive the retained selection from the rejected result indexes, update
selection through the existing state setter, then preserve the current error
message and return flow.
- Around line 400-401: Update the virtual-machine add failure handling around
the NAD-not-found branch and the related lines to stop logging the full VM
resource or raw API error. Replace those payloads with a generic failure
category while preserving the existing rejection behavior and user-facing error
handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a86f3edb-db72-4954-a4a5-c7923d5c1346

📥 Commits

Reviewing files that changed from the base of the PR and between 86e8b1f and 6b08d37.

📒 Files selected for processing (16)
  • locales/en/plugin__networking-console-plugin.json
  • locales/es/plugin__networking-console-plugin.json
  • locales/fr/plugin__networking-console-plugin.json
  • locales/ja/plugin__networking-console-plugin.json
  • locales/ko/plugin__networking-console-plugin.json
  • locales/zh/plugin__networking-console-plugin.json
  • package.json
  • src/utils/components/VMNetworkTable/vmNetworkDataViewContent.tsx
  • src/utils/resources/vm/utils.ts
  • src/utils/utils/units.js
  • src/views/nads/details/tabs/virtualMachines/components/AddNADVirtualMachinesModal.tsx
  • src/views/nads/list/components/NADsRow/NADsRow.tsx
  • src/views/nads/manifest.ts
  • src/views/udns/details/tabs/details/UDNDetailsTab.tsx
  • src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx
  • src/views/udns/details/tabs/virtualMachines/components/UDNVirtualMachineRowActions.tsx
🚧 Files skipped from review as they are similar to previous changes (5)
  • locales/fr/plugin__networking-console-plugin.json
  • locales/es/plugin__networking-console-plugin.json
  • locales/ko/plugin__networking-console-plugin.json
  • locales/ja/plugin__networking-console-plugin.json
  • locales/zh/plugin__networking-console-plugin.json

Comment thread src/utils/utils/units.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/utils/resources/vm/utils.ts (1)

429-440: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Guard detach removals against stale array indexes.

These unconditional removes can delete another NIC/network after a concurrent VM edit shifts an index. Use removeAtIndex (or equivalent test operations) with the objects read above.

Proposed fix
-  const patches: PatchItem<unknown>[] =
-    networkIndex >= ifaceIndex
-      ? [
-          { op: 'remove', path: `${NETWORK_PATH}/${networkIndex}`, value: undefined },
-          { op: 'remove', path: `${INTERFACE_PATH}/${ifaceIndex}`, value: undefined },
-        ]
-      : [
-          { op: 'remove', path: `${INTERFACE_PATH}/${ifaceIndex}`, value: undefined },
-          { op: 'remove', path: `${NETWORK_PATH}/${networkIndex}`, value: undefined },
-        ];
-
-  return patchVM(vm, patches);
+  return patchVM(vm, [
+    ...removeAtIndex({ index: networkIndex, path: NETWORK_PATH, value: network }),
+    ...removeAtIndex({ index: ifaceIndex, path: INTERFACE_PATH, value: iface }),
+  ]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/resources/vm/utils.ts` around lines 429 - 440, Update the patch
construction in the VM detach flow to guard both interface and network removals
against stale indexes. Replace the unconditional remove operations with
removeAtIndex or equivalent test-and-remove operations using the corresponding
objects read earlier, while preserving the existing removal ordering based on
networkIndex and ifaceIndex.
src/views/udns/details/tabs/virtualMachines/UDNVirtualMachines.tsx (1)

100-103: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Page index is not clamped when the filtered set shrinks. Both pagination slices compute start from the raw page, so filtering while on a later page yields an empty slice with a non-empty filteredData — a blank table instead of the empty state.

  • src/views/udns/details/tabs/virtualMachines/UDNVirtualMachines.tsx#L100-L103: clamp page to Math.ceil(sortedData.length / perPage) before slicing (or reset the page param when filters.name changes).
  • src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalData.ts#L60-L63: apply the same clamp/reset in the modal's paginatedData.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/views/udns/details/tabs/virtualMachines/UDNVirtualMachines.tsx` around
lines 100 - 103, The pagination logic must clamp the requested page to the last
valid page after filtering. In
src/views/udns/details/tabs/virtualMachines/UDNVirtualMachines.tsx lines
100-103, update paginatedData to clamp page using sortedData.length and perPage
before slicing; apply the same change to paginatedData in
src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalData.ts
lines 60-63, preserving valid-page slicing and empty-data behavior.
♻️ Duplicate comments (2)
src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx (2)

127-134: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Retry after a partial failure resubmits already-attached VMs.

Successful VMs stay in selected; the next Add re-attempts them and addVMToNAD rejects them as already connected. Narrow selected to the rejected VMs before setting errorMessage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx`
around lines 127 - 134, Update the partial-failure handling in
AddUDNVirtualMachinesModal so selected contains only the VMs listed in
failedNames before calling setErrorMessage. Preserve the existing failure
message and return behavior, allowing retries to resubmit only rejected VMs.

104-104: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Still logging full VM objects and raw API errors.

vm and result.reason can carry customer metadata/spec and internal endpoint details; log a generic failure category plus the VM name instead. As per coding guidelines, "Flag logging that may expose passwords, tokens, API keys, PII ... internal hostnames, or customer data".

Also applies to: 117-121

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx`
at line 104, Update the failure logging in the AddUDNVirtualMachinesModal flow,
including the NAD-not-found path and the result.reason handling around the
affected lines, to avoid logging full VM objects or raw API errors. Log only a
generic failure category and the VM name, using the existing VM name field,
while preserving the current failure handling behavior.

Source: Coding guidelines

🧹 Nitpick comments (2)
src/views/nads/details/tabs/virtualMachines/components/hooks/useAddNADVMModalSelection.ts (1)

26-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicated VM-equality logic.

The matchOption passed to useDataViewSelection and the local vmMatches callback implement identical name+namespace equality checks. Extracting a single shared comparator avoids drift if the identity criteria change later.

♻️ Proposed refactor
+const vmMatches = (a: V1VirtualMachine, b: V1VirtualMachine) =>
+  getName(a) === getName(b) && getNamespace(a) === getNamespace(b);
+
 const useAddNADVMModalSelection = ({...}) => {
   const {...} = useDataViewSelection<V1VirtualMachine>({
-    matchOption: (item, another) =>
-      getName(item) === getName(another) && getNamespace(item) === getNamespace(another),
+    matchOption: vmMatches,
   });
   ...
-  const vmMatches = useCallback(
-    (a: V1VirtualMachine, b: V1VirtualMachine) =>
-      getName(a) === getName(b) && getNamespace(a) === getNamespace(b),
-    [],
-  );

Also applies to: 57-61

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/views/nads/details/tabs/virtualMachines/components/hooks/useAddNADVMModalSelection.ts`
around lines 26 - 28, Extract the name-and-namespace comparison used by
matchOption and the local vmMatches callback into one shared VM comparator, then
reuse it in both useDataViewSelection and the selection logic. Preserve the
existing equality behavior while eliminating the duplicated checks.
src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalSelection.ts (1)

26-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the VM identity predicate once.

matchOption and vmMatches implement the same name+namespace comparison; a single shared helper avoids the two drifting apart (and it is the same key used for rowId in useAddUDNVMModalTable).

Also applies to: 57-61

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalSelection.ts`
around lines 26 - 28, Extract the shared VM identity comparison of name and
namespace into a helper, then reuse it for both matchOption and vmMatches in
useAddUDNVMModalSelection and for the rowId key in useAddUDNVMModalTable. Remove
the duplicated inline predicates while preserving the existing matching
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/views/nads/details/hooks/useNADVirtualMachines/utils/utils.ts`:
- Around line 24-26: Require a matching interface before reporting a VM as
connected: update the interface-connection check in
src/views/nads/details/hooks/useNADVirtualMachines/utils/utils.ts lines 24-26 to
return false when getInterfaces(vm).find finds no interface, and apply the same
paired-interface requirement in
src/views/udns/details/hooks/useUDNVirtualMachines/utils/utils.ts lines 14-21.

In `@src/views/udns/details/tabs/details/UDNDetailsTab.tsx`:
- Around line 106-114: Update the translation resources used by the
UDNDetailsTab annotation calls to define the i18next plural keys annotation_one
and annotation_other for every affected locale, preserving the existing
annotation text and adding missing forms so t('annotation', { count:
annotationCount }) always resolves instead of returning the raw key.

In
`@src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalTable.tsx`:
- Around line 47-58: Update getSortParams and UseAddUDNVMModalTableParams to
accept the current sortBy value from the useAddUDNVMModalData caller, then apply
the sort direction only when sortBy.index matches columnIndex; otherwise provide
the inactive direction expected by the table headers. Preserve the existing
onSort behavior and thread the sortBy dependency through the callback.

---

Outside diff comments:
In `@src/utils/resources/vm/utils.ts`:
- Around line 429-440: Update the patch construction in the VM detach flow to
guard both interface and network removals against stale indexes. Replace the
unconditional remove operations with removeAtIndex or equivalent test-and-remove
operations using the corresponding objects read earlier, while preserving the
existing removal ordering based on networkIndex and ifaceIndex.

In `@src/views/udns/details/tabs/virtualMachines/UDNVirtualMachines.tsx`:
- Around line 100-103: The pagination logic must clamp the requested page to the
last valid page after filtering. In
src/views/udns/details/tabs/virtualMachines/UDNVirtualMachines.tsx lines
100-103, update paginatedData to clamp page using sortedData.length and perPage
before slicing; apply the same change to paginatedData in
src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalData.ts
lines 60-63, preserving valid-page slicing and empty-data behavior.

---

Duplicate comments:
In
`@src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx`:
- Around line 127-134: Update the partial-failure handling in
AddUDNVirtualMachinesModal so selected contains only the VMs listed in
failedNames before calling setErrorMessage. Preserve the existing failure
message and return behavior, allowing retries to resubmit only rejected VMs.
- Line 104: Update the failure logging in the AddUDNVirtualMachinesModal flow,
including the NAD-not-found path and the result.reason handling around the
affected lines, to avoid logging full VM objects or raw API errors. Log only a
generic failure category and the VM name, using the existing VM name field,
while preserving the current failure handling behavior.

---

Nitpick comments:
In
`@src/views/nads/details/tabs/virtualMachines/components/hooks/useAddNADVMModalSelection.ts`:
- Around line 26-28: Extract the name-and-namespace comparison used by
matchOption and the local vmMatches callback into one shared VM comparator, then
reuse it in both useDataViewSelection and the selection logic. Preserve the
existing equality behavior while eliminating the duplicated checks.

In
`@src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalSelection.ts`:
- Around line 26-28: Extract the shared VM identity comparison of name and
namespace into a helper, then reuse it for both matchOption and vmMatches in
useAddUDNVMModalSelection and for the rowId key in useAddUDNVMModalTable. Remove
the duplicated inline predicates while preserving the existing matching
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a806962f-fa68-40ed-9a1b-e05e8a4488b5

📥 Commits

Reviewing files that changed from the base of the PR and between 6b08d37 and ec4501e.

📒 Files selected for processing (31)
  • src/utils/resources/nads/types/types.ts
  • src/utils/resources/udns/constants.ts
  • src/utils/resources/udns/helper.ts
  • src/utils/resources/vm/constants.ts
  • src/utils/resources/vm/utils.ts
  • src/views/nads/details/hooks/useNADTabs.tsx
  • src/views/nads/details/hooks/useNADVirtualMachines/index.ts
  • src/views/nads/details/hooks/useNADVirtualMachines/useNADVirtualMachines.ts
  • src/views/nads/details/hooks/useNADVirtualMachines/utils/utils.ts
  • src/views/nads/details/tabs/details/NADDetails.tsx
  • src/views/nads/details/tabs/virtualMachines/NADVirtualMachines.tsx
  • src/views/nads/details/tabs/virtualMachines/components/AddNADVirtualMachinesModal.tsx
  • src/views/nads/details/tabs/virtualMachines/components/hooks/useAddNADVMModalData.ts
  • src/views/nads/details/tabs/virtualMachines/components/hooks/useAddNADVMModalSelection.ts
  • src/views/nads/details/tabs/virtualMachines/components/hooks/useAddNADVMModalTable.tsx
  • src/views/nads/details/tabs/virtualMachines/constants.ts
  • src/views/nads/details/tabs/virtualMachines/utils.ts
  • src/views/nads/details/tabs/yaml/NetworkAttachmentDefinitionYAML.tsx
  • src/views/udns/details/hooks/useUDNTabs.tsx
  • src/views/udns/details/hooks/useUDNVirtualMachines/index.ts
  • src/views/udns/details/hooks/useUDNVirtualMachines/useUDNVirtualMachines.ts
  • src/views/udns/details/hooks/useUDNVirtualMachines/utils/utils.ts
  • src/views/udns/details/tabs/details/UDNDetailsTab.tsx
  • src/views/udns/details/tabs/virtualMachines/UDNVirtualMachines.tsx
  • src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx
  • src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalData.ts
  • src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalSelection.ts
  • src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalTable.tsx
  • src/views/udns/details/tabs/virtualMachines/constants.ts
  • src/views/udns/details/tabs/virtualMachines/utils.ts
  • src/views/udns/details/tabs/yaml/UserDefinedNetworkYAML.tsx

Comment thread src/views/nads/details/hooks/useNADVirtualMachines/utils/utils.ts Outdated
Comment thread src/views/udns/details/tabs/details/UDNDetailsTab.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx (1)

133-136: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use nullable-safe namespace/name labels in both failure messages.

VM names are namespace-scoped. The UDN flow is ambiguous for duplicate names, while the NAD flow can render undefined/name.

  • src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx#L133-L136: include getNamespace(vm) before the name.
  • src/views/nads/details/tabs/virtualMachines/components/AddNADVirtualMachinesModal.tsx#L105-L105: prefix with ${namespace}/ only when a namespace exists.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx`
around lines 133 - 136, The failure messages need unambiguous, nullable-safe VM
labels. In
src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx
lines 133-136, update the failedNames mapping to include getNamespace(vm) before
the name; in
src/views/nads/details/tabs/virtualMachines/components/AddNADVirtualMachinesModal.tsx
line 105, prefix the name with namespace and a slash only when the namespace
exists, avoiding undefined/name output.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In
`@src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx`:
- Around line 133-136: The failure messages need unambiguous, nullable-safe VM
labels. In
src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx
lines 133-136, update the failedNames mapping to include getNamespace(vm) before
the name; in
src/views/nads/details/tabs/virtualMachines/components/AddNADVirtualMachinesModal.tsx
line 105, prefix the name with namespace and a slash only when the namespace
exists, avoiding undefined/name output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a6d33a8-dfcb-4574-a50a-597834bdfa66

📥 Commits

Reviewing files that changed from the base of the PR and between ec4501e and bebfa08.

📒 Files selected for processing (8)
  • src/utils/utils/constants.ts
  • src/utils/utils/units.js
  • src/views/nads/details/hooks/useNADVirtualMachines/utils/utils.ts
  • src/views/nads/details/tabs/virtualMachines/components/AddNADVirtualMachinesModal.tsx
  • src/views/udns/details/hooks/useUDNVirtualMachines/utils/utils.ts
  • src/views/udns/details/tabs/virtualMachines/components/AddUDNVirtualMachinesModal.tsx
  • src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalSelection.ts
  • src/views/udns/details/tabs/virtualMachines/components/hooks/useAddUDNVMModalTable.tsx

Comment thread src/utils/utils/units.js Outdated
return defaultReturn;
}

let units_ = unitArray.slice().reverse();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the underscore at the end of the name?

Comment thread src/utils/utils/units.js Outdated

// find which unit we're given
let truncateStringAt = -1;
const startingUnitIndex = _.findIndex(units_, function (currentUnitValue) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the general lodash import and import only the functions that are used.

Comment thread src/utils/utils/units.js Outdated
return { unit, value };
};

const convertValueWithUnitsToBaseValue = (value, unitArray, divisor) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did all of this units-based code come from?

@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Parthivk100: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants