summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/commit_sidebar/new_merge_request_option.vue
blob: 43bf2e1a90cbea01702919f2cf5ec239bd06ee31 (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
<script>
import { GlTooltipDirective } from '@gitlab/ui';
import { createNamespacedHelpers } from 'vuex';
import { s__ } from '~/locale';

const { mapActions: mapCommitActions, mapGetters: mapCommitGetters } = createNamespacedHelpers(
  'commit',
);

export default {
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  computed: {
    ...mapCommitGetters(['shouldHideNewMrOption', 'shouldDisableNewMrOption', 'shouldCreateMR']),
    tooltipText() {
      if (this.shouldDisableNewMrOption) {
        return s__(
          'IDE|This option is disabled because you are not allowed to create merge requests in this project.',
        );
      }

      return '';
    },
  },
  methods: {
    ...mapCommitActions(['toggleShouldCreateMR']),
  },
};
</script>

<template>
  <fieldset v-if="!shouldHideNewMrOption">
    <hr class="my-2" />
    <label
      v-gl-tooltip="tooltipText"
      class="mb-0 js-ide-commit-new-mr"
      :class="{ 'is-disabled': shouldDisableNewMrOption }"
    >
      <input
        :disabled="shouldDisableNewMrOption"
        :checked="shouldCreateMR"
        type="checkbox"
        @change="toggleShouldCreateMR"
      />
      <span class="gl-ml-3 ide-option-label">
        {{ __('Start a new merge request') }}
      </span>
    </label>
  </fieldset>
</template>