summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-10-31 10:54:06 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-10-31 10:54:06 +0000
commitca01ee515ced41d43dc53dba0a9c63409b02f8dc (patch)
tree6ae842006ac0d4a61965855de29e58d0f6a859e2
parent7e78db6e04c3760c90d676e9a797b1b16b1dff7b (diff)
downloadgitlab-ce-39639-clusters-poll.tar.gz
Adds callback function to inital cluster request39639-clusters-poll
-rw-r--r--app/assets/javascripts/clusters.js22
-rw-r--r--changelogs/unreleased/39639-clusters-poll.yml5
2 files changed, 19 insertions, 8 deletions
diff --git a/app/assets/javascripts/clusters.js b/app/assets/javascripts/clusters.js
index 180aa30e98c..661870c226c 100644
--- a/app/assets/javascripts/clusters.js
+++ b/app/assets/javascripts/clusters.js
@@ -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');
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