fix: wait for contextReady in NamespaceStore

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

No files matched your search

+4 -1
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,
});
}));
}
@@ -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();
@@ -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));
}