Skip to content

Commit 5524878

Browse files
committed
add CurWorkflowExists, format tmpl
1 parent c241c6c commit 5524878

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

routers/web/repo/actions/actions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ func WorkflowDispatchInputs(ctx *context.Context) {
105105
func prepareWorkflowDispatchTemplate(ctx *context.Context, commit *git.Commit) (workflows []Workflow) {
106106
workflowID := ctx.FormString("workflow")
107107
ctx.Data["CurWorkflow"] = workflowID
108+
ctx.Data["CurWorkflowExists"] = false
108109

109110
var curWorkflow *model.Workflow
110111

@@ -182,6 +183,7 @@ func prepareWorkflowDispatchTemplate(ctx *context.Context, commit *git.Commit) (
182183

183184
if workflow.Entry.Name() == workflowID {
184185
curWorkflow = wf
186+
ctx.Data["CurWorkflowExists"] = true
185187
}
186188
}
187189

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
11
{{if not .WorkflowDispatchConfig}}
2-
<div class="ui red info message tw-flex tw-justify-between tw-items-center">
3-
<span class="ui text middle">{{ctx.Locale.Tr "actions.workflow.not_found" $.CurWorkflow}}</span>
2+
<div class="ui red message">
3+
{{/* TODO: Technically this error is also shown if no workflow_dispatch is defined. However we need to know if the workflow exist like in #33098 (comment) to render a different error text.
4+
A: does the newly added "CurWorkflowExists" help? */}}
5+
{{ctx.Locale.Tr "actions.workflow.not_found" $.CurWorkflow}}
46
</div>
57
{{else}}
68
{{range $item := .WorkflowDispatchConfig.Inputs}}
7-
<div class="ui field {{if .Required}}required{{end}}">
8-
{{if eq .Type "choice"}}
9-
<label>{{Iif .Description .Description .Name}}:</label>
10-
<select class="ui selection type dropdown" name="{{.Name}}">
11-
{{range .Options}}
12-
<option value="{{.}}" {{if eq $item.Default .}}selected{{end}} >{{.}}</option>
13-
{{end}}
14-
</select>
15-
{{else if eq .Type "boolean"}}
16-
<div class="ui inline checkbox">
17-
<label>{{Iif .Description .Description .Name}}</label>
18-
<input type="checkbox" name="{{.Name}}" {{if eq .Default "true"}}checked{{end}}>
19-
</div>
20-
{{else if eq .Type "number"}}
21-
<label>{{Iif .Description .Description .Name}}:</label>
22-
<input name="{{.Name}}" value="{{.Default}}" {{if .Required}}required{{end}}>
23-
{{else}}
24-
<label>{{Iif .Description .Description .Name}}:</label>
25-
<input name="{{.Name}}" value="{{.Default}}" {{if .Required}}required{{end}}>
26-
{{end}}
27-
</div>
9+
<div class="ui field {{if .Required}}required{{end}}">
10+
{{if eq .Type "choice"}}
11+
<label>{{or .Description .Name}}:</label>
12+
<select class="ui selection type dropdown" name="{{.Name}}">
13+
{{range .Options}}
14+
<option value="{{.}}" {{if eq $item.Default .}}selected{{end}} >{{.}}</option>
15+
{{end}}
16+
</select>
17+
{{else if eq .Type "boolean"}}
18+
<div class="ui inline checkbox">
19+
<label>{{or .Description .Name}}</label>
20+
<input type="checkbox" name="{{.Name}}" {{if eq .Default "true"}}checked{{end}}>
21+
</div>
22+
{{else if eq .Type "number"}}
23+
<label>{{or .Description .Name}}:</label>
24+
<input name="{{.Name}}" value="{{.Default}}" {{if .Required}}required{{end}}>
25+
{{else}}
26+
<label>{{or .Description .Name}}:</label>
27+
<input name="{{.Name}}" value="{{.Default}}" {{if .Required}}required{{end}}>
28+
{{end}}
29+
</div>
2830
{{end}}
29-
<button class="ui tiny primary button" type="submit">Submit</button>
31+
<div class="ui field">
32+
<button class="ui tiny primary button" type="submit">Submit</button>
33+
</div>
3034
{{end}}
3135
{{range .workflows}}
3236
{{if and .ErrMsg (eq .Entry.Name $.CurWorkflow)}}
33-
<span data-tooltip-content="{{.ErrMsg}}">
34-
{{svg "octicon-alert" 16 "text red"}}
35-
</span>
37+
<div class="ui field">
38+
<div>{{svg "octicon-alert" 16 "text red"}} {{.ErrMsg}}</div>
39+
</div>
3640
{{end}}
3741
{{end}}

0 commit comments

Comments
 (0)