From 354597bd60944c35bc71f5c2d4ecc2d881c70f84 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Fri, 5 Feb 2021 09:44:57 +0200 Subject: [PATCH] Revert "proper select-all option for NamespaceSelect (#2084)" This reverts commit b514e5c833e9166e8c046e0ba5d308df752ac25e. Signed-off-by: Jari Kolehmainen --- src/renderer/api/kube-watch-api.ts | 1 - .../+namespaces/namespace-select.tsx | 5 +++-- .../components/+namespaces/namespace.store.ts | 21 ++----------------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/renderer/api/kube-watch-api.ts b/src/renderer/api/kube-watch-api.ts index 06cab9c06c..d3b2b4512a 100644 --- a/src/renderer/api/kube-watch-api.ts +++ b/src/renderer/api/kube-watch-api.ts @@ -70,7 +70,6 @@ export class KubeWatchApi { return []; } - // TODO: optimize - check when all namespaces are selected and then request all in one if (api.isNamespaced && !this.cluster.isGlobalWatchEnabled) { return this.namespaces.map(namespace => api.getWatchUrl(namespace)); } diff --git a/src/renderer/components/+namespaces/namespace-select.tsx b/src/renderer/components/+namespaces/namespace-select.tsx index c3d26ba192..5bcf07e1cf 100644 --- a/src/renderer/components/+namespaces/namespace-select.tsx +++ b/src/renderer/components/+namespaces/namespace-select.tsx @@ -85,9 +85,10 @@ export class NamespaceSelectFilter extends React.Component { const namespaces = namespaceStore.getContextNamespaces(); switch (namespaces.length) { - case 0: case namespaceStore.allowedNamespaces.length: return <>All namespaces; + case 0: + return <>Select a namespace; case 1: return <>Namespace: {namespaces[0]}; default: @@ -115,7 +116,7 @@ export class NamespaceSelectFilter extends React.Component { if (namespace) { namespaceStore.toggleContext(namespace); } else { - namespaceStore.resetContext(); // "All namespaces" clicked, empty list considered as "all" + namespaceStore.toggleAll(); // "All namespaces" option clicked } }; diff --git a/src/renderer/components/+namespaces/namespace.store.ts b/src/renderer/components/+namespaces/namespace.store.ts index 51f7606e8b..c56043766a 100644 --- a/src/renderer/components/+namespaces/namespace.store.ts +++ b/src/renderer/components/+namespaces/namespace.store.ts @@ -103,20 +103,8 @@ export class NamespaceStore extends KubeObjectStore { return []; } - getContextNamespaces(): string[] { - const namespaces = Array.from(this.contextNs); - - // show all namespaces when nothing selected - if (!namespaces.length) { - // return actual namespaces list since "allowedNamespaces" updating every 30s in cluster and thus might be stale - if (this.isLoaded) { - return this.items.map(namespace => namespace.getName()); - } - - return this.allowedNamespaces; - } - - return namespaces; + public getContextNamespaces(): string[] { + return Array.from(this.contextNs); } getSubscribeApis() { @@ -151,11 +139,6 @@ export class NamespaceStore extends KubeObjectStore { this.contextNs.replace(namespaces); } - @action - resetContext() { - this.contextNs.clear(); - } - hasContext(namespaces: string | string[]) { return [namespaces].flat().every(namespace => this.contextNs.has(namespace)); }