summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/clusters/clusters_bundle.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 14:02:45 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 14:02:45 +0000
commit80f61b4035607d7cd87de993b8f5e996bde3481f (patch)
tree06b12f51e97d87192e3dd0e05edf55143645b894 /app/assets/javascripts/clusters/clusters_bundle.js
parent4ab54c2233e91f60a80e5b6fa2181e6899fdcc3e (diff)
downloadgitlab-ce-80f61b4035607d7cd87de993b8f5e996bde3481f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/clusters/clusters_bundle.js')
-rw-r--r--app/assets/javascripts/clusters/clusters_bundle.js54
1 files changed, 31 insertions, 23 deletions
diff --git a/app/assets/javascripts/clusters/clusters_bundle.js b/app/assets/javascripts/clusters/clusters_bundle.js
index 28850710f80..d386960f3b6 100644
--- a/app/assets/javascripts/clusters/clusters_bundle.js
+++ b/app/assets/javascripts/clusters/clusters_bundle.js
@@ -111,15 +111,25 @@ export default class Clusters {
this.initApplications(clusterType);
this.initEnvironments();
- if (clusterEnvironmentsPath) {
- this.fetchEnvironments();
+ if (clusterEnvironmentsPath && this.environments) {
+ this.store.toggleFetchEnvironments(true);
+
+ this.initPolling(
+ 'fetchClusterEnvironments',
+ data => this.handleClusterEnvironmentsSuccess(data),
+ () => this.handleEnvironmentsPollError(),
+ );
}
this.updateContainer(null, this.store.state.status, this.store.state.statusReason);
this.addListeners();
if (statusPath && !this.environments) {
- this.initPolling();
+ this.initPolling(
+ 'fetchClusterStatus',
+ data => this.handleClusterStatusSuccess(data),
+ () => this.handlePollError(),
+ );
}
}
@@ -179,16 +189,9 @@ export default class Clusters {
});
}
- fetchEnvironments() {
- this.store.toggleFetchEnvironments(true);
-
- this.service
- .fetchClusterEnvironments()
- .then(data => {
- this.store.toggleFetchEnvironments(false);
- this.store.updateEnvironments(data.data);
- })
- .catch(() => Clusters.handleError());
+ handleClusterEnvironmentsSuccess(data) {
+ this.store.toggleFetchEnvironments(false);
+ this.store.updateEnvironments(data.data);
}
static initDismissableCallout() {
@@ -224,21 +227,16 @@ export default class Clusters {
eventHub.$off('uninstallApplication');
}
- initPolling() {
+ initPolling(method, successCallback, errorCallback) {
this.poll = new Poll({
resource: this.service,
- method: 'fetchData',
- successCallback: data => this.handleSuccess(data),
- errorCallback: () => Clusters.handleError(),
+ method,
+ successCallback,
+ errorCallback,
});
if (!Visibility.hidden()) {
this.poll.makeRequest();
- } else {
- this.service
- .fetchData()
- .then(data => this.handleSuccess(data))
- .catch(() => Clusters.handleError());
}
Visibility.change(() => {
@@ -250,11 +248,21 @@ export default class Clusters {
});
}
+ handlePollError() {
+ this.constructor.handleError();
+ }
+
+ handleEnvironmentsPollError() {
+ this.store.toggleFetchEnvironments(false);
+
+ this.handlePollError();
+ }
+
static handleError() {
Flash(s__('ClusterIntegration|Something went wrong on our end.'));
}
- handleSuccess(data) {
+ handleClusterStatusSuccess(data) {
const prevStatus = this.store.state.status;
const prevApplicationMap = Object.assign({}, this.store.state.applications);