summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs/components/sidebar_details_block.vue
blob: 56814a525255223ee8d6b5c663c7bb3e2bf0faca (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<script>
  import detailRow from './sidebar_detail_row.vue';
  import loadingIcon from '../../vue_shared/components/loading_icon.vue';
  import timeagoMixin from '../../vue_shared/mixins/timeago';
  import { timeIntervalInWords } from '../../lib/utils/datetime_utility';

  export default {
    name: 'SidebarDetailsBlock',
    components: {
      detailRow,
      loadingIcon,
    },
    mixins: [
      timeagoMixin,
    ],
    props: {
      job: {
        type: Object,
        required: true,
      },
      isLoading: {
        type: Boolean,
        required: true,
      },
    },
    computed: {
      shouldRenderContent() {
        return !this.isLoading && Object.keys(this.job).length > 0;
      },
      coverage() {
        return `${this.job.coverage}%`;
      },
      duration() {
        return timeIntervalInWords(this.job.duration);
      },
      queued() {
        return timeIntervalInWords(this.job.queued);
      },
      runnerId() {
        return `#${this.job.runner.id}`;
      },
      renderBlock() {
        return this.job.merge_request ||
          this.job.duration ||
          this.job.finished_data ||
          this.job.erased_at ||
          this.job.queued ||
          this.job.runner ||
          this.job.coverage ||
          this.job.tags.length ||
          this.job.cancel_path;
      },
    },
  };
</script>
<template>
  <div>
    <template v-if="shouldRenderContent">
      <div
        class="block retry-link"
        v-if="job.retry_path || job.new_issue_path"
      >
        <a
          v-if="job.new_issue_path"
          class="js-new-issue btn btn-new btn-inverted"
          :href="job.new_issue_path"
        >
          New issue
        </a>
        <a
          v-if="job.retry_path"
          class="js-retry-job btn btn-inverted-secondary"
          :href="job.retry_path"
          data-method="post"
          rel="nofollow"
        >
          Retry
        </a>
      </div>
      <div :class="{block : renderBlock }">
        <p
          class="build-detail-row js-job-mr"
          v-if="job.merge_request"
        >
          <span class="build-light-text">
            Merge Request:
          </span>
          <a :href="job.merge_request.path">
            !{{ job.merge_request.iid }}
          </a>
        </p>

        <detail-row
          class="js-job-duration"
          v-if="job.duration"
          title="Duration"
          :value="duration"
        />
        <detail-row
          class="js-job-finished"
          v-if="job.finished_at"
          title="Finished"
          :value="timeFormated(job.finished_at)"
        />
        <detail-row
          class="js-job-erased"
          v-if="job.erased_at"
          title="Erased"
          :value="timeFormated(job.erased_at)"
        />
        <detail-row
          class="js-job-queued"
          v-if="job.queued"
          title="Queued"
          :value="queued"
        />
        <detail-row
          class="js-job-runner"
          v-if="job.runner"
          title="Runner"
          :value="runnerId"
        />
        <detail-row
          class="js-job-coverage"
          v-if="job.coverage"
          title="Coverage"
          :value="coverage"
        />
        <p
          class="build-detail-row js-job-tags"
          v-if="job.tags.length"
        >
          <span class="build-light-text">
            Tags:
          </span>
          <span
            v-for="(tag, i) in job.tags"
            :key="i"
            class="label label-primary">
            {{ tag }}
          </span>
        </p>

        <div
          v-if="job.cancel_path"
          class="btn-group prepend-top-5"
          role="group">
          <a
            class="js-cancel-job btn btn-sm btn-default"
            :href="job.cancel_path"
            data-method="post"
            rel="nofollow"
          >
            Cancel
          </a>
        </div>
      </div>
    </template>
    <loading-icon
      class="prepend-top-10"
      v-if="isLoading"
      size="2"
    />
  </div>
</template>