Fix/chart-link-cluster-mode (#474)

This commit is contained in:
Nir Parisian
2023-10-02 19:10:04 +03:00
committed by GitHub
parent 88ea89a5ba
commit c251e6c697
19 changed files with 157 additions and 170 deletions

View File

@@ -1,5 +1,4 @@
import { useParams } from "react-router-dom";
import useAlertError from "../../../hooks/useAlertError";
import { useMemo, useState } from "react";
import { useGetVersions, useVersionData } from "../../../API/releases";
import Modal, { ModalButtonStyle } from "../Modal";
@@ -13,6 +12,7 @@ import { isNewerVersion, isNoneEmptyArray } from "../../../utils";
import { useDiffData } from "../../../API/shared";
import { InstallChartModalProps } from "../../../data/types";
import { DefinedValues } from "./DefinedValues";
import apiService from "../../../API/apiService";
export const InstallRepoChartModal = ({
isOpen,
@@ -22,7 +22,6 @@ export const InstallRepoChartModal = ({
latestVersion,
}: InstallChartModalProps) => {
const navigate = useNavigateWithSearchParams();
const { setShowErrorModal } = useAlertError();
const [userValues, setUserValues] = useState("");
const [installError, setInstallError] = useState("");
@@ -130,32 +129,20 @@ export const InstallRepoChartModal = ({
formData.append("version", selectedVersion || "");
formData.append("values", userValues);
formData.append("name", releaseName || "");
const res = await fetch(
// Todo: Change to BASE_URL from env
const data = await apiService.fetchWithDefaults(
`/api/helm/releases/${namespace ? namespace : "default"}`,
{
method: "post",
body: formData,
headers: {
"X-Kubecontext": selectedCluster as string,
},
}
);
if (!res.ok) {
setShowErrorModal({
title: "Failed to install the chart",
msg: String(await res.text()),
});
}
return res.json();
return data;
},
{
onSuccess: async (response) => {
onClose();
navigate(
`/${selectedCluster}/${response.namespace}/${response.name}/installed/revision/1`
`/${response.namespace}/${response.name}/installed/revision/1`
);
},
onError: (error) => {