From 83da3ae68c06cc4144c91302d61ed229570f689b Mon Sep 17 00:00:00 2001 From: forgejo-backport-action Date: Sat, 20 Dec 2025 16:22:36 +0100 Subject: [PATCH] [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 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10500 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: forgejo-backport-action Co-committed-by: forgejo-backport-action --- options/locale_next/locale_en-US.json | 1 + templates/shared/issuelist.tmpl | 6 ++++++ tests/integration/issue_test.go | 30 +++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/options/locale_next/locale_en-US.json b/options/locale_next/locale_en-US.json index d9d23653cd..38d7d18e7e 100644 --- a/options/locale_next/locale_en-US.json +++ b/options/locale_next/locale_en-US.json @@ -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 waiting to be reviewed.", "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.", diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index ff7aa9c0a4..3e20cc5080 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -142,6 +142,12 @@ {{end}} {{end}} + {{if or (eq $.SortType "recentupdate") (eq $.SortType "leastupdate")}} + + {{svg "octicon-history" 14}} + {{ctx.Locale.Tr "issues.updated" (DateUtils.TimeSince .UpdatedUnix)}} + + {{end}} diff --git a/tests/integration/issue_test.go b/tests/integration/issue_test.go index 2e7428a1ac..b47f3fd534 100644 --- a/tests/integration/issue_test.go +++ b/tests/integration/issue_test.go @@ -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)()