@@ -32,8 +32,9 @@ import (
32
32
)
33
33
34
34
const (
35
- tplListActions templates.TplName = "repo/actions/list"
36
- tplViewActions templates.TplName = "repo/actions/view"
35
+ tplListActions templates.TplName = "repo/actions/list"
36
+ tplDispatchInputsActions templates.TplName = "repo/actions/workflow_dispatch_inputs"
37
+ tplViewActions templates.TplName = "repo/actions/view"
37
38
)
38
39
39
40
type Workflow struct {
@@ -62,6 +63,14 @@ func MustEnableActions(ctx *context.Context) {
62
63
}
63
64
64
65
func List (ctx * context.Context ) {
66
+ renderListAndWorkflowDispatchTemplate (ctx , tplListActions , false )
67
+ }
68
+
69
+ func WorkflowDispatchInputs (ctx * context.Context ) {
70
+ renderListAndWorkflowDispatchTemplate (ctx , tplDispatchInputsActions , true )
71
+ }
72
+
73
+ func renderListAndWorkflowDispatchTemplate (ctx * context.Context , tplName templates.TplName , inputsOnly bool ) {
65
74
ctx .Data ["Title" ] = ctx .Tr ("actions.actions" )
66
75
ctx .Data ["PageIsActions" ] = true
67
76
workflowID := ctx .FormString ("workflow" )
@@ -75,10 +84,34 @@ func List(ctx *context.Context) {
75
84
ctx .ServerError ("IsEmpty" , err )
76
85
return
77
86
} else if ! empty {
78
- commit , err := ctx .Repo .GitRepo .GetBranchCommit (ctx .Repo .Repository .DefaultBranch )
79
- if err != nil {
80
- ctx .ServerError ("GetBranchCommit" , err )
81
- return
87
+ var commit * git.Commit
88
+ if inputsOnly {
89
+ ref := ctx .FormString ("ref" )
90
+ if len (ref ) == 0 {
91
+ ctx .ServerError ("ref" , nil )
92
+ return
93
+ }
94
+ // get target commit of run from specified ref
95
+ refName := git .RefName (ref )
96
+ var err error
97
+ if refName .IsTag () {
98
+ commit , err = ctx .Repo .GitRepo .GetTagCommit (refName .TagName ())
99
+ } else if refName .IsBranch () {
100
+ commit , err = ctx .Repo .GitRepo .GetBranchCommit (refName .BranchName ())
101
+ } else {
102
+ ctx .ServerError ("git_ref_name_error" , nil )
103
+ return
104
+ }
105
+ if err != nil {
106
+ ctx .ServerError ("target_ref_not_exist" , err )
107
+ return
108
+ }
109
+ } else {
110
+ commit , err = ctx .Repo .GitRepo .GetBranchCommit (ctx .Repo .Repository .DefaultBranch )
111
+ if err != nil {
112
+ ctx .ServerError ("GetBranchCommit" , err )
113
+ return
114
+ }
82
115
}
83
116
entries , err := actions .ListWorkflows (commit )
84
117
if err != nil {
@@ -207,65 +240,67 @@ func List(ctx *context.Context) {
207
240
}
208
241
}
209
242
210
- // if status or actor query param is not given to frontend href, (href="/<repoLink>/actions")
211
- // they will be 0 by default, which indicates get all status or actors
212
- ctx .Data ["CurActor" ] = actorID
213
- ctx .Data ["CurStatus" ] = status
214
- if actorID > 0 || status > int (actions_model .StatusUnknown ) {
215
- ctx .Data ["IsFiltered" ] = true
216
- }
243
+ if ! inputsOnly {
244
+ // if status or actor query param is not given to frontend href, (href="/<repoLink>/actions")
245
+ // they will be 0 by default, which indicates get all status or actors
246
+ ctx .Data ["CurActor" ] = actorID
247
+ ctx .Data ["CurStatus" ] = status
248
+ if actorID > 0 || status > int (actions_model .StatusUnknown ) {
249
+ ctx .Data ["IsFiltered" ] = true
250
+ }
217
251
218
- opts := actions_model.FindRunOptions {
219
- ListOptions : db.ListOptions {
220
- Page : page ,
221
- PageSize : convert .ToCorrectPageSize (ctx .FormInt ("limit" )),
222
- },
223
- RepoID : ctx .Repo .Repository .ID ,
224
- WorkflowID : workflowID ,
225
- TriggerUserID : actorID ,
226
- }
252
+ opts := actions_model.FindRunOptions {
253
+ ListOptions : db.ListOptions {
254
+ Page : page ,
255
+ PageSize : convert .ToCorrectPageSize (ctx .FormInt ("limit" )),
256
+ },
257
+ RepoID : ctx .Repo .Repository .ID ,
258
+ WorkflowID : workflowID ,
259
+ TriggerUserID : actorID ,
260
+ }
227
261
228
- // if status is not StatusUnknown, it means user has selected a status filter
229
- if actions_model .Status (status ) != actions_model .StatusUnknown {
230
- opts .Status = []actions_model.Status {actions_model .Status (status )}
231
- }
262
+ // if status is not StatusUnknown, it means user has selected a status filter
263
+ if actions_model .Status (status ) != actions_model .StatusUnknown {
264
+ opts .Status = []actions_model.Status {actions_model .Status (status )}
265
+ }
232
266
233
- runs , total , err := db .FindAndCount [actions_model.ActionRun ](ctx , opts )
234
- if err != nil {
235
- ctx .ServerError ("FindAndCount" , err )
236
- return
237
- }
267
+ runs , total , err := db .FindAndCount [actions_model.ActionRun ](ctx , opts )
268
+ if err != nil {
269
+ ctx .ServerError ("FindAndCount" , err )
270
+ return
271
+ }
238
272
239
- for _ , run := range runs {
240
- run .Repo = ctx .Repo .Repository
241
- }
273
+ for _ , run := range runs {
274
+ run .Repo = ctx .Repo .Repository
275
+ }
242
276
243
- if err := actions_model .RunList (runs ).LoadTriggerUser (ctx ); err != nil {
244
- ctx .ServerError ("LoadTriggerUser" , err )
245
- return
246
- }
277
+ if err := actions_model .RunList (runs ).LoadTriggerUser (ctx ); err != nil {
278
+ ctx .ServerError ("LoadTriggerUser" , err )
279
+ return
280
+ }
247
281
248
- if err := loadIsRefDeleted (ctx , ctx .Repo .Repository .ID , runs ); err != nil {
249
- log .Error ("LoadIsRefDeleted" , err )
250
- }
282
+ if err := loadIsRefDeleted (ctx , ctx .Repo .Repository .ID , runs ); err != nil {
283
+ log .Error ("LoadIsRefDeleted" , err )
284
+ }
251
285
252
- ctx .Data ["Runs" ] = runs
286
+ ctx .Data ["Runs" ] = runs
253
287
254
- actors , err := actions_model .GetActors (ctx , ctx .Repo .Repository .ID )
255
- if err != nil {
256
- ctx .ServerError ("GetActors" , err )
257
- return
258
- }
259
- ctx .Data ["Actors" ] = shared_user .MakeSelfOnTop (ctx .Doer , actors )
288
+ actors , err := actions_model .GetActors (ctx , ctx .Repo .Repository .ID )
289
+ if err != nil {
290
+ ctx .ServerError ("GetActors" , err )
291
+ return
292
+ }
293
+ ctx .Data ["Actors" ] = shared_user .MakeSelfOnTop (ctx .Doer , actors )
260
294
261
- ctx .Data ["StatusInfoList" ] = actions_model .GetStatusInfoList (ctx )
295
+ ctx .Data ["StatusInfoList" ] = actions_model .GetStatusInfoList (ctx )
262
296
263
- pager := context .NewPagination (int (total ), opts .PageSize , opts .Page , 5 )
264
- pager .AddParamFromRequest (ctx .Req )
265
- ctx .Data ["Page" ] = pager
266
- ctx .Data ["HasWorkflowsOrRuns" ] = len (workflows ) > 0 || len (runs ) > 0
297
+ pager := context .NewPagination (int (total ), opts .PageSize , opts .Page , 5 )
298
+ pager .AddParamFromRequest (ctx .Req )
299
+ ctx .Data ["Page" ] = pager
300
+ ctx .Data ["HasWorkflowsOrRuns" ] = len (workflows ) > 0 || len (runs ) > 0
301
+ }
267
302
268
- ctx .HTML (http .StatusOK , tplListActions )
303
+ ctx .HTML (http .StatusOK , tplName )
269
304
}
270
305
271
306
// loadIsRefDeleted loads the IsRefDeleted field for each run in the list.
0 commit comments