1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Revert "proper select-all option for NamespaceSelect (#2084)"

This reverts commit b514e5c833.

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-02-05 09:44:57 +02:00
parent 19c0e73760
commit 354597bd60
3 changed files with 5 additions and 22 deletions

View File

@ -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));
}

View File

@ -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
}
};

View File

@ -103,20 +103,8 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
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<Namespace> {
this.contextNs.replace(namespaces);
}
@action
resetContext() {
this.contextNs.clear();
}
hasContext(namespaces: string | string[]) {
return [namespaces].flat().every(namespace => this.contextNs.has(namespace));
}