Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issuable_tabs.vue « components « list « issuable « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0691bc02b5c960b2057049f7efd891e67a010ac9 (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
<script>
import { GlTabs, GlTab, GlBadge } from '@gitlab/ui';
import { numberToMetricPrefix } from '~/lib/utils/number_utils';
import { formatNumber } from '~/locale';

export default {
  components: {
    GlTabs,
    GlTab,
    GlBadge,
  },
  props: {
    tabs: {
      type: Array,
      required: true,
    },
    tabCounts: {
      type: Object,
      required: false,
      default: null,
    },
    currentTab: {
      type: String,
      required: true,
    },
    truncateCounts: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  methods: {
    isTabActive(tabName) {
      return tabName === this.currentTab;
    },
    isTabCountNumeric(tab) {
      return Number.isInteger(this.tabCounts[tab.name]);
    },
    formatNumber(count) {
      return this.truncateCounts ? numberToMetricPrefix(count) : formatNumber(count);
    },
  },
};
</script>

<template>
  <div class="top-area">
    <gl-tabs
      class="gl-display-flex gl-flex-grow-1 gl-p-0 gl-m-0 mobile-separator issuable-state-filters"
      nav-class="gl-border-b-0"
    >
      <gl-tab
        v-for="tab in tabs"
        :key="tab.id"
        :active="isTabActive(tab.name)"
        @click="$emit('click', tab.name)"
      >
        <template #title>
          <span :title="tab.titleTooltip" :data-qa-selector="`${tab.name}_issuables_tab`">
            {{ tab.title }}
          </span>
          <gl-badge
            v-if="tabCounts && isTabCountNumeric(tab)"
            variant="muted"
            size="sm"
            class="gl-tab-counter-badge"
          >
            {{ formatNumber(tabCounts[tab.name]) }}
          </gl-badge>
        </template>
      </gl-tab>
    </gl-tabs>
    <div class="nav-controls">
      <slot name="nav-actions"></slot>
    </div>
  </div>
</template>