Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pipelines_commit.vue « pipelines_list « components « pipelines « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cc676883c1d0184a3085b13a5802346534ab4ab3 (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
<script>
import { CHILD_VIEW } from '~/pipelines/constants';
import CommitComponent from '~/vue_shared/components/commit.vue';

export default {
  components: {
    CommitComponent,
  },
  props: {
    pipeline: {
      type: Object,
      required: true,
    },
    viewType: {
      type: String,
      required: true,
    },
  },
  computed: {
    commitAuthor() {
      let commitAuthorInformation;

      if (!this.pipeline || !this.pipeline.commit) {
        return null;
      }

      // 1. person who is an author of a commit might be a GitLab user
      if (this.pipeline.commit.author) {
        // 2. if person who is an author of a commit is a GitLab user
        // they can have a GitLab avatar
        if (this.pipeline.commit.author.avatar_url) {
          commitAuthorInformation = this.pipeline.commit.author;

          // 3. If GitLab user does not have avatar, they might have a Gravatar
        } else if (this.pipeline.commit.author_gravatar_url) {
          commitAuthorInformation = {
            ...this.pipeline.commit.author,
            avatar_url: this.pipeline.commit.author_gravatar_url,
          };
        }
        // 4. If committer is not a GitLab User, they can have a Gravatar
      } else {
        commitAuthorInformation = {
          avatar_url: this.pipeline.commit.author_gravatar_url,
          path: `mailto:${this.pipeline.commit.author_email}`,
          username: this.pipeline.commit.author_name,
        };
      }

      return commitAuthorInformation;
    },
    commitTag() {
      return this.pipeline?.ref?.tag;
    },
    commitRef() {
      return this.pipeline?.ref;
    },
    commitUrl() {
      return this.pipeline?.commit?.commit_path;
    },
    commitShortSha() {
      return this.pipeline?.commit?.short_id;
    },
    commitTitle() {
      return this.pipeline?.commit?.title;
    },
    isChildView() {
      return this.viewType === CHILD_VIEW;
    },
  },
};
</script>

<template>
  <commit-component
    :tag="commitTag"
    :commit-ref="commitRef"
    :commit-url="commitUrl"
    :merge-request-ref="pipeline.merge_request"
    :short-sha="commitShortSha"
    :title="commitTitle"
    :author="commitAuthor"
    :show-ref-info="!isChildView"
  />
</template>