summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/groups/components/item_stats.vue
blob: 2aa812250a0a372883058fc7d14f374845d661ba (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
<script>
import { GlBadge } from '@gitlab/ui';
import isProjectPendingRemoval from 'ee_else_ce/groups/mixins/is_project_pending_removal';
import timeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import {
  ITEM_TYPE,
  VISIBILITY_TYPE_ICON,
  GROUP_VISIBILITY_TYPE,
  PROJECT_VISIBILITY_TYPE,
} from '../constants';
import itemStatsValue from './item_stats_value.vue';

export default {
  components: {
    timeAgoTooltip,
    itemStatsValue,
    GlBadge,
  },
  mixins: [isProjectPendingRemoval],
  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;
    },
  },
  methods: {
    displayValue(value) {
      return this.isGroup && value !== undefined;
    },
  },
};
</script>

<template>
  <div class="stats gl-text-gray-500">
    <item-stats-value
      v-if="displayValue(item.subgroupCount)"
      :title="__('Subgroups')"
      :value="item.subgroupCount"
      css-class="number-subgroups gl-ml-5"
      icon-name="subgroup"
      data-testid="subgroups-count"
    />
    <item-stats-value
      v-if="displayValue(item.projectCount)"
      :title="__('Projects')"
      :value="item.projectCount"
      css-class="number-projects gl-ml-5"
      icon-name="project"
      data-testid="projects-count"
    />
    <item-stats-value
      v-if="isGroup"
      :title="__('Direct members')"
      :value="item.memberCount"
      css-class="number-users gl-ml-5"
      icon-name="users"
    />
    <item-stats-value
      v-if="isProject"
      :value="item.starCount"
      css-class="project-stars"
      icon-name="star"
    />
    <div v-if="isProjectPendingRemoval">
      <gl-badge variant="warning">{{ __('pending deletion') }}</gl-badge>
    </div>
    <div v-if="isProject" class="last-updated">
      <time-ago-tooltip :time="item.lastActivityAt" tooltip-placement="bottom" />
    </div>
  </div>
</template>