summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/issues/show/components/edited.vue
blob: 5138a4530e9dd9bc536eeafcdc36da7237c79f35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<script>
import { GlSprintf } from '@gitlab/ui';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';

export default {
  components: {
    TimeAgoTooltip,
    GlSprintf,
  },
  props: {
    updatedAt: {
      type: String,
      required: false,
      default: '',
    },
    updatedByName: {
      type: String,
      required: false,
      default: '',
    },
    updatedByPath: {
      type: String,
      required: false,
      default: '',
    },
  },
  computed: {
    hasUpdatedBy() {
      return this.updatedByName && this.updatedByPath;
    },
  },
};
</script>

<template>
  <small class="edited-text js-issue-widgets">
    <gl-sprintf v-if="!hasUpdatedBy" :message="__('Edited %{timeago}')">
      <template #timeago>
        <time-ago-tooltip :time="updatedAt" tooltip-placement="bottom" />
      </template>
    </gl-sprintf>
    <gl-sprintf v-else-if="!updatedAt" :message="__('Edited by %{author}')">
      <template #author>
        <a :href="updatedByPath" class="author-link gl-hover-text-decoration-underline">
          <span>{{ updatedByName }}</span>
        </a>
      </template>
    </gl-sprintf>
    <gl-sprintf v-else :message="__('Edited %{timeago} by %{author}')">
      <template #timeago>
        <time-ago-tooltip :time="updatedAt" tooltip-placement="bottom" />
      </template>
      <template #author>
        <a :href="updatedByPath" class="author-link gl-hover-text-decoration-underline">
          <span>{{ updatedByName }}</span>
        </a>
      </template>
    </gl-sprintf>
  </small>
</template>