mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Respect static list of allowed namespaces (#1639)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
67f3f83610
commit
29f2497d48
@ -5,6 +5,7 @@ import { Namespace, namespacesApi } from "../../api/endpoints";
|
||||
import { IQueryParams, navigation, setQueryParams } from "../../navigation";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { isAllowedResource } from "../../../common/rbac";
|
||||
import { getHostedCluster } from "../../../common/cluster-store";
|
||||
|
||||
@autobind()
|
||||
export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||
@ -41,6 +42,17 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||
};
|
||||
}
|
||||
|
||||
subscribe(apis = [this.api]) {
|
||||
const { allowedNamespaces } = getHostedCluster();
|
||||
|
||||
// if user has given static list of namespaces let's not start watches because watch adds stuff that's not wanted
|
||||
if (allowedNamespaces.length > 0) {
|
||||
return () => { return; };
|
||||
}
|
||||
|
||||
return super.subscribe(apis);
|
||||
}
|
||||
|
||||
protected updateUrl(namespaces: string[]) {
|
||||
setQueryParams({ namespaces }, { replace: true });
|
||||
}
|
||||
|
||||
@ -83,9 +83,9 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
|
||||
let items: T[];
|
||||
|
||||
try {
|
||||
const { isAdmin, allowedNamespaces } = getHostedCluster();
|
||||
const { allowedNamespaces } = getHostedCluster();
|
||||
|
||||
items = await this.loadItems(!isAdmin ? allowedNamespaces : null);
|
||||
items = await this.loadItems(allowedNamespaces);
|
||||
items = this.filterItemsOnLoad(items);
|
||||
} finally {
|
||||
if (items) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user