From 09aaad6c60774cc9d794721899cfe1bbc0bde327 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Thu, 20 Apr 2023 13:29:40 +0000 Subject: [PATCH 1/3] default show closed actions list if all actions was closed Signed-off-by: a1012112796 <1012112796@qq.com> --- routers/web/repo/actions/actions.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go index fc7ac2d714ec8..0a52aa8c6a1d6 100644 --- a/routers/web/repo/actions/actions.go +++ b/routers/web/repo/actions/actions.go @@ -165,9 +165,13 @@ func List(ctx *context.Context) { if ctx.FormString("state") == "closed" { opts.IsClosed = util.OptionalBoolTrue ctx.Data["IsShowClosed"] = true - } else { + } else if ctx.FormString("state") == "open" || numOpenRuns != 0 || numClosedRuns == 0 { opts.IsClosed = util.OptionalBoolFalse + } else { + opts.IsClosed = util.OptionalBoolTrue + ctx.Data["IsShowClosed"] = true } + runs, total, err := actions_model.FindRuns(ctx, opts) if err != nil { ctx.Error(http.StatusInternalServerError, err.Error()) From bf8a986930d05581a8e5997175614fc40c5c1d70 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Sat, 22 Apr 2023 04:30:41 +0000 Subject: [PATCH 2/3] simpfy logic Signed-off-by: a1012112796 <1012112796@qq.com> --- routers/web/repo/actions/actions.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go index 0a52aa8c6a1d6..36ce8e99a8fb8 100644 --- a/routers/web/repo/actions/actions.go +++ b/routers/web/repo/actions/actions.go @@ -162,10 +162,7 @@ func List(ctx *context.Context) { ctx.Data["NumClosedActionRuns"] = numClosedRuns opts.IsClosed = util.OptionalBoolNone - if ctx.FormString("state") == "closed" { - opts.IsClosed = util.OptionalBoolTrue - ctx.Data["IsShowClosed"] = true - } else if ctx.FormString("state") == "open" || numOpenRuns != 0 || numClosedRuns == 0 { + if ctx.FormString("state") == "open" || numOpenRuns != 0 || numClosedRuns == 0 { opts.IsClosed = util.OptionalBoolFalse } else { opts.IsClosed = util.OptionalBoolTrue From e4f1f5dbabeaa9018babaad920c4fc13f078cad3 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Mon, 24 Apr 2023 12:06:46 +0000 Subject: [PATCH 3/3] fix logic Signed-off-by: a1012112796 <1012112796@qq.com> --- routers/web/repo/actions/actions.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go index 36ce8e99a8fb8..8a44e836c5045 100644 --- a/routers/web/repo/actions/actions.go +++ b/routers/web/repo/actions/actions.go @@ -162,11 +162,16 @@ func List(ctx *context.Context) { ctx.Data["NumClosedActionRuns"] = numClosedRuns opts.IsClosed = util.OptionalBoolNone - if ctx.FormString("state") == "open" || numOpenRuns != 0 || numClosedRuns == 0 { - opts.IsClosed = util.OptionalBoolFalse - } else { + 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)