From 34a7dc57b28fd4e9812ce88ede3c8c84a383ba7f Mon Sep 17 00:00:00 2001 From: ronahk <74967920+ronahk@users.noreply.github.com> Date: Wed, 16 Nov 2022 13:50:32 +0200 Subject: [PATCH] Use namespace defined in kubeconfig as default in install view (#99) * respect defualt namespace from kubeconfig * respect defualt namespace from kubeconfig * Replace exists with available - avoid confusion in status * use data attribute * remove commented line * fix --- pkg/dashboard/static/actions.js | 2 +- pkg/dashboard/static/repo.js | 4 +++- pkg/dashboard/static/scripts.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/dashboard/static/actions.js b/pkg/dashboard/static/actions.js index 6113e2e..d20ec32 100644 --- a/pkg/dashboard/static/actions.js +++ b/pkg/dashboard/static/actions.js @@ -70,7 +70,7 @@ function popUpUpgrade(elm, ns, name, verCur, lastRev) { $("#upgradeModalLabel .type").text("Install") $("#upgradeModal .ver-old").hide() $("#upgradeModal .rel-name").prop("disabled", false).val(elm.name.split("/").pop()) - $("#upgradeModal .rel-ns").prop("disabled", false).val("") + $("#upgradeModal .rel-ns").prop("disabled", false).val(ns) } $.getJSON("/api/helm/repo/search?name=" + elm.name).fail(function (xhr) { diff --git a/pkg/dashboard/static/repo.js b/pkg/dashboard/static/repo.js index f79cec6..9b9be9e 100644 --- a/pkg/dashboard/static/repo.js +++ b/pkg/dashboard/static/repo.js @@ -130,6 +130,8 @@ function repoChartClicked() { setHashParam("chart", elm.installed_name) window.location.reload() } else { - popUpUpgrade(elm) + const contexts = $("body").data("contexts") + contextNamespace = contexts.filter(obj => {return obj.Name === getHashParam("context")})[0].Namespace + popUpUpgrade(elm, contextNamespace) } } \ No newline at end of file diff --git a/pkg/dashboard/static/scripts.js b/pkg/dashboard/static/scripts.js index 4e9d0ba..f81288f 100644 --- a/pkg/dashboard/static/scripts.js +++ b/pkg/dashboard/static/scripts.js @@ -4,10 +4,10 @@ $(function () { window.location.href = "/#context=" + clusterSelect.find("input:radio:checked").val() window.location.reload() }) - $.getJSON("/api/kube/contexts").fail(function (xhr) { reportError("Failed to get list of clusters", xhr) }).done(function (data) { + $("body").data("contexts", data) const context = getHashParam("context") data.sort((a, b) => (getCleanClusterName(a.Name) > getCleanClusterName(b.Name)) - (getCleanClusterName(a.Name) < getCleanClusterName(b.Name))) fillClusterList(data, context);