summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/releases/components/release_block_footer.vue
blob: cb795b3cba76a75aefcb488e602ef0bedb99d1fb (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
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
113
114
115
116
<script>
import { GlTooltipDirective, GlLink, GlIcon } from '@gitlab/ui';
import { __, sprintf } from '~/locale';
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago';

export default {
  name: 'ReleaseBlockFooter',
  components: {
    GlIcon,
    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.timeFormatted(this.releasedAt);
    },
    userImageAltDescription() {
      return this.author && this.author.username
        ? sprintf(__("%{username}'s avatar"), { username: this.author.username })
        : null;
    },
    createdTime() {
      const now = new Date();
      const isFuture = now < new Date(this.releasedAt);
      return isFuture ? __('Will be created') : __('Created');
    },
  },
};
</script>
<template>
  <div>
    <div v-if="commit" class="float-left mr-3 d-flex align-items-center js-commit-info">
      <gl-icon ref="commitIcon" name="commit" class="mr-1" />
      <div v-gl-tooltip.bottom :title="commit.title">
        <gl-link v-if="commitPath" :href="commitPath">
          {{ commit.shortId }}
        </gl-link>
        <span v-else>{{ commit.shortId }}</span>
      </div>
    </div>

    <div v-if="tagName" class="float-left mr-3 d-flex align-items-center js-tag-info">
      <gl-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">{{ createdTime }}&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.webUrl"
          :img-src="author.avatarUrl"
          :img-alt="userImageAltDescription"
          :tooltip-text="author.username"
          tooltip-placement="bottom"
        />
      </div>
    </div>
  </div>
</template>