Fixes an visual bug where the info box to dispatch a workflow is shown even for users that lack permissions to actualy run the workflow. (#4305)

Example: Visit https://v8.next.forgejo.org/Mai-Lapyst/test/actions?workflow=dispatch.yaml&actor=0&status=0 without being logged in.

![image](/attachments/98e74104-4d60-4f7f-b17c-7e76467cd397)

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4305
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Mai-Lapyst <mai-lapyst@noreply.codeberg.org>
Co-committed-by: Mai-Lapyst <mai-lapyst@noreply.codeberg.org>
This commit is contained in:
Mai-Lapyst 2024-07-06 05:30:58 +00:00 committed by Earl Warren
parent c49afdf0ff
commit 98c8d45f0b
2 changed files with 13 additions and 2 deletions

View file

@ -95,6 +95,8 @@ func List(ctx *context.Context) {
allRunnerLabels.AddMultiple(r.AgentLabels...)
}
canRun := ctx.Repo.CanWrite(unit.TypeActions)
workflows = make([]Workflow, 0, len(entries))
for _, entry := range entries {
workflow := Workflow{Entry: *entry}
@ -146,7 +148,7 @@ func List(ctx *context.Context) {
}
workflows = append(workflows, workflow)
if workflow.Entry.Name() == curWorkflow {
if canRun && workflow.Entry.Name() == curWorkflow {
config := wf.WorkflowDispatchConfig()
if config != nil {
keys := util.KeysOfMap(config.Inputs)