Skip to content

fix: restore vm create modal behavior#1743

Merged
ZhangSetSail merged 1 commit intomainfrom
0408-dev
Apr 8, 2026
Merged

fix: restore vm create modal behavior#1743
ZhangSetSail merged 1 commit intomainfrom
0408-dev

Conversation

@ZhangSetSail
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings April 8, 2026 11:00
@ZhangSetSail ZhangSetSail merged commit e66f3f0 into main Apr 8, 2026
4 of 5 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR restores the “VM create” flow inside the component creation modal by wiring the VM entry to a real form + submission path, and improves the VM form’s initial group selection behavior.

Changes:

  • Re-enable VM creation in CreateComponentModal by adding the VM form, fetching VM images, and submitting via createApp/createAppByVirtualMachine.
  • Load existing VM images on-demand when entering the VM form.
  • Avoid NaN/incorrect defaults for the VM form’s group_id initial value.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/components/ImageVirtualMachineForm/index.js Adjusts group_id initial value logic to avoid invalid defaults and better match modal behavior.
src/components/CreateComponentModal/index.js Adds VM entry as a form-based flow, including VM image fetching and VM create submission routing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1160 to +1164
setVirtualMachineImages((data && data.list) || []);
},
handleError: err => {
setVirtualMachineImages([]);
handleAPIError(err);
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

fetchVirtualMachineImages passes a handleError callback, but createApp/getAppByVirtualMachineImage currently delegates to getAppByVirtualMachineImage in src/services/createApp.js, which does not forward handleError to request(...). As a result, this handleError branch (and the setVirtualMachineImages([]) reset) will never run, and the UI may keep showing stale VM images after a failed request. Fix by updating the service (or model effect) to propagate/catch errors and invoke the provided handleError callback.

Copilot uses AI. Check for mistakes.
Comment on lines +1313 to 1316
if (currentFormType === 'vm') {
fetchVirtualMachineImages();
}
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

This effect now depends on currentFormType, so switching between different create forms while the modal is open will re-run fetchLocalImageList() and fetchArchInfo() each time (extra network calls even when those results are unchanged). Consider splitting VM-image loading into its own useEffect (triggered only when entering vm) so fetchLocalImageList/fetchArchInfo stay tied to [visible, currentView].

Suggested change
if (currentFormType === 'vm') {
fetchVirtualMachineImages();
}
}
}
}, [visible, currentView]);
useEffect(() => {
if (visible && currentView === 'form' && currentFormType === 'vm') {
fetchVirtualMachineImages();
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants