-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/relui: simplify rendering of homepage
This refactors the homepage rendering to use a nested template for each task row. This will help simplify the template as we add more complex layout to the outputs of workflows and tasks. Updates golang/go#51797 Updates golang/go#40279 For golang/go#53382 Change-Id: I85a86b82bdc79c7fb4e837d884af922c7028295d Reviewed-on: https://go-review.googlesource.com/c/build/+/412176 Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Alex Rakoczy <[email protected]>
- Loading branch information
Showing
5 changed files
with
145 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<!-- | ||
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}} | ||
<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"> | ||
{{$task.Result.String}} | ||
</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.Finished) (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="7"> | ||
{{if $task.Error.Valid}} | ||
<div class="TaskList-itemLogLine TaskList-itemLogLineError"> | ||
{{- $task.Error.Value -}} | ||
</div> | ||
{{end}} | ||
{{range $log := index $.TaskLogs $task.Name}} | ||
<div class="TaskList-itemLogLine"> | ||
{{- $log.CreatedAt.UTC.Format "2006/01/02 15:04:05"}} {{$log.Body -}} | ||
</div> | ||
{{end}} | ||
</td> | ||
</tr> | ||
</tbody> | ||
{{end}} | ||
</table> | ||
{{end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters