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

Keep feature install loading state

Waiting for props to change before
disabling loading state (gray button
width spinner)

Signed-off-by: alexfront <alex.andreev.email@gmail.com>
This commit is contained in:
alexfront 2020-08-07 13:13:22 +03:00
parent e2abd8b7eb
commit fbbbe6241a

View File

@ -1,6 +1,6 @@
import React from "react";
import { observable } from "mobx";
import { observer } from "mobx-react";
import { observable, reaction } from "mobx";
import { observer, disposeOnUnmount } from "mobx-react";
import { clusterIpc } from "../../../../common/cluster-ipc";
import { Cluster } from "../../../../main/cluster";
import { Button } from "../../button";
@ -16,6 +16,14 @@ interface Props {
export class InstallFeature extends React.Component<Props> {
@observable loading = false;
componentDidMount() {
disposeOnUnmount(this, [
reaction(() => this.props.cluster.features[this.props.feature], () => {
this.loading = false;
})
]);
}
getActionButtons() {
const { cluster, feature } = this.props;
const features = cluster.features[feature];
@ -65,14 +73,12 @@ export class InstallFeature extends React.Component<Props> {
runAction(action: () => Promise<any>): () => Promise<void> {
return async () => {
const { cluster, feature } = this.props;
try {
this.loading = true;
await action();
} catch (err) {
Notifications.error(err.toString());
}
this.loading = false;
};
}