From c5bb91a9eb27d99f9b210ce6222e4838a8bfad82 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Wed, 22 Nov 2023 10:29:54 +0800 Subject: [PATCH] Add guide page to actions when there's no workflows (#28145) (#28153) Backport #28145 by @yp05327 Before: ![image](https://github.com/go-gitea/gitea/assets/18380374/599d40c1-9b8d-4189-9286-c9c36fb780dd) After: ![image](https://github.com/go-gitea/gitea/assets/18380374/848a73d1-aaec-478f-93a7-adcc7ee18907) Co-authored-by: yp05327 <576951401@qq.com> (cherry picked from commit 9bfee5014b408216d1ac8e19a803649109625dff) --- modules/context/repo.go | 1 + options/locales/gitea_en-US.ini | 3 +++ templates/repo/actions/list.tmpl | 4 ++++ templates/repo/actions/no_workflows.tmpl | 8 ++++++++ 4 files changed, 16 insertions(+) create mode 100644 templates/repo/actions/no_workflows.tmpl diff --git a/modules/context/repo.go b/modules/context/repo.go index 861df4af59..dca0791fe3 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -560,6 +560,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc { ctx.Data["CanWriteCode"] = ctx.Repo.CanWrite(unit_model.TypeCode) ctx.Data["CanWriteIssues"] = ctx.Repo.CanWrite(unit_model.TypeIssues) ctx.Data["CanWritePulls"] = ctx.Repo.CanWrite(unit_model.TypePullRequests) + ctx.Data["CanWriteActions"] = ctx.Repo.CanWrite(unit_model.TypeActions) canSignedUserFork, err := repo_module.CanUserForkRepo(ctx, ctx.Doer, ctx.Repo.Repository) if err != nil { diff --git a/options/locales/gitea_en-US.ini b/options/locales/gitea_en-US.ini index 6892fc0449..6535095bdb 100644 --- a/options/locales/gitea_en-US.ini +++ b/options/locales/gitea_en-US.ini @@ -3557,6 +3557,9 @@ runs.status = Status runs.actors_no_select = All actors runs.status_no_select = All status runs.no_results = No results matched. +runs.no_workflows = There are no workflows yet. +runs.no_workflows.quick_start = Don't know how to start with Gitea Action? See the quick start guide. +runs.no_workflows.documentation = For more information on the Gitea Action, see the documentation. runs.no_runs = The workflow has no runs yet. runs.empty_commit_message = (empty commit message) diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index aa6d66fa68..ede4c82602 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -4,6 +4,7 @@
{{template "base/alert" .}} + {{if .workflows}}
+ {{else}} + {{template "repo/actions/no_workflows" .}} + {{end}}
{{template "base/footer" .}} diff --git a/templates/repo/actions/no_workflows.tmpl b/templates/repo/actions/no_workflows.tmpl new file mode 100644 index 0000000000..af1f28e8cf --- /dev/null +++ b/templates/repo/actions/no_workflows.tmpl @@ -0,0 +1,8 @@ +
+ {{svg "octicon-no-entry" 48}} +

{{ctx.Locale.Tr "actions.runs.no_workflows"}}

+ {{if and .CanWriteCode .CanWriteActions}} +

{{ctx.Locale.Tr "actions.runs.no_workflows.quick_start" "https://docs.gitea.com/usage/actions/quickstart/" | Safe}}

+ {{end}} +

{{ctx.Locale.Tr "actions.runs.no_workflows.documentation" "https://docs.gitea.com/usage/actions/overview/" | Safe}}

+