[v14.0/forgejo] feat(ui): show update time when sorting by recently updated (#10500)

**Backport:** https://codeberg.org/forgejo/forgejo/pulls/10488

Fixes #4712
Fixes #7783

When filtering issues or PRs by "Recently updated" or "Least recently updated", the last updated time is shown:
![image](/attachments/f8e52a05-6055-42f9-9370-78196a173108)
![image](/attachments/50b63323-fe73-4ca5-8283-79fd6952d318)

Co-authored-by: Bram Hagens <bram@bramh.me>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10500
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
This commit is contained in:
forgejo-backport-action 2025-12-20 16:22:36 +01:00 committed by 0ko
parent 44102c47d4
commit 83da3ae68c
3 changed files with 37 additions and 0 deletions

View file

@ -62,6 +62,7 @@
"repo.issues.filter_mention.hint": "Filter by mentioned user",
"repo.issues.filter_modified.hint": "Filter by last modified date",
"repo.issues.filter_sort.hint": "Sort by: created/comments/updated/deadline",
"issues.updated": "updated %s",
"repo.pulls.poster_manage_approval": "Manage approval",
"repo.pulls.poster_requires_approval": "Some workflows are <a href=\"%[1]s\">waiting to be reviewed.</a>",
"repo.pulls.poster_requires_approval.tooltip": "The author of this pull request is not trusted to run workflows triggered by a pull request created from a forked repository or with AGit. The workflows triggered by a `pull_request` event will not run until they are approved.",

View file

@ -142,6 +142,12 @@
</span>
{{end}}
{{end}}
{{if or (eq $.SortType "recentupdate") (eq $.SortType "leastupdate")}}
<span class="flex-text-inline">
{{svg "octicon-history" 14}}
{{ctx.Locale.Tr "issues.updated" (DateUtils.TimeSince .UpdatedUnix)}}
</span>
{{end}}
</div>
</div>
</div>

View file

@ -131,6 +131,36 @@ func TestViewIssuesSortByType(t *testing.T) {
}
}
func TestViewIssuesSortByUpdatedTime(t *testing.T) {
defer tests.PrepareTestEnv(t)()
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
// When sorting by update time, the "updated" text and icon should appear
for _, sort := range []string{"recentupdate", "leastupdate"} {
req := NewRequest(t, "GET", repo.Link()+"/issues?sort="+sort)
resp := MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
issueList := htmlDoc.doc.Find("#issue-list")
updatedText := issueList.Find(".flex-item-body").First().Text()
assert.Contains(t, updatedText, "updated")
historyIcon := issueList.Find(".octicon-history")
assert.Positive(t, historyIcon.Length())
}
// When sorting by something else, the "updated" text and icon should NOT appear
req := NewRequest(t, "GET", repo.Link()+"/issues?sort=latest")
resp := MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
issueList := htmlDoc.doc.Find("#issue-list")
historyIcon := issueList.Find(".octicon-history")
assert.Empty(t, historyIcon.Length())
}
func TestViewIssuesKeyword(t *testing.T) {
defer tests.PrepareTestEnv(t)()