mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-20 01:11:10 +00:00
feat: show timestamp on release attachments (#8757)
- Show the `created_unix` timestamp as relative time for each non-external release attachment. - The details section of the release attachment can become quite long in width, for smaller screens it's now shown as columns. - Integration test added. Close #7600 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8757 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Squel <squeljur+git@gmail.com> Co-committed-by: Squel <squeljur+git@gmail.com>
This commit is contained in:
parent
72bac98365
commit
dd653c4784
2 changed files with 21 additions and 2 deletions
|
@ -103,12 +103,12 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{else}}
|
{{else}}
|
||||||
<li>
|
<li class="max-sm:tw-flex-col max-sm:tw-gap-2">
|
||||||
<a class="tw-flex-1 flex-text-inline tw-font-bold" target="_blank" rel="nofollow" href="{{.DownloadURL}}" download>
|
<a class="tw-flex-1 flex-text-inline tw-font-bold" target="_blank" rel="nofollow" href="{{.DownloadURL}}" download>
|
||||||
{{svg "octicon-package" 16 "tw-mr-1"}}{{.Name}}
|
{{svg "octicon-package" 16 "tw-mr-1"}}{{.Name}}
|
||||||
</a>
|
</a>
|
||||||
<div>
|
<div>
|
||||||
<span class="text grey">{{ctx.Locale.TrN .DownloadCount "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .DownloadCount)}} · {{.Size | ctx.Locale.TrSize}}</span>
|
<span class="text grey">{{ctx.Locale.TrN .DownloadCount "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .DownloadCount)}} · {{DateUtils.TimeSince .CreatedUnix}} · {{.Size | ctx.Locale.TrSize}}</span>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
auth_model "forgejo.org/models/auth"
|
auth_model "forgejo.org/models/auth"
|
||||||
"forgejo.org/models/db"
|
"forgejo.org/models/db"
|
||||||
|
@ -17,6 +18,7 @@ import (
|
||||||
"forgejo.org/modules/setting"
|
"forgejo.org/modules/setting"
|
||||||
api "forgejo.org/modules/structs"
|
api "forgejo.org/modules/structs"
|
||||||
"forgejo.org/modules/test"
|
"forgejo.org/modules/test"
|
||||||
|
"forgejo.org/modules/timeutil"
|
||||||
"forgejo.org/modules/translation"
|
"forgejo.org/modules/translation"
|
||||||
"forgejo.org/tests"
|
"forgejo.org/tests"
|
||||||
|
|
||||||
|
@ -329,6 +331,23 @@ func TestViewTagsList(t *testing.T) {
|
||||||
assert.Equal(t, []string{"v1.0", "delete-tag", "v1.1"}, tagNames)
|
assert.Equal(t, []string{"v1.0", "delete-tag", "v1.1"}, tagNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAttachmentTimestamp(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", "user2/repo1/releases")
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
|
||||||
|
var timeStamp int64 = 946684800
|
||||||
|
unittest.AssertExistsAndLoadBean(t, &repo_model.Attachment{
|
||||||
|
UUID: "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a20",
|
||||||
|
CreatedUnix: timeutil.TimeStamp(timeStamp),
|
||||||
|
})
|
||||||
|
|
||||||
|
formattedTime := time.Unix(timeStamp, 0).Format(time.RFC3339)
|
||||||
|
htmlDoc.AssertElement(t, fmt.Sprintf("details.download relative-time[datetime='%s']", formattedTime), true)
|
||||||
|
}
|
||||||
|
|
||||||
func TestDownloadReleaseAttachment(t *testing.T) {
|
func TestDownloadReleaseAttachment(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue