diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 09:10:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 09:10:17 +0000 |
commit | ad0265eead72a624ce7a020847db4f0f0c877e57 (patch) | |
tree | 206e0564b02aa9530e3c95f70eb10a77e074bdf0 /app/assets/javascripts/ide/components | |
parent | 4dfc8711171fe0c04bc6b8b224687603026dea46 (diff) | |
download | gitlab-ce-ad0265eead72a624ce7a020847db4f0f0c877e57.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/ide/components')
-rw-r--r-- | app/assets/javascripts/ide/components/commit_sidebar/actions.vue | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/app/assets/javascripts/ide/components/commit_sidebar/actions.vue b/app/assets/javascripts/ide/components/commit_sidebar/actions.vue index 3276d21a04e..6a8ea506d1b 100644 --- a/app/assets/javascripts/ide/components/commit_sidebar/actions.vue +++ b/app/assets/javascripts/ide/components/commit_sidebar/actions.vue @@ -18,7 +18,7 @@ export default { computed: { ...mapState(['currentBranchId', 'changedFiles', 'stagedFiles']), ...mapCommitState(['commitAction']), - ...mapGetters(['currentBranch']), + ...mapGetters(['currentBranch', 'emptyRepo', 'canPushToBranch']), commitToCurrentBranchText() { return sprintf( s__('IDE|Commit to %{branchName} branch'), @@ -29,6 +29,13 @@ export default { containsStagedChanges() { return this.changedFiles.length > 0 && this.stagedFiles.length > 0; }, + shouldDefaultToCurrentBranch() { + if (this.emptyRepo) { + return true; + } + + return this.canPushToBranch && !this.currentBranch?.default; + }, }, watch: { containsStagedChanges() { @@ -43,13 +50,11 @@ export default { methods: { ...mapCommitActions(['updateCommitAction']), updateSelectedCommitAction() { - if (!this.currentBranch) { + if (!this.currentBranch && !this.emptyRepo) { return; } - const { can_push: canPush = false, default: isDefault = false } = this.currentBranch; - - if (canPush && !isDefault) { + if (this.shouldDefaultToCurrentBranch) { this.updateCommitAction(consts.COMMIT_TO_CURRENT_BRANCH); } else { this.updateCommitAction(consts.COMMIT_TO_NEW_BRANCH); @@ -68,7 +73,7 @@ export default { <div class="append-bottom-15 ide-commit-options"> <radio-group :value="$options.commitToCurrentBranch" - :disabled="currentBranch && !currentBranch.can_push" + :disabled="!canPushToBranch" :title="$options.currentBranchPermissionsTooltip" > <span @@ -77,11 +82,13 @@ export default { v-html="commitToCurrentBranchText" ></span> </radio-group> - <radio-group - :value="$options.commitToNewBranch" - :label="__('Create a new branch')" - :show-input="true" - /> - <new-merge-request-option /> + <template v-if="!emptyRepo"> + <radio-group + :value="$options.commitToNewBranch" + :label="__('Create a new branch')" + :show-input="true" + /> + <new-merge-request-option /> + </template> </div> </template> |