Skip to content

Commit

Permalink
Adding a filter to only allow .workflow repo workflow to be added
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Lau(AvengerMoJo) <[email protected]>
  • Loading branch information
AvengerMoJo committed Sep 18, 2024
1 parent 882e683 commit f80737d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions routers/web/repo/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func MustEnableActions(ctx *context.Context) {
return
}
}

}

func List(ctx *context.Context) {
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions templates/repo/actions/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@
<a class="item link-action" data-url="{{$.Link}}/{{if .CurWorkflowDisabled}}enable{{else}}disable{{end}}?workflow={{$.CurWorkflow}}&actor={{.CurActor}}&status={{$.CurStatus}}">
{{if .CurWorkflowDisabled}}{{ctx.Locale.Tr "actions.workflow.enable"}}{{else}}{{ctx.Locale.Tr "actions.workflow.disable"}}{{end}}
</a>
<a class="item link-action" data-url="{{$.Link}}/{{if .CurGlobalWorkflowEnable}}global_disable{{else}}global_enable{{end}}?workflow={{$.CurWorkflow}}&actor={{.CurActor}}&status={{$.CurStatus}}">
{{if .CurGlobalWorkflowEnable}}{{ctx.Locale.Tr "actions.workflow.global_disable"}}{{else}}{{ctx.Locale.Tr "actions.workflow.global_enable"}}{{end}}
</a>

{{if .AllowGlobalWorkflow}}
<a class="item link-action" data-url="{{$.Link}}/{{if .CurGlobalWorkflowEnable}}global_disable{{else}}global_enable{{end}}?workflow={{$.CurWorkflow}}&actor={{.CurActor}}&status={{$.CurStatus}}">
{{if .CurGlobalWorkflowEnable}}{{ctx.Locale.Tr "actions.workflow.global_disable"}}{{else}}{{ctx.Locale.Tr "actions.workflow.global_enable"}}{{end}}
</a>
{{end}}
</div>
</button>
{{end}}
Expand Down

0 comments on commit f80737d

Please sign in to comment.