Wizard: Fix VMware select and unselect
This updates the behaviour of VMware checkbox to make it possible to unselect VMware as a target. How to reproduce: 1. select VMware vSphere checkbox 2. click on Virtual disk radio 3. try to unselect VMware vSphere checkbox Previous behaviour - the checkbox can't be unselected New behaviour - the checkbox can be unselected, removing relevant type of VMware target from imageTypes
This commit is contained in:
parent
27db0e1a03
commit
79a4e98d0e
1 changed files with 14 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useState } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import {
|
||||
Button,
|
||||
|
|
@ -44,7 +44,8 @@ const TargetEnvironment = () => {
|
|||
// TODO: Handle isFetching state (add skeletons)
|
||||
// TODO: Handle isError state (very unlikely...)
|
||||
|
||||
const [hasVSphere, setHasVSphere] = useState(false);
|
||||
const hasVsphere =
|
||||
environments.includes('vsphere') || environments.includes('vsphere-ova');
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
const prefetchSources = provisioningApi.usePrefetch('getSourceList');
|
||||
|
|
@ -191,13 +192,18 @@ const TargetEnvironment = () => {
|
|||
>
|
||||
<Checkbox
|
||||
label="VMware vSphere"
|
||||
isChecked={
|
||||
environments.includes('vsphere') ||
|
||||
environments.includes('vsphere-ova')
|
||||
}
|
||||
isChecked={hasVsphere}
|
||||
onChange={() => {
|
||||
setHasVSphere(!hasVSphere);
|
||||
handleToggleEnvironment('vsphere-ova');
|
||||
if (!hasVsphere) {
|
||||
dispatch(addImageType('vsphere-ova'));
|
||||
} else {
|
||||
if (environments.includes('vsphere')) {
|
||||
dispatch(removeImageType('vsphere'));
|
||||
}
|
||||
if (environments.includes('vsphere-ova')) {
|
||||
dispatch(removeImageType('vsphere-ova'));
|
||||
}
|
||||
}
|
||||
}}
|
||||
aria-label="VMware checkbox"
|
||||
id="checkbox-vmware"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue