Skip to content

Commit b29d401

Browse files
committed
Complete the grouping design within the existing table.
1 parent c27d87a commit b29d401

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

Diff for: modules/templates/util_date.go

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ func NewDateUtils() *DateUtils {
2020
return (*DateUtils)(nil) // the util is stateless, and we do not need to create an instance
2121
}
2222

23+
func (du *DateUtils) DaysInterval(t1, t2 time.Time) int {
24+
t1 = time.Date(t1.Year(), t1.Month(), t1.Day(), 0, 0, 0, 0, t1.Location())
25+
t2 = time.Date(t2.Year(), t2.Month(), t2.Day(), 0, 0, 0, 0, t2.Location())
26+
return int(t2.Sub(t1).Hours() / 24)
27+
}
28+
2329
// AbsoluteShort renders in "Jan 01, 2006" format
2430
func (du *DateUtils) AbsoluteShort(time any) template.HTML {
2531
return dateTimeFormat("short", time)

Diff for: templates/repo/commits_list.tmpl

+6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
</thead>
1212
<tbody class="commit-list">
1313
{{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}}
14+
{{$groupDate := DateUtils.ParseLegacy ""}}
1415
{{range .Commits}}
16+
{{$commitDate := ""}}{{if .Committer}}{{$commitDate = .Committer.When}}{{else}}{{$commitDate = .Author.When}}{{end}}
17+
{{if ne (DateUtils.DaysInterval $groupDate $commitDate) 0}}
18+
{{$groupDate = $commitDate}}
19+
<tr class="header"><td colspan="5">Commits on {{DateUtils.AbsoluteShort $groupDate}}</td></tr>
20+
{{end}}
1521
<tr>
1622
<td class="author">
1723
<div class="tw-flex">

Diff for: web_src/css/repo.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,11 @@ td .commit-summary {
916916
width: 200px;
917917
}
918918

919-
.repository #commits-table.ui.basic.striped.table tbody tr:nth-child(2n) {
919+
.repository #commits-table.ui.basic.striped.table tbody tr {
920+
background-color: inherit !important;
921+
}
922+
923+
.repository #commits-table.ui.basic.striped.table tbody tr:not(.header):nth-child(2n) {
920924
background-color: var(--color-light) !important;
921925
}
922926

0 commit comments

Comments
 (0)