From 80f51fef7ed61b9b61070bffddbcd8f8de00a4a1 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 | 4 ++++ templates/repo/actions/list.tmpl | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go index 4511629948..a8e791a584 100644 --- a/routers/web/repo/actions/actions.go +++ b/routers/web/repo/actions/actions.go @@ -208,6 +208,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 3ad80fc037..0a582291b1 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}}