mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-18 00:47:48 -04:00
fix: check if can_cancel and can_rerun
This commit is contained in:
parent
c355172878
commit
1f48a9ad6f
@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
actions_model "code.gitea.io/gitea/models/actions"
|
actions_model "code.gitea.io/gitea/models/actions"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
|
"code.gitea.io/gitea/models/unit"
|
||||||
"code.gitea.io/gitea/modules/actions"
|
"code.gitea.io/gitea/modules/actions"
|
||||||
context_module "code.gitea.io/gitea/modules/context"
|
context_module "code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
@ -51,9 +52,9 @@ type ViewRequest struct {
|
|||||||
type ViewResponse struct {
|
type ViewResponse struct {
|
||||||
StateData struct {
|
StateData struct {
|
||||||
RunInfo struct {
|
RunInfo struct {
|
||||||
HTMLURL string `json:"htmlurl"`
|
HTMLURL string `json:"htmlurl"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Cancelable bool `json:"cancelable"`
|
CanCancel bool `json:"can_cancel"`
|
||||||
} `json:"runInfo"`
|
} `json:"runInfo"`
|
||||||
AllJobGroups []ViewGroup `json:"allJobGroups"`
|
AllJobGroups []ViewGroup `json:"allJobGroups"`
|
||||||
CurrentJobInfo struct {
|
CurrentJobInfo struct {
|
||||||
@ -73,9 +74,10 @@ type ViewGroup struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ViewJob struct {
|
type ViewJob struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
CanRerun bool `json:"can_rerun"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ViewJobStep struct {
|
type ViewJobStep struct {
|
||||||
@ -110,14 +112,15 @@ func ViewPost(ctx *context_module.Context) {
|
|||||||
resp := &ViewResponse{}
|
resp := &ViewResponse{}
|
||||||
resp.StateData.RunInfo.Title = run.Title
|
resp.StateData.RunInfo.Title = run.Title
|
||||||
resp.StateData.RunInfo.HTMLURL = run.HTMLURL()
|
resp.StateData.RunInfo.HTMLURL = run.HTMLURL()
|
||||||
resp.StateData.RunInfo.Cancelable = !run.Status.IsDone()
|
resp.StateData.RunInfo.CanCancel = !run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
|
||||||
|
|
||||||
respJobs := make([]*ViewJob, len(jobs))
|
respJobs := make([]*ViewJob, len(jobs))
|
||||||
for i, v := range jobs {
|
for i, v := range jobs {
|
||||||
respJobs[i] = &ViewJob{
|
respJobs[i] = &ViewJob{
|
||||||
ID: v.ID,
|
ID: v.ID,
|
||||||
Name: v.Name,
|
Name: v.Name,
|
||||||
Status: v.Status.String(),
|
Status: v.Status.String(),
|
||||||
|
CanRerun: run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,12 +20,12 @@
|
|||||||
<SvgIcon name="octicon-meter" class="ui text yellow" class-name="job-status-rotate" v-else-if="job.status === 'running'"/>
|
<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/>
|
<SvgIcon name="octicon-x-circle-fill" class="red" v-else/>
|
||||||
{{ job.name }}
|
{{ job.name }}
|
||||||
<button class="job-brief-rerun" @click="rerunJob(index)" v-if="job.status !== 'waiting' && job.status !== 'blocked' && job.status !== 'running'">
|
<button class="job-brief-rerun" @click="rerunJob(index)" v-if="job.can_rerun">
|
||||||
<SvgIcon name="octicon-sync" class="ui text black"/>
|
<SvgIcon name="octicon-sync" class="ui text black"/>
|
||||||
</button>
|
</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<button class="ui fluid tiny basic red button" @click="cancelRun()" v-if="runInfo.cancelable">
|
<button class="ui fluid tiny basic red button" @click="cancelRun()" v-if="runInfo.can_cancel">
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user