mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Workloads overview: don't block on store load (#1829)
* workloads overview: don't block on store load Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * subscribe after loadAll Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
beaf2c69ff
commit
8bc42e91b4
@ -14,7 +14,6 @@ import { statefulSetStore } from "../+workloads-statefulsets/statefulset.store";
|
|||||||
import { replicaSetStore } from "../+workloads-replicasets/replicasets.store";
|
import { replicaSetStore } from "../+workloads-replicasets/replicasets.store";
|
||||||
import { jobStore } from "../+workloads-jobs/job.store";
|
import { jobStore } from "../+workloads-jobs/job.store";
|
||||||
import { cronJobStore } from "../+workloads-cronjobs/cronjob.store";
|
import { cronJobStore } from "../+workloads-cronjobs/cronjob.store";
|
||||||
import { Spinner } from "../spinner";
|
|
||||||
import { Events } from "../+events";
|
import { Events } from "../+events";
|
||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { isAllowedResource } from "../../../common/rbac";
|
import { isAllowedResource } from "../../../common/rbac";
|
||||||
@ -24,7 +23,6 @@ interface Props extends RouteComponentProps<IWorkloadsOverviewRouteParams> {
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class WorkloadsOverview extends React.Component<Props> {
|
export class WorkloadsOverview extends React.Component<Props> {
|
||||||
@observable isReady = false;
|
|
||||||
@observable isUnmounting = false;
|
@observable isUnmounting = false;
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
@ -61,10 +59,13 @@ export class WorkloadsOverview extends React.Component<Props> {
|
|||||||
if (isAllowedResource("events")) {
|
if (isAllowedResource("events")) {
|
||||||
stores.push(eventStore);
|
stores.push(eventStore);
|
||||||
}
|
}
|
||||||
this.isReady = stores.every(store => store.isLoaded);
|
|
||||||
await Promise.all(stores.map(store => store.loadAll()));
|
const unsubscribeList: Array<() => void> = [];
|
||||||
this.isReady = true;
|
|
||||||
const unsubscribeList = stores.map(store => store.subscribe());
|
for (const store of stores) {
|
||||||
|
await store.loadAll();
|
||||||
|
unsubscribeList.push(store.subscribe());
|
||||||
|
}
|
||||||
|
|
||||||
await when(() => this.isUnmounting);
|
await when(() => this.isUnmounting);
|
||||||
unsubscribeList.forEach(dispose => dispose());
|
unsubscribeList.forEach(dispose => dispose());
|
||||||
@ -74,11 +75,7 @@ export class WorkloadsOverview extends React.Component<Props> {
|
|||||||
this.isUnmounting = true;
|
this.isUnmounting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderContents() {
|
get contents() {
|
||||||
if (!this.isReady) {
|
|
||||||
return <Spinner center/>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<OverviewStatuses/>
|
<OverviewStatuses/>
|
||||||
@ -94,7 +91,7 @@ export class WorkloadsOverview extends React.Component<Props> {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="WorkloadsOverview flex column gaps">
|
<div className="WorkloadsOverview flex column gaps">
|
||||||
{this.renderContents()}
|
{this.contents}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user