From b7e3adc66c01dc6c81126ca4c031cad48d6eb6c4 Mon Sep 17 00:00:00 2001
From: Giteabot <teabot@gitea.io>
Date: Wed, 6 Dec 2023 15:28:00 +0800
Subject: [PATCH] Fix the runs will not be displayed bug when the main branch
 have no workflows but other branches have (#28359) (#28365)

Backport #28359 by @lunny

The left menu will only display the default branch's workflows but the
right side will display the runs triggered by all branches' workflows.
So we cannot hide right side if default branch has no workflows.

Fix #28332
Replace #28333

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
---
 routers/web/repo/actions/actions.go | 1 +
 templates/repo/actions/list.tmpl    | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go
index 6284d21463..1de402ccc0 100644
--- a/routers/web/repo/actions/actions.go
+++ b/routers/web/repo/actions/actions.go
@@ -201,6 +201,7 @@ func List(ctx *context.Context) {
 	pager.AddParamString("actor", fmt.Sprint(actorID))
 	pager.AddParamString("status", fmt.Sprint(status))
 	ctx.Data["Page"] = pager
+	ctx.Data["HasWorkflowsOrRuns"] = len(workflows) > 0 || len(runs) > 0
 
 	ctx.HTML(http.StatusOK, tplListActions)
 }
diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl
index ede4c82602..62d30305b3 100644
--- a/templates/repo/actions/list.tmpl
+++ b/templates/repo/actions/list.tmpl
@@ -4,7 +4,7 @@
 	<div class="ui container">
 		{{template "base/alert" .}}
 
-		{{if .workflows}}
+		{{if .HasWorkflowsOrRuns}}
 		<div class="ui stackable grid">
 			<div class="four wide column">
 				<div class="ui fluid vertical menu">