diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 18:09:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 18:09:09 +0300 |
commit | d0bb0e04f40b962576353ce56e270aa7bd25a5c0 (patch) | |
tree | 8d78f5e9adf8d965f84869c936ac997e8748900e /app/assets/javascripts/vue_merge_request_widget | |
parent | 0eea37aefa31ed22e32eadbe6164dd92e3c64ec2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/vue_merge_request_widget')
-rw-r--r-- | app/assets/javascripts/vue_merge_request_widget/components/extensions/base.vue | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/app/assets/javascripts/vue_merge_request_widget/components/extensions/base.vue b/app/assets/javascripts/vue_merge_request_widget/components/extensions/base.vue index 0bc17de638b..0efc157bcdf 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/extensions/base.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/extensions/base.vue @@ -12,6 +12,7 @@ import { DynamicScroller, DynamicScrollerItem } from 'vendor/vue-virtual-scrolle import api from '~/api'; import { sprintf, s__, __ } from '~/locale'; import Poll from '~/lib/utils/poll'; +import { normalizeHeaders } from '~/lib/utils/common_utils'; import { EXTENSION_ICON_CLASS, EXTENSION_ICONS } from '../../constants'; import StatusIcon from './status_icon.vue'; import Actions from './actions.vue'; @@ -147,6 +148,35 @@ export default { this.triggerRedisTracking(); } }, + initExtensionMultiPolling() { + const allData = []; + const requests = this.fetchMultiData(); + + requests.forEach((request) => { + const poll = new Poll({ + resource: { + fetchData: () => request(this.$props), + }, + method: 'fetchData', + successCallback: (response) => { + const headers = normalizeHeaders(response.headers); + + if (!headers['POLL-INTERVAL']) { + allData.push(response.data); + } + + if (allData.length === requests.length) { + this.setCollapsedData(allData); + } + }, + errorCallback: (e) => { + this.setCollapsedError(e); + }, + }); + + poll.makeRequest(); + }); + }, initExtensionPolling() { const poll = new Poll({ resource: { @@ -172,7 +202,11 @@ export default { this.loadingState = LOADING_STATES.collapsedLoading; if (this.$options.enablePolling) { - this.initExtensionPolling(); + if (this.fetchMultiData) { + this.initExtensionMultiPolling(); + } else { + this.initExtensionPolling(); + } } else { this.fetchCollapsedData(this.$props) .then((data) => { |