mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fixes / responding to comments
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
ddf45c2025
commit
62e0f575c7
@ -60,12 +60,11 @@ export class ReleaseStore extends ItemStore<HelmRelease> {
|
||||
@action
|
||||
async loadAll() {
|
||||
this.isLoading = true;
|
||||
let items: HelmRelease[];
|
||||
|
||||
try {
|
||||
items = await this.loadItems(namespaceStore.getContextNamespaces());
|
||||
items = this.sortItems(items);
|
||||
this.items.replace(items);
|
||||
const items = await this.loadItems(namespaceStore.getContextNamespaces());
|
||||
|
||||
this.items.replace(this.sortItems(items));
|
||||
this.isLoaded = true;
|
||||
} catch (error) {
|
||||
console.error(`Loading Helm Chart releases has failed: ${error}`);
|
||||
|
||||
@ -18,6 +18,19 @@ export const namespaceUrlParam = createPageParam<string[]>({
|
||||
}
|
||||
});
|
||||
|
||||
export function getDummyNamespace(name: string) {
|
||||
return new Namespace({
|
||||
kind: Namespace.kind,
|
||||
apiVersion: "v1",
|
||||
metadata: {
|
||||
name,
|
||||
uid: "",
|
||||
resourceVersion: "",
|
||||
selfLink: `/api/v1/namespaces/${name}`
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@autobind()
|
||||
export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||
api = namespacesApi;
|
||||
@ -59,7 +72,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||
equals: comparer.identity,
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
// auto-load allowed namespaces
|
||||
disposers.push(
|
||||
reaction(() => this.allowedNamespaces, () => this.loadAll(), {
|
||||
@ -112,15 +125,6 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||
return namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
getContextParams() {
|
||||
return {
|
||||
namespaces: this.getContextNamespaces(),
|
||||
};
|
||||
}
|
||||
|
||||
subscribe(apis = [this.api]) {
|
||||
const { accessibleNamespaces } = getHostedCluster();
|
||||
|
||||
@ -144,25 +148,12 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||
}
|
||||
|
||||
if (!isAllowedResource("namespaces")) {
|
||||
return namespaces.map(this.getDummyNamespace);
|
||||
return namespaces.map(getDummyNamespace);
|
||||
}
|
||||
|
||||
return Promise.all(namespaces.map(name => this.api.get({ name })));
|
||||
}
|
||||
|
||||
protected getDummyNamespace(name: string) {
|
||||
return new Namespace({
|
||||
kind: "Namespace",
|
||||
apiVersion: "v1",
|
||||
metadata: {
|
||||
name,
|
||||
uid: "",
|
||||
resourceVersion: "",
|
||||
selfLink: `/api/v1/namespaces/${name}`
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
setContext(namespaces: string[]) {
|
||||
this.contextNs.replace(namespaces);
|
||||
|
||||
@ -39,9 +39,7 @@ export class WorkloadsOverview extends React.Component<Props> {
|
||||
isAllowedResource("events") && eventStore,
|
||||
].filter(Boolean);
|
||||
|
||||
const unsubscribeMap = new Map<KubeObjectStore, Function>(
|
||||
stores.map(store => [store, Function])
|
||||
);
|
||||
const unsubscribeMap = new Map<KubeObjectStore, () => void>();
|
||||
|
||||
const loadStores = async () => {
|
||||
this.isLoading = true;
|
||||
@ -52,7 +50,7 @@ export class WorkloadsOverview extends React.Component<Props> {
|
||||
try {
|
||||
store.reset();
|
||||
await store.loadAll();
|
||||
unsubscribeMap.get(store)(); // unsubscribe previous watcher
|
||||
unsubscribeMap.get(store)?.(); // unsubscribe previous watcher
|
||||
unsubscribeMap.set(store, store.subscribe());
|
||||
} catch (error) {
|
||||
console.error("loading store error", error);
|
||||
|
||||
@ -2,7 +2,7 @@ import "./item-list-layout.scss";
|
||||
import groupBy from "lodash/groupBy";
|
||||
|
||||
import React, { ReactNode } from "react";
|
||||
import { computed, IReactionDisposer, observable, reaction, toJS, when } from "mobx";
|
||||
import { computed, IReactionDisposer, observable, reaction, toJS } from "mobx";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { ConfirmDialog, ConfirmDialogParams } from "../confirm-dialog";
|
||||
import { Table, TableCell, TableCellProps, TableHead, TableProps, TableRow, TableRowProps, TableSortCallback } from "../table";
|
||||
@ -92,7 +92,6 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
||||
|
||||
private watchDisposers: IReactionDisposer[] = [];
|
||||
|
||||
@observable isLoaded = false;
|
||||
@observable isUnmounting = false;
|
||||
|
||||
@observable userSettings: ItemListLayoutUserSettings = {
|
||||
@ -122,7 +121,6 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
||||
|
||||
async componentWillUnmount() {
|
||||
this.isUnmounting = true;
|
||||
await when(() => this.isLoaded);
|
||||
this.unsubscribeStores();
|
||||
}
|
||||
|
||||
@ -135,12 +133,14 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
||||
}
|
||||
|
||||
// reset
|
||||
this.isLoaded = false;
|
||||
this.unsubscribeStores();
|
||||
|
||||
// load
|
||||
for (const store of stores) {
|
||||
if (this.isUnmounting) break;
|
||||
if (this.isUnmounting) {
|
||||
this.unsubscribeStores();
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
store.reset();
|
||||
@ -150,7 +150,6 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
||||
console.error("loading store error", error);
|
||||
}
|
||||
}
|
||||
this.isLoaded = true;
|
||||
}
|
||||
|
||||
unsubscribeStores() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user