summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/header_ci_component.vue
blob: fd0dcd716d6b97cc7adb9ee51e8e6dd7b992a77d (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
117
118
119
120
121
122
<script>
import ciIconBadge from './ci_badge_link.vue';
import timeagoTooltip from './time_ago_tooltip.vue';
import tooltipMixin from '../mixins/tooltip';
import userAvatarLink from './user_avatar/user_avatar_link.vue';

/**
 * Renders header component for job and pipeline page based on UI mockups
 *
 * Used in:
 * - job show page
 * - pipeline show page
 */
export default {
  props: {
    status: {
      type: Object,
      required: true,
    },
    itemName: {
      type: String,
      required: true,
    },
    itemId: {
      type: Number,
      required: true,
    },
    time: {
      type: String,
      required: true,
    },
    user: {
      type: Object,
      required: true,
    },
    actions: {
      type: Array,
      required: false,
      default: () => [],
    },
  },

  mixins: [
    tooltipMixin,
  ],

  components: {
    ciIconBadge,
    timeagoTooltip,
    userAvatarLink,
  },

  computed: {
    userAvatarAltText() {
      return `${this.user.name}'s avatar`;
    },
  },

  methods: {
    onClickAction(action) {
      this.$emit('postAction', action);
    },
  },
};
</script>
<template>
  <header class="page-content-header top-area">
    <section class="header-main-content">

      <ci-icon-badge :status="status" />

      <strong>
        {{itemName}} #{{itemId}}
      </strong>

      triggered

      <timeago-tooltip :time="time" />

      by

      <user-avatar-link
        :link-href="user.web_url"
        :img-src="user.avatar_url"
        :img-alt="userAvatarAltText"
        :tooltip-text="user.name"
        :img-size="24"
        />

      <a
        :href="user.web_url"
        :title="user.email"
        class="js-user-link commit-committer-link"
        ref="tooltip">
        {{user.name}}
      </a>
    </section>

    <section
      class="header-action-button nav-controls"
      v-if="actions.length">
      <template
        v-for="action in actions">
        <a
          v-if="action.type === 'link'"
          :href="action.path"
          :class="action.cssClass">
          {{action.label}}
        </a>

        <button
          v-else="action.type === 'button'"
          @click="onClickAction(action)"
          :class="action.cssClass"
          type="button">
          {{action.label}}
        </button>

      </template>
    </section>
  </header>
</template>