repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/container"
- "code.gitea.io/gitea/modules/util"
"xorm.io/builder"
)
db.ListOptions
RepoID int64
OwnerID int64
- IsClosed util.OptionalBool
WorkflowFileName string
TriggerUserID int64
Approved bool // not util.OptionalBool, it works only when it's true
if opts.OwnerID > 0 {
cond = cond.And(builder.Eq{"owner_id": opts.OwnerID})
}
- if opts.IsClosed.IsFalse() {
- cond = cond.And(builder.Eq{"status": StatusWaiting}.Or(
- builder.Eq{"status": StatusRunning}))
- } else if opts.IsClosed.IsTrue() {
- cond = cond.And(
- builder.Neq{"status": StatusWaiting}.And(
- builder.Neq{"status": StatusRunning}))
- }
if opts.WorkflowFileName != "" {
cond = cond.And(builder.Eq{"workflow_id": opts.WorkflowFileName})
}
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
- "code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/services/convert"
"github.com/nektos/act/pkg/model"
WorkflowFileName: workflow,
}
- // open counts
- opts.IsClosed = util.OptionalBoolFalse
- numOpenRuns, err := actions_model.CountRuns(ctx, opts)
- if err != nil {
- ctx.Error(http.StatusInternalServerError, err.Error())
- return
- }
- ctx.Data["NumOpenActionRuns"] = numOpenRuns
-
- // closed counts
- opts.IsClosed = util.OptionalBoolTrue
- numClosedRuns, err := actions_model.CountRuns(ctx, opts)
- if err != nil {
- ctx.Error(http.StatusInternalServerError, err.Error())
- return
- }
- ctx.Data["NumClosedActionRuns"] = numClosedRuns
-
- opts.IsClosed = util.OptionalBoolNone
- isShowClosed := ctx.FormString("state") == "closed"
- if len(ctx.FormString("state")) == 0 && numOpenRuns == 0 && numClosedRuns != 0 {
- isShowClosed = true
- }
-
- if isShowClosed {
- opts.IsClosed = util.OptionalBoolTrue
- ctx.Data["IsShowClosed"] = true
- } else {
- opts.IsClosed = util.OptionalBoolFalse
- }
-
runs, total, err := actions_model.FindRuns(ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
pager := context.NewPagination(int(total), opts.PageSize, opts.Page, 5)
pager.SetDefaultParams(ctx)
pager.AddParamString("workflow", workflow)
- pager.AddParamString("state", ctx.FormString("state"))
ctx.Data["Page"] = pager
ctx.HTML(http.StatusOK, tplListActions)
+++ /dev/null
-<div class="small-menu-items ui compact tiny menu">
- <a class="{{if not .IsShowClosed}}active {{end}}item" href="{{$.Link}}?workflow={{.CurWorkflow}}&state=open">
- {{svg "octicon-issue-opened" 16 "gt-mr-3"}}
- {{.locale.Tr "actions.runs.open_tab" $.NumOpenActionRuns}}
- </a>
- <a class="{{if .IsShowClosed}}active {{end}}item" href="{{$.Link}}?workflow={{.CurWorkflow}}&state=closed">
- {{svg "octicon-issue-closed" 16 "gt-mr-3"}}
- {{.locale.Tr "actions.runs.closed_tab" $.NumClosedActionRuns}}
- </a>
-</div>