UploadAppData error state handled

This commit is contained in:
Kasra Bigdeli
2019-01-02 19:02:13 -08:00
parent f859f95811
commit bc3e62bdd0
5 changed files with 15 additions and 2 deletions
+2
View File
@@ -85,12 +85,14 @@ export default class HttpClient {
return new Promise(function(resolve, reject) {
// data.data here is the "data" field inside the API response! {status: 100, description: "Login succeeded", data: {…}}
if (!self.isDestroyed) return resolve(data.data);
Logger.dev("Destroyed then not called");
});
})
.catch(function(error) {
Logger.error(error);
return new Promise(function(resolve, reject) {
if (!self.isDestroyed) return reject(error);
Logger.dev("Destroyed catch not called");
});
});
};
@@ -30,6 +30,7 @@ export default class BuildLogsView extends ApiComponent<
}
componentWillUnmount() {
if (super.componentWillMount) super.componentWillMount();
if (this.fetchBuildLogsInterval) {
clearInterval(this.fetchBuildLogsInterval);
}
@@ -52,17 +52,25 @@ export default class TarUploader extends ApiComponent<
startUploadAndDeploy() {
const self = this;
const file = self.state.fileToBeUploaded!;
self.setState({ fileToBeUploaded: undefined });
message.info("Upload has started");
Promise.resolve()
.then(function() {
return self.apiManager.uploadAppData(
self.props.appName,
self.state.fileToBeUploaded!.originFileObj!
file.originFileObj!
);
})
.then(function() {
self.props.onUploadSucceeded();
})
.catch(Toaster.createCatcher());
.catch(
Toaster.createCatcher(function() {
self.setState({ fileToBeUploaded: file });
})
);
}
render() {
@@ -44,6 +44,7 @@ export default class OneClickAppConfigPage extends Component<
}
componentWillUnmount() {
if (super.componentWillMount) super.componentWillMount();
this.isUnmount = true;
}
@@ -61,6 +61,7 @@ export default class LoadBalancerStats extends ApiComponent<
}
componentWillUnmount() {
if (super.componentWillMount) super.componentWillMount();
if (this.updateApiInterval) {
clearInterval(this.updateApiInterval);
}