Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-10-31 15:14:59 +0300
committerPhil Hughes <me@iamphill.com>2017-10-31 15:14:59 +0300
commitde16fb138b1f0d9801c1a88cdabb4a3e3bdc6f5e (patch)
tree72ebd5cd441e838c351409a3e8ebf0a0edf1991a /app/assets/javascripts
parent19bf710354b0eb232232c80002c68e59f2cd842b (diff)
parentca01ee515ced41d43dc53dba0a9c63409b02f8dc (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
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/clusters.js22
1 files changed, 14 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');