actions.vue 1.41 KB
Newer Older
Phil Hughes's avatar
Phil Hughes committed
1
<script>
2
import { mapState } from 'vuex';
Phil Hughes's avatar
Phil Hughes committed
3 4 5
import { sprintf, __ } from '~/locale';
import * as consts from '../../stores/modules/commit/constants';
import RadioGroup from './radio_group.vue';
Phil Hughes's avatar
Phil Hughes committed
6

Phil Hughes's avatar
Phil Hughes committed
7 8 9 10 11
export default {
  components: {
    RadioGroup,
  },
  computed: {
12
    ...mapState(['currentBranchId', 'changedFiles', 'stagedFiles']),
Phil Hughes's avatar
Phil Hughes committed
13 14 15 16 17 18
    commitToCurrentBranchText() {
      return sprintf(
        __('Commit to %{branchName} branch'),
        { branchName: `<strong class="monospace">${this.currentBranchId}</strong>` },
        false,
      );
Phil Hughes's avatar
Phil Hughes committed
19
    },
Phil Hughes's avatar
Phil Hughes committed
20 21 22
    disableMergeRequestRadio() {
      return this.changedFiles.length > 0 && this.stagedFiles.length > 0;
    },
Phil Hughes's avatar
Phil Hughes committed
23 24 25 26 27
  },
  commitToCurrentBranch: consts.COMMIT_TO_CURRENT_BRANCH,
  commitToNewBranch: consts.COMMIT_TO_NEW_BRANCH,
  commitToNewBranchMR: consts.COMMIT_TO_NEW_BRANCH_MR,
};
Phil Hughes's avatar
Phil Hughes committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
</script>

<template>
  <div class="append-bottom-15 ide-commit-radios">
    <radio-group
      :value="$options.commitToCurrentBranch"
      :checked="true"
    >
      <span
        v-html="commitToCurrentBranchText"
      >
      </span>
    </radio-group>
    <radio-group
      :value="$options.commitToNewBranch"
      :label="__('Create a new branch')"
      :show-input="true"
    />
    <radio-group
      :value="$options.commitToNewBranchMR"
      :label="__('Create a new branch and merge request')"
      :show-input="true"
Phil Hughes's avatar
Phil Hughes committed
50
      :disabled="disableMergeRequestRadio"
Phil Hughes's avatar
Phil Hughes committed
51 52 53
    />
  </div>
</template>