diff --git a/ui/src/app/machines/components/HeaderStrip/ActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.js b/ui/src/app/machines/components/HeaderStrip/ActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.js index 5129d45125..ecfb702b18 100644 --- a/ui/src/app/machines/components/HeaderStrip/ActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.js +++ b/ui/src/app/machines/components/HeaderStrip/ActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.js @@ -16,9 +16,10 @@ export const DeployFormFields = () => { const user = useSelector(authSelectors.get); const osOptions = useSelector(configSelectors.defaultOSystemOptions); - const releaseOptions = useSelector((state) => - generalSelectors.osInfo.getOsReleases(state, values.oSystem) + const allReleaseOptions = useSelector( + generalSelectors.osInfo.getAllOsReleases ); + const releaseOptions = allReleaseOptions[values.oSystem]; const kernelOptions = useSelector((state) => generalSelectors.osInfo.getUbuntuKernelOptions(state, values.release) ); @@ -35,7 +36,11 @@ export const DeployFormFields = () => { options={osOptions} onChange={(e) => { handleChange(e); - if (e.target.value !== "ubuntu") { + const value = e.target.value; + if (allReleaseOptions[value] && allReleaseOptions[value].length) { + setFieldValue("release", allReleaseOptions[value][0].value); + } + if (value !== "ubuntu") { setFieldValue("installKVM", false); } }} diff --git a/ui/src/app/machines/components/HeaderStrip/ActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.test.js b/ui/src/app/machines/components/HeaderStrip/ActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.test.js index 88dc054e82..57db07c481 100644 --- a/ui/src/app/machines/components/HeaderStrip/ActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.test.js +++ b/ui/src/app/machines/components/HeaderStrip/ActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.test.js @@ -193,6 +193,44 @@ describe("DeployFormFields", () => { expect(wrapper.find("[data-test='kvm-warning']").exists()).toBe(false); }); + it("enables KVM checkbox when switching to Ubuntu 18.04 from a different OS/Release", async () => { + const state = { ...initialState }; + state.general.osInfo.data.default_release = "bionic"; + const store = mockStore(state); + const wrapper = mount( + + + + + + ); + // Initial selection is Ubuntu 18.04. Switch to CentOS 6 to CentOS 7 back to + // Ubuntu 18.04 and checkbox should be enabled. + await act(async () => { + wrapper + .find("Select[name='oSystem']") + .simulate("change", { target: { name: "oSystem", value: "centos" } }); + }); + wrapper.update(); + await act(async () => { + wrapper + .find("Select[name='release']") + .simulate("change", { target: { name: "release", value: "centos70" } }); + }); + wrapper.update(); + await act(async () => { + wrapper + .find("Select[name='oSystem']") + .simulate("change", { target: { name: "oSystem", value: "ubuntu" } }); + }); + wrapper.update(); + expect(wrapper.find("Input[name='installKVM']").props().disabled).toBe( + false + ); + }); + it("displays a warning if user has no SSH keys", () => { const state = { ...initialState }; state.user.auth.user.sshkeys_count = 0;