Skip to content

Conversation

@batyana
Copy link
Member

@batyana batyana commented Feb 11, 2026

📝 Description

  • Redesigned the Add CD-ROM modal UI: replaced the dropdown/checkbox interface with three radio buttons (Mount existing ISO, Upload new ISO, Leave empty drive) for a more intuitive experience.
  • For hotpluggable VMs, the modal now closes immediately when an upload starts. A dynamic alert on the Storage tab tracks the upload status (uploading / success / error).
  • Added the option to add a CD-ROM with an empty drive. The option is disabled when the DeclarativeHotplugVolumes feature gate is not enabled.
  • Extracted CD-ROM submit logic from AddCDROMModal into a submitCDROM helper in submit.ts, keeping the component focused on form state and rendering.
  • Extracted upload alert state management into a useUploadAlert hook and moved alert configuration to storage/utils/constants.ts.
  • Added a createMutableUploadData helper in helpers.ts to safely handle fire-and-forget uploads without mutating frozen form data.

🎥 Demo

Screenshot at Feb 11 14-30-08
Screen.Recording.2026-02-11.at.14.26.21.mov

Summary by CodeRabbit

  • New Features

    • Enhanced CD-ROM configuration with three options: mount existing ISO, upload new ISO, or leave drive empty
    • Added upload start callback and integrated upload flow with visible upload alerts (uploading, success, error)
    • Storage view surfaces upload alerts above storage list and propagates upload state
  • Localization

    • Expanded CD-ROM/ISO translations for EN, ES, FR, JA, KO, ZH; removed one outdated upload wording entry

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 11, 2026

@batyana: This pull request references CNV-77263 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 "4.22.0" version, but no target version was set.

Details

In response to this:

📝 Description

  • Redesigned the Add CD-ROM modal UI: replaced the dropdown/checkbox interface with three radio buttons (Mount existing ISO, Upload new ISO, Leave empty drive) for a more intuitive experience.
  • For hotpluggable VMs, the modal now closes immediately when an upload starts. A dynamic alert on the Storage tab tracks the upload status (uploading / success / error).
  • Added the option to add a CD-ROM with an empty drive. The option is disabled when the DeclarativeHotplugVolumes feature gate is not enabled.
  • Extracted CD-ROM submit logic from AddCDROMModal into a submitCDROM helper in submit.ts, keeping the component focused on form state and rendering.
  • Extracted upload alert state management into a useUploadAlert hook and moved alert configuration to storage/utils/constants.ts.
  • Added a createMutableUploadData helper in helpers.ts to safely handle fire-and-forget uploads without mutating frozen form data.

🎥 Demo

Screenshot at Feb 11 14-30-08
Screen.Recording.2026-02-11.at.14.26.21.mov

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
Copy link
Contributor

openshift-ci bot commented Feb 11, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: batyana
Once this PR has been reviewed and has the lgtm label, please assign rszwajko for approval. For more information see the Code Review Process.

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

Details Needs approval from an approver in each of these files:

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

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

Reworks CD‑ROM modal to a radio-based source selector (Mount ISO / Upload / Empty), extracts submission/upload logic into submitCDROM, adds upload lifecycle callbacks (onUploadStarted), introduces upload-alert hook/constants, and adds/updates locale keys for CD‑ROM/ISO flows.

Changes

Cohort / File(s) Summary
Localization Files
locales/en/plugin__kubevirt-plugin.json, locales/es/plugin__kubevirt-plugin.json, locales/fr/plugin__kubevirt-plugin.json, locales/ja/plugin__kubevirt-plugin.json, locales/ko/plugin__kubevirt-plugin.json, locales/zh/plugin__kubevirt-plugin.json
Added CD‑ROM/ISO translation keys (e.g., "CD‑ROM source", "Leave empty drive", "Mount existing ISO", "Select ISO file", "Upload new ISO", "Requires enabling advanced CD‑ROM features."); removed an older "Upload a new ISO file to the cluster" entry in some locales.
AddCDROMModal refactor
src/utils/components/DiskModal/AddCDROMModal.tsx
Replaced legacy multipart/upload-mode flow with radio-driven CD‑ROM source (select ISO / upload / empty), delegates submission to submitCDROM, adds onUploadStarted prop and updates UI/validation accordingly.
DiskModal component & types
src/utils/components/DiskModal/DiskModal.tsx, src/utils/components/DiskModal/utils/types.ts
Added optional onUploadStarted?: (uploadPromise: Promise<unknown>) => void to component props and forwarded it to child Modal.
DiskModal utils
src/utils/components/DiskModal/utils/constants.ts, src/utils/components/DiskModal/utils/helpers.ts, src/utils/components/DiskModal/utils/submit.ts
Added UPLOAD_MODE_EMPTY constant; new createMutableUploadData helper; new SubmitCDROMInput type and submitCDROM function that orchestrates ISO selection, upload (hotplug/non‑hotplug), empty drives, callbacks, and final disk attach flow.
DiskSourceUploadPVC tweak
src/utils/components/DiskModal/components/DiskSourceSelect/components/DiskSourceUploadPVC/DiskSourceUploadPVC.tsx
Changed label defaulting to use nullish coalescing to preserve explicit empty-string labels.
Mount CD‑ROM form hook
src/views/virtualmachines/details/tabs/configuration/storage/components/modal/hooks/useMountCDROMForm.ts
Extended uploadMode union to include UPLOAD_MODE_EMPTY; added and exposed handleEmptyDriveSelection to set empty-drive mode and clear ISO/upload selection.
DiskList prop passthrough
src/views/virtualmachines/details/tabs/configuration/storage/components/tables/disk/DiskList.tsx
Added optional onUploadStarted prop to DiskListProps and forwarded it through DiskSourceSelect → DiskModal so upload start can be observed.
Upload alert & constants
src/views/virtualmachines/details/tabs/configuration/storage/components/hooks/useUploadAlert.ts, src/views/virtualmachines/details/tabs/configuration/storage/utils/constants.ts
New useUploadAlert hook managing upload lifecycle (uploading/success/error) and uploadAlertConfig with PatternFly variants; exposes alertConfig, dismissAlert, onUploadStarted, and uploadError.
StorageTab integration
src/views/virtualmachines/details/tabs/configuration/storage/StorageTab.tsx
Integrated useUploadAlert, renders conditional Alert for upload feedback, passes onUploadStarted to DiskList, and added translation usage for alert content.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

lgtm, approved

Suggested reviewers

  • vojtechszocs
  • upalatucci
  • galkremer1
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly identifies the main change: a redesign of the CD-ROM modal as specified in the issue CNV-77263.
Description check ✅ Passed The pull request description includes both required template sections (📝 Description and 🎥 Demo). The description is comprehensive and covers the key changes, and a screenshot/video is provided.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 11, 2026

@batyana: This pull request references CNV-77263 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 "4.22.0" version, but no target version was set.

Details

In response to this:

📝 Description

  • Redesigned the Add CD-ROM modal UI: replaced the dropdown/checkbox interface with three radio buttons (Mount existing ISO, Upload new ISO, Leave empty drive) for a more intuitive experience.
  • For hotpluggable VMs, the modal now closes immediately when an upload starts. A dynamic alert on the Storage tab tracks the upload status (uploading / success / error).
  • Added the option to add a CD-ROM with an empty drive. The option is disabled when the DeclarativeHotplugVolumes feature gate is not enabled.
  • Extracted CD-ROM submit logic from AddCDROMModal into a submitCDROM helper in submit.ts, keeping the component focused on form state and rendering.
  • Extracted upload alert state management into a useUploadAlert hook and moved alert configuration to storage/utils/constants.ts.
  • Added a createMutableUploadData helper in helpers.ts to safely handle fire-and-forget uploads without mutating frozen form data.

🎥 Demo

Screenshot at Feb 11 14-30-08
Screen.Recording.2026-02-11.at.14.26.21.mov

Summary by CodeRabbit

Release Notes

  • New Features
  • Enhanced CD-ROM configuration with three mounting options: mount existing ISO, upload new ISO, or leave empty drive
  • Added upload progress and status alerts (uploading, success, error) for improved user feedback during ISO uploads
  • Expanded localization support for CD-ROM and ISO operations across English, Spanish, French, Japanese, Korean, and Chinese

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.

Copy link

@coderabbitai coderabbitai bot left a comment

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 (1)
src/views/virtualmachines/details/tabs/configuration/storage/components/modal/hooks/useMountCDROMForm.ts (1)

74-74: ⚠️ Potential issue | 🟠 Major

isFormValid doesn't account for the empty drive mode — "Add" button will be disabled.

When the user selects "Leave empty drive", selectedISO is '' and uploadFile is null, so isFormValid evaluates to false. The submit button will remain disabled for the empty drive option.

🐛 Proposed fix
-  const isFormValid = Boolean(selectedISO || uploadFile?.filename);
+  const isFormValid = Boolean(selectedISO || uploadFile?.filename || uploadMode === UPLOAD_MODE_EMPTY);
🤖 Fix all issues with AI agents
In `@src/utils/components/DiskModal/utils/helpers.ts`:
- Around line 330-339: createMutableUploadData currently always fabricates a
dataVolumeTemplate when data.dataVolumeTemplate is undefined; change it to guard
for existence of data.dataVolumeTemplate and only shallow-copy/modify
spec.source when the template exists—i.e., in createMutableUploadData, detect if
data.dataVolumeTemplate is truthy and then return a new object with
dataVolumeTemplate: { ...data.dataVolumeTemplate, spec: {
...data.dataVolumeTemplate.spec, source: {
...data.dataVolumeTemplate.spec?.source } } }, otherwise return the original
data unchanged (or copy other fields without adding dataVolumeTemplate);
reference createMutableUploadData and the dataVolumeTemplate/spec/source
properties to locate the change.

In `@src/utils/components/DiskModal/utils/submit.ts`:
- Around line 239-256: The hot-plug upload path creates the DataVolume with a
generated name inside uploadDataVolume (which uses generateUploadDiskName) but
then reads dvName from data.dataVolumeTemplate?.metadata?.name (which may
instead have been set by createDataVolumeName), causing a mismatch; fix by using
the DataVolume returned by uploadDataVolume to update
data.dataVolumeTemplate.metadata.name and data.volume.dataVolume.name (or
replace data.dataVolumeTemplate and data.volume.dataVolume with the returned
object) inside the uploadPromise.then handler (and keep calling
onUploadedDataVolume/uploadStarted as before) so the VM volume references the
actual uploaded DataVolume name generated by uploadDataVolume.

In
`@src/views/virtualmachines/details/tabs/configuration/storage/components/hooks/useUploadAlert.ts`:
- Around line 8-23: The hook useUploadAlert should declare explicit return types
and its internal handlers should be typed: add a return type for useUploadAlert
(including uploadStatus, uploadError, onUploadStarted, dismissAlert), annotate
onUploadStarted as (uploadPromise: Promise<unknown>) => void and dismissAlert as
() => void, and change the catch handler parameter to err: unknown and narrow it
(e.g., if (err instanceof Error) setUploadError(err.message) else
setUploadError(String(err))) before calling setUploadError; keep using
setUploadStatus('error'/'success'/'uploading') as before.
🧹 Nitpick comments (4)
src/views/virtualmachines/details/tabs/configuration/storage/utils/constants.ts (1)

5-24: Rename uploadAlertConfig to uppercase constant style.

This is a utility constant and should follow the repo’s uppercase underscore naming convention. Update call sites accordingly.

Proposed fix
-export const uploadAlertConfig: Record<
+export const UPLOAD_ALERT_CONFIG: Record<
   UploadAlertStatus,
   { body: string; title: string; variant: AlertVariant }
 > = {

As per coding guidelines, "Define constants in utility files with uppercase and underscore-separated naming (e.g., API_URL)."

src/utils/components/DiskModal/utils/submit.ts (2)

217-274: Missing explicit return type on submitCDROM.

Per coding guidelines, functions should always have explicit return types rather than relying on inference.

Proposed fix
 export const submitCDROM = async (
   data: V1DiskFormState,
   {
     isHotPluggable,
     onSubmit,
     onUploadedDataVolume,
     onUploadStarted,
     selectedISO,
     uploadData: uploadDataFn,
     uploadEnabled,
     vm,
   }: SubmitCDROMInput,
-) => {
+): Promise<V1VirtualMachine | void> => {

As per coding guidelines, "Always explicitly define return types for functions rather than relying on TypeScript type inference."


230-269: Direct mutation of data parameter may cause issues.

submitCDROM mutates its data parameter in-place (delete data.dataVolumeTemplate, data.volume = ..., etc.). If the caller or any .then() handler references data after this call, it will see the mutated state. Consider working on a local copy instead of mutating the input.

src/utils/components/DiskModal/AddCDROMModal.tsx (1)

94-104: Wrap handleModalSubmit in useCallback and add an explicit return type.

handleModalSubmit is recreated every render and passed as onSubmit to TabModal. This can trigger unnecessary child re-renders. Per the project's coding guidelines, memoization tools should be used, and functions should have explicit return types.

♻️ Suggested refactor
-  const handleModalSubmit = () =>
-    submitCDROM(getValues(), {
+  const handleModalSubmit = useCallback((): Promise<void> =>
+    submitCDROM(getValues(), {
       isHotPluggable,
       onSubmit,
       onUploadedDataVolume,
       onUploadStarted,
       selectedISO,
       uploadData,
       uploadEnabled,
       vm,
-    });
+    }), [getValues, isHotPluggable, onSubmit, onUploadedDataVolume, onUploadStarted, selectedISO, uploadData, uploadEnabled, vm]);

You'll also need to add useCallback to the React import on line 1:

import React, { FC, useCallback, useEffect } from 'react';

As per coding guidelines: "Use React's memoization tools (React.memo, useMemo, useCallback) to avoid unnecessary re-renders." and "Always explicitly define return types for functions rather than relying on TypeScript type inference."

Comment on lines +8 to +23
export const useUploadAlert = () => {
const [uploadStatus, setUploadStatus] = useState<null | UploadAlertStatus>(null);
const [uploadError, setUploadError] = useState('');

const onUploadStarted = (uploadPromise: Promise<unknown>) => {
setUploadStatus('uploading');
setUploadError('');
uploadPromise
.then(() => setUploadStatus('success'))
.catch((err) => {
setUploadStatus('error');
setUploadError(err?.message || '');
});
};

const dismissAlert = () => setUploadStatus(null);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n "src/views/virtualmachines/details/tabs/configuration/storage/components/hooks/useUploadAlert.ts"

Repository: kubevirt-ui/kubevirt-plugin

Length of output: 1117


🏁 Script executed:

cat -n "src/views/virtualmachines/details/tabs/configuration/storage/utils/constants.ts" | head -50

Repository: kubevirt-ui/kubevirt-plugin

Length of output: 951


Add explicit return types and type the catch handler error as unknown.

Guidelines require explicit function return types for all functions in TypeScript files. Additionally, the caught error must be typed as unknown and narrowed to avoid implicit any.

Suggested fix
+type UploadAlertConfig = (typeof uploadAlertConfig)[UploadAlertStatus];
+
+type UseUploadAlertResult = {
+  alertConfig: UploadAlertConfig | null;
+  dismissAlert: () => void;
+  onUploadStarted: (uploadPromise: Promise<unknown>) => void;
+  uploadError: string;
+};
+
-export const useUploadAlert = () => {
+export const useUploadAlert = (): UseUploadAlertResult => {
   const [uploadStatus, setUploadStatus] = useState<null | UploadAlertStatus>(null);
   const [uploadError, setUploadError] = useState('');
 
-  const onUploadStarted = (uploadPromise: Promise<unknown>) => {
+  const onUploadStarted = (uploadPromise: Promise<unknown>): void => {
     setUploadStatus('uploading');
     setUploadError('');
     uploadPromise
       .then(() => setUploadStatus('success'))
-      .catch((err) => {
+      .catch((err: unknown) => {
         setUploadStatus('error');
-        setUploadError(err?.message || '');
+        setUploadError(err instanceof Error ? err.message : '');
       });
   };
 
-  const dismissAlert = () => setUploadStatus(null);
+  const dismissAlert = (): void => setUploadStatus(null);
🤖 Prompt for AI Agents
In
`@src/views/virtualmachines/details/tabs/configuration/storage/components/hooks/useUploadAlert.ts`
around lines 8 - 23, The hook useUploadAlert should declare explicit return
types and its internal handlers should be typed: add a return type for
useUploadAlert (including uploadStatus, uploadError, onUploadStarted,
dismissAlert), annotate onUploadStarted as (uploadPromise: Promise<unknown>) =>
void and dismissAlert as () => void, and change the catch handler parameter to
err: unknown and narrow it (e.g., if (err instanceof Error)
setUploadError(err.message) else setUploadError(String(err))) before calling
setUploadError; keep using setUploadStatus('error'/'success'/'uploading') as
before.

@batyana batyana force-pushed the CNV-77263-redesign-add-cd-rom-modal branch from ab0acd4 to ee93633 Compare February 11, 2026 13:11
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 11, 2026

@batyana: This pull request references CNV-77263 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 "4.22.0" version, but no target version was set.

Details

In response to this:

📝 Description

  • Redesigned the Add CD-ROM modal UI: replaced the dropdown/checkbox interface with three radio buttons (Mount existing ISO, Upload new ISO, Leave empty drive) for a more intuitive experience.
  • For hotpluggable VMs, the modal now closes immediately when an upload starts. A dynamic alert on the Storage tab tracks the upload status (uploading / success / error).
  • Added the option to add a CD-ROM with an empty drive. The option is disabled when the DeclarativeHotplugVolumes feature gate is not enabled.
  • Extracted CD-ROM submit logic from AddCDROMModal into a submitCDROM helper in submit.ts, keeping the component focused on form state and rendering.
  • Extracted upload alert state management into a useUploadAlert hook and moved alert configuration to storage/utils/constants.ts.
  • Added a createMutableUploadData helper in helpers.ts to safely handle fire-and-forget uploads without mutating frozen form data.

🎥 Demo

Screenshot at Feb 11 14-30-08
Screen.Recording.2026-02-11.at.14.26.21.mov

Summary by CodeRabbit

  • New Features
  • Enhanced CD-ROM configuration with three mounting options: mount existing ISO, upload new ISO, or leave drive empty
  • Added upload start callback and upload flow handling to surface upload state
  • Added upload progress/status alerts (uploading, success, error) for improved feedback
  • Expanded localization for CD-ROM/ISO operations in English, Spanish, French, Japanese, Korean, and Chinese

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.

@galkremer1
Copy link
Member

@yfrimanm - do you think we should use Requires enabling advanced CD-ROM features instead of Requires the DeclarativeHotplugVolumes feature gate to be enabled.?
We can also link directly to k8s/all-namespaces/virtualization-overview/settings/features (If the user is an admin, but I am not sure if we want to over complicate it).

@yfrimanm
Copy link
Collaborator

@ronensdeor please review @galkremer1 question. Thanks.

@galkremer1
Copy link
Member

@yfrimanm - do you think we should use Requires enabling advanced CD-ROM features instead of Requires the DeclarativeHotplugVolumes feature gate to be enabled.? We can also link directly to k8s/all-namespaces/virtualization-overview/settings/features (If the user is an admin, but I am not sure if we want to over complicate it).

@yfrimanm is good with that change - @batyana please update the description message, thank you.

@batyana batyana force-pushed the CNV-77263-redesign-add-cd-rom-modal branch from ee93633 to 01e4d66 Compare February 12, 2026 15:39
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 12, 2026

@batyana: This pull request references CNV-77263 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 "4.22.0" version, but no target version was set.

Details

In response to this:

📝 Description

  • Redesigned the Add CD-ROM modal UI: replaced the dropdown/checkbox interface with three radio buttons (Mount existing ISO, Upload new ISO, Leave empty drive) for a more intuitive experience.
  • For hotpluggable VMs, the modal now closes immediately when an upload starts. A dynamic alert on the Storage tab tracks the upload status (uploading / success / error).
  • Added the option to add a CD-ROM with an empty drive. The option is disabled when the DeclarativeHotplugVolumes feature gate is not enabled.
  • Extracted CD-ROM submit logic from AddCDROMModal into a submitCDROM helper in submit.ts, keeping the component focused on form state and rendering.
  • Extracted upload alert state management into a useUploadAlert hook and moved alert configuration to storage/utils/constants.ts.
  • Added a createMutableUploadData helper in helpers.ts to safely handle fire-and-forget uploads without mutating frozen form data.

🎥 Demo

Screenshot at Feb 11 14-30-08
Screen.Recording.2026-02-11.at.14.26.21.mov

Summary by CodeRabbit

  • New Features

  • Enhanced CD-ROM configuration with three options: mount existing ISO, upload new ISO, or leave drive empty

  • Added upload start callback and integrated upload flow with visible upload alerts (uploading, success, error)

  • Storage view surfaces upload alerts above storage list and propagates upload state

  • Localization

  • Expanded CD-ROM/ISO translations for EN, ES, FR, JA, KO, ZH; removed one outdated upload wording entry

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
src/views/virtualmachines/details/tabs/configuration/storage/components/modal/hooks/useMountCDROMForm.ts (1)

74-74: ⚠️ Potential issue | 🟡 Minor

Include uploadMode === UPLOAD_MODE_EMPTY in the isFormValid calculation.

The hook exports handleEmptyDriveSelection, which sets uploadMode to UPLOAD_MODE_EMPTY, but the isFormValid check on line 74 only validates selectedISO or uploadFile?.filename. When a user selects "Leave empty drive", both values are empty, making isFormValid return false despite being a valid selection.

While AddCDROMModal compensates by computing its own validity check, the hook's exported isFormValid is incomplete and misleading for any other consumer.

Proposed fix
-  const isFormValid = Boolean(selectedISO || uploadFile?.filename);
+  const isFormValid = Boolean(selectedISO || uploadFile?.filename || uploadMode === UPLOAD_MODE_EMPTY);
🤖 Fix all issues with AI agents
In `@src/utils/components/DiskModal/utils/submit.ts`:
- Around line 292-294: The current forked chain on uploadPromise
(.then(...).catch(...)) logs errors but swallows them, and onUploadStarted is
still given the original rejecting uploadPromise; also any error thrown inside
onUploadedDataVolume will be caught and suppressed by that catch. Replace the
fork with a chained promise that preserves rejection: create a new promise like
uploadPromise.then((u) => onUploadedDataVolume?.(u)).catch((err) => {
kubevirtConsole.error('CD-ROM upload error:', err); throw err; }) and pass that
chained promise to onUploadStarted (or return it) so errors are logged but
rethrown and propagate to consumers (references: uploadPromise,
onUploadedDataVolume, kubevirtConsole.error, onUploadStarted, useUploadAlert).
🧹 Nitpick comments (2)
src/utils/components/DiskModal/utils/submit.ts (1)

206-215: SubmitCDROMInput could be exported for testability.

The type is private, which is fine for current usage, but exporting it would make it easier to unit-test submitCDROM in isolation (constructing typed mock inputs). This is a minor suggestion.

src/utils/components/DiskModal/AddCDROMModal.tsx (1)

94-104: handleModalSubmit is missing an explicit return type.

Per coding guidelines: "Always explicitly define return types for functions."

Proposed fix
-  const handleModalSubmit = () =>
+  const handleModalSubmit = (): Promise<V1VirtualMachine | void> =>
     submitCDROM(getValues(), {

As per coding guidelines, "Always explicitly define return types for functions rather than relying on TypeScript type inference."

Comment on lines +292 to +294
uploadPromise
.then((uploaded) => onUploadedDataVolume?.(uploaded))
.catch((err) => kubevirtConsole.error('CD-ROM upload error:', err));
Copy link

@coderabbitai coderabbitai bot Feb 12, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Swallowed upload errors — the .catch only logs, but onUploadStarted still receives the rejecting promise.

The .catch on line 294 logs the error but also means the promise chain itself resolves (the catch handler returns undefined). Meanwhile, onUploadStarted on line 295 receives the original uploadPromise (before .then/.catch), which will reject. This is fine for the useUploadAlert hook (which attaches its own .catch), but be aware that .then/.catch on line 292–294 creates a separate fork that won't propagate to onUploadStarted's consumer. If onUploadedDataVolume throws, that error is silently swallowed by the .catch on line 294.

🤖 Prompt for AI Agents
In `@src/utils/components/DiskModal/utils/submit.ts` around lines 292 - 294, The
current forked chain on uploadPromise (.then(...).catch(...)) logs errors but
swallows them, and onUploadStarted is still given the original rejecting
uploadPromise; also any error thrown inside onUploadedDataVolume will be caught
and suppressed by that catch. Replace the fork with a chained promise that
preserves rejection: create a new promise like uploadPromise.then((u) =>
onUploadedDataVolume?.(u)).catch((err) => { kubevirtConsole.error('CD-ROM upload
error:', err); throw err; }) and pass that chained promise to onUploadStarted
(or return it) so errors are logged but rethrown and propagate to consumers
(references: uploadPromise, onUploadedDataVolume, kubevirtConsole.error,
onUploadStarted, useUploadAlert).

Copy link
Member

@upalatucci upalatucci Feb 13, 2026

Choose a reason for hiding this comment

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

@batyana this is a really good point. Why did u decide not to await this promise?

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Comment on lines +223 to +229
draft.volume = {
name: draft.volume.name,
persistentVolumeClaim: {
claimName: selectedISO,
...(isHotPluggable && { hotpluggable: true }),
},
};
Copy link
Member

Choose a reason for hiding this comment

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

With produce u should be able to do that. draft is already a copy of the original object so i don't want to do

name: draft.volume.name

Suggested change
draft.volume = {
name: draft.volume.name,
persistentVolumeClaim: {
claimName: selectedISO,
...(isHotPluggable && { hotpluggable: true }),
},
};
draft.volume.persistentVolumeClaim = {
claimName: selectedISO,
...(isHotPluggable && { hotpluggable: true }),
};

Comment on lines +245 to +249
draft.volume = {
name: draft.volume.name,
persistentVolumeClaim: { claimName },
};
delete draft.dataVolumeTemplate;
Copy link
Member

Choose a reason for hiding this comment

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

same here

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants