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

fix: wait for contextReady in NamespaceStore

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2021-02-05 14:51:04 +02:00
parent 77e3a7fb83
commit 36d54c64fc
3 changed files with 6 additions and 3 deletions

View File

@ -26,6 +26,7 @@ export interface IKubeWatchMessage<T extends KubeObject = any> {
}
export interface IKubeWatchSubscribeStoreOptions {
namespaces?: string[]; // todo: support custom namespaces to subscribe
preload?: boolean; // preload store items, default: true
waitUntilLoaded?: boolean; // subscribe only after loading all stores, default: true
loadOnce?: boolean; // check store.isLoaded to skip loading if done already, default: false
@ -133,7 +134,9 @@ export class KubeWatchApi {
preloading.push(limitRequests(async () => {
if (store.isLoaded && opts.loadOnce) return; // skip
return store.loadAll({ namespaces: opts.namespaces });
return store.loadAll({
namespaces: opts.namespaces ?? this.context?.contextNamespaces,
});
}));
}

View File

@ -41,7 +41,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
}
private async init() {
if (!this.context) return; // skip for non-cluster context window
await this.contextReady;
this.setContext(this.initialNamespaces);
this.autoLoadAllowedNamespaces();

View File

@ -138,7 +138,7 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
const { store, dependentStores } = this.props;
const stores = Array.from(new Set([store, ...dependentStores]));
// loads context namespaces by default (see also: `<NamespaceSelectFilter/>`)
// load context namespaces by default (see also: `<NamespaceSelectFilter/>`)
stores.forEach(store => store.loadAll(namespaceStore.contextNamespaces));
}