Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reconfigure issue #443

Merged
merged 2 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ export const InstallChartModal = ({
refetch: refetchChartValues,
} = useChartRepoValues(namespace || "default", selectedVersion || "", chart, {
enabled: isInstall && Boolean(selectedRepo) && selectedRepo !== "",
onSuccess: (data) => {
if (data) {
fetchDiff({ userValues: data });
}
},
});

const { data: releaseValues, isLoading: loadingReleaseValues } =
Expand Down Expand Up @@ -154,12 +149,12 @@ export const InstallChartModal = ({
formData.append("chart", chart);
formData.append("version", selectedVersion || "");
formData.append("values", userValues);
formData.append("name", releaseName || "");

if (isInstall) {
formData.append("name", releaseName || "");
}
const res = await fetch(
// Todo: Change to BASE_URL from env
`/api/helm/releases/${namespace ? namespace : "default"}${
!isInstall ? `/${releaseName}` : `/${releaseValues ? chartName : ""}` // if there is no release we don't provide anything, and we dont display version
`/api/helm/releases/${namespace ? namespace : "default"}${!isInstall ? `/${releaseName}` : `/${releaseValues ? chartName : ""}` // if there is no release we don't provide anything, and we dont display version
}`,
{
method: "post",
Expand Down Expand Up @@ -189,8 +184,7 @@ export const InstallChartModal = ({
} else {
setSelectedVersionData({ version: "", urls: [] }); //cleanup
navigate(
`/${selectedCluster}/${
namespace ? namespace : "default"
`/${selectedCluster}/${namespace ? namespace : "default"
}/${releaseName}/installed/revision/${response.version}`
);
window.location.reload();
Expand All @@ -205,18 +199,20 @@ export const InstallChartModal = ({
const getVersionManifestFormData = useCallback(
({ version, userValues }: { version: string; userValues?: string }) => {
const formData = new FormData();
// preview needs to come first, for some reason it has a meaning at the backend
formData.append("preview", "true");
formData.append("chart", chart);
formData.append("version", version);
formData.append(
"values",
userValues ? userValues : releaseValues ? releaseValues : ""
);
formData.append("preview", "true");
formData.append("name", chartName);

if (isInstall) {
formData.append("name", chartName);
}
return formData;
},
[userValues, chart, chartName]
[userValues, chart, chartName, isInstall]
);

// It actually fetches the manifest for the diffs
Expand All @@ -228,13 +224,11 @@ export const InstallChartModal = ({
userValues?: string;
}) => {
const formData = getVersionManifestFormData({ version, userValues });
const fetchUrl = `/api/helm/releases/${
namespace ? namespace : isInstall ? "" : "[empty]"
}${
!isInstall
const fetchUrl = `/api/helm/releases/${namespace ? namespace : isInstall ? "" : "[empty]"
}${!isInstall
? `/${releaseName}`
: `${releaseValues ? chartName : !namespace ? "default" : ""}`
}`; // if there is no release we don't provide anything, and we dont display version;
}`; // if there is no release we don't provide anything, and we dont display version;
try {
setErrorMessage("");
const data = await callApi(fetchUrl, {
Expand Down Expand Up @@ -304,9 +298,8 @@ export const InstallChartModal = ({
}}
title={
<div className="font-bold">
{`${
isUpgrade || (!isUpgrade && !isInstall) ? "Upgrade" : "Install"
} `}
{`${isUpgrade || (!isUpgrade && !isInstall) ? "Upgrade" : "Install"
} `}
{(isUpgrade || releaseValues || isInstall) && (
<span className="text-green-700 ">{chartName}</span>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export const UserDefinedValues = ({
User-Defined Values:
</label>
<textarea
value={localState}
defaultValue={initialValue}
value={localState || initialValue}
onChange={(e) => setLocalState(e.target.value)}
rows={14}
className="block p-2.5 w-full text-md text-gray-900 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 resize-none font-monospace"
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/revision/RevisionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ const Uninstall = () => {
<div>Following resources will be deleted from the cluster:</div>
<div>
{resources?.map((resource) => (
<div className="flex justify-start gap-1 w-full mb-3">
<div key={resource.apiVersion + resource.kind + resource.metadata.name} className="flex justify-start gap-1 w-full mb-3">
<span
style={{
textAlign: "end",
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/revision/RevisionResource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function RevisionResource({ isLatest }: Props) {
})
.reverse()
.map((resource: StructuredResources) => (
<ResourceRow resource={resource} isLatest={isLatest} />
<ResourceRow key={resource.apiVersion + resource.kind + resource.metadata.name} resource={resource} isLatest={isLatest} />
))
) : (
<tr>
Expand Down
Loading