Skip to content

Commit

Permalink
await for release chart schema
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-cvit committed Oct 24, 2024
1 parent ad33e12 commit ea1880f
Showing 1 changed file with 38 additions and 34 deletions.
72 changes: 38 additions & 34 deletions cyclops-ui/src/components/pages/Helm/EditRelease/EditRelease.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,42 +70,46 @@ const EditRelease = () => {
const [loadingSubmitRequest, setLoadingSubmitRequest] = useState(false);

useEffect(() => {
axios
.get(`/api/helm/releases/${releaseNamespace}/${releaseName}/fields`)
.then((res) => {
setRootField(res.data);
})
.catch((error) => {
setError(mapResponseError(error));
})
.finally(() => {
setLoadTemplate(true);
});

axios
.get(`/api/helm/releases/${releaseNamespace}/${releaseName}/values`)
.then((res) => {
setInitialValuesRaw(res.data);
})
.catch(function (error) {
setError(mapResponseError(error));
})
.finally(() => {
setLoadValues(true);
});
}, [releaseNamespace, releaseName]);
const fetchReleaseFields = async () => {
axios
.get(`/api/helm/releases/${releaseNamespace}/${releaseName}/fields`)
.then((fieldsResponse) => {
setRootField(fieldsResponse.data);

axios
.get(`/api/helm/releases/${releaseNamespace}/${releaseName}/values`)
.then((valuesRes) => {
setInitialValuesRaw(valuesRes.data);

let initialValuesMapped = mapsToArray(
fieldsResponse.data.properties,
valuesRes.data,
);

setInitialValues(initialValuesMapped);

form.setFieldsValue(initialValuesMapped);
})
.catch(function (error) {
setError(mapResponseError(error));
})
.finally(() => {
setLoadValues(true);
});
})
.catch((error) => {
setError(mapResponseError(error));
})
.finally(() => {
setLoadTemplate(true);
});
};
fetchReleaseFields();
}, [releaseNamespace, releaseName, form]);

useEffect(() => {
let initialValuesMapped = mapsToArray(
rootField.properties,
initialValuesRaw,
);

setInitialValues(initialValuesMapped);

form.setFieldsValue(initialValuesMapped);
form.validateFields(flattenObjectKeys(initialValuesMapped));
}, [initialValuesRaw, form, rootField]);
form.validateFields(flattenObjectKeys(initialValues));
}, [initialValues, form]);

const handleValuesChange = (changedValues: any, allValues: any) => {
if (JSON.stringify(allValues) === JSON.stringify(initialValues)) {
Expand Down

0 comments on commit ea1880f

Please sign in to comment.