summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/commit_sidebar/radio_group.vue
blob: 4310d762c78e6252cb6584d218208328301fd72a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<script>
  import { mapActions, mapState, mapGetters } from 'vuex';
  import tooltip from '~/vue_shared/directives/tooltip';

  export default {
    directives: {
      tooltip,
    },
    props: {
      value: {
        type: String,
        required: true,
      },
      label: {
        type: String,
        required: false,
        default: null,
      },
      checked: {
        type: Boolean,
        required: false,
        default: false,
      },
      showInput: {
        type: Boolean,
        required: false,
        default: false,
      },
      helpText: {
        type: String,
        required: false,
        default: null,
      },
    },
    computed: {
      ...mapState('commit', [
        'commitAction',
      ]),
      ...mapGetters('commit', [
        'newBranchName',
      ]),
    },
    methods: {
      ...mapActions('commit', [
        'updateCommitAction',
        'updateBranchName',
      ]),
    },
  };
</script>

<template>
  <fieldset>
    <label>
      <input
        type="radio"
        name="commit-action"
        :value="value"
        @change="updateCommitAction($event.target.value)"
        :checked="checked"
        v-once
      />
      <span class="prepend-left-10">
        <template v-if="label">
          {{ label }}
        </template>
        <slot v-else></slot>
        <span
          v-if="helpText"
          v-tooltip
          class="help-block inline"
          :title="helpText"
        >
          <i
            class="fa fa-question-circle"
            aria-hidden="true"
          >
          </i>
        </span>
      </span>
    </label>
    <div
      v-if="commitAction === value && showInput"
      class="ide-commit-new-branch"
    >
      <input
        type="text"
        class="form-control"
        :placeholder="newBranchName"
        @input="updateBranchName($event.target.value)"
      />
    </div>
  </fieldset>
</template>