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

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

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 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 95 96 97 98 99 100 101 102 103 104 105                                                                                                                                                                                                                 
<script>
import {
  GlTooltipDirective,
  GlFormRadio,
  GlFormRadioGroup,
  GlFormGroup,
  GlFormInput,
} from '@gitlab/ui';
// eslint-disable-next-line no-restricted-imports
import { mapActions, mapState, mapGetters } from 'vuex';
 
export default {
  components: {
    GlFormRadio,
    GlFormRadioGroup,
    GlFormGroup,
    GlFormInput,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  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,
    },
    disabled: {
      type: Boolean,
      required: false,
      default: false,
    },
    title: {
      type: String,
      required: false,
      default: '',
    },
  },
  computed: {
    ...mapState('commit', ['commitAction', 'newBranchName']),
    ...mapGetters('commit', ['placeholderBranchName']),
    tooltipTitle() {
      return this.disabled ? this.title : '';
    },
  },
  methods: {
    ...mapActions('commit', ['updateCommitAction', 'updateBranchName']),
  },
};
</script>
 
<template>
  <fieldset class="gl-mb-2">
    <gl-form-radio-group
      v-gl-tooltip="tooltipTitle"
      :checked="commitAction"
      :class="{
        'is-disabled': disabled,
      }"
    >
      <gl-form-radio
        :value="value"
        :disabled="disabled"
        name="commit-action"
        @change="updateCommitAction(value)"
      >
        <span v-if="label" class="ide-option-label">
          {{ label }}
        </span>
        <slot v-else></slot>
      </gl-form-radio>
    </gl-form-radio-group>
 
    <gl-form-group
      v-if="commitAction === value && showInput"
      :label="placeholderBranchName"
      :label-sr-only="true"
      class="gl-ml-6 gl-mb-0"
    >
      <gl-form-input
        :placeholder="placeholderBranchName"
        :value="newBranchName"
        :disabled="disabled"
        data-testid="ide-new-branch-name"
        class="gl-font-monospace"
        @input="updateBranchName($event)"
      />
    </gl-form-group>
  </fieldset>
</template>