diff options
author | yp05327 <576951401@qq.com> | 2023-11-02 23:49:02 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-02 14:49:02 +0000 |
commit | dcb648ee71853073d54e8a6e107b764212ede58e (patch) | |
tree | c36b409ccd001f2dcbae5f60d7fda35661068a43 /templates/repo | |
parent | 0ba4ecc3bd8443f0d3a834530a44e0c1334554b7 (diff) | |
download | gitea-dcb648ee71853073d54e8a6e107b764212ede58e.tar.gz gitea-dcb648ee71853073d54e8a6e107b764212ede58e.zip |
Add `Hide/Show all checks` button to commit status check (#26284)
Step one for a GitHub like commit status check ui:
![image](https://github.com/go-gitea/gitea/assets/18380374/22953b88-1f91-4d19-bc57-ad92d33fa11f)
![image](https://github.com/go-gitea/gitea/assets/18380374/78572a49-c9b0-472b-86a8-8293197e807b)
![image](https://github.com/go-gitea/gitea/assets/18380374/bc5c8d1c-2ab5-4b03-b8c6-20c34b86d856)
Step two:
![image](https://github.com/go-gitea/gitea/assets/18380374/938b359e-8823-4192-b82d-55fa40b986fd)
![image](https://github.com/go-gitea/gitea/assets/18380374/2de5bb8f-40f5-462a-8d6d-bac13a32bc2a)
The design now will list all commit status checks which takes too much
space.
This is a pre-improve for #26247
---------
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'templates/repo')
-rw-r--r-- | templates/repo/commit_page.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/commit_statuses.tmpl | 12 | ||||
-rw-r--r-- | templates/repo/commits_list.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/commits_list_small.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/issue/view_content/pull.tmpl | 9 | ||||
-rw-r--r-- | templates/repo/pulls/status.tmpl | 67 | ||||
-rw-r--r-- | templates/repo/view_list.tmpl | 2 |
7 files changed, 56 insertions, 40 deletions
diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index c0dfc6e0ad..efdbb23e00 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -19,7 +19,7 @@ {{end}} <div class="ui top attached header clearing segment gt-relative commit-header {{$class}}"> <div class="gt-df gt-mb-4 gt-fw"> - <h3 class="gt-mb-0 gt-f1"><span class="commit-summary" title="{{.Commit.Summary}}">{{RenderCommitMessage $.Context .Commit.Message $.RepoLink ($.Repository.ComposeMetas ctx)}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses "root" $}}</h3> + <h3 class="gt-mb-0 gt-f1"><span class="commit-summary" title="{{.Commit.Summary}}">{{RenderCommitMessage $.Context .Commit.Message $.RepoLink ($.Repository.ComposeMetas ctx)}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses}}</h3> {{if not $.PageIsWiki}} <div> <a class="ui primary tiny button" href="{{.SourcePath}}"> diff --git a/templates/repo/commit_statuses.tmpl b/templates/repo/commit_statuses.tmpl index 0006dcb4a7..ec2be6c38d 100644 --- a/templates/repo/commit_statuses.tmpl +++ b/templates/repo/commit_statuses.tmpl @@ -8,15 +8,7 @@ {{template "repo/commit_status" .Status}} </span> {{end}} - <div class="tippy-target ui relaxed list divided"> - {{range .Statuses}} - <div class="ui item singular-status gt-df"> - {{template "repo/commit_status" .}} - <span class="ui gt-ml-3 gt-f1">{{.Context}} <span class="text grey">{{.Description}}</span></span> - {{if .TargetURL}} - <a class="gt-ml-3" href="{{.TargetURL}}" target="_blank" rel="noopener noreferrer">{{ctx.Locale.Tr "repo.pulls.status_checks_details"}}</a> - {{end}} - </div> - {{end}} + <div class="tippy-target"> + {{template "repo/pulls/status" (dict "CommitStatuses" .Statuses "CommitStatus" .Status)}} </div> {{end}} diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index cdb893f51f..77f1684245 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -66,7 +66,7 @@ {{if IsMultilineCommitMessage .Message}} <button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button> {{end}} - {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $}} + {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}} {{if IsMultilineCommitMessage .Message}} <pre class="commit-body gt-hidden">{{RenderCommitBody $.Context .Message $commitRepoLink ($.Repository.ComposeMetas ctx)}}</pre> {{end}} diff --git a/templates/repo/commits_list_small.tmpl b/templates/repo/commits_list_small.tmpl index 5b715a71d4..63eb5945bc 100644 --- a/templates/repo/commits_list_small.tmpl +++ b/templates/repo/commits_list_small.tmpl @@ -14,7 +14,7 @@ {{$commitLink:= printf "%s/commit/%s" $.comment.Issue.PullRequest.BaseRepo.Link (PathEscape .ID.String)}} <span class="shabox gt-df gt-ac gt-float-right"> - {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $.root}} + {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}} {{$class := "ui sha label"}} {{if .Signature}} {{$class = (print $class " isSigned")}} diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index e06404376c..2b5776ea03 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -20,7 +20,14 @@ {{- else if .Issue.PullRequest.CanAutoMerge}}green {{- else}}red{{end}}">{{svg "octicon-git-merge" 40}}</div> <div class="content"> - {{template "repo/pulls/status" .}} + <div class="ui attached segment fitted"> + {{template "repo/pulls/status" (dict + "CommitStatus" .LatestCommitStatus + "CommitStatuses" .LatestCommitStatuses + "ShowHideChecks" true + "is_context_required" .is_context_required + )}} + </div> {{$showGeneralMergeForm := false}} <div class="ui attached merge-section segment {{if not $.LatestCommitStatus}}no-header{{end}} flex-items-block"> {{if .Issue.PullRequest.HasMerged}} diff --git a/templates/repo/pulls/status.tmpl b/templates/repo/pulls/status.tmpl index 476b89a425..ae508b8fa4 100644 --- a/templates/repo/pulls/status.tmpl +++ b/templates/repo/pulls/status.tmpl @@ -1,27 +1,43 @@ -{{if $.LatestCommitStatus}} - {{if not $.Issue.PullRequest.HasMerged}} - <div class="ui top attached header"> - {{if eq .LatestCommitStatus.State "pending"}} - {{ctx.Locale.Tr "repo.pulls.status_checking"}} - {{else if eq .LatestCommitStatus.State "success"}} - {{ctx.Locale.Tr "repo.pulls.status_checks_success"}} - {{else if eq .LatestCommitStatus.State "warning"}} - {{ctx.Locale.Tr "repo.pulls.status_checks_warning"}} - {{else if eq .LatestCommitStatus.State "failure"}} - {{ctx.Locale.Tr "repo.pulls.status_checks_failure"}} - {{else if eq .LatestCommitStatus.State "error"}} - {{ctx.Locale.Tr "repo.pulls.status_checks_error"}} - {{else}} - {{ctx.Locale.Tr "repo.pulls.status_checking"}} - {{end}} - </div> - {{end}} +{{/* +Template Attributes: +* CommitStatus: summary of all commit status state +* CommitStatuses: all commit status elements +* ShowHideChecks: whether use a button to show/hide the checks +* is_context_required: Used in pull request commit status check table +*/}} + +{{if .CommitStatus}} +<div class="commit-status-panel"> + <div class="ui top attached header commit-status-header"> + {{if eq .CommitStatus.State "pending"}} + {{ctx.Locale.Tr "repo.pulls.status_checking"}} + {{else if eq .CommitStatus.State "success"}} + {{ctx.Locale.Tr "repo.pulls.status_checks_success"}} + {{else if eq .CommitStatus.State "warning"}} + {{ctx.Locale.Tr "repo.pulls.status_checks_warning"}} + {{else if eq .CommitStatus.State "failure"}} + {{ctx.Locale.Tr "repo.pulls.status_checks_failure"}} + {{else if eq .CommitStatus.State "error"}} + {{ctx.Locale.Tr "repo.pulls.status_checks_error"}} + {{else}} + {{ctx.Locale.Tr "repo.pulls.status_checking"}} + {{end}} - {{range $.LatestCommitStatuses}} - <div class="ui attached segment pr-status"> - {{template "repo/commit_status" .}} - <div class="status-context"> - <span>{{.Context}} <span class="text grey">{{.Description}}</span></span> + {{if .ShowHideChecks}} + <div class="ui right"> + <button class="commit-status-hide-checks btn interact-fg" + data-show-all="{{ctx.Locale.Tr "repo.pulls.status_checks_show_all"}}" + data-hide-all="{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}"> + {{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}</button> + </div> + {{end}} + </div> + + <div class="commit-status-list"> + {{range .CommitStatuses}} + <div class="commit-status-item"> + {{template "repo/commit_status" .}} + <div class="status-context gt-ellipsis">{{.Context}} <span class="text light-2">{{.Description}}</span></div> <div class="ui status-details"> {{if $.is_context_required}} {{if (call $.is_context_required .Context)}}<div class="ui label">{{ctx.Locale.Tr "repo.pulls.status_checks_requested"}}</div>{{end}} @@ -29,6 +45,7 @@ <span>{{if .TargetURL}}<a href="{{.TargetURL}}">{{ctx.Locale.Tr "repo.pulls.status_checks_details"}}</a>{{end}}</span> </div> </div> - </div> - {{end}} + {{end}} + </div> +</div> {{end}} diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index 7e60f27291..836c633ced 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -24,7 +24,7 @@ {{template "repo/shabox_badge" dict "root" $ "verification" .LatestCommitVerification}} {{end}} </a> - {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses "root" $}} + {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}} {{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}} <span class="grey commit-summary" title="{{.LatestCommit.Summary}}"><span class="message-wrapper">{{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $.RepoLink $commitLink ($.Repository.ComposeMetas ctx)}}</span> {{if IsMultilineCommitMessage .LatestCommit.Message}} |