Skip to content

Commit 4a2ce82

Browse files
committed
add runstatus component
1 parent 785a3e6 commit 4a2ce82

File tree

2 files changed

+60
-12
lines changed

2 files changed

+60
-12
lines changed

web_src/js/components/RepoActionView.vue

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@
1717
<div class="job-brief-list">
1818
<div class="job-brief-item" v-for="(job, index) in run.jobs" :key="job.id">
1919
<a class="job-brief-link" :href="run.link+'/jobs/'+index">
20-
<SvgIcon name="octicon-check-circle-fill" class="green" v-if="job.status === 'success'"/>
21-
<SvgIcon name="octicon-skip" class="ui text grey" v-else-if="job.status === 'skipped'"/>
22-
<SvgIcon name="octicon-clock" class="ui text yellow" v-else-if="job.status === 'waiting'"/>
23-
<SvgIcon name="octicon-blocked" class="ui text yellow" v-else-if="job.status === 'blocked'"/>
24-
<SvgIcon name="octicon-meter" class="ui text yellow" class-name="job-status-rotate" v-else-if="job.status === 'running'"/>
25-
<SvgIcon name="octicon-x-circle-fill" class="red" v-else/>
20+
<RunStatus :status="job.status"/>
2621
<span class="ui text">{{ job.name }}</span>
2722
</a>
2823
<button class="job-brief-rerun" @click="rerunJob(index)" v-if="job.canRerun">
@@ -48,12 +43,7 @@
4843
<SvgIcon name="octicon-chevron-down" class="gt-mr-3" v-show="currentJobStepsStates[i].expanded"/>
4944
<SvgIcon name="octicon-chevron-right" class="gt-mr-3" v-show="!currentJobStepsStates[i].expanded"/>
5045

51-
<SvgIcon name="octicon-check-circle-fill" class="green gt-mr-3" v-if="jobStep.status === 'success'"/>
52-
<SvgIcon name="octicon-skip" class="ui text grey gt-mr-3" v-else-if="jobStep.status === 'skipped'"/>
53-
<SvgIcon name="octicon-clock" class="ui text yellow gt-mr-3" v-else-if="jobStep.status === 'waiting'"/>
54-
<SvgIcon name="octicon-blocked" class="ui text yellow gt-mr-3" v-else-if="jobStep.status === 'blocked'"/>
55-
<SvgIcon name="octicon-meter" class="ui text yellow gt-mr-3" class-name="job-status-rotate" v-else-if="jobStep.status === 'running'"/>
56-
<SvgIcon name="octicon-x-circle-fill" class="red gt-mr-3 " v-else/>
46+
<RunStatus :status="jobStep.status" class="gt-mr-3"/>
5747

5848
<span class="step-summary-msg">{{ jobStep.summary }}</span>
5949
<span class="step-summary-dur">{{ jobStep.duration }}</span>
@@ -70,6 +60,7 @@
7060

7161
<script>
7262
import {SvgIcon} from '../svg.js';
63+
import {RunStatus} from '../runstatus.js';
7364
import {createApp} from 'vue';
7465
import AnsiToHTML from 'ansi-to-html';
7566
@@ -79,6 +70,7 @@ const sfc = {
7970
name: 'RepoActionView',
8071
components: {
8172
SvgIcon,
73+
RunStatus,
8274
},
8375
props: {
8476
runIndex: String,

web_src/js/runstatus.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import {svg} from './svg.js';
2+
3+
// retrieve a HTML string for given run status, size and additional classes
4+
export function runstatus(status, size = 16, className = '') {
5+
switch (status) {
6+
case "success":
7+
return svg('octicon-check-circle-fill', size, className);
8+
case "skipped":
9+
return svg('octicon-skip', size, className);
10+
case "waiting":
11+
return svg('octicon-clock', size, className);
12+
case "blocked":
13+
return svg('octicon-blocked', size, className);
14+
case "running":
15+
return svg('octicon-meter', size, className);
16+
default:
17+
return svg('octicon-x-circle-fill', size, className);
18+
}
19+
}
20+
21+
function spanclass(status){
22+
switch (status) {
23+
case "success":
24+
return "green";
25+
case "skipped":
26+
return "ui text grey";
27+
case "waiting":
28+
return "ui text yellow";
29+
case "blocked":
30+
return "ui text yellow";
31+
case "running":
32+
return "ui text yellow";
33+
default:
34+
return "red";
35+
}
36+
}
37+
38+
export const RunStatus = {
39+
name: 'RunStatus',
40+
props: {
41+
status: {type: String, required: true},
42+
size: {type: Number, default: 16},
43+
className: {type: String, default: ''},
44+
},
45+
46+
computed: {
47+
runstatus() {
48+
return runstatus(this.status, this.size, this.className);
49+
},
50+
spanclass() {
51+
return spanclass(this.status)
52+
}
53+
},
54+
55+
template: `<span v-html="runstatus" :class="spanclass"/>`
56+
};

0 commit comments

Comments
 (0)