Skip to content

Commit

Permalink
fix(ui): add proxmox field names to add_chassis parameter map
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb Ellis committed Mar 11, 2021
1 parent cadac76 commit 4948e38
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Spinner, Strip } from "@canonical/react-components";
import PropTypes from "prop-types";
import React, { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
Expand Down Expand Up @@ -63,6 +64,7 @@ export const CommissionForm = ({ setSelectedAction }: Props): JSX.Element => {
const dispatch = useDispatch();
const selectedMachines = useSelector(machineSelectors.selected);
const errors = useSelector(machineSelectors.errors);
const scriptsLoaded = useSelector(scriptSelectors.loaded);
const commissioningScripts = useSelector(scriptSelectors.commissioning);
const preselectedCommissioningScripts = useSelector(
scriptSelectors.preselectedCommissioning
Expand Down Expand Up @@ -102,6 +104,13 @@ export const CommissionForm = ({ setSelectedAction }: Props): JSX.Element => {
}
}, [dispatch, scriptsLoaded]);

if (!scriptsLoaded) {
return (
<Strip shallow>
<Spinner text="Loading..." />
</Strip>
);
}
return (
<ActionForm
actionName="commission"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Spinner, Strip } from "@canonical/react-components";
import PropTypes from "prop-types";
import React, { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
Expand Down Expand Up @@ -33,6 +34,7 @@ export const TestForm = ({ setSelectedAction }) => {
const errors = useSelector(machineSelectors.errors);
const testingSelected = useSelector(machineSelectors.testingSelected);
const scripts = useSelector(scriptSelectors.testing);
const scriptsLoaded = useSelector(scriptSelectors.loaded);
const urlScripts = useSelector(scriptSelectors.testingWithUrl);

const formattedScripts = scripts.map((script) => ({
Expand Down Expand Up @@ -61,6 +63,13 @@ export const TestForm = ({ setSelectedAction }) => {
}
}, [dispatch, scriptsLoaded]);

if (!scriptsLoaded) {
return (
<Strip shallow>
<Spinner text="Loading..." />
</Strip>
);
}
return (
<ActionForm
actionName="test"
Expand Down
3 changes: 3 additions & 0 deletions ui/src/app/utils/formatPowerParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const chassisParameterMap = new Map([
["power_pass", "password"],
["power_port", "port"],
["power_protocol", "protocol"],
["power_token_name", "token_name"],
["power_token_secret", "token_secret"],
["power_user", "username"],
["power_verify_ssl", "verify_ssl"],
]);

export const formatPowerParameters = (
Expand Down
13 changes: 11 additions & 2 deletions ui/src/app/utils/formatPowerParameters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ describe("formatPowerParameters", () => {
{ name: "power_pass" },
{ name: "power_port" },
{ name: "power_protocol" },
{ name: "power_token_name" },
{ name: "power_token_secret" },
{ name: "power_user" },
{ name: "power_verify_ssl" },
],
};

Expand All @@ -32,7 +35,10 @@ describe("formatPowerParameters", () => {
power_pass: "value2",
power_port: "value3",
power_protocol: "value4",
power_user: "value5",
power_token_name: "value5",
power_token_secret: "value6",
power_user: "value7",
power_verify_ssl: "value8",
};
expect(
formatPowerParameters(powerType, powerParameters, "chassis")
Expand All @@ -41,7 +47,10 @@ describe("formatPowerParameters", () => {
password: "value2",
port: "value3",
protocol: "value4",
username: "value5",
token_name: "value5",
token_secret: "value6",
username: "value7",
verify_ssl: "value8",
});
});

Expand Down

0 comments on commit 4948e38

Please sign in to comment.