Skip to content
Snippets Groups Projects
Commit 0ae04924 authored by Imre Toth's avatar Imre Toth
Browse files

Merge branch 'CE-2104_Convert_useUpdateIoc' into 'develop'

CE-2104: Convert useUpdateIoc hook

See merge request !381
parents 077b0399 b509dc9b
No related branches found
No related tags found
2 merge requests!407CE-2141: 3.0.0,!381CE-2104: Convert useUpdateIoc hook
Pipeline #161887 passed
......@@ -283,20 +283,6 @@ export function unpackGitProject(project) {
return { ...project };
}
export function useUpdateIoc(id, onError) {
const api = useContext(apiContext);
const method = useCallAndUnpack(
(body) => api.apis.IOCs.updateIoc({ ioc_id: id }, { requestBody: body }),
unpackUpdateIoc
);
return useAsync({ fcn: method, call: false, onError: onError });
}
export function unpackUpdateIoc(updateIoc) {
const d = { ...updateIoc };
return d;
}
export function unpackUpdateActiveDeploymentHost(ioc) {
return { ...ioc };
}
......@@ -13,7 +13,6 @@ import {
Autocomplete,
Alert
} from "@mui/material";
import { useUpdateIoc } from "../../../api/SwaggerApi";
import { useTypingTimer } from "../../common/SearchBoxFilter/TypingTimer";
import AccessControl from "../../auth/AccessControl";
import { apiContext } from "../../../api/DeployApi";
......@@ -37,10 +36,6 @@ export default function IOCDetailAdmin({
const [open, setOpen] = useState(false);
const [error, setError] = useState();
function onError(message) {
setError(message);
}
const client = useContext(apiContext);
const {
......@@ -63,6 +58,21 @@ export default function IOCDetailAdmin({
call: false
});
const {
value: uioc,
wrapper: actionUpdateIoc,
error: updateError
} = useAPIMethod({
fcn: client.apis.IOCs.updateIoc,
call: false
});
useEffect(() => {
if (updateError) {
setError(updateError?.message);
}
}, [updateError, setError]);
const requiredDataMissing = useCallback(() => !gitId || !name, [gitId, name]);
const noModification = useCallback(
......@@ -74,8 +84,6 @@ export default function IOCDetailAdmin({
[gitId, name, ioc]
);
const [uioc, actionUpdateIoc] = useUpdateIoc(ioc.id, onError);
useEffect(() => {
getAllowedGitProjects();
}, [getAllowedGitProjects]);
......@@ -95,11 +103,16 @@ export default function IOCDetailAdmin({
}, [setOpen]);
const onConfirm = useCallback(() => {
actionUpdateIoc({
gitProjectId: gitId,
namingUuid: name ? name.uuid : null
});
}, [actionUpdateIoc, gitId, name]);
actionUpdateIoc(
{ ioc_id: ioc?.id },
{
requestBody: {
gitProjectId: gitId,
namingUuid: name ? name.uuid : null
}
}
);
}, [actionUpdateIoc, ioc, name, gitId]);
useEffect(() => {
if (uioc) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment