Skip to content

Commit ba336f6

Browse files
saithozeripath
authored andcommitted
Unifies commit list in repository commit table and wiki revision page (#7907)
Signed-off-by: Mario Lubenka <[email protected]>
1 parent 9175556 commit ba336f6

File tree

4 files changed

+101
-121
lines changed

4 files changed

+101
-121
lines changed

modules/templates/helper.go

+12
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,18 @@ func NewFuncMap() []template.FuncMap {
246246
"MirrorFullAddress": mirror_service.AddressNoCredentials,
247247
"MirrorUserName": mirror_service.Username,
248248
"MirrorPassword": mirror_service.Password,
249+
"CommitType": func(commit interface{}) string {
250+
switch commit.(type) {
251+
case models.SignCommitWithStatuses:
252+
return "SignCommitWithStatuses"
253+
case models.SignCommit:
254+
return "SignCommit"
255+
case models.UserCommit:
256+
return "UserCommit"
257+
default:
258+
return ""
259+
}
260+
},
249261
}}
250262
}
251263

templates/repo/commits_list.tmpl

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<div class="ui attached table segment">
2+
<table class="ui very basic striped fixed table single line" id="commits-table">
3+
<thead>
4+
<tr>
5+
<th class="four wide">{{.i18n.Tr "repo.commits.author"}}</th>
6+
<th class="two wide sha">SHA1</th>
7+
<th class="seven wide message">{{.i18n.Tr "repo.commits.message"}}</th>
8+
<th class="three wide right aligned">{{.i18n.Tr "repo.commits.date"}}</th>
9+
</tr>
10+
</thead>
11+
<tbody class="commit-list">
12+
{{ $r:= List .Commits}}
13+
{{range $r}}
14+
<tr>
15+
<td class="author">
16+
{{$userName := .Author.Name}}
17+
{{if .User}}
18+
{{if .User.FullName}}
19+
{{$userName = .User.FullName}}
20+
{{end}}
21+
<img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/>&nbsp;&nbsp;<a href="{{AppSubUrl}}/{{.User.Name}}">{{$userName}}</a>
22+
{{else}}
23+
<img class="ui avatar image" src="{{AvatarLink .Author.Email}}" alt=""/>&nbsp;&nbsp;{{$userName}}
24+
{{end}}
25+
</td>
26+
<td class="sha">
27+
{{$class := "ui sha label"}}
28+
{{if .Signature}}
29+
{{$class = (printf "%s%s" $class " isSigned")}}
30+
{{if .Verification.Verified}}
31+
{{$class = (printf "%s%s" $class " isVerified")}}
32+
{{else if .Verification.Warning}}
33+
{{$class = (printf "%s%s" $class " isWarning")}}
34+
{{end}}
35+
{{end}}
36+
{{if $.Reponame}}
37+
<a href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
38+
{{else}}
39+
<span class="{{$class}}">
40+
{{end}}
41+
{{ShortSha .ID.String}}
42+
{{if .Signature}}
43+
<div class="ui detail icon button">
44+
{{if .Verification.Verified}}
45+
<i title="{{.Verification.Reason}}" class="lock green icon"></i>
46+
{{if ne .Verification.SigningUser.ID 0}}
47+
<i title="{{.Verification.Reason}}" class="lock green icon"></i>
48+
{{else}}
49+
<i title="{{.Verification.Reason}}" class="icons">
50+
<i class="green lock icon"></i>
51+
<i class="tiny inverted cog icon centerlock"></i>
52+
</i>
53+
{{end}}
54+
{{else if .Verification.Warning}}
55+
<i title="{{$.i18n.Tr .Verification.Reason}}" class="red unlock icon"></i>
56+
{{else}}
57+
<i title="{{$.i18n.Tr .Verification.Reason}}" class="unlock icon"></i>
58+
{{end}}
59+
</div>
60+
{{end}}
61+
{{if $.Reponame}}
62+
</a>
63+
{{else}}
64+
</span>
65+
{{end}}
66+
</td>
67+
<td class="message">
68+
<span class="message-wrapper">
69+
{{ $commitLink:= printf "%s/%s/%s/commit/%s" AppSubUrl $.Username $.Reponame .ID }}
70+
<span class="commit-summary has-emoji{{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject .Message $.RepoLink $commitLink $.Repository.ComposeMetas}}</span>
71+
</span>
72+
{{if IsMultilineCommitMessage .Message}}
73+
<button class="basic compact mini ui icon button commit-button"><i class="ellipsis horizontal icon"></i></button>
74+
{{end}}
75+
{{if eq (CommitType .) "SignCommitWithStatuses"}}
76+
{{template "repo/commit_status" .Status}}
77+
{{end}}
78+
{{if IsMultilineCommitMessage .Message}}
79+
<pre class="commit-body" style="display: none;">{{RenderCommitBody .Message $.RepoLink $.Repository.ComposeMetas}}</pre>
80+
{{end}}
81+
</td>
82+
<td class="grey text right aligned">{{TimeSince .Author.When $.Lang}}</td>
83+
</tr>
84+
{{end}}
85+
</tbody>
86+
</table>
87+
</div>

templates/repo/commits_table.tmpl

+1-67
Original file line numberDiff line numberDiff line change
@@ -30,73 +30,7 @@
3030
</h4>
3131

3232
{{if and .Commits (gt .CommitCount 0)}}
33-
<div class="ui attached table segment">
34-
<table class="ui very basic striped fixed table single line" id="commits-table">
35-
<thead>
36-
<tr>
37-
<th class="four wide">{{.i18n.Tr "repo.commits.author"}}</th>
38-
<th class="two wide sha">SHA1</th>
39-
<th class="seven wide message">{{.i18n.Tr "repo.commits.message"}}</th>
40-
<th class="three wide right aligned">{{.i18n.Tr "repo.commits.date"}}</th>
41-
</tr>
42-
</thead>
43-
<tbody class="commit-list">
44-
{{ $r:= List .Commits}}
45-
{{range $r}}
46-
<tr>
47-
<td class="author">
48-
{{if .User}}
49-
{{if .User.FullName}}
50-
<img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/>&nbsp;&nbsp;<a href="{{AppSubUrl}}/{{.User.Name}}">{{.User.FullName}}</a>
51-
{{else}}
52-
<img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/>&nbsp;&nbsp;<a href="{{AppSubUrl}}/{{.User.Name}}">{{.Author.Name}}</a>
53-
{{end}}
54-
{{else}}
55-
<img class="ui avatar image" src="{{AvatarLink .Author.Email}}" alt=""/>&nbsp;&nbsp;{{.Author.Name}}
56-
{{end}}
57-
</td>
58-
<td class="sha">
59-
<a rel="nofollow" class="ui sha label {{if .Signature}} isSigned {{if .Verification.Verified }} isVerified {{else if .Verification.Warning}} isWarning {{end}}{{end}}" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}">
60-
{{ShortSha .ID.String}}
61-
{{if .Signature}}
62-
<div class="ui detail icon button">
63-
{{if .Verification.Verified}}
64-
{{if ne .Verification.SigningUser.ID 0}}
65-
<i title="{{.Verification.Reason}}" class="lock green icon"></i>
66-
{{else}}
67-
<i title="{{.Verification.Reason}}" class="icons">
68-
<i class="green lock icon"></i>
69-
<i class="tiny inverted cog icon centerlock"></i>
70-
</i>
71-
{{end}}
72-
{{else if .Verification.Warning}}
73-
<i title="{{$.i18n.Tr .Verification.Reason}}" class="red unlock icon"></i>
74-
{{else}}
75-
<i title="{{$.i18n.Tr .Verification.Reason}}" class="unlock icon"></i>
76-
{{end}}
77-
</div>
78-
{{end}}
79-
</a>
80-
</td>
81-
<td class="message">
82-
<span class="message-wrapper">
83-
{{ $commitLink:= printf "%s/%s/%s/commit/%s" AppSubUrl $.Username $.Reponame .ID }}
84-
<span class="commit-summary has-emoji{{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject .Message $.RepoLink $commitLink $.Repository.ComposeMetas}}</span>
85-
</span>
86-
{{if IsMultilineCommitMessage .Message}}
87-
<button class="basic compact mini ui icon button commit-button"><i class="ellipsis horizontal icon"></i></button>
88-
{{end}}
89-
{{template "repo/commit_status" .Status}}
90-
{{if IsMultilineCommitMessage .Message}}
91-
<pre class="commit-body" style="display: none;">{{RenderCommitBody .Message $.RepoLink $.Repository.ComposeMetas}}</pre>
92-
{{end}}
93-
</td>
94-
<td class="grey text right aligned">{{TimeSince .Author.When $.Lang}}</td>
95-
</tr>
96-
{{end}}
97-
</tbody>
98-
</table>
99-
</div>
33+
{{template "repo/commits_list" .}}
10034
{{end}}
10135

10236
{{template "base/paginate" .}}

templates/repo/wiki/revision.tmpl

+1-54
Original file line numberDiff line numberDiff line change
@@ -48,60 +48,7 @@
4848
</h4>
4949

5050
{{if and .Commits (gt .CommitCount 0)}}
51-
<div class="ui attached table segment">
52-
<table class="ui very basic striped fixed table single line" id="commits-table">
53-
<thead>
54-
<tr>
55-
<th class="four wide">{{.i18n.Tr "repo.commits.author"}}</th>
56-
<th class="tree wide sha">SHA1</th>
57-
<th class="five wide message">{{.i18n.Tr "repo.commits.message"}}</th>
58-
<th class="four wide">{{.i18n.Tr "repo.commits.date"}}</th>
59-
</tr>
60-
</thead>
61-
<tbody class="commit-list">
62-
{{ $r:= List .Commits}}
63-
{{range $r}}
64-
<tr>
65-
<td class="author">
66-
{{if .User}}
67-
{{if .User.FullName}}
68-
<img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/>&nbsp;&nbsp;<a href="{{AppSubUrl}}/{{.User.Name}}">{{.User.FullName}}</a>
69-
{{else}}
70-
<img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/>&nbsp;&nbsp;<a href="{{AppSubUrl}}/{{.User.Name}}">{{.Author.Name}}</a>
71-
{{end}}
72-
{{else}}
73-
<img class="ui avatar image" src="{{AvatarLink .Author.Email}}" alt=""/>&nbsp;&nbsp;{{.Author.Name}}
74-
{{end}}
75-
</td>
76-
<td class="sha">
77-
<label rel="nofollow" class="ui sha label {{if .Signature}} isSigned {{if .Verification.Verified }} isVerified {{end}}{{end}}">
78-
{{ShortSha .ID.String}}
79-
{{if .Signature}}
80-
<div class="ui detail icon button">
81-
{{if .Verification.Verified}}
82-
<i title="{{.Verification.Reason}}" class="lock green icon"></i>
83-
{{else}}
84-
<i title="{{$.i18n.Tr .Verification.Reason}}" class="unlock icon"></i>
85-
{{end}}
86-
</div>
87-
{{end}}
88-
</label>
89-
</td>
90-
<td class="message">
91-
<span class="message-wrapper">
92-
<span class="commit-summary has-emoji{{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{.Summary}}</span>
93-
{{if IsMultilineCommitMessage .Message}}
94-
<button class="basic compact mini ui icon button commit-button"><i class="ellipsis horizontal icon"></i></button>
95-
<pre class="commit-body" style="display: none;">{{RenderCommitBody .Message $.RepoLink $.Repository.ComposeMetas}}</pre>
96-
{{end}}
97-
</span>
98-
</td>
99-
<td class="grey text">{{TimeSince .Author.When $.Lang}}</td>
100-
</tr>
101-
{{end}}
102-
</tbody>
103-
</table>
104-
</div>
51+
{{template "repo/commits_list" .}}
10552
{{end}}
10653

10754
{{template "base/paginate" .}}

0 commit comments

Comments
 (0)