diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index 8a268a5d14cd2..6001180734d2a 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -1,89 +1,79 @@
- - - - - - - - - - - - {{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}} - {{range .Commits}} - - - - - {{if .Committer}} - - {{else}} - + + {{if IsMultilineCommitMessage .Message}} +
{{ctx.RenderUtils.RenderCommitBody .Message $.Repository}}
{{end}} - - - {{end}} - -
{{ctx.Locale.Tr "repo.commits.author"}}{{StringUtils.ToUpper $.Repository.ObjectFormatName}}{{ctx.Locale.Tr "repo.commits.message"}}{{ctx.Locale.Tr "repo.commits.date"}}
-
- {{$userName := .Author.Name}} - {{if .User}} - {{if and .User.FullName DefaultShowFullName}} - {{$userName = .User.FullName}} - {{end}} - {{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}{{$userName}} +
+ {{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}} + {{range .Commits}} +
+
+
+ + {{if $.PageIsWiki}} + {{.Summary | ctx.RenderUtils.RenderEmoji}} {{else}} - {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "tw-mr-2"}} - {{$userName}} + {{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}} + {{ctx.RenderUtils.RenderCommitMessageLinkSubject .Message $commitLink $.Repository}} {{end}} -
-
- {{$commitBaseLink := ""}} - {{if $.PageIsWiki}} - {{$commitBaseLink = printf "%s/wiki/commit" $commitRepoLink}} - {{else if $.PageIsPullCommits}} - {{$commitBaseLink = printf "%s/pulls/%d/commits" $commitRepoLink $.Issue.Index}} - {{else if $.Reponame}} - {{$commitBaseLink = printf "%s/commit" $commitRepoLink}} - {{end}} - {{template "repo/commit_sign_badge" dict "Commit" . "CommitBaseLink" $commitBaseLink "CommitSignVerification" .Verification}} - - - {{if $.PageIsWiki}} - {{.Summary | ctx.RenderUtils.RenderEmoji}} - {{else}} - {{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}} - {{ctx.RenderUtils.RenderCommitMessageLinkSubject .Message $commitLink $.Repository}} - {{end}} {{if IsMultilineCommitMessage .Message}} - + {{end}} +
+ {{$commitBaseLink := ""}} + {{if $.PageIsWiki}} + {{$commitBaseLink = printf "%s/wiki/commit" $commitRepoLink}} + {{else if $.PageIsPullCommits}} + {{$commitBaseLink = printf "%s/pulls/%d/commits" $commitRepoLink $.Issue.Index}} + {{else if $.Reponame}} + {{$commitBaseLink = printf "%s/commit" $commitRepoLink}} + {{end}} + {{template "repo/commit_sign_badge" dict "Commit" . "CommitBaseLink" $commitBaseLink "CommitSignVerification" .Verification}} +
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}} - {{if IsMultilineCommitMessage .Message}} -
{{ctx.RenderUtils.RenderCommitBody .Message $.Repository}}
- {{end}} {{if $.CommitsTagsMap}} {{range (index $.CommitsTagsMap .ID.String)}} {{- template "repo/tag/name" dict "RepoLink" $.Repository.Link "TagName" .TagName "IsRelease" (not .IsTag) -}} {{end}} {{end}} -
{{DateUtils.TimeSince .Committer.When}}{{DateUtils.TimeSince .Author.When}} - - {{/* at the moment, wiki doesn't support these "view" links like "view at history point" */}} - {{if not $.PageIsWiki}} - {{/* view single file diff */}} - {{if $.FileTreePath}} - {{svg "octicon-file-diff"}} +
+ {{$userName := .Author.Name}} + {{if .User}} + {{if and .User.FullName DefaultShowFullName}} + {{$userName = .User.FullName}} {{end}} - - {{/* view at history point */}} - {{$viewCommitLink := printf "%s/src/commit/%s" $commitRepoLink (PathEscape .ID.String)}} - {{if $.FileTreePath}}{{$viewCommitLink = printf "%s/%s" $viewCommitLink (PathEscapeSegments $.FileTreePath)}}{{end}} - {{svg "octicon-file-code"}} + {{ctx.AvatarUtils.Avatar .User 20}} + {{$userName}} + {{else}} + {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "tw-mr-2"}} + {{$userName}} {{end}} -
+ {{if .Committer}} + {{DateUtils.TimeSince .Committer.When}} + {{else}} + {{DateUtils.TimeSince .Author.When}} + {{end}} +
+ +
+ + {{/* at the moment, wiki doesn't support these "view" links like "view at history point" */}} + {{if not $.PageIsWiki}} + {{/* view single file diff */}} + {{if $.FileTreePath}} + {{svg "octicon-file-diff"}} + {{end}} + + {{/* view at history point */}} + {{$viewCommitLink := printf "%s/src/commit/%s" $commitRepoLink (PathEscape .ID.String)}} + {{if $.FileTreePath}}{{$viewCommitLink = printf "%s/%s" $viewCommitLink (PathEscapeSegments $.FileTreePath)}}{{end}} + {{svg "octicon-file-code"}} + {{end}} +
+ + {{end}} + diff --git a/tests/integration/git_general_test.go b/tests/integration/git_general_test.go index 3b0f9589d2c63..c7a51d5191d3d 100644 --- a/tests/integration/git_general_test.go +++ b/tests/integration/git_general_test.go @@ -708,7 +708,7 @@ func doAutoPRMerge(baseCtx *APITestContext, dstPath string) func(t *testing.T) { doc := NewHTMLParser(t, resp.Body) // Get first commit URL - commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Last().Attr("href") + commitURL, exists := doc.doc.Find(".commit-table .flex-list .flex-item .sha a").Last().Attr("href") assert.True(t, exists) assert.NotEmpty(t, commitURL) diff --git a/tests/integration/pull_status_test.go b/tests/integration/pull_status_test.go index 49326a594aee6..4b413d4477316 100644 --- a/tests/integration/pull_status_test.go +++ b/tests/integration/pull_status_test.go @@ -50,7 +50,7 @@ func TestPullCreate_CommitStatus(t *testing.T) { doc := NewHTMLParser(t, resp.Body) // Get first commit URL - commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Last().Attr("href") + commitURL, exists := doc.doc.Find(".commit-table .flex-list .flex-item .sha a").Last().Attr("href") assert.True(t, exists) assert.NotEmpty(t, commitURL) @@ -88,12 +88,12 @@ func TestPullCreate_CommitStatus(t *testing.T) { resp = session.MakeRequest(t, req, http.StatusOK) doc = NewHTMLParser(t, resp.Body) - commitURL, exists = doc.doc.Find("#commits-table tbody tr td.sha a").Last().Attr("href") + commitURL, exists = doc.doc.Find(".commit-table .flex-list .flex-item .sha a").Last().Attr("href") assert.True(t, exists) assert.NotEmpty(t, commitURL) assert.Equal(t, commitID, path.Base(commitURL)) - cls, ok := doc.doc.Find("#commits-table tbody tr td.message .commit-status").Last().Attr("class") + cls, ok := doc.doc.Find(".commit-table .flex-list .flex-item .flex-item-title .commit-status").Last().Attr("class") assert.True(t, ok) assert.Contains(t, cls, statesIcons[status]) } diff --git a/tests/integration/repo_commits_search_test.go b/tests/integration/repo_commits_search_test.go index 9b05e3639912d..e97d50831f855 100644 --- a/tests/integration/repo_commits_search_test.go +++ b/tests/integration/repo_commits_search_test.go @@ -22,7 +22,7 @@ func testRepoCommitsSearch(t *testing.T, query, commit string) { resp := session.MakeRequest(t, req, http.StatusOK) doc := NewHTMLParser(t, resp.Body) - sel := doc.doc.Find("#commits-table tbody tr td.sha a") + sel := doc.doc.Find(".commit-table .flex-list .flex-item .sha a") assert.Equal(t, commit, strings.TrimSpace(sel.Text())) } diff --git a/tests/integration/repo_commits_test.go b/tests/integration/repo_commits_test.go index 0097a7f62eb87..154d8edf65ad5 100644 --- a/tests/integration/repo_commits_test.go +++ b/tests/integration/repo_commits_test.go @@ -32,7 +32,7 @@ func TestRepoCommits(t *testing.T) { resp := session.MakeRequest(t, req, http.StatusOK) doc := NewHTMLParser(t, resp.Body) - commitURL, exists := doc.doc.Find("#commits-table .commit-id-short").Attr("href") + commitURL, exists := doc.doc.Find(".commit-table .commit-id-short").Attr("href") assert.True(t, exists) assert.NotEmpty(t, commitURL) } @@ -45,14 +45,14 @@ func Test_ReposGitCommitListNotMaster(t *testing.T) { doc := NewHTMLParser(t, resp.Body) var commits []string - doc.doc.Find("#commits-table .commit-id-short").Each(func(i int, s *goquery.Selection) { + doc.doc.Find(".commit-table .commit-id-short").Each(func(i int, s *goquery.Selection) { commitURL, _ := s.Attr("href") commits = append(commits, path.Base(commitURL)) }) assert.Equal(t, []string{"69554a64c1e6030f051e5c3f94bfbd773cd6a324", "27566bd5738fc8b4e3fef3c5e72cce608537bd95", "5099b81332712fe655e34e8dd63574f503f61811"}, commits) var userHrefs []string - doc.doc.Find("#commits-table .author-wrapper").Each(func(i int, s *goquery.Selection) { + doc.doc.Find(".commit-table .author-wrapper").Each(func(i int, s *goquery.Selection) { userHref, _ := s.Attr("href") userHrefs = append(userHrefs, userHref) }) @@ -70,7 +70,7 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) { doc := NewHTMLParser(t, resp.Body) // Get first commit URL - commitURL, exists := doc.doc.Find("#commits-table .commit-id-short").Attr("href") + commitURL, exists := doc.doc.Find(".commit-table .commit-id-short").Attr("href") assert.True(t, exists) assert.NotEmpty(t, commitURL) @@ -88,7 +88,7 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) { doc = NewHTMLParser(t, resp.Body) // Check if commit status is displayed in message column (.tippy-target to ignore the tippy trigger) - sel := doc.doc.Find("#commits-table .message .tippy-target .commit-status") + sel := doc.doc.Find(".commit-table .flex-item-title .tippy-target .commit-status") assert.Equal(t, 1, sel.Length()) for _, class := range classes { assert.True(t, sel.HasClass(class)) @@ -164,7 +164,7 @@ func TestRepoCommitsStatusParallel(t *testing.T) { doc := NewHTMLParser(t, resp.Body) // Get first commit URL - commitURL, exists := doc.doc.Find("#commits-table .commit-id-short").Attr("href") + commitURL, exists := doc.doc.Find(".commit-table .commit-id-short").Attr("href") assert.True(t, exists) assert.NotEmpty(t, commitURL) @@ -199,7 +199,7 @@ func TestRepoCommitsStatusMultiple(t *testing.T) { doc := NewHTMLParser(t, resp.Body) // Get first commit URL - commitURL, exists := doc.doc.Find("#commits-table .commit-id-short").Attr("href") + commitURL, exists := doc.doc.Find(".commit-table .commit-id-short").Attr("href") assert.True(t, exists) assert.NotEmpty(t, commitURL) @@ -224,6 +224,6 @@ func TestRepoCommitsStatusMultiple(t *testing.T) { doc = NewHTMLParser(t, resp.Body) // Check that the data-global-init="initCommitStatuses" (for trigger) and commit-status (svg) are present - sel := doc.doc.Find(`#commits-table .message [data-global-init="initCommitStatuses"] .commit-status`) + sel := doc.doc.Find(`.commit-table .flex-list .flex-item .flex-item-title [data-global-init="initCommitStatuses"] .commit-status`) assert.Equal(t, 1, sel.Length()) } diff --git a/tests/integration/view_test.go b/tests/integration/view_test.go index 9ed3e30857522..2065ddda8d8c3 100644 --- a/tests/integration/view_test.go +++ b/tests/integration/view_test.go @@ -36,9 +36,9 @@ func TestCommitListActions(t *testing.T) { req := NewRequest(t, "GET", "/user2/repo1/wiki/Home?action=_revision") resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - AssertHTMLElement(t, htmlDoc, ".commit-list .copy-commit-id", true) - AssertHTMLElement(t, htmlDoc, `.commit-list .view-single-diff`, false) - AssertHTMLElement(t, htmlDoc, `.commit-list .view-commit-path`, false) + AssertHTMLElement(t, htmlDoc, ".commit-table .copy-commit-id", true) + AssertHTMLElement(t, htmlDoc, `.commit-table .view-single-diff`, false) + AssertHTMLElement(t, htmlDoc, `.commit-table .view-commit-path`, false) }) t.Run("RepoCommitList", func(t *testing.T) { @@ -48,9 +48,9 @@ func TestCommitListActions(t *testing.T) { resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - AssertHTMLElement(t, htmlDoc, `.commit-list .copy-commit-id`, true) - AssertHTMLElement(t, htmlDoc, `.commit-list .view-single-diff`, false) - AssertHTMLElement(t, htmlDoc, `.commit-list .view-commit-path`, true) + AssertHTMLElement(t, htmlDoc, `.commit-table .copy-commit-id`, true) + AssertHTMLElement(t, htmlDoc, `.commit-table .view-single-diff`, false) + AssertHTMLElement(t, htmlDoc, `.commit-table .view-commit-path`, true) }) t.Run("RepoFileHistory", func(t *testing.T) { @@ -60,8 +60,8 @@ func TestCommitListActions(t *testing.T) { resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - AssertHTMLElement(t, htmlDoc, `.commit-list .copy-commit-id`, true) - AssertHTMLElement(t, htmlDoc, `.commit-list .view-single-diff`, true) - AssertHTMLElement(t, htmlDoc, `.commit-list .view-commit-path`, true) + AssertHTMLElement(t, htmlDoc, `.commit-table .copy-commit-id`, true) + AssertHTMLElement(t, htmlDoc, `.commit-table .view-single-diff`, true) + AssertHTMLElement(t, htmlDoc, `.commit-table .view-commit-path`, true) }) } diff --git a/web_src/css/repo.css b/web_src/css/repo.css index 41fec58f9444c..66f00adcd41a1 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -612,12 +612,6 @@ td .commit-summary { padding-top: 0; } -.repository.view.issue .comment-list .timeline-item.event > .commit-status-link { - float: right; - margin-right: 8px; - margin-top: 4px; -} - .repository.view.issue .comment-list .timeline-item .comparebox { line-height: 32px; vertical-align: middle; @@ -918,17 +912,6 @@ td .commit-summary { padding: 5px 10px; } -.repository #commits-table td:not(.message) { - white-space: nowrap; -} -.repository #commits-table thead .sha { - width: 200px; -} - -.repository #commits-table.ui.basic.striped.table tbody tr:nth-child(2n) { - background-color: var(--color-light) !important; -} - .repository .data-table { width: 100%; } @@ -1581,10 +1564,6 @@ td .commit-summary { min-height: 30px; } -tbody.commit-list { - vertical-align: baseline; -} - .message-wrapper, .author-wrapper { overflow: hidden; @@ -1604,44 +1583,12 @@ tbody.commit-list { max-width: calc(100% - 2.5rem); } -/* in the commit list, messages can wrap so we can use inline */ -.commit-list .message-wrapper { - display: inline; - overflow-wrap: anywhere; -} - @media (max-width: 767.98px) { - tr.commit-list { - width: 100%; - } .author-wrapper { max-width: 80px; } } -@media (min-width: 768px) and (max-width: 991.98px) { - tr.commit-list { - width: 723px; - } -} - -@media (min-width: 992px) and (max-width: 1200px) { - tr.commit-list { - width: 933px; - } -} - -@media (min-width: 1201px) { - tr.commit-list { - width: 1127px; - } -} - -.commit-list .commit-status-link { - display: inline-block; - vertical-align: middle; -} - .commit-body { margin: 0.25em 0; white-space: pre-wrap; @@ -2050,10 +1997,6 @@ tbody.commit-list { .commit-table { overflow-x: auto; } - .commit-table td.sha, - .commit-table th.sha { - display: none !important; - } .comment-header { flex-wrap: wrap; } diff --git a/web_src/js/features/repo-commit.ts b/web_src/js/features/repo-commit.ts index 98ec2328ec5f4..3c179a31c33a1 100644 --- a/web_src/js/features/repo-commit.ts +++ b/web_src/js/features/repo-commit.ts @@ -6,7 +6,7 @@ export function initRepoEllipsisButton() { registerGlobalEventFunc('click', 'onRepoEllipsisButtonClick', async (el: HTMLInputElement, e: Event) => { e.preventDefault(); const expanded = el.getAttribute('aria-expanded') === 'true'; - toggleElem(el.parentElement.querySelector('.commit-body')); + toggleElem(el.parentElement.parentElement.querySelector('.commit-body')); el.setAttribute('aria-expanded', String(!expanded)); }); }