summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/commit_sidebar/actions.vue
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/ide/components/commit_sidebar/actions.vue')
-rw-r--r--app/assets/javascripts/ide/components/commit_sidebar/actions.vue26
1 files changed, 21 insertions, 5 deletions
diff --git a/app/assets/javascripts/ide/components/commit_sidebar/actions.vue b/app/assets/javascripts/ide/components/commit_sidebar/actions.vue
index b4f3778d946..eb7cb9745ec 100644
--- a/app/assets/javascripts/ide/components/commit_sidebar/actions.vue
+++ b/app/assets/javascripts/ide/components/commit_sidebar/actions.vue
@@ -10,7 +10,7 @@ export default {
},
computed: {
...mapState(['currentBranchId', 'changedFiles', 'stagedFiles']),
- ...mapGetters(['currentProject']),
+ ...mapGetters(['currentProject', 'currentBranch']),
commitToCurrentBranchText() {
return sprintf(
__('Commit to %{branchName} branch'),
@@ -22,17 +22,30 @@ export default {
return this.changedFiles.length > 0 && this.stagedFiles.length > 0;
},
},
+ watch: {
+ disableMergeRequestRadio() {
+ this.updateSelectedCommitAction();
+ },
+ },
mounted() {
- if (this.disableMergeRequestRadio) {
- this.updateCommitAction(consts.COMMIT_TO_CURRENT_BRANCH);
- }
+ this.updateSelectedCommitAction();
},
methods: {
...mapActions('commit', ['updateCommitAction']),
+ updateSelectedCommitAction() {
+ if (this.currentBranch && !this.currentBranch.can_push) {
+ this.updateCommitAction(consts.COMMIT_TO_NEW_BRANCH);
+ } else if (this.disableMergeRequestRadio) {
+ this.updateCommitAction(consts.COMMIT_TO_CURRENT_BRANCH);
+ }
+ },
},
commitToCurrentBranch: consts.COMMIT_TO_CURRENT_BRANCH,
commitToNewBranch: consts.COMMIT_TO_NEW_BRANCH,
commitToNewBranchMR: consts.COMMIT_TO_NEW_BRANCH_MR,
+ currentBranchPermissionsTooltip: __(
+ "This option is disabled as you don't have write permissions for the current branch",
+ ),
};
</script>
@@ -40,9 +53,11 @@ export default {
<div class="append-bottom-15 ide-commit-radios">
<radio-group
:value="$options.commitToCurrentBranch"
- :checked="true"
+ :disabled="currentBranch && !currentBranch.can_push"
+ :title="$options.currentBranchPermissionsTooltip"
>
<span
+ class="ide-radio-label"
v-html="commitToCurrentBranchText"
>
</span>
@@ -56,6 +71,7 @@ export default {
v-if="currentProject.merge_requests_enabled"
:value="$options.commitToNewBranchMR"
:label="__('Create a new branch and merge request')"
+ :title="__('This option is disabled while you still have unstaged changes')"
:show-input="true"
:disabled="disableMergeRequestRadio"
/>