summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/mixins
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2018-04-11 14:12:10 +0100
committerFilipa Lacerda <filipa@gitlab.com>2018-04-13 18:57:13 +0100
commitcac2ed25d0ded19c73cb28df25bae121cdf38a20 (patch)
tree7935399f7e05e9d240be9166f58f26b265cfc209 /app/assets/javascripts/pipelines/mixins
parent0bc8440d4eb401a86bd154514425a73213e80063 (diff)
downloadgitlab-ce-cac2ed25d0ded19c73cb28df25bae121cdf38a20.tar.gz
Handle cancelled request40487-stop-polling
[ci skip] Adds specs Adds specs
Diffstat (limited to 'app/assets/javascripts/pipelines/mixins')
-rw-r--r--app/assets/javascripts/pipelines/mixins/pipelines.js31
1 files changed, 19 insertions, 12 deletions
diff --git a/app/assets/javascripts/pipelines/mixins/pipelines.js b/app/assets/javascripts/pipelines/mixins/pipelines.js
index a70b777d726..6d87f75ae8e 100644
--- a/app/assets/javascripts/pipelines/mixins/pipelines.js
+++ b/app/assets/javascripts/pipelines/mixins/pipelines.js
@@ -7,6 +7,7 @@ import SvgBlankState from '../components/blank_state.vue';
import LoadingIcon from '../../vue_shared/components/loading_icon.vue';
import PipelinesTableComponent from '../components/pipelines_table.vue';
import eventHub from '../event_hub';
+import { CANCEL_REQUEST } from '../constants';
export default {
components: {
@@ -65,15 +66,13 @@ export default {
updateTable() {
// Cancel ongoing request
if (this.isMakingRequest) {
- this.service.cancelationSource.cancel();
+ this.service.cancelationSource.cancel(CANCEL_REQUEST);
}
-
// Stop polling
this.poll.stop();
- // make new request
- this.getPipelines();
- // restart polling
- this.poll.restart();
+ // Update the table
+ return this.getPipelines()
+ .then(() => this.poll.restart());
},
fetchPipelines() {
if (!this.isMakingRequest) {
@@ -83,21 +82,29 @@ export default {
}
},
getPipelines() {
- this.service.getPipelines(this.requestData)
+ return this.service.getPipelines(this.requestData)
.then(response => this.successCallback(response))
- .catch(() => this.errorCallback());
+ .catch((error) => this.errorCallback(error));
},
setCommonData(pipelines) {
this.store.storePipelines(pipelines);
this.isLoading = false;
this.updateGraphDropdown = true;
this.hasMadeRequest = true;
+
+ // In case the previous polling request returned an error, we need to reset it
+ if (this.hasError) {
+ this.hasError = false;
+ }
},
- errorCallback() {
- this.hasError = true;
- this.isLoading = false;
- this.updateGraphDropdown = false;
+ errorCallback(error) {
this.hasMadeRequest = true;
+ this.isLoading = false;
+
+ if (error && error.message && error.message !== CANCEL_REQUEST) {
+ this.hasError = true;
+ this.updateGraphDropdown = false;
+ }
},
setIsMakingRequest(isMakingRequest) {
this.isMakingRequest = isMakingRequest;