Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ActionRunStatus component #23259

Merged
merged 9 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions web_src/js/components/RepoActionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
<div class="job-brief-list">
<div class="job-brief-item" v-for="(job, index) in run.jobs" :key="job.id">
<a class="job-brief-link" :href="run.link+'/jobs/'+index">
<SvgIcon name="octicon-check-circle-fill" class="green" v-if="job.status === 'success'"/>
<SvgIcon name="octicon-skip" class="ui text grey" v-else-if="job.status === 'skipped'"/>
<SvgIcon name="octicon-clock" class="ui text yellow" v-else-if="job.status === 'waiting'"/>
<SvgIcon name="octicon-blocked" class="ui text yellow" v-else-if="job.status === 'blocked'"/>
<SvgIcon name="octicon-meter" class="ui text yellow" class-name="job-status-rotate" v-else-if="job.status === 'running'"/>
<SvgIcon name="octicon-x-circle-fill" class="red" v-else/>
<RunStatus :status="job.status"/>
<span class="ui text">{{ job.name }}</span>
</a>
<button class="job-brief-rerun" @click="rerunJob(index)" v-if="job.canRerun">
Expand All @@ -48,12 +43,7 @@
<SvgIcon name="octicon-chevron-down" class="gt-mr-3" v-show="currentJobStepsStates[i].expanded"/>
<SvgIcon name="octicon-chevron-right" class="gt-mr-3" v-show="!currentJobStepsStates[i].expanded"/>

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

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

<script>
import {SvgIcon} from '../svg.js';
import {RunStatus} from '../runstatus.js';
import {createApp} from 'vue';
import AnsiToHTML from 'ansi-to-html';

Expand All @@ -79,6 +70,7 @@ const sfc = {
name: 'RepoActionView',
components: {
SvgIcon,
RunStatus,
},
props: {
runIndex: String,
Expand Down
54 changes: 54 additions & 0 deletions web_src/js/runstatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {svg} from './svg.js';

// retrieve a HTML string for given run status, size and additional classes
function runstatus(status, size = 16, className = '') {
switch (status) {
case 'success':
return [
svg('octicon-check-circle-fill', size, className),
'green'
];
case 'skipped':
return [
svg('octicon-skip', size, className),
'ui text grey'
];
case 'waiting':
return [
svg('octicon-clock', size, className),
'ui text yellow'
];
case 'blocked':
return [
svg('octicon-blocked', size, className),
'ui text yellow'
];
case 'running':
return [
svg('octicon-meter', size, className),
'ui text yellow'
];
default:
return [
svg('octicon-x-circle-fill', size, className),
'red'
];
}
}

export const RunStatus = {
name: 'RunStatus',
props: {
status: {type: String, required: true},
size: {type: Number, default: 16},
className: {type: String, default: ''},
},

computed: {
runstatus() {
return runstatus(this.status, this.size, this.className);
},
},

template: `<span v-html="runstatus[0]" :class="runstatus[1]"/>`
};