Adds callback function to inital cluster request

This commit is contained in:
Filipa Lacerda 2017-10-31 10:54:06 +00:00
parent 7e78db6e04
commit ca01ee515c
No known key found for this signature in database
GPG Key ID: 9CA3FDE4D1E2F1C8
2 changed files with 19 additions and 8 deletions

View File

@ -64,19 +64,16 @@ export default class Clusters {
this.poll = new Poll({
resource: this.service,
method: 'fetchData',
successCallback: (data) => {
const { status, status_reason } = data.data;
this.updateContainer(status, status_reason);
},
errorCallback: () => {
Flash(s__('ClusterIntegration|Something went wrong on our end.'));
},
successCallback: data => this.handleSuccess(data),
errorCallback: () => Clusters.handleError(),
});
if (!Visibility.hidden()) {
this.poll.makeRequest();
} else {
this.service.fetchData();
this.service.fetchData()
.then(data => this.handleSuccess(data))
.catch(() => Clusters.handleError());
}
Visibility.change(() => {
@ -88,6 +85,15 @@ export default class Clusters {
});
}
static handleError() {
Flash(s__('ClusterIntegration|Something went wrong on our end.'));
}
handleSuccess(data) {
const { status, status_reason } = data.data;
this.updateContainer(status, status_reason);
}
hideAll() {
this.errorContainer.classList.add('hidden');
this.successContainer.classList.add('hidden');

View File

@ -0,0 +1,5 @@
---
title: Adds callback functions for initial request in clusters page
merge_request:
author:
type: fixed