All files / app/assets/javascripts/ide/components nav_dropdown_button.vue

100% Statements 7/7
100% Branches 6/6
100% Functions 3/3
100% Lines 7/7

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  7x 7x 7x   7x                                 11x     29x           141x                          
<script>
import { GlIcon } from '@gitlab/ui';
import { mapState } from 'vuex';
import DropdownButton from '~/vue_shared/components/dropdown/dropdown_button.vue';
 
const EMPTY_LABEL = '-';
 
export default {
  components: {
    GlIcon,
    DropdownButton,
  },
  props: {
    showMergeRequests: {
      type: Boolean,
      required: false,
      default: true,
    },
  },
  computed: {
    ...mapState(['currentBranchId', 'currentMergeRequestId']),
    mergeRequestLabel() {
      return this.currentMergeRequestId ? `!${this.currentMergeRequestId}` : EMPTY_LABEL;
    },
    branchLabel() {
      return this.currentBranchId || EMPTY_LABEL;
    },
  },
};
</script>
 
<template>
  <dropdown-button>
    <span class="row gl-flex-nowrap">
      <span class="col-auto flex-fill text-truncate">
        <gl-icon :size="16" :aria-label="__('Current Branch')" name="branch" /> {{ branchLabel }}
      </span>
      <span v-if="showMergeRequests" class="col-5 pl-0 text-truncate">
        <gl-icon :size="16" :aria-label="__('Merge request')" name="merge-request" />
        {{ mergeRequestLabel }}
      </span>
    </span>
  </dropdown-button>
</template>