gitlab-org--gitlab-foss/app/assets/javascripts/groups/components/item_stats.vue

90 lines
2.3 KiB
Vue
Raw Normal View History

<script>
import { GlBadge } from '@gitlab/ui';
import isProjectPendingRemoval from 'ee_else_ce/groups/mixins/is_project_pending_removal';
2018-10-24 15:17:03 -04:00
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';
2018-10-24 15:17:03 -04:00
export default {
components: {
timeAgoTooltip,
itemStatsValue,
GlBadge,
2018-10-24 15:17:03 -04:00
},
mixins: [isProjectPendingRemoval],
2018-10-24 15:17:03 -04:00
props: {
item: {
type: Object,
required: true,
},
2018-10-24 15:17:03 -04:00
},
computed: {
visibilityIcon() {
return VISIBILITY_TYPE_ICON[this.item.visibility];
},
2018-10-24 15:17:03 -04:00
visibilityTooltip() {
if (this.item.type === ITEM_TYPE.GROUP) {
return GROUP_VISIBILITY_TYPE[this.item.visibility];
}
return PROJECT_VISIBILITY_TYPE[this.item.visibility];
},
2018-10-24 15:17:03 -04:00
isProject() {
return this.item.type === ITEM_TYPE.PROJECT;
},
isGroup() {
return this.item.type === ITEM_TYPE.GROUP;
},
},
methods: {
displayValue(value) {
return this.isGroup && value !== undefined;
},
},
2018-10-24 15:17:03 -04:00
};
</script>
<template>
<div class="stats gl-text-gray-500">
<item-stats-value
v-if="displayValue(item.subgroupCount)"
:title="__('Subgroups')"
2018-01-04 11:03:25 -05:00
:value="item.subgroupCount"
css-class="number-subgroups gl-ml-5"
icon-name="group"
data-testid="subgroups-count"
/>
<item-stats-value
v-if="displayValue(item.projectCount)"
:title="__('Projects')"
2018-01-04 11:03:25 -05:00
: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')"
2018-01-04 11:03:25 -05:00
:value="item.memberCount"
css-class="number-users gl-ml-5"
2018-06-11 05:49:47 -04:00
icon-name="users"
/>
<item-stats-value
v-if="isProject"
2018-06-11 05:49:47 -04:00
:value="item.starCount"
css-class="project-stars"
icon-name="star"
/>
<div v-if="isProjectPendingRemoval">
<gl-badge variant="warning">{{ __('pending deletion') }}</gl-badge>
</div>
2018-11-16 15:07:38 -05:00
<div v-if="isProject" class="last-updated">
<time-ago-tooltip :time="item.lastActivityAt" tooltip-placement="bottom" />
</div>
</div>
</template>