summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/environments/components/commit.vue
blob: 8577bf629a3cc55e8b4d42613cf16d0190eb62a8 (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
<script>
import { GlAvatar, GlAvatarLink, GlLink, GlTooltipDirective as GlTooltip } from '@gitlab/ui';
import { escape } from 'lodash';

export default {
  components: {
    GlAvatar,
    GlAvatarLink,
    GlLink,
  },
  directives: {
    GlTooltip,
  },
  props: {
    commit: {
      required: true,
      type: Object,
    },
  },
  computed: {
    commitMessage() {
      return this.commit?.message;
    },
    commitAuthorPath() {
      return this.commit?.author?.path || `mailto:${escape(this.commit?.authorEmail)}`;
    },
    commitAuthorAvatar() {
      return this.commit?.author?.avatarUrl || this.commit?.authorGravatarUrl;
    },
    commitAuthor() {
      return this.commit?.author?.name || this.commit?.authorName;
    },
    commitPath() {
      return this.commit?.commitPath;
    },
  },
};
</script>
<template>
  <div data-testid="deployment-commit" class="gl-display-flex gl-align-items-center">
    <gl-avatar-link v-gl-tooltip :title="commitAuthor" :href="commitAuthorPath">
      <gl-avatar :size="16" :src="commitAuthorAvatar" />
    </gl-avatar-link>
    <gl-link
      v-gl-tooltip
      :title="commitMessage"
      :href="commitPath"
      class="gl-ml-3 gl-str-truncated"
    >
      {{ commitMessage }}
    </gl-link>
  </div>
</template>