diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-01 18:09:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-01 18:09:28 +0300 |
commit | 893ba862a7808ac7099c0d5c6d6ad618ae4e2665 (patch) | |
tree | 1465b217b3111ddc7b0120bdbbce2ebc377f42fa /app/assets/javascripts/pipeline_new | |
parent | 7b2635a55d4e87431bae752bd44c6fd2d2657b03 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/pipeline_new')
-rw-r--r-- | app/assets/javascripts/pipeline_new/components/pipeline_new_form.vue | 55 | ||||
-rw-r--r-- | app/assets/javascripts/pipeline_new/constants.js | 1 |
2 files changed, 38 insertions, 18 deletions
diff --git a/app/assets/javascripts/pipeline_new/components/pipeline_new_form.vue b/app/assets/javascripts/pipeline_new/components/pipeline_new_form.vue index 6552665100a..790460c79f1 100644 --- a/app/assets/javascripts/pipeline_new/components/pipeline_new_form.vue +++ b/app/assets/javascripts/pipeline_new/components/pipeline_new_form.vue @@ -19,7 +19,9 @@ import { import { s__, __, n__ } from '~/locale'; import axios from '~/lib/utils/axios_utils'; import { redirectTo } from '~/lib/utils/url_utility'; -import { VARIABLE_TYPE, FILE_TYPE } from '../constants'; +import { VARIABLE_TYPE, FILE_TYPE, CONFIG_VARIABLES_TIMEOUT } from '../constants'; +import { backOff } from '~/lib/utils/common_utils'; +import httpStatusCodes from '~/lib/utils/http_status'; export default { typeOptions: [ @@ -211,32 +213,49 @@ export default { }, fetchConfigVariables(refValue) { - if (gon?.features?.newPipelineFormPrefilledVars) { - this.isLoading = true; + if (!gon?.features?.newPipelineFormPrefilledVars) { + return Promise.resolve({ params: {}, descriptions: {} }); + } + + this.isLoading = true; - return axios + return backOff((next, stop) => { + axios .get(this.configVariablesPath, { params: { sha: refValue, }, }) - .then(({ data }) => { - const params = {}; - const descriptions = {}; + .then(({ data, status }) => { + if (status === httpStatusCodes.NO_CONTENT) { + next(); + } else { + this.isLoading = false; + stop(data); + } + }) + .catch(error => { + stop(error); + }); + }, CONFIG_VARIABLES_TIMEOUT) + .then(data => { + const params = {}; + const descriptions = {}; - Object.entries(data).forEach(([key, { value, description }]) => { - if (description !== null) { - params[key] = value; - descriptions[key] = description; - } - }); + Object.entries(data).forEach(([key, { value, description }]) => { + if (description !== null) { + params[key] = value; + descriptions[key] = description; + } + }); - this.isLoading = false; + return { params, descriptions }; + }) + .catch(() => { + this.isLoading = false; - return { params, descriptions }; - }); - } - return Promise.resolve({ params: {}, descriptions: {} }); + return { params: {}, descriptions: {} }; + }); }, createPipeline() { const filteredVariables = this.variables diff --git a/app/assets/javascripts/pipeline_new/constants.js b/app/assets/javascripts/pipeline_new/constants.js index b4ab1143f60..3d4a0ee328d 100644 --- a/app/assets/javascripts/pipeline_new/constants.js +++ b/app/assets/javascripts/pipeline_new/constants.js @@ -1,2 +1,3 @@ export const VARIABLE_TYPE = 'env_var'; export const FILE_TYPE = 'file'; +export const CONFIG_VARIABLES_TIMEOUT = 5000; |