From 6d2c63f6ffcbcd4a928b39527ecfd2cb53a2828c Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sun, 14 May 2023 19:04:24 +0300 Subject: [PATCH] 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 ![image](https://github.com/go-gitea/gitea/assets/20454870/be4fb69a-ea84-44bb-9606-65a0626be721) ![image](https://github.com/go-gitea/gitea/assets/20454870/68942224-e519-43f1-87fe-f3cffef5879a) # After ![image](https://github.com/go-gitea/gitea/assets/20454870/b3c3b200-ad44-4163-86ec-44a76362eae6) --------- Signed-off-by: Yarden Shoham --- models/actions/run_list.go | 10 -------- options/locale/locale_en-US.ini | 2 -- routers/web/repo/actions/actions.go | 33 --------------------------- templates/repo/actions/list.tmpl | 5 ---- templates/repo/actions/openclose.tmpl | 10 -------- templates/repo/actions/runs_list.tmpl | 2 +- 6 files changed, 1 insertion(+), 61 deletions(-) delete mode 100644 templates/repo/actions/openclose.tmpl diff --git a/models/actions/run_list.go b/models/actions/run_list.go index 18790db52..56de8eb91 100644 --- a/models/actions/run_list.go +++ b/models/actions/run_list.go @@ -10,7 +10,6 @@ import ( 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" ) @@ -69,7 +68,6 @@ type FindRunOptions struct { 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 @@ -83,14 +81,6 @@ func (opts FindRunOptions) toConds() builder.Cond { 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}) } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 0385c28c4..906a32dc2 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -3421,8 +3421,6 @@ runners.version = Version runners.reset_registration_token_success = Runner registration token reset successfully runs.all_workflows = All Workflows -runs.open_tab = %d Open -runs.closed_tab = %d Closed runs.commit = Commit runs.pushed_by = Pushed by runs.invalid_workflow_helper = Workflow config file is invalid. Please check your config file: %s diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go index 2e3a8976b..87ff07d5e 100644 --- a/routers/web/repo/actions/actions.go +++ b/routers/web/repo/actions/actions.go @@ -16,7 +16,6 @@ import ( "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" @@ -138,37 +137,6 @@ func List(ctx *context.Context) { 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()) @@ -189,7 +157,6 @@ func List(ctx *context.Context) { 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) diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index 2885aa0fb..ca97b67fa 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -19,11 +19,6 @@
-
-
- {{template "repo/actions/openclose" .}} -
-
{{template "repo/actions/runs_list" .}}
diff --git a/templates/repo/actions/openclose.tmpl b/templates/repo/actions/openclose.tmpl deleted file mode 100644 index 6874115a1..000000000 --- a/templates/repo/actions/openclose.tmpl +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/templates/repo/actions/runs_list.tmpl b/templates/repo/actions/runs_list.tmpl index caa14b339..fdef2e644 100644 --- a/templates/repo/actions/runs_list.tmpl +++ b/templates/repo/actions/runs_list.tmpl @@ -1,4 +1,4 @@ -
+
{{range .Runs}}