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

63 lines
1.2 KiB
Vue
Raw Normal View History

2017-12-22 02:34:15 -05:00
<script>
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
2017-12-22 02:34:15 -05:00
2018-10-24 15:17:03 -04:00
export default {
components: {
GlIcon,
2018-10-24 15:17:03 -04:00
},
directives: {
GlTooltip: GlTooltipDirective,
2018-10-24 15:17:03 -04:00
},
props: {
title: {
type: String,
required: false,
default: '',
2017-12-22 02:34:15 -05:00
},
2018-10-24 15:17:03 -04:00
cssClass: {
type: String,
required: false,
default: '',
2017-12-22 02:34:15 -05:00
},
2018-10-24 15:17:03 -04:00
iconName: {
type: String,
required: true,
2017-12-22 02:34:15 -05:00
},
2018-10-24 15:17:03 -04:00
tooltipPlacement: {
type: String,
required: false,
default: 'bottom',
2017-12-22 02:34:15 -05:00
},
2018-10-24 15:17:03 -04:00
/**
* value could either be number or string
* as `memberCount` is always passed as string
* while `subgroupCount` & `projectCount`
* are always number
*/
value: {
type: [Number, String],
required: false,
default: '',
},
},
computed: {
isValuePresent() {
return this.value !== '';
},
},
};
2017-12-22 02:34:15 -05:00
</script>
<template>
<span
v-gl-tooltip
2017-12-22 02:34:15 -05:00
:data-placement="tooltipPlacement"
:class="cssClass"
:title="title"
2018-06-11 05:49:47 -04:00
data-container="body"
2017-12-22 02:34:15 -05:00
>
<gl-icon :name="iconName" />
<span v-if="isValuePresent" class="stat-value" data-testid="itemStatValue"> {{ value }} </span>
2017-12-22 02:34:15 -05:00
</span>
</template>