From d4a73257c017c3eca16acdc091bf7babf7c9913c Mon Sep 17 00:00:00 2001 From: Jeroen Nijhuis Date: Wed, 7 Feb 2024 14:13:18 +0100 Subject: [PATCH] fix: don't crash with empty context --- src/components/ContextSwitcher.vue | 5 +++-- src/components/Navigation.vue | 4 ++++ src/components/RouterViewport.vue | 11 ++++++++++- src/components/ui/DataTable.vue | 5 +++-- src/router.ts | 3 +++ src/views/NoContext.vue | 5 +++++ 6 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 src/views/NoContext.vue diff --git a/src/components/ContextSwitcher.vue b/src/components/ContextSwitcher.vue index 0f863e8..d4a4f1d 100644 --- a/src/components/ContextSwitcher.vue +++ b/src/components/ContextSwitcher.vue @@ -66,8 +66,9 @@ onMounted(() => { class="flex flex-col w-full text-xs border rounded-lg p-2 text-left hover:bg-background" @click="showSingleCommand('switch-context')" > - {{ context }} - {{ namespace == "" ? "All namespaces" : namespace }} + {{ context || "No context" }} + {{ namespace == "" ? "All namespaces" : namespace }} + Click here to set context diff --git a/src/components/Navigation.vue b/src/components/Navigation.vue index 6ee1593..3ba996c 100644 --- a/src/components/Navigation.vue +++ b/src/components/Navigation.vue @@ -109,6 +109,10 @@ const formatResourceKind = (kind: string) => { }; const fetchResources = () => { + if (context.value === '') { + return; + } + clusterResources.value.clear(); Kubernetes.getCoreApiVersions(context.value).then((results) => { results.forEach((version) => { diff --git a/src/components/RouterViewport.vue b/src/components/RouterViewport.vue index deb20e4..31e30ab 100644 --- a/src/components/RouterViewport.vue +++ b/src/components/RouterViewport.vue @@ -1,13 +1,22 @@