Skip to content

Commit 485d8f1

Browse files
authored
Add "Cancel workflow run" button to Actions list page (#34817)
1 parent 181db69 commit 485d8f1

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3839,6 +3839,7 @@ runs.no_runs = The workflow has no runs yet.
38393839
runs.empty_commit_message = (empty commit message)
38403840
runs.expire_log_message = Logs have been purged because they were too old.
38413841
runs.delete = Delete workflow run
3842+
runs.cancel = Cancel workflow run
38423843
runs.delete.description = Are you sure you want to permanently delete this workflow run? This action cannot be undone.
38433844
runs.not_done = This workflow run is not done.
38443845
runs.view_workflow_file = View workflow file

routers/web/repo/actions/actions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func prepareWorkflowList(ctx *context.Context, workflows []Workflow) {
318318
ctx.Data["Page"] = pager
319319
ctx.Data["HasWorkflowsOrRuns"] = len(workflows) > 0 || len(runs) > 0
320320

321-
ctx.Data["AllowDeleteWorkflowRuns"] = ctx.Repo.CanWrite(unit.TypeActions)
321+
ctx.Data["CanWriteRepoUnitActions"] = ctx.Repo.CanWrite(unit.TypeActions)
322322
}
323323

324324
// loadIsRefDeleted loads the IsRefDeleted field for each run in the list.

templates/repo/actions/runs_list.tmpl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@
4040
{{svg "octicon-kebab-horizontal"}}
4141
<div class="menu flex-items-menu">
4242
<a class="item" href="{{$run.Link}}/workflow">{{svg "octicon-play"}}{{ctx.Locale.Tr "actions.runs.view_workflow_file"}}</a>
43-
{{if and $.AllowDeleteWorkflowRuns $run.Status.IsDone}}
43+
{{if and $.CanWriteRepoUnitActions (not $run.Status.IsDone)}}
44+
<a class="item link-action" data-url="{{$run.Link}}/cancel">
45+
{{svg "octicon-x"}}{{ctx.Locale.Tr "actions.runs.cancel"}}
46+
</a>
47+
{{end}}
48+
{{if and $.CanWriteRepoUnitActions $run.Status.IsDone}}
4449
<a class="item link-action"
4550
data-url="{{$run.Link}}/delete"
4651
data-modal-confirm="{{ctx.Locale.Tr "actions.runs.delete.description"}}"

templates/repo/actions/view_component.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
data-actions-url="{{.ActionsURL}}"
55

66
data-locale-approve="{{ctx.Locale.Tr "repo.diff.review.approve"}}"
7-
data-locale-cancel="{{ctx.Locale.Tr "cancel"}}"
7+
data-locale-cancel="{{ctx.Locale.Tr "actions.runs.cancel"}}"
88
data-locale-rerun="{{ctx.Locale.Tr "rerun"}}"
99
data-locale-rerun-all="{{ctx.Locale.Tr "rerun_all"}}"
1010
data-locale-runs-scheduled="{{ctx.Locale.Tr "actions.runs.scheduled"}}"

0 commit comments

Comments
 (0)