{{template "base/head" .}}
<div class="page-content repository actions">
	{{template "repo/header" .}}
	<div class="ui container">
		{{template "base/alert" .}}

		{{if .HasWorkflowsOrRuns}}
		<div class="flex-container">
			<div class="flex-container-nav">
				<div class="ui fluid vertical menu">
					<a class="item {{if not $.CurWorkflow}}active{{end}}" href="?actor={{$.CurActor}}&status={{$.CurStatus}}&branch={{$.CurBranch}}">{{ctx.Locale.Tr "actions.runs.all_workflows"}}</a>
					{{range .workflows}}
						<a class="item flex-text-block {{if eq .Entry.Name $.CurWorkflow}}active{{end}}" href="?workflow={{.Entry.Name}}&actor={{$.CurActor}}&status={{$.CurStatus}}&branch={{$.CurBranch}}">
							<span class="gt-ellipsis">{{.DisplayName}}</span>

							{{if .ErrMsg}}
								<span class="flex-text-inline" data-tooltip-content="{{.ErrMsg}}">{{svg "octicon-alert" 16 "tw-text-red"}}</span>
							{{end}}

							{{if $.ActionsConfig.IsWorkflowDisabled .Entry.Name}}
								<div class="ui red label">{{ctx.Locale.Tr "disabled"}}</div>
							{{end}}
						</a>
					{{end}}
					{{if .OtherWorkflows}}
						<details class="item"{{if not $.CurWorkflowIsListed}} open{{end}}>
							<summary data-tooltip-content="{{ctx.Locale.Tr "actions.runs.other_workflows_tooltip"}}">
								<span class="flex-text-block">
									{{ctx.Locale.Tr "actions.runs.other_workflows"}}
									<span class="ui label">{{len .OtherWorkflows}}</span>
								</span>
							</summary>
							<div class="menu items-full-width">
								{{range .OtherWorkflows}}
									<a class="item {{if eq . $.CurWorkflow}}active{{end}}" href="?workflow={{.}}&actor={{$.CurActor}}&status={{$.CurStatus}}">
										<span class="gt-ellipsis">{{.}}</span>
									</a>
								{{end}}
							</div>
						</details>
					{{end}}
				</div>
			</div>
			<div class="flex-container-main">
				<div class="ui top attached header flex-left-right">
					<strong>{{ctx.Locale.TrN .Page.Paginater.Total "actions.runs.workflow_run_count_1" "actions.runs.workflow_run_count_n" .Page.Paginater.Total}}</strong>
					<div class="ui secondary filter menu flex-text-block tw-m-0">
						<!-- Actor -->
						<div class="ui{{if not .Actors}} disabled{{end}} dropdown jump item">
							<span class="text">{{ctx.Locale.Tr "actions.runs.actor"}}</span>
							{{svg "octicon-triangle-down" 14 "dropdown icon"}}
							<div class="menu">
								<div class="ui icon search input">
									<i class="icon">{{svg "octicon-search"}}</i>
									<input type="text" placeholder="{{ctx.Locale.Tr "actions.runs.actor"}}">
								</div>
								<a class="item{{if not $.CurActor}} selected{{end}}" href="?workflow={{$.CurWorkflow}}&status={{$.CurStatus}}&branch={{$.CurBranch}}&actor=0">
									{{ctx.Locale.Tr "actions.runs.actors_no_select"}}
								</a>
								{{range .Actors}}
									<a class="item{{if eq .ID $.CurActor}} selected{{end}}" href="?workflow={{$.CurWorkflow}}&actor={{.ID}}&status={{$.CurStatus}}&branch={{$.CurBranch}}">
										{{ctx.AvatarUtils.Avatar . 20}} {{.GetDisplayName}}
									</a>
								{{end}}
							</div>
						</div>
						<!-- Status -->
						<div class="ui dropdown jump item">
							<span class="text">{{ctx.Locale.Tr "actions.runs.status"}}</span>
							{{svg "octicon-triangle-down" 14 "dropdown icon"}}
							<div class="menu">
								<div class="ui icon search input">
									<i class="icon">{{svg "octicon-search"}}</i>
									<input type="text" placeholder="{{ctx.Locale.Tr "actions.runs.status"}}">
								</div>
								<a class="item{{if not $.CurStatus}} selected{{end}}" href="?workflow={{$.CurWorkflow}}&actor={{$.CurActor}}&branch={{$.CurBranch}}&status=0">
									{{ctx.Locale.Tr "actions.runs.status_no_select"}}
								</a>
								{{range .StatusInfoList}}
									<a class="item{{if eq .Status $.CurStatus}} selected{{end}}" href="?workflow={{$.CurWorkflow}}&actor={{$.CurActor}}&status={{.Status}}&branch={{$.CurBranch}}">
										{{.DisplayedStatus}}
									</a>
								{{end}}
							</div>
						</div>
						<!-- Branch -->
						<div class="ui{{if not .RunBranches}} disabled{{end}} dropdown jump item" data-test-id="filter-branch">
							<span class="text">{{ctx.Locale.Tr "actions.runs.branch"}}</span>
							{{svg "octicon-triangle-down" 14 "dropdown icon"}}
							<div class="menu">
								<div class="ui icon search input">
									<i class="icon">{{svg "octicon-search"}}</i>
									<input type="text" placeholder="{{ctx.Locale.Tr "actions.runs.branch"}}">
								</div>
								<a class="item{{if not $.CurBranch}} selected{{end}}" href="?workflow={{$.CurWorkflow}}&actor={{$.CurActor}}&status={{$.CurStatus}}">
									{{ctx.Locale.Tr "actions.runs.branches_no_select"}}
								</a>
								{{range .RunBranches}}
									<a class="item{{if eq . $.CurBranch}} selected{{end}}" href="?workflow={{$.CurWorkflow}}&actor={{$.CurActor}}&status={{$.CurStatus}}&branch={{.}}">
										{{.}}
									</a>
								{{end}}
							</div>
						</div>

						{{if and .AllowDisableOrEnableWorkflow .CurWorkflowIsListed $.CurWorkflow}}
						<button class="ui jump dropdown btn interact-bg tw-p-2">
							{{svg "octicon-kebab-horizontal"}}
							<div class="menu">
								<a class="item link-action" data-url="{{$.Link}}/{{if .CurWorkflowDisabled}}enable{{else}}disable{{end}}?workflow={{$.CurWorkflow}}&actor={{.CurActor}}&status={{$.CurStatus}}&branch={{$.CurBranch}}">
									{{if .CurWorkflowDisabled}}{{ctx.Locale.Tr "actions.workflow.enable"}}{{else}}{{ctx.Locale.Tr "actions.workflow.disable"}}{{end}}
								</a>
							</div>
						</button>
						{{end}}
					</div>
				</div>

				{{if .WorkflowDispatchConfig}}
					{{template "repo/actions/workflow_dispatch" .}}
				{{end}}

				<div class="ui attached segment">
					{{template "repo/actions/runs_list" .}}
				</div>
			</div>
		</div>
		{{else}}
			{{template "repo/actions/no_workflows" .}}
		{{end}}
	</div>
</div>
{{template "base/footer" .}}
