diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-26 06:09:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-26 06:09:01 +0300 |
commit | baaa5c45c022d394bf1478d462a3b1aea413b7ed (patch) | |
tree | c18f52b77c9b4a92f504dfd1060e7495e293a937 /app/assets/javascripts/pipeline_editor | |
parent | b3618e799d30ae6df5c55e47b8ec8ebedb1af5a0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/pipeline_editor')
3 files changed, 21 insertions, 2 deletions
diff --git a/app/assets/javascripts/pipeline_editor/components/commit/commit_section.vue b/app/assets/javascripts/pipeline_editor/components/commit/commit_section.vue index edc8c126cc8..0308cd9c565 100644 --- a/app/assets/javascripts/pipeline_editor/components/commit/commit_section.vue +++ b/app/assets/javascripts/pipeline_editor/components/commit/commit_section.vue @@ -112,6 +112,9 @@ export default { this.$emit('commit', { type: COMMIT_SUCCESS }); this.updateLastCommitBranch(targetBranch); this.updateCurrentBranch(targetBranch); + if (this.currentBranch === targetBranch) { + this.$emit('updateCommitSha'); + } } } catch (error) { this.$emit('showError', { type: COMMIT_FAILURE, reasons: [error?.message] }); diff --git a/app/assets/javascripts/pipeline_editor/constants.js b/app/assets/javascripts/pipeline_editor/constants.js index d05b06d16db..bb03fa126a5 100644 --- a/app/assets/javascripts/pipeline_editor/constants.js +++ b/app/assets/javascripts/pipeline_editor/constants.js @@ -43,3 +43,5 @@ export const pipelineEditorTrackingOptions = { export const TEMPLATE_REPOSITORY_URL = 'https://gitlab.com/gitlab-org/gitlab-foss/tree/master/lib/gitlab/ci/templates'; + +export const COMMIT_SHA_POLL_INTERVAL = 1000; diff --git a/app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue b/app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue index 8650db42076..dcbfa431126 100644 --- a/app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue +++ b/app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue @@ -10,6 +10,7 @@ import ConfirmUnsavedChangesDialog from './components/ui/confirm_unsaved_changes import PipelineEditorEmptyState from './components/ui/pipeline_editor_empty_state.vue'; import PipelineEditorMessages from './components/ui/pipeline_editor_messages.vue'; import { + COMMIT_SHA_POLL_INTERVAL, EDITOR_APP_STATUS_EMPTY, EDITOR_APP_STATUS_ERROR, EDITOR_APP_STATUS_LOADING, @@ -48,6 +49,7 @@ export default { failureType: null, failureReasons: [], initialCiFileContent: '', + isFetchingCommitSha: false, isNewCiConfigFile: false, lastCommittedContent: '', currentCiFileContent: '', @@ -170,15 +172,22 @@ export default { // in this case, we start polling until we get a commit sha. if (pipelineNodes.length === 0) { if (![EDITOR_APP_STATUS_LOADING, EDITOR_APP_STATUS_EMPTY].includes(this.appStatus)) { - this.$apollo.queries.commitSha.startPolling(1000); + this.$apollo.queries.commitSha.startPolling(COMMIT_SHA_POLL_INTERVAL); return this.commitSha; } return ''; } + const latestCommitSha = pipelineNodes[0].sha; + if (this.isFetchingCommitSha && latestCommitSha === this.commitSha) { + this.$apollo.queries.commitSha.startPolling(COMMIT_SHA_POLL_INTERVAL); + return this.commitSha; + } + + this.isFetchingCommitSha = false; this.$apollo.queries.commitSha.stopPolling(); - return pipelineNodes[0].sha; + return latestCommitSha; }, }, currentBranch: { @@ -280,6 +289,10 @@ export default { updateCiConfig(ciFileContent) { this.currentCiFileContent = ciFileContent; }, + updateCommitSha() { + this.isFetchingCommitSha = true; + this.$apollo.queries.commitSha.refetch(); + }, updateOnCommit({ type }) { this.reportSuccess(type); @@ -333,6 +346,7 @@ export default { @showError="showErrorAlert" @refetchContent="refetchContent" @updateCiConfig="updateCiConfig" + @updateCommitSha="updateCommitSha" /> <confirm-unsaved-changes-dialog :has-unsaved-changes="hasUnsavedChanges" /> </div> |