release_block_footer.vue 2.83 KB
Newer Older
Nathan Friend's avatar
Nathan Friend committed
1
2
<script>
import { GlTooltipDirective, GlLink } from '@gitlab/ui';
3
import Icon from '~/vue_shared/components/icon.vue';
Nathan Friend's avatar
Nathan Friend committed
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago';
import { __, sprintf } from '~/locale';

export default {
  name: 'ReleaseBlockFooter',
  components: {
    Icon,
    GlLink,
    UserAvatarLink,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  mixins: [timeagoMixin],
  props: {
    commit: {
      type: Object,
      required: false,
      default: null,
    },
    commitPath: {
      type: String,
      required: false,
      default: '',
    },
    tagName: {
      type: String,
      required: false,
      default: '',
    },
    tagPath: {
      type: String,
      required: false,
      default: '',
    },
    author: {
      type: Object,
      required: false,
      default: null,
    },
    releasedAt: {
      type: String,
      required: false,
      default: '',
    },
  },
  computed: {
    releasedAtTimeAgo() {
      return this.timeFormated(this.releasedAt);
    },
    userImageAltDescription() {
      return this.author && this.author.username
        ? sprintf(__("%{username}'s avatar"), { username: this.author.username })
        : null;
    },
  },
};
</script>
<template>
  <div>
    <div v-if="commit" class="float-left mr-3 d-flex align-items-center js-commit-info">
      <icon ref="commitIcon" name="commit" class="mr-1" />
      <div v-gl-tooltip.bottom :title="commit.title">
        <gl-link v-if="commitPath" :href="commitPath">
          {{ commit.short_id }}
        </gl-link>
        <span v-else>{{ commit.short_id }}</span>
      </div>
    </div>

    <div v-if="tagName" class="float-left mr-3 d-flex align-items-center js-tag-info">
      <icon name="tag" class="mr-1" />
      <div v-gl-tooltip.bottom :title="__('Tag')">
        <gl-link v-if="tagPath" :href="tagPath">
          {{ tagName }}
        </gl-link>
        <span v-else>{{ tagName }}</span>
      </div>
    </div>

    <div
      v-if="releasedAt || author"
      class="float-left d-flex align-items-center js-author-date-info"
    >
      <span class="text-secondary">{{ __('Created') }}&nbsp;</span>
      <template v-if="releasedAt">
        <span
          v-gl-tooltip.bottom
          :title="tooltipTitle(releasedAt)"
          class="text-secondary flex-shrink-0"
        >
          {{ releasedAtTimeAgo }}&nbsp;
        </span>
      </template>

      <div v-if="author" class="d-flex">
        <span class="text-secondary">{{ __('by') }}&nbsp;</span>
        <user-avatar-link
          :link-href="author.web_url"
          :img-src="author.avatar_url"
          :img-alt="userImageAltDescription"
          :tooltip-text="author.username"
          tooltip-placement="bottom"
        />
      </div>
    </div>
  </div>
</template>