summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/groups/components/item_stats.vue
blob: 9f8ac138fc370733de7a18f6d207284dc675a2f8 (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
91
92
93
94
95
96
97
98
<script>
import tooltip from '../../vue_shared/directives/tooltip';
import { ITEM_TYPE, VISIBILITY_TYPE_ICON, GROUP_VISIBILITY_TYPE, PROJECT_VISIBILITY_TYPE } from '../constants';

export default {
  directives: {
    tooltip,
  },
  props: {
    item: {
      type: Object,
      required: true,
    },
  },
  computed: {
    visibilityIcon() {
      return VISIBILITY_TYPE_ICON[this.item.visibility];
    },
    visibilityTooltip() {
      if (this.item.type === ITEM_TYPE.GROUP) {
        return GROUP_VISIBILITY_TYPE[this.item.visibility];
      }
      return PROJECT_VISIBILITY_TYPE[this.item.visibility];
    },
    isProject() {
      return this.item.type === ITEM_TYPE.PROJECT;
    },
    isGroup() {
      return this.item.type === ITEM_TYPE.GROUP;
    },
  },
};
</script>

<template>
  <div class="stats">
    <span
      v-tooltip
      v-if="isGroup"
      :title="s__('Subgroups')"
      class="number-subgroups"
      data-placement="top"
      data-container="body">
      <i
        class="fa fa-folder"
        aria-hidden="true"
      />
      {{item.subgroupCount}}
    </span>
    <span
      v-tooltip
      v-if="isGroup"
      :title="s__('Projects')"
      class="number-projects"
      data-placement="top"
      data-container="body">
      <i
        class="fa fa-bookmark"
        aria-hidden="true"
      />
      {{item.projectCount}}
    </span>
    <span
      v-tooltip
      v-if="isGroup"
      :title="s__('Members')"
      class="number-users"
      data-placement="top"
      data-container="body">
      <i
        class="fa fa-users"
        aria-hidden="true"
      />
      {{item.memberCount}}
    </span>
    <span
      v-if="isProject"
      class="project-stars">
      <i
        class="fa fa-star"
        aria-hidden="true"
      />
      {{item.starCount}}
    </span>
    <span
      v-tooltip
      :title="visibilityTooltip"
      data-placement="left"
      data-container="body"
      class="item-visibility">
      <i
        :class="visibilityIcon"
        class="fa"
        aria-hidden="true"
      />
    </span>
  </div>
</template>