Add run status in action view page (#24223)

Backport #23212
This commit is contained in:
yp05327 2023-04-20 16:24:50 +09:00 committed by GitHub
parent 7d717e22a8
commit 95c2cb4b79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -51,6 +51,7 @@ type ViewResponse struct {
Run struct { Run struct {
Link string `json:"link"` Link string `json:"link"`
Title string `json:"title"` Title string `json:"title"`
Status string `json:"status"`
CanCancel bool `json:"canCancel"` CanCancel bool `json:"canCancel"`
Done bool `json:"done"` Done bool `json:"done"`
Jobs []*ViewJob `json:"jobs"` Jobs []*ViewJob `json:"jobs"`
@ -109,6 +110,7 @@ func ViewPost(ctx *context_module.Context) {
resp.State.Run.CanCancel = !run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions) resp.State.Run.CanCancel = !run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
resp.State.Run.Done = run.Status.IsDone() resp.State.Run.Done = run.Status.IsDone()
resp.State.Run.Jobs = make([]*ViewJob, 0, len(jobs)) // marshal to '[]' instead fo 'null' in json resp.State.Run.Jobs = make([]*ViewJob, 0, len(jobs)) // marshal to '[]' instead fo 'null' in json
resp.State.Run.Status = run.Status.String()
for _, v := range jobs { for _, v := range jobs {
resp.State.Run.Jobs = append(resp.State.Run.Jobs, &ViewJob{ resp.State.Run.Jobs = append(resp.State.Run.Jobs, &ViewJob{
ID: v.ID, ID: v.ID,

View file

@ -2,7 +2,13 @@
<div class="action-view-container"> <div class="action-view-container">
<div class="action-view-header"> <div class="action-view-header">
<div class="action-info-summary"> <div class="action-info-summary">
<SvgIcon name="octicon-check-circle-fill" size="20" class="green" v-if="run.status === 'success'"/>
<SvgIcon name="octicon-clock" size="20" class="ui text yellow" v-else-if="run.status === 'waiting'"/>
<SvgIcon name="octicon-meter" size="20" class="ui text yellow" class-name="job-status-rotate" v-else-if="run.status === 'running'"/>
<SvgIcon name="octicon-x-circle-fill" size="20" class="red" v-else/>
<div class="action-title">
{{ run.title }} {{ run.title }}
</div>
<button class="run_cancel" @click="cancelRun()" v-if="run.canCancel"> <button class="run_cancel" @click="cancelRun()" v-if="run.canCancel">
<i class="stop circle outline icon"/> <i class="stop circle outline icon"/>
</button> </button>
@ -95,6 +101,7 @@ const sfc = {
run: { run: {
link: '', link: '',
title: '', title: '',
status: '',
canCancel: false, canCancel: false,
done: false, done: false,
jobs: [ jobs: [