gitlab-org--gitlab-foss/app/assets/javascripts/vue_shared/components/time_ago_tooltip.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
893 B
Vue
Raw Normal View History

<script>
2018-11-19 11:46:32 +00:00
import { GlTooltipDirective } from '@gitlab/ui';
import timeagoMixin from '../mixins/timeago';
import '~/lib/utils/datetime_utility';
/**
* Port of ruby helper time_ago_with_tooltip
*/
export default {
2018-01-04 19:07:28 +00:00
directives: {
GlTooltip: GlTooltipDirective,
2018-01-04 19:07:28 +00:00
},
2018-10-10 07:06:25 +00:00
mixins: [timeagoMixin],
props: {
time: {
type: [String, Number],
required: true,
},
2018-11-07 10:25:49 +00:00
tooltipPlacement: {
type: String,
required: false,
default: 'top',
},
cssClass: {
type: String,
required: false,
default: '',
},
},
computed: {
timeAgo() {
return this.timeFormatted(this.time);
},
},
};
</script>
<template>
<time
v-gl-tooltip.viewport="{ placement: tooltipPlacement }"
:class="cssClass"
:title="tooltipTitle(time)"
:datetime="time"
><slot :time-ago="timeAgo">{{ timeAgo }}</slot></time
2018-11-19 11:46:32 +00:00
>
</template>