| <!-- |
| Copyright 2022 The Go Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style |
| license that can be found in the LICENSE file. |
| --> |
| {{define "task_list"}} |
| {{$workflow := .Workflow}} |
| <table class="TaskList"> |
| <thead> |
| <tr class="TaskList-item TaskList-itemHeader"> |
| <th class="TaskList-itemHeaderCol TaskList-itemExpand"></th> |
| <th class="TaskList-itemHeaderCol TaskList-itemState">State</th> |
| <th class="TaskList-itemHeaderCol TaskList-itemName">Name</th> |
| <th class="TaskList-itemHeaderCol TaskList-itemStarted">Started</th> |
| <th class="TaskList-itemHeaderCol TaskList-itemUpdated">Updated</th> |
| <th class="TaskList-itemHeaderCol TaskList-itemResult">Result</th> |
| <th class="TaskList-itemHeaderCol TaskList-itemActions">Actions</th> |
| </tr> |
| </thead> |
| {{range $task := .Tasks}} |
| {{ $resultDetail := unmarshalResultDetail $task.Result.String }} |
| <tbody> |
| <tr class="TaskList-item TaskList-itemSummary TaskList-expandableItem"> |
| <td class="TaskList-itemCol TaskList-itemExpand"> |
| <span class="TaskList-itemExpandClosed"> |
| <img class="TaskList-itemExpandControl" alt="unfold more" src="{{baseLink "/static/images/chevron_right_black_24dp.svg"}}" /> |
| </span> |
| <span class="TaskList-ItemExpandOpened"> |
| <img class="TaskList-itemExpandControl" alt="unfold less" src="{{baseLink "/static/images/expand_more_black_24dp.svg"}}" /> |
| </span> |
| </td> |
| <td class="TaskList-itemCol TaskList-itemState"> |
| {{if $task.Error.Valid}} |
| <img class="TaskList-itemStateIcon" alt="error" src="{{baseLink "/static/images/error_red_24dp.svg"}}" /> |
| {{else if $task.Finished}} |
| <img |
| class="TaskList-itemStateIcon" |
| alt="finished" |
| src="{{baseLink "/static/images/check_circle_green_24dp.svg"}}" /> |
| {{else}} |
| <img |
| class="TaskList-itemStateIcon" |
| alt="pending" |
| src="{{baseLink "/static/images/pending_yellow_24dp.svg"}}" /> |
| {{end}} |
| </td> |
| <td class="TaskList-itemCol TaskList-itemName"> |
| {{$task.Name}} |
| </td> |
| <td class="TaskList-itemCol TaskList-itemStarted"> |
| {{$task.CreatedAt.UTC.Format "Mon Jan _2 2006 15:04:05"}} |
| </td> |
| <td class="TaskList-itemCol TaskList-itemUpdated"> |
| {{$task.UpdatedAt.UTC.Format "Mon Jan _2 2006 15:04:05"}} |
| </td> |
| <td class="TaskList-itemCol TaskList-itemResult"> |
| {{if $task.ApprovedAt.Valid}} |
| Approved |
| {{else}} |
| {{ $resultDetail.Kind }} |
| {{end}} |
| </td> |
| <td class="TaskList-itemCol TaskList-itemAction"> |
| {{if $task.Error.Valid}} |
| <div class="TaskList-retryTask"> |
| <form action="{{baseLink (printf "/workflows/%s/tasks/%s/retry" $workflow.ID $task.Name)}}" method="post"> |
| <input type="hidden" id="workflow.id" name="workflow.id" value="{{$workflow.ID}}" /> |
| <input class="Button Button--small" name="task.reset" type="submit" value="Retry" onclick="return this.form.reportValidity() && confirm('This will retry the task and clear workflow errors.\n\nReady to proceed?')" /> |
| </form> |
| </div> |
| {{end}} |
| {{if and (not $task.ApprovedAt.Valid) (hasPrefix $task.Name "APPROVE-")}} |
| <div class="TaskList-approveTask"> |
| <form action="{{baseLink (printf "/workflows/%s/tasks/%s/approve" $workflow.ID $task.Name)}}" method="post"> |
| <input type="hidden" id="workflow.id" name="workflow.id" value="{{$workflow.ID}}" /> |
| <input class="Button Button--small" name="task.approve" type="submit" value="Approve" onclick="return this.form.reportValidity() && confirm('This will mark the task approved and resume the workflow.\n\nReady to proceed?')" /> |
| </form> |
| </div> |
| {{end}} |
| </td> |
| </tr> |
| <tr class="TaskList-itemLogsRow"> |
| <td class="TaskList-itemLogs" colspan="5"> |
| {{if $task.Error.Valid}} |
| <div class="TaskList-itemLogLine TaskList-itemLogLineError"> |
| {{- $task.Error.Value -}} |
| </div> |
| {{end}} |
| {{if $task.ApprovedAt.Valid}} |
| <div class="TaskList-itemLogLine TaskList-itemLogLineApproved"> |
| {{- printf "Approved at: %s" ($task.ApprovedAt.Value.UTC.Format "2006/01/02 15:04:05") -}} |
| </div> |
| {{end}} |
| {{range $log := index $.TaskLogs $task.Name}} |
| <div class="TaskList-itemLogLine"> |
| {{- printf "%s %s" ($log.CreatedAt.UTC.Format "2006/01/02 15:04:05") $log.Body -}} |
| </div> |
| {{end}} |
| {{if $task.Result.Valid}} |
| <div class="TaskList-itemLogLine"> |
| {{- $task.Result.String -}} |
| </div> |
| {{end}} |
| </td> |
| <td class="TaskList-itemResultDetail" colspan="2"> |
| {{template "itemResult" $resultDetail}} |
| </td> |
| </tr> |
| </tbody> |
| {{end}} |
| </table> |
| {{end}} |
| |
| {{define "itemResult"}} |
| {{$resultDetail := .}} |
| {{if eq $resultDetail.Kind "Artifact"}} |
| <dl class="TaskList-itemResultDetailList"> |
| <dt class="TaskList-itemResultTerm">Name</dt> |
| <dd class="TaskList-itemResultDefinition"> |
| {{$resultDetail.Artifact.Target.Name}} |
| </dd> |
| <dt class="TaskList-itemResultTerm">Filename</dt> |
| <dd class="TaskList-itemResultDefinition"> |
| {{$resultDetail.Artifact.Filename}} |
| </dd> |
| <dt class="TaskList-itemResultTerm">ScratchPath</dt> |
| <dd class="TaskList-itemResultDefinition"> |
| {{$resultDetail.Artifact.ScratchPath}} |
| </dd> |
| <dt class="TaskList-itemResultTerm">StagingPath</dt> |
| <dd class="TaskList-itemResultDefinition"> |
| {{$resultDetail.Artifact.StagingPath}} |
| </dd> |
| </dl> |
| {{else if eq $resultDetail.Kind "Artifacts"}} |
| <dt class="TaskList-itemResultTerm">Filenames</dt> |
| <dd class="TaskList-itemResultDefinition"> |
| {{range $artifact := $resultDetail.Artifacts}} |
| {{$artifact.Filename}} <span class="TaskList-itemResultArtifactSize">{{prettySize $artifact.Size}}</span> |
| {{end}} |
| </dd> |
| {{else if eq $resultDetail.Kind "Outputs"}} |
| {{range $key, $value := $resultDetail.Outputs}} |
| <dt class="TaskList-itemResultTerm"> |
| {{$key}} |
| </dt> |
| <dd class="TaskList-itemResultDefinition"> |
| {{template "itemResult" $value}} |
| </dd> |
| {{end}} |
| {{else if eq $resultDetail.Kind "JSON"}} |
| {{range $key, $value := $resultDetail.JSON}} |
| <dt class="TaskList-itemResultTerm"> |
| {{$key}} |
| </dt> |
| <dd class="TaskList-itemResultDefinition"> |
| {{$value}} |
| </dd> |
| {{end}} |
| {{else if eq $resultDetail.Kind "String"}} |
| <dt class="TaskList-itemResultTerm"> |
| String |
| </dt> |
| <dd class="TaskList-itemResultDefinition TaskList-itemResultDefinition--string"> |
| {{$resultDetail.String}} |
| </dd> |
| {{end}} |
| {{end}} |