Adds callback function to inital cluster request
This commit is contained in:
parent
7e78db6e04
commit
ca01ee515c
2 changed files with 19 additions and 8 deletions
|
@ -64,19 +64,16 @@ export default class Clusters {
|
||||||
this.poll = new Poll({
|
this.poll = new Poll({
|
||||||
resource: this.service,
|
resource: this.service,
|
||||||
method: 'fetchData',
|
method: 'fetchData',
|
||||||
successCallback: (data) => {
|
successCallback: data => this.handleSuccess(data),
|
||||||
const { status, status_reason } = data.data;
|
errorCallback: () => Clusters.handleError(),
|
||||||
this.updateContainer(status, status_reason);
|
|
||||||
},
|
|
||||||
errorCallback: () => {
|
|
||||||
Flash(s__('ClusterIntegration|Something went wrong on our end.'));
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Visibility.hidden()) {
|
if (!Visibility.hidden()) {
|
||||||
this.poll.makeRequest();
|
this.poll.makeRequest();
|
||||||
} else {
|
} else {
|
||||||
this.service.fetchData();
|
this.service.fetchData()
|
||||||
|
.then(data => this.handleSuccess(data))
|
||||||
|
.catch(() => Clusters.handleError());
|
||||||
}
|
}
|
||||||
|
|
||||||
Visibility.change(() => {
|
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() {
|
hideAll() {
|
||||||
this.errorContainer.classList.add('hidden');
|
this.errorContainer.classList.add('hidden');
|
||||||
this.successContainer.classList.add('hidden');
|
this.successContainer.classList.add('hidden');
|
||||||
|
|
5
changelogs/unreleased/39639-clusters-poll.yml
Normal file
5
changelogs/unreleased/39639-clusters-poll.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Adds callback functions for initial request in clusters page
|
||||||
|
merge_request:
|
||||||
|
author:
|
||||||
|
type: fixed
|
Loading…
Reference in a new issue