-
Notifications
You must be signed in to change notification settings - Fork 77
fix: restore vm create modal behavior #1743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,6 +12,7 @@ import RbdPluginsCom from '../RBDPluginsCom'; | |||||||||||||||||||||||
| import AppMarketContent from '../AppMarketContent'; | ||||||||||||||||||||||||
| import ImageNameForm from '../ImageNameForm'; | ||||||||||||||||||||||||
| import ImageComposeForm from '../ImageComposeForm'; | ||||||||||||||||||||||||
| import ImageVirtualMachineForm from '../ImageVirtualMachineForm'; | ||||||||||||||||||||||||
| import AddOrEditImageRegistry from '../AddOrEditImageRegistry'; | ||||||||||||||||||||||||
| import OauthForm from '../OauthForm'; | ||||||||||||||||||||||||
| import CodeCustomForm from '../CodeCustomForm'; | ||||||||||||||||||||||||
|
|
@@ -106,6 +107,7 @@ const CreateComponentModal = ({ visible, onCancel, dispatch, currentEnterprise, | |||||||||||||||||||||||
| const [loadingDatabaseInfo, setLoadingDatabaseInfo] = useState(false); | ||||||||||||||||||||||||
| const [currentDatabaseType, setCurrentDatabaseType] = useState(null); | ||||||||||||||||||||||||
| const [showDatabaseForm, setShowDatabaseForm] = useState(false); | ||||||||||||||||||||||||
| const [virtualMachineImages, setVirtualMachineImages] = useState([]); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // 插件相关状态 | ||||||||||||||||||||||||
| const [availablePlugins, setAvailablePlugins] = useState([]); | ||||||||||||||||||||||||
|
|
@@ -160,6 +162,7 @@ const CreateComponentModal = ({ visible, onCancel, dispatch, currentEnterprise, | |||||||||||||||||||||||
| const thirdPartyFormRef = useRef(null); | ||||||||||||||||||||||||
| const thirdListFormRef = useRef(null); | ||||||||||||||||||||||||
| const databaseFormRef = useRef(null); | ||||||||||||||||||||||||
| const vmFormRef = useRef(null); | ||||||||||||||||||||||||
| const marketInstallFormRef = useRef(null); | ||||||||||||||||||||||||
| const localInstallFormRef = useRef(null); | ||||||||||||||||||||||||
| const imageRepoFormRef = useRef(null); | ||||||||||||||||||||||||
|
|
@@ -880,8 +883,9 @@ const CreateComponentModal = ({ visible, onCancel, dispatch, currentEnterprise, | |||||||||||||||||||||||
| ...(showVmEntry ? [{ | ||||||||||||||||||||||||
| iconSrc: InstalledVmIcon, | ||||||||||||||||||||||||
| title: formatMessage({ id: 'componentOverview.body.CreateComponentModal.vm' }), | ||||||||||||||||||||||||
| key: 'vm-display', | ||||||||||||||||||||||||
| displayOnly: true, | ||||||||||||||||||||||||
| key: 'vm', | ||||||||||||||||||||||||
| showForm: true, | ||||||||||||||||||||||||
| formType: 'vm', | ||||||||||||||||||||||||
| iconColor: '#fa8c16', | ||||||||||||||||||||||||
| }] : []), | ||||||||||||||||||||||||
| ...(showLlmEntry ? [{ | ||||||||||||||||||||||||
|
|
@@ -1139,6 +1143,29 @@ const CreateComponentModal = ({ visible, onCancel, dispatch, currentEnterprise, | |||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const fetchVirtualMachineImages = () => { | ||||||||||||||||||||||||
| const teamName = globalUtil.getCurrTeamName(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (!teamName) { | ||||||||||||||||||||||||
| setVirtualMachineImages([]); | ||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| dispatch({ | ||||||||||||||||||||||||
| type: 'createApp/getAppByVirtualMachineImage', | ||||||||||||||||||||||||
| payload: { | ||||||||||||||||||||||||
| team_name: teamName | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| callback: data => { | ||||||||||||||||||||||||
| setVirtualMachineImages((data && data.list) || []); | ||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||
| handleError: err => { | ||||||||||||||||||||||||
| setVirtualMachineImages([]); | ||||||||||||||||||||||||
| handleAPIError(err); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // 监听滚动事件进行自动加载 - 商店应用 | ||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||
| if (currentView !== 'marketStore') { | ||||||||||||||||||||||||
|
|
@@ -1283,8 +1310,11 @@ const CreateComponentModal = ({ visible, onCancel, dispatch, currentEnterprise, | |||||||||||||||||||||||
| if (visible && currentView === 'form') { | ||||||||||||||||||||||||
| fetchLocalImageList(); | ||||||||||||||||||||||||
| fetchArchInfo(); | ||||||||||||||||||||||||
| if (currentFormType === 'vm') { | ||||||||||||||||||||||||
| fetchVirtualMachineImages(); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+1313
to
1316
|
||||||||||||||||||||||||
| if (currentFormType === 'vm') { | |
| fetchVirtualMachineImages(); | |
| } | |
| } | |
| } | |
| }, [visible, currentView]); | |
| useEffect(() => { | |
| if (visible && currentView === 'form' && currentFormType === 'vm') { | |
| fetchVirtualMachineImages(); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetchVirtualMachineImagespasses ahandleErrorcallback, butcreateApp/getAppByVirtualMachineImagecurrently delegates togetAppByVirtualMachineImageinsrc/services/createApp.js, which does not forwardhandleErrortorequest(...). As a result, thishandleErrorbranch (and thesetVirtualMachineImages([])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 providedhandleErrorcallback.