summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/clusters
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
parent4ab54c2233e91f60a80e5b6fa2181e6899fdcc3e (diff)
downloadgitlab-ce-80f61b4035607d7cd87de993b8f5e996bde3481f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/clusters')
-rw-r--r--app/assets/javascripts/clusters/clusters_bundle.js54
-rw-r--r--app/assets/javascripts/clusters/services/clusters_service.js2
-rw-r--r--app/assets/javascripts/clusters/stores/clusters_store.js1
3 files changed, 33 insertions, 24 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);
diff --git a/app/assets/javascripts/clusters/services/clusters_service.js b/app/assets/javascripts/clusters/services/clusters_service.js
index 9139e0beafb..fa12802b3de 100644
--- a/app/assets/javascripts/clusters/services/clusters_service.js
+++ b/app/assets/javascripts/clusters/services/clusters_service.js
@@ -17,7 +17,7 @@ export default class ClusterService {
};
}
- fetchData() {
+ fetchClusterStatus() {
return axios.get(this.options.endpoint);
}
diff --git a/app/assets/javascripts/clusters/stores/clusters_store.js b/app/assets/javascripts/clusters/stores/clusters_store.js
index a032f589ee4..5cddb4cc098 100644
--- a/app/assets/javascripts/clusters/stores/clusters_store.js
+++ b/app/assets/javascripts/clusters/stores/clusters_store.js
@@ -218,6 +218,7 @@ export default class ClusterStore {
environmentPath: environment.environment_path,
lastDeployment: environment.last_deployment,
rolloutStatus: {
+ status: environment.rollout_status ? environment.rollout_status.status : null,
instances: environment.rollout_status ? environment.rollout_status.instances : [],
},
updatedAt: environment.updated_at,