From f80737d257775ff224be0777902d7b54826f71c3 Mon Sep 17 00:00:00 2001 From: "Alex Lau(AvengerMoJo)" Date: Wed, 18 Sep 2024 20:02:50 +0800 Subject: [PATCH] Adding a filter to only allow .workflow repo workflow to be added Signed-off-by: Alex Lau(AvengerMoJo) --- routers/web/repo/actions/actions.go | 5 +++++ templates/repo/actions/list.tmpl | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go index 4511629948584..d484daef98041 100644 --- a/routers/web/repo/actions/actions.go +++ b/routers/web/repo/actions/actions.go @@ -61,6 +61,7 @@ func MustEnableActions(ctx *context.Context) { return } } + } func List(ctx *context.Context) { @@ -208,6 +209,10 @@ func List(ctx *context.Context) { actionsConfig := ctx.Repo.Repository.MustGetUnit(ctx, unit.TypeActions).ActionsConfig() ctx.Data["ActionsConfig"] = actionsConfig + if strings.HasSuffix(ctx.Repo.Repository.Name, ".workflow") { + ctx.Data["AllowGlobalWorkflow"] = true + } + if len(workflowID) > 0 && ctx.Repo.IsAdmin() { ctx.Data["AllowDisableOrEnableWorkflow"] = true isWorkflowDisabled := actionsConfig.IsWorkflowDisabled(workflowID) diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index 3ad80fc03710c..0a582291b175f 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -81,10 +81,11 @@ {{if .CurWorkflowDisabled}}{{ctx.Locale.Tr "actions.workflow.enable"}}{{else}}{{ctx.Locale.Tr "actions.workflow.disable"}}{{end}} - - {{if .CurGlobalWorkflowEnable}}{{ctx.Locale.Tr "actions.workflow.global_disable"}}{{else}}{{ctx.Locale.Tr "actions.workflow.global_enable"}}{{end}} - - + {{if .AllowGlobalWorkflow}} + + {{if .CurGlobalWorkflowEnable}}{{ctx.Locale.Tr "actions.workflow.global_disable"}}{{else}}{{ctx.Locale.Tr "actions.workflow.global_enable"}}{{end}} + + {{end}} {{end}}