mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-08 17:05:45 +02: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"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/modules/actions"
|
||||
context_module "code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
@ -51,9 +52,9 @@ type ViewRequest struct {
|
||||
type ViewResponse struct {
|
||||
StateData struct {
|
||||
RunInfo struct {
|
||||
HTMLURL string `json:"htmlurl"`
|
||||
Title string `json:"title"`
|
||||
Cancelable bool `json:"cancelable"`
|
||||
HTMLURL string `json:"htmlurl"`
|
||||
Title string `json:"title"`
|
||||
CanCancel bool `json:"can_cancel"`
|
||||
} `json:"runInfo"`
|
||||
AllJobGroups []ViewGroup `json:"allJobGroups"`
|
||||
CurrentJobInfo struct {
|
||||
@ -73,9 +74,10 @@ type ViewGroup struct {
|
||||
}
|
||||
|
||||
type ViewJob struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
CanRerun bool `json:"can_rerun"`
|
||||
}
|
||||
|
||||
type ViewJobStep struct {
|
||||
@ -110,14 +112,15 @@ func ViewPost(ctx *context_module.Context) {
|
||||
resp := &ViewResponse{}
|
||||
resp.StateData.RunInfo.Title = run.Title
|
||||
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))
|
||||
for i, v := range jobs {
|
||||
respJobs[i] = &ViewJob{
|
||||
ID: v.ID,
|
||||
Name: v.Name,
|
||||
Status: v.Status.String(),
|
||||
ID: v.ID,
|
||||
Name: v.Name,
|
||||
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-x-circle-fill" class="red" v-else/>
|
||||
{{ 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"/>
|
||||
</button>
|
||||
</a>
|
||||
</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
|
||||
</button>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user