2017-05-26 17:31:16 +00:00
|
|
|
<script>
|
2018-11-19 11:46:32 +00:00
|
|
|
import { GlTooltipDirective } from '@gitlab/ui';
|
2020-08-17 12:10:12 +00:00
|
|
|
|
2017-05-26 17:31:16 +00:00
|
|
|
import timeagoMixin from '../mixins/timeago';
|
2022-04-04 18:08:38 +00:00
|
|
|
import '~/lib/utils/datetime_utility';
|
2017-05-26 17:31:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Port of ruby helper time_ago_with_tooltip
|
|
|
|
*/
|
|
|
|
|
|
|
|
export default {
|
2018-01-04 19:07:28 +00:00
|
|
|
directives: {
|
2018-11-05 13:12:40 +00:00
|
|
|
GlTooltip: GlTooltipDirective,
|
2018-01-04 19:07:28 +00:00
|
|
|
},
|
2018-10-10 07:06:25 +00:00
|
|
|
mixins: [timeagoMixin],
|
2017-05-26 17:31:16 +00:00
|
|
|
props: {
|
|
|
|
time: {
|
2021-05-13 12:10:02 +00:00
|
|
|
type: [String, Number],
|
2017-05-26 17:31:16 +00:00
|
|
|
required: true,
|
|
|
|
},
|
2018-11-07 10:25:49 +00:00
|
|
|
tooltipPlacement: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 'top',
|
|
|
|
},
|
2017-05-26 17:31:16 +00:00
|
|
|
cssClass: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
},
|
2020-08-17 12:10:12 +00:00
|
|
|
computed: {
|
|
|
|
timeAgo() {
|
|
|
|
return this.timeFormatted(this.time);
|
|
|
|
},
|
|
|
|
},
|
2017-05-26 17:31:16 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<time
|
2019-11-05 15:06:17 +00:00
|
|
|
v-gl-tooltip.viewport="{ placement: tooltipPlacement }"
|
2017-06-13 14:27:42 +00:00
|
|
|
:class="cssClass"
|
2017-05-26 17:31:16 +00:00
|
|
|
:title="tooltipTitle(time)"
|
2020-08-17 12:10:12 +00:00
|
|
|
:datetime="time"
|
2022-04-26 21:08:42 +00:00
|
|
|
><slot :time-ago="timeAgo">{{ timeAgo }}</slot></time
|
2018-11-19 11:46:32 +00:00
|
|
|
>
|
2017-05-26 17:31:16 +00:00
|
|
|
</template>
|