Skip to content

Commit f0b0f22

Browse files
yp05327lunny
andauthored
Add ActionRunStatus component (#23259)
Related to: #23212 (comment) Decrease duplication of SvgIcon when display a run status svg. --------- Co-authored-by: Lunny Xiao <[email protected]>
1 parent 68d7d77 commit f0b0f22

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<template>
2+
<SvgIcon name="octicon-check-circle-fill" class="green" :size="size" :class-name="className" v-if="status === 'success'"/>
3+
<SvgIcon name="octicon-skip" class="ui text grey" :size="size" :class-name="className" v-else-if="status === 'skipped'"/>
4+
<SvgIcon name="octicon-clock" class="ui text yellow" :size="size" :class-name="className" v-else-if="status === 'waiting'"/>
5+
<SvgIcon name="octicon-blocked" class="ui text yellow" :size="size" :class-name="className" v-else-if="status === 'blocked'"/>
6+
<SvgIcon name="octicon-meter" class="ui text yellow" :size="size" :class-name="'job-status-rotate ' + className" v-else-if="status === 'running'"/>
7+
<SvgIcon name="octicon-x-circle-fill" class="red" :size="size" v-else/>
8+
</template>
9+
10+
<script>
11+
import {SvgIcon} from '../svg.js';
12+
13+
export default {
14+
components: {SvgIcon},
15+
props: {
16+
status: {
17+
type: String,
18+
required: true
19+
},
20+
size: {
21+
type: Number,
22+
default: 16
23+
},
24+
className: {
25+
type: String,
26+
default: ''
27+
}
28+
},
29+
};
30+
</script>

web_src/js/components/RepoActionView.vue

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
<div class="action-view-container">
33
<div class="action-view-header">
44
<div class="action-info-summary">
5-
<SvgIcon name="octicon-check-circle-fill" size="20" class="green" v-if="run.status === 'success'"/>
6-
<SvgIcon name="octicon-clock" size="20" class="ui text yellow" v-else-if="run.status === 'waiting'"/>
7-
<SvgIcon name="octicon-meter" size="20" class="ui text yellow" class-name="job-status-rotate" v-else-if="run.status === 'running'"/>
8-
<SvgIcon name="octicon-x-circle-fill" size="20" class="red" v-else/>
5+
<ActionRunStatus :status="run.status" :size="20"/>
96
<div class="action-title">
107
{{ run.title }}
118
</div>
@@ -23,12 +20,7 @@
2320
<div class="job-brief-list">
2421
<div class="job-brief-item" v-for="(job, index) in run.jobs" :key="job.id">
2522
<a class="job-brief-link" :href="run.link+'/jobs/'+index">
26-
<SvgIcon name="octicon-check-circle-fill" class="green" v-if="job.status === 'success'"/>
27-
<SvgIcon name="octicon-skip" class="ui text grey" v-else-if="job.status === 'skipped'"/>
28-
<SvgIcon name="octicon-clock" class="ui text yellow" v-else-if="job.status === 'waiting'"/>
29-
<SvgIcon name="octicon-blocked" class="ui text yellow" v-else-if="job.status === 'blocked'"/>
30-
<SvgIcon name="octicon-meter" class="ui text yellow" class-name="job-status-rotate" v-else-if="job.status === 'running'"/>
31-
<SvgIcon name="octicon-x-circle-fill" class="red" v-else/>
23+
<ActionRunStatus :status="job.status"/>
3224
<span class="ui text">{{ job.name }}</span>
3325
</a>
3426
<button class="job-brief-rerun" @click="rerunJob(index)" v-if="job.canRerun">
@@ -54,12 +46,7 @@
5446
<SvgIcon name="octicon-chevron-down" class="gt-mr-3" v-show="currentJobStepsStates[i].expanded"/>
5547
<SvgIcon name="octicon-chevron-right" class="gt-mr-3" v-show="!currentJobStepsStates[i].expanded"/>
5648

57-
<SvgIcon name="octicon-check-circle-fill" class="green gt-mr-3" v-if="jobStep.status === 'success'"/>
58-
<SvgIcon name="octicon-skip" class="ui text grey gt-mr-3" v-else-if="jobStep.status === 'skipped'"/>
59-
<SvgIcon name="octicon-clock" class="ui text yellow gt-mr-3" v-else-if="jobStep.status === 'waiting'"/>
60-
<SvgIcon name="octicon-blocked" class="ui text yellow gt-mr-3" v-else-if="jobStep.status === 'blocked'"/>
61-
<SvgIcon name="octicon-meter" class="ui text yellow gt-mr-3" class-name="job-status-rotate" v-else-if="jobStep.status === 'running'"/>
62-
<SvgIcon name="octicon-x-circle-fill" class="red gt-mr-3 " v-else/>
49+
<ActionRunStatus :status="jobStep.status" class="gt-mr-3"/>
6350

6451
<span class="step-summary-msg">{{ jobStep.summary }}</span>
6552
<span class="step-summary-dur">{{ jobStep.duration }}</span>
@@ -76,6 +63,7 @@
7663

7764
<script>
7865
import {SvgIcon} from '../svg.js';
66+
import ActionRunStatus from './ActionRunStatus.vue';
7967
import {createApp} from 'vue';
8068
import AnsiToHTML from 'ansi-to-html';
8169
@@ -85,6 +73,7 @@ const sfc = {
8573
name: 'RepoActionView',
8674
components: {
8775
SvgIcon,
76+
ActionRunStatus,
8877
},
8978
props: {
9079
runIndex: String,

0 commit comments

Comments
 (0)