Skip to content
Snippets Groups Projects

CE-2918: Host selector not displaying result

Merged CE-2918: Host selector not displaying result
All threads resolved!
Merged Johanna Szepanski requested to merge CE-2918-host-selector-not-displaying-result into develop
All threads resolved!
3 files
+ 38
33
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -2,8 +2,8 @@ import React, {
@@ -2,8 +2,8 @@ import React, {
useState,
useState,
useEffect,
useEffect,
useCallback,
useCallback,
useMemo,
useContext,
useContext
useMemo
} from "react";
} from "react";
import AccessControl from "../../auth/AccessControl";
import AccessControl from "../../auth/AccessControl";
import { ConfirmationDialog, useAPIMethod } from "@ess-ics/ce-ui-common";
import { ConfirmationDialog, useAPIMethod } from "@ess-ics/ce-ui-common";
@@ -30,15 +30,12 @@ export default function ChangeHostAdmin({
@@ -30,15 +30,12 @@ export default function ChangeHostAdmin({
}) {
}) {
const initHost = useMemo(
const initHost = useMemo(
() => ({
() => ({
netBoxHost: {
fqdn: ioc.activeDeployment.host.fqdn,
fqdn: ioc?.activeDeployment.host.fqdn,
hostId: ioc.activeDeployment.host.hostId
hostId: ioc?.activeDeployment.host.hostId
}
}),
}),
[ioc?.activeDeployment?.host]
[ioc.activeDeployment.host]
);
);
const [host, setHost] = useState(initHost);
const [host, setHost] = useState(initHost);
const client = useContext(apiContext);
const client = useContext(apiContext);
const {
const {
@@ -53,8 +50,7 @@ export default function ChangeHostAdmin({
@@ -53,8 +50,7 @@ export default function ChangeHostAdmin({
const [query, onHostKeyUp] = useTypingTimer({ interval: 500 });
const [query, onHostKeyUp] = useTypingTimer({ interval: 500 });
const noModification = useCallback(
const noModification = useCallback(
() =>
() => !host || host?.hostId === ioc.activeDeployment.host.hostId,
!host || host?.netBoxHost?.hostId === ioc.activeDeployment.host.hostId,
[host, ioc]
[host, ioc]
);
);
@@ -81,6 +77,10 @@ export default function ChangeHostAdmin({
@@ -81,6 +77,10 @@ export default function ChangeHostAdmin({
useEffect(() => {
useEffect(() => {
if (updatedIoc) {
if (updatedIoc) {
getIOC();
getIOC();
 
setHost({
 
fqdn: updatedIoc.activeDeployment.host.fqdn,
 
hostId: updatedIoc.activeDeployment.host.hostId
 
});
resetTab();
resetTab();
setButtonDisabled(false);
setButtonDisabled(false);
}
}
@@ -99,15 +99,15 @@ export default function ChangeHostAdmin({
@@ -99,15 +99,15 @@ export default function ChangeHostAdmin({
setButtonDisabled(true);
setButtonDisabled(true);
updateHost(
updateHost(
{
{
ioc_id: ioc?.id
ioc_id: ioc.id
},
},
{
{
requestBody: {
requestBody: {
hostId: host?.netBoxHost.hostId
hostId: host?.hostId
}
}
}
}
);
);
}, [updateHost, ioc, host?.netBoxHost?.hostId, setButtonDisabled]);
}, [updateHost, ioc, host?.hostId, setButtonDisabled]);
let disabledButtonTitle = "";
let disabledButtonTitle = "";
if (buttonDisabled || ioc.operationInProgress) {
if (buttonDisabled || ioc.operationInProgress) {
@@ -188,7 +188,7 @@ export default function ChangeHostAdmin({
@@ -188,7 +188,7 @@ export default function ChangeHostAdmin({
clearOnBlur={false}
clearOnBlur={false}
value={host}
value={host}
getOptionLabel={(option) => {
getOptionLabel={(option) => {
return option?.netBoxHost?.fqdn ?? "";
return option?.fqdn ?? "";
}}
}}
renderInput={(params) => (
renderInput={(params) => (
<TextField
<TextField
Loading