From 3bdb3dfba9208e37d3f4d4140774feb130a0744d Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Thu, 7 Oct 2021 09:58:47 -0400 Subject: [PATCH] Fix NamespaceSelectFilter all namespaces button Signed-off-by: Sebastian Malton --- .../+namespaces/namespace-select-filter.tsx | 2 +- .../components/+namespaces/namespace.store.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/+namespaces/namespace-select-filter.tsx b/src/renderer/components/+namespaces/namespace-select-filter.tsx index 5863e4244f..27f3ac959f 100644 --- a/src/renderer/components/+namespaces/namespace-select-filter.tsx +++ b/src/renderer/components/+namespaces/namespace-select-filter.tsx @@ -121,7 +121,7 @@ export class NamespaceSelectFilter extends React.Component { namespaceStore.toggleSingle(namespace); } } else { - namespaceStore.toggleAll(true); // "All namespaces" clicked + namespaceStore.selectAll(); } }; diff --git a/src/renderer/components/+namespaces/namespace.store.ts b/src/renderer/components/+namespaces/namespace.store.ts index 54f98702fc..7eb9fa2256 100644 --- a/src/renderer/components/+namespaces/namespace.store.ts +++ b/src/renderer/components/+namespaces/namespace.store.ts @@ -149,7 +149,7 @@ export class NamespaceStore extends KubeObjectStore { } @computed get hasAllContexts(): boolean { - return this.selectedNamespaces.length === this.allowedNamespaces.length; + return this.contextNamespaces.length === this.allowedNamespaces.length; } @action @@ -167,8 +167,18 @@ export class NamespaceStore extends KubeObjectStore { this.selectNamespaces(namespace); } + @action + selectAll() { + this.selectNamespaces([]); // Empty array means "all" + } + + /** + * @deprecated This function is broken, `showAll` is opposite of what + */ @action toggleAll(showAll?: boolean) { + console.warn("NamespaceStore.toggleAll is deprecated. Use selectAll"); + if (typeof showAll === "boolean") { if (showAll) { this.selectNamespaces(this.allowedNamespaces);