mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Don't filter action runs based on state (#24711)
We should just show all runs. This removes the filtering altogether. - Replaces https://github.com/go-gitea/gitea/pull/24553 # Before   # After  --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com>
This commit is contained in:
		@@ -10,7 +10,6 @@ import (
 | 
				
			|||||||
	repo_model "code.gitea.io/gitea/models/repo"
 | 
						repo_model "code.gitea.io/gitea/models/repo"
 | 
				
			||||||
	user_model "code.gitea.io/gitea/models/user"
 | 
						user_model "code.gitea.io/gitea/models/user"
 | 
				
			||||||
	"code.gitea.io/gitea/modules/container"
 | 
						"code.gitea.io/gitea/modules/container"
 | 
				
			||||||
	"code.gitea.io/gitea/modules/util"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"xorm.io/builder"
 | 
						"xorm.io/builder"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -69,7 +68,6 @@ type FindRunOptions struct {
 | 
				
			|||||||
	db.ListOptions
 | 
						db.ListOptions
 | 
				
			||||||
	RepoID           int64
 | 
						RepoID           int64
 | 
				
			||||||
	OwnerID          int64
 | 
						OwnerID          int64
 | 
				
			||||||
	IsClosed         util.OptionalBool
 | 
					 | 
				
			||||||
	WorkflowFileName string
 | 
						WorkflowFileName string
 | 
				
			||||||
	TriggerUserID    int64
 | 
						TriggerUserID    int64
 | 
				
			||||||
	Approved         bool // not util.OptionalBool, it works only when it's true
 | 
						Approved         bool // not util.OptionalBool, it works only when it's true
 | 
				
			||||||
@@ -83,14 +81,6 @@ func (opts FindRunOptions) toConds() builder.Cond {
 | 
				
			|||||||
	if opts.OwnerID > 0 {
 | 
						if opts.OwnerID > 0 {
 | 
				
			||||||
		cond = cond.And(builder.Eq{"owner_id": opts.OwnerID})
 | 
							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 != "" {
 | 
						if opts.WorkflowFileName != "" {
 | 
				
			||||||
		cond = cond.And(builder.Eq{"workflow_id": opts.WorkflowFileName})
 | 
							cond = cond.And(builder.Eq{"workflow_id": opts.WorkflowFileName})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3421,8 +3421,6 @@ runners.version = Version
 | 
				
			|||||||
runners.reset_registration_token_success = Runner registration token reset successfully
 | 
					runners.reset_registration_token_success = Runner registration token reset successfully
 | 
				
			||||||
 | 
					
 | 
				
			||||||
runs.all_workflows = All Workflows
 | 
					runs.all_workflows = All Workflows
 | 
				
			||||||
runs.open_tab = %d Open
 | 
					 | 
				
			||||||
runs.closed_tab = %d Closed
 | 
					 | 
				
			||||||
runs.commit = Commit
 | 
					runs.commit = Commit
 | 
				
			||||||
runs.pushed_by = Pushed by
 | 
					runs.pushed_by = Pushed by
 | 
				
			||||||
runs.invalid_workflow_helper = Workflow config file is invalid. Please check your config file: %s
 | 
					runs.invalid_workflow_helper = Workflow config file is invalid. Please check your config file: %s
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,6 @@ import (
 | 
				
			|||||||
	"code.gitea.io/gitea/modules/context"
 | 
						"code.gitea.io/gitea/modules/context"
 | 
				
			||||||
	"code.gitea.io/gitea/modules/git"
 | 
						"code.gitea.io/gitea/modules/git"
 | 
				
			||||||
	"code.gitea.io/gitea/modules/setting"
 | 
						"code.gitea.io/gitea/modules/setting"
 | 
				
			||||||
	"code.gitea.io/gitea/modules/util"
 | 
					 | 
				
			||||||
	"code.gitea.io/gitea/services/convert"
 | 
						"code.gitea.io/gitea/services/convert"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/nektos/act/pkg/model"
 | 
						"github.com/nektos/act/pkg/model"
 | 
				
			||||||
@@ -138,37 +137,6 @@ func List(ctx *context.Context) {
 | 
				
			|||||||
		WorkflowFileName: workflow,
 | 
							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)
 | 
						runs, total, err := actions_model.FindRuns(ctx, opts)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		ctx.Error(http.StatusInternalServerError, err.Error())
 | 
							ctx.Error(http.StatusInternalServerError, err.Error())
 | 
				
			||||||
@@ -189,7 +157,6 @@ func List(ctx *context.Context) {
 | 
				
			|||||||
	pager := context.NewPagination(int(total), opts.PageSize, opts.Page, 5)
 | 
						pager := context.NewPagination(int(total), opts.PageSize, opts.Page, 5)
 | 
				
			||||||
	pager.SetDefaultParams(ctx)
 | 
						pager.SetDefaultParams(ctx)
 | 
				
			||||||
	pager.AddParamString("workflow", workflow)
 | 
						pager.AddParamString("workflow", workflow)
 | 
				
			||||||
	pager.AddParamString("state", ctx.FormString("state"))
 | 
					 | 
				
			||||||
	ctx.Data["Page"] = pager
 | 
						ctx.Data["Page"] = pager
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx.HTML(http.StatusOK, tplListActions)
 | 
						ctx.HTML(http.StatusOK, tplListActions)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,11 +19,6 @@
 | 
				
			|||||||
				</div>
 | 
									</div>
 | 
				
			||||||
			</div>
 | 
								</div>
 | 
				
			||||||
			<div class="twelve wide column content">
 | 
								<div class="twelve wide column content">
 | 
				
			||||||
				<div class="ui stackable grid">
 | 
					 | 
				
			||||||
					<div class="six wide column">
 | 
					 | 
				
			||||||
						{{template "repo/actions/openclose" .}}
 | 
					 | 
				
			||||||
					</div>
 | 
					 | 
				
			||||||
				</div>
 | 
					 | 
				
			||||||
				{{template "repo/actions/runs_list" .}}
 | 
									{{template "repo/actions/runs_list" .}}
 | 
				
			||||||
			</div>
 | 
								</div>
 | 
				
			||||||
		</div>
 | 
							</div>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +0,0 @@
 | 
				
			|||||||
<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>
 | 
					 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
<div class="issue list">
 | 
					<div class="issue list gt-m-0">
 | 
				
			||||||
	{{range .Runs}}
 | 
						{{range .Runs}}
 | 
				
			||||||
		<li class="item gt-df gt-py-3 gt-ab">
 | 
							<li class="item gt-df gt-py-3 gt-ab">
 | 
				
			||||||
			<div class="issue-item-left gt-df gt-mr-2">
 | 
								<div class="issue-item-left gt-df gt-mr-2">
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user