summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs/components/header.vue
blob: 6d671845f8e0ce393e161a4893625f4f6946ed6b (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
<script>
  import ciHeader from '../../vue_shared/components/header_ci_component.vue';
  import loadingIcon from '../../vue_shared/components/loading_icon.vue';

  export default {
    name: 'jobHeaderSection',
    props: {
      job: {
        type: Object,
        required: true,
      },
      isLoading: {
        type: Boolean,
        required: true,
      },
    },
    components: {
      ciHeader,
      loadingIcon,
    },
    data() {
      return {
        actions: this.getActions(),
      };
    },
    computed: {
      status() {
        return this.job && this.job.status;
      },
      shouldRenderContent() {
        return !this.isLoading && Object.keys(this.job).length;
      },
    },
    methods: {
      getActions() {
        const actions = [];

        if (this.job.new_issue_path) {
          actions.push({
            label: 'New issue',
            path: this.job.new_issue_path,
            cssClass: 'js-new-issue btn btn-new btn-inverted visible-md-block visible-lg-block',
            type: 'link',
          });
        }
        return actions;
      },
    },
    watch: {
      job() {
        this.actions = this.getActions();
      },
    },
  };
</script>
<template>
  <div class="js-build-header build-header top-area">
    <ci-header
      v-if="shouldRenderContent"
      :status="status"
      item-name="Job"
      :item-id="job.id"
      :time="job.created_at"
      :user="job.user"
      :actions="actions"
      :hasSidebarButton="true"
      />
    <loading-icon
      v-if="isLoading"
      size="2"
      />
  </div>
</template>