All files / app/assets/javascripts/ide/components/commit_sidebar new_merge_request_option.vue

50% Statements 1/2
0% Branches 0/2
0% Functions 0/1
50% Lines 1/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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            5x                                                                                                
<script>
import { GlTooltipDirective, GlFormCheckbox } from '@gitlab/ui';
// eslint-disable-next-line no-restricted-imports
import { createNamespacedHelpers } from 'vuex';
import { s__ } from '~/locale';
 
const { mapActions: mapCommitActions, mapGetters: mapCommitGetters } = createNamespacedHelpers(
  'commit',
);
 
export default {
  components: { GlFormCheckbox },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  i18n: {
    newMrText: s__('IDE|Start a new merge request'),
    tooltipText: s__(
      'IDE|This option is disabled because you are not allowed to create merge requests in this project.',
    ),
  },
  computed: {
    ...mapCommitGetters(['shouldHideNewMrOption', 'shouldDisableNewMrOption', 'shouldCreateMR']),
    tooltipText() {
      return this.shouldDisableNewMrOption ? this.$options.i18n.tooltipText : null;
    },
  },
  methods: {
    ...mapCommitActions(['toggleShouldCreateMR']),
  },
};
</script>
 
<template>
  <fieldset
    v-if="!shouldHideNewMrOption"
    v-gl-tooltip="tooltipText"
    data-testid="new-merge-request-fieldset"
    class="js-ide-commit-new-mr"
    :class="{ 'is-disabled': shouldDisableNewMrOption }"
  >
    <hr class="gl-mt-3 gl-mb-4" />
 
    <gl-form-checkbox
      :disabled="shouldDisableNewMrOption"
      :checked="shouldCreateMR"
      @change="toggleShouldCreateMR"
    >
      <span class="ide-option-label">
        {{ $options.i18n.newMrText }}
      </span>
    </gl-form-checkbox>
  </fieldset>
</template>