Skip to content

New commits list #24423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ visibility.private = Private
visibility.private_tooltip = Visible only to organization members

[repo]
user_committed_date = %s committed %s
new_repo_helper = A repository contains all project files, including revision history. Already have it elsewhere? <a href="%s">Migrate repository.</a>
owner = Owner
owner_helper = Some organizations may not show up in the dropdown due to a maximum repository count limit.
Expand Down
155 changes: 71 additions & 84 deletions templates/repo/commits_list.tmpl
Original file line number Diff line number Diff line change
@@ -1,87 +1,74 @@
<div class="ui attached table segment commit-table">
<table class="ui very basic striped table unstackable fixed" id="commits-table">
<thead>
<tr>
<th class="three wide">{{.locale.Tr "repo.commits.author"}}</th>
<th class="two wide sha">SHA1</th>
<th class="nine wide message">{{.locale.Tr "repo.commits.message"}}</th>
<th class="two wide right aligned">{{.locale.Tr "repo.commits.date"}}</th>
</tr>
</thead>
<tbody class="commit-list">
{{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}}
{{range .Commits}}
<tr>
<td class="author">
{{$userName := .Author.Name}}
{{if .User}}
{{if .User.FullName}}
{{$userName = .User.FullName}}
{{end}}
{{avatar $.Context .User 28 "gt-mr-2"}}<a href="{{.User.HomeLink}}">{{$userName}}</a>
<div class="ui attached table segment commits-list">
{{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}}
{{range .Commits}}
<div class="commits-list-row gt-df gt-ac gt-px-4 gt-py-2">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These "gt-df gt-ac gt-px-4 gt-py-2" seems quite wordy.

Since it has a class commits-list-row, is it better to put the styles on the particular CSS class name?

Copy link
Member Author

@silverwind silverwind Apr 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the other issue, I think what can be done with helper classes should be done with them. I see CSS currently only for stuff that can not be done with helper classes.

Another benefit of helper classes is that they move when the element moves, so won't leave garbage CSS during refactoring.

I do like to retain descriptive class names, primarily as a visual aid for reading the code.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what can be done with helper classes should be done with them.

Totally agree. It helps when working on other people's code.

I do like to retain descriptive class names, primarily as a visual aid for reading the code.

Interesting idea. I'll give that a try,

<div class="commits-list-left gt-df gt-fc gt-f1">
<div class="commits-list-top-row">
<span class="message-wrapper">
{{if $.PageIsWiki}}
<span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{.Summary | RenderEmoji $.Context}}</span>
{{else}}
{{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}}
<span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject $.Context .Message $commitRepoLink $commitLink $.Repository.ComposeMetas}}</span>
{{end}}
</span>
{{if IsMultilineCommitMessage .Message}}
<button class="ui button ellipsis-button" aria-expanded="false">...</button>
{{end}}
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $}}
{{if IsMultilineCommitMessage .Message}}
<pre class="commit-body gt-hidden">{{RenderCommitBody $.Context .Message $commitRepoLink $.Repository.ComposeMetas}}</pre>
{{end}}
</div>
<div class="commits-list-bottom-row gt-df gt-ac gt-fw gt-my-1">
{{if .User}}
{{avatar $.Context .User 16 "gt-mr-2"}}
{{else}}
{{avatarByEmail $.Context .Author.Email .Author.Name 16 "gt-mr-2"}}
{{end}}
<div class="gt-dib">
{{$.locale.Tr "repo.user_committed_date"
(printf "<a href='%s'>%s</a>" (.User.HomeLink | Escape) (.Author.Name | Escape))
(TimeSince .Committer.When $.locale) | Safe}}
</div>
</div>
</div>
<div class="commits-list-right gt-df gt-ac">
<div class="sha gt-df">
<button class="ui button copy-commit-sha gt-df gt-ac" data-clipboard-text="{{.ID}}">{{svg "octicon-copy" 14}}</button>
{{$class := "ui sha label"}}
{{if .Signature}}
{{$class = (printf "%s%s" $class " isSigned")}}
{{if .Verification.Verified}}
{{if eq .Verification.TrustStatus "trusted"}}
{{$class = (printf "%s%s" $class " isVerified")}}
{{else if eq .Verification.TrustStatus "untrusted"}}
{{$class = (printf "%s%s" $class " isVerifiedUntrusted")}}
{{else}}
{{avatarByEmail $.Context .Author.Email .Author.Name 28 "gt-mr-2"}}
{{$userName}}
{{$class = (printf "%s%s" $class " isVerifiedUnmatched")}}
{{end}}
</td>
<td class="sha gt-df">
<button class="ui button copy-commit-sha gt-df gt-ac" data-clipboard-text="{{.ID}}">{{svg "octicon-copy" 14}}</button>
{{$class := "ui sha label"}}
{{if .Signature}}
{{$class = (printf "%s%s" $class " isSigned")}}
{{if .Verification.Verified}}
{{if eq .Verification.TrustStatus "trusted"}}
{{$class = (printf "%s%s" $class " isVerified")}}
{{else if eq .Verification.TrustStatus "untrusted"}}
{{$class = (printf "%s%s" $class " isVerifiedUntrusted")}}
{{else}}
{{$class = (printf "%s%s" $class " isVerifiedUnmatched")}}
{{end}}
{{else if .Verification.Warning}}
{{$class = (printf "%s%s" $class " isWarning")}}
{{end}}
{{end}}
{{if $.PageIsWiki}}
<a href="{{$commitRepoLink}}/wiki/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
{{else if $.Reponame}}
<a href="{{$commitRepoLink}}/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
{{else}}
<span class="{{$class}}">
{{end}}
<span class="shortsha">{{ShortSha .ID.String}}</span>
{{if .Signature}}
{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}
{{end}}
{{if $.Reponame}}
</a>
{{else}}
</span>
{{end}}
</td>
<td class="message">
<span class="message-wrapper">
{{if $.PageIsWiki}}
<span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{.Summary | RenderEmoji $.Context}}</span>
{{else}}
{{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}}
<span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject $.Context .Message $commitRepoLink $commitLink $.Repository.ComposeMetas}}</span>
{{end}}
</span>
{{if IsMultilineCommitMessage .Message}}
<button class="ui button ellipsis-button" aria-expanded="false">...</button>
{{end}}
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $}}
{{if IsMultilineCommitMessage .Message}}
<pre class="commit-body gt-hidden">{{RenderCommitBody $.Context .Message $commitRepoLink $.Repository.ComposeMetas}}</pre>
{{end}}
</td>
{{if .Committer}}
<td class="text right aligned">{{TimeSince .Committer.When $.locale}}</td>
{{else}}
<td class="text right aligned">{{TimeSince .Author.When $.locale}}</td>
{{else if .Verification.Warning}}
{{$class = (printf "%s%s" $class " isWarning")}}
{{end}}
{{end}}
{{if $.PageIsWiki}}
<a href="{{$commitRepoLink}}/wiki/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
{{else if $.Reponame}}
<a href="{{$commitRepoLink}}/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
{{else}}
<span class="{{$class}}">
{{end}}
<span class="shortsha">{{ShortSha .ID.String}}</span>
{{if .Signature}}
{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}
{{end}}
</tr>
{{end}}
</tbody>
</table>
</div>
{{if $.Reponame}}
</a>
{{else}}
</span>
{{end}}
</div>
</div>
</div>
{{end}}
</div>
Loading