diff options
author | Phil Hughes <me@iamphill.com> | 2017-10-31 15:14:59 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-10-31 17:50:40 +0300 |
commit | ba31a2972b0513fbf4b81c56745135573829a367 (patch) | |
tree | 06c3277cf0c03fee01143e320779465b4c52bac9 | |
parent | 4a3fd8abcbca6d5c85cc88f50c46c4b6ffaada52 (diff) |
Merge branch '39639-clusters-poll' into 'master'
Adds callback function to initial cluster request
Closes #39639
See merge request gitlab-org/gitlab-ce!15105
-rw-r--r-- | app/assets/javascripts/clusters.js | 22 | ||||
-rw-r--r-- | changelogs/unreleased/39639-clusters-poll.yml | 5 |
2 files changed, 19 insertions, 8 deletions
diff --git a/app/assets/javascripts/clusters.js b/app/assets/javascripts/clusters.js index 50dbeb06362..b36df96a4d3 100644 --- a/app/assets/javascripts/clusters.js +++ b/app/assets/javascripts/clusters.js @@ -61,19 +61,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(() => { @@ -85,6 +82,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'); diff --git a/changelogs/unreleased/39639-clusters-poll.yml b/changelogs/unreleased/39639-clusters-poll.yml new file mode 100644 index 00000000000..f0a82f58b19 --- /dev/null +++ b/changelogs/unreleased/39639-clusters-poll.yml @@ -0,0 +1,5 @@ +--- +title: Adds callback functions for initial request in clusters page +merge_request: +author: +type: fixed |