item_stats.vue 1.99 KB
Newer Older
1
<script>
2
import { GlBadge } from '@gitlab/ui';
3 4 5 6 7 8 9 10
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';
11
import isProjectPendingRemoval from 'ee_else_ce/groups/mixins/is_project_pending_removal';
12

13 14 15 16
export default {
  components: {
    timeAgoTooltip,
    itemStatsValue,
17
    GlBadge,
18
  },
19
  mixins: [isProjectPendingRemoval],
20 21 22 23
  props: {
    item: {
      type: Object,
      required: true,
24
    },
25 26 27 28
  },
  computed: {
    visibilityIcon() {
      return VISIBILITY_TYPE_ICON[this.item.visibility];
29
    },
30 31 32 33 34
    visibilityTooltip() {
      if (this.item.type === ITEM_TYPE.GROUP) {
        return GROUP_VISIBILITY_TYPE[this.item.visibility];
      }
      return PROJECT_VISIBILITY_TYPE[this.item.visibility];
35
    },
36 37 38 39 40 41 42 43
    isProject() {
      return this.item.type === ITEM_TYPE.PROJECT;
    },
    isGroup() {
      return this.item.type === ITEM_TYPE.GROUP;
    },
  },
};
44 45 46 47
</script>

<template>
  <div class="stats">
48
    <item-stats-value
49
      v-if="isGroup"
50
      :title="__('Subgroups')"
Kushal Pandya's avatar
Kushal Pandya committed
51
      :value="item.subgroupCount"
52
      css-class="number-subgroups"
Dennis Tang's avatar
Dennis Tang committed
53
      icon-name="folder-o"
54 55
    />
    <item-stats-value
56
      v-if="isGroup"
57
      :title="__('Projects')"
Kushal Pandya's avatar
Kushal Pandya committed
58
      :value="item.projectCount"
59 60
      css-class="number-projects"
      icon-name="bookmark"
61 62
    />
    <item-stats-value
63
      v-if="isGroup"
64
      :title="__('Members')"
Kushal Pandya's avatar
Kushal Pandya committed
65
      :value="item.memberCount"
66 67
      css-class="number-users"
      icon-name="users"
68
    />
69
    <item-stats-value
70
      v-if="isProject"
71
      :value="item.starCount"
72 73 74
      css-class="project-stars"
      icon-name="star"
    />
75 76 77
    <div v-if="isProjectPendingRemoval">
      <gl-badge variant="warning">{{ __('pending removal') }}</gl-badge>
    </div>
Mike Greiling's avatar
Mike Greiling committed
78 79
    <div v-if="isProject" class="last-updated">
      <time-ago-tooltip :time="item.updatedAt" tooltip-placement="bottom" />
80
    </div>
81 82
  </div>
</template>