summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/components/navigation_tabs.vue
blob: 73f7e3a0cad531ee0cfba718ab896abdad693c73 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
<script>
  export default {
    name: 'PipelineNavigationTabs',
    props: {
      scope: {
        type: String,
        required: true,
      },
      count: {
        type: Object,
        required: true,
      },
      paths: {
        type: Object,
        required: true,
      },
    },
    mounted() {
      $(document).trigger('init.scrolling-tabs');
    },
    methods: {
      shouldRenderBadge(count) {
        // 0 is valid in a badge, but evaluates to false, we need to check for undefined
        return count !== undefined;
      },
    },
};
</script>
<template>
  <ul class="nav-links scrolling-tabs">
    <li
      class="js-pipelines-tab-all"
      :class="{ active: scope === 'all'}">
      <a :href="paths.allPath">
        All
        <span
          v-if="shouldRenderBadge(count.all)"
          class="badge js-totalbuilds-count">
          {{count.all}}
        </span>
      </a>
    </li>
    <li
      class="js-pipelines-tab-pending"
      :class="{ active: scope === 'pending'}">
      <a :href="paths.pendingPath">
        Pending
        <span
          v-if="shouldRenderBadge(count.pending)"
          class="badge">
          {{count.pending}}
        </span>
      </a>
    </li>
    <li
      class="js-pipelines-tab-running"
      :class="{ active: scope === 'running'}">
      <a :href="paths.runningPath">
        Running
        <span
          v-if="shouldRenderBadge(count.running)"
          class="badge">
          {{count.running}}
        </span>
      </a>
    </li>
    <li
      class="js-pipelines-tab-finished"
      :class="{ active: scope === 'finished'}">
      <a :href="paths.finishedPath">
        Finished
        <span
          v-if="shouldRenderBadge(count.finished)"
          class="badge">
          {{count.finished}}
        </span>
      </a>
    </li>
    <li
      class="js-pipelines-tab-branches"
      :class="{ active: scope === 'branches'}">
      <a :href="paths.branchesPath">Branches</a>
    </li>
    <li
      class="js-pipelines-tab-tags"
      :class="{ active: scope === 'tags'}">
      <a :href="paths.tagsPath">Tags</a>
    </li>
  </ul>
</template>