Skip to content

Commit abac1ea

Browse files
committed
Adding a filter to only allow .workflow repo workflow to be added
Signed-off-by: Alex Lau(AvengerMoJo) <avengermojo@gmail.com>
1 parent 882e683 commit abac1ea

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

routers/web/repo/actions/actions.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func MustEnableActions(ctx *context.Context) {
6161
return
6262
}
6363
}
64+
6465
}
6566

6667
func List(ctx *context.Context) {
@@ -208,6 +209,10 @@ func List(ctx *context.Context) {
208209
actionsConfig := ctx.Repo.Repository.MustGetUnit(ctx, unit.TypeActions).ActionsConfig()
209210
ctx.Data["ActionsConfig"] = actionsConfig
210211

212+
if strings.HasSuffix(ctx.Repo.Repository.Name, ".workflow") {
213+
ctx.Data["AllowGlobalWorkflow"] = true
214+
}
215+
211216
if len(workflowID) > 0 && ctx.Repo.IsAdmin() {
212217
ctx.Data["AllowDisableOrEnableWorkflow"] = true
213218
isWorkflowDisabled := actionsConfig.IsWorkflowDisabled(workflowID)

templates/repo/actions/list.tmpl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@
8181
<a class="item link-action" data-url="{{$.Link}}/{{if .CurWorkflowDisabled}}enable{{else}}disable{{end}}?workflow={{$.CurWorkflow}}&actor={{.CurActor}}&status={{$.CurStatus}}">
8282
{{if .CurWorkflowDisabled}}{{ctx.Locale.Tr "actions.workflow.enable"}}{{else}}{{ctx.Locale.Tr "actions.workflow.disable"}}{{end}}
8383
</a>
84-
<a class="item link-action" data-url="{{$.Link}}/{{if .CurGlobalWorkflowEnable}}global_disable{{else}}global_enable{{end}}?workflow={{$.CurWorkflow}}&actor={{.CurActor}}&status={{$.CurStatus}}">
85-
{{if .CurGlobalWorkflowEnable}}{{ctx.Locale.Tr "actions.workflow.global_disable"}}{{else}}{{ctx.Locale.Tr "actions.workflow.global_enable"}}{{end}}
86-
</a>
87-
84+
{{if .AllowGlobalWorkflow}}
85+
<a class="item link-action" data-url="{{$.Link}}/{{if .CurGlobalWorkflowEnable}}global_disable{{else}}global_enable{{end}}?workflow={{$.CurWorkflow}}&actor={{.CurActor}}&status={{$.CurStatus}}">
86+
{{if .CurGlobalWorkflowEnable}}{{ctx.Locale.Tr "actions.workflow.global_disable"}}{{else}}{{ctx.Locale.Tr "actions.workflow.global_enable"}}{{end}}
87+
</a>
88+
{{end}}
8889
</div>
8990
</button>
9091
{{end}}

0 commit comments

Comments
 (0)