mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: reverting NamespaceStore public-api breaking changes
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
a9d0af1656
commit
68001990a0
@ -14,14 +14,14 @@ export const namespaceUrlParam = createPageParam<string[]>({
|
|||||||
isSystem: true,
|
isSystem: true,
|
||||||
multiValues: true,
|
multiValues: true,
|
||||||
get defaultValue() {
|
get defaultValue() {
|
||||||
return storage.get();
|
return storage.get(); // initial namespaces coming from URL or local-storage (default)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
export class NamespaceStore extends KubeObjectStore<Namespace> {
|
export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||||
api = namespacesApi;
|
api = namespacesApi;
|
||||||
contextNs = observable.array<string>(storage.get());
|
contextNs = observable.array<string>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -29,8 +29,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private init() {
|
private init() {
|
||||||
// setup initial context namespaces from URL (when provided) or local-storage (default)
|
this.setContext(this.initNamespaces);
|
||||||
this.setContext(namespaceUrlParam.get());
|
|
||||||
|
|
||||||
return reaction(() => this.contextNs.toJS(), namespaces => {
|
return reaction(() => this.contextNs.toJS(), namespaces => {
|
||||||
storage.set(namespaces); // save to local-storage
|
storage.set(namespaces); // save to local-storage
|
||||||
@ -41,12 +40,22 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get initNamespaces() {
|
||||||
|
return namespaceUrlParam.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
getContextParams() {
|
||||||
|
return {
|
||||||
|
namespaces: this.contextNs.toJS(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
subscribe(apis = [this.api]) {
|
subscribe(apis = [this.api]) {
|
||||||
const { allowedNamespaces } = getHostedCluster();
|
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 user has given static list of namespaces let's not start watches because watch adds stuff that's not wanted
|
||||||
if (allowedNamespaces.length > 0) {
|
if (allowedNamespaces.length > 0) {
|
||||||
return () => { return; };
|
return Function; // no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.subscribe(apis);
|
return super.subscribe(apis);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user