feat(UI): fix links, add labels for releases on repo activity page
This commit is contained in:
parent
3d3ddd7704
commit
2795f5bc0e
3 changed files with 43 additions and 9 deletions
|
@ -2119,7 +2119,9 @@ activity.unresolved_conv_label = Open
|
||||||
activity.title.releases_1 = %d release
|
activity.title.releases_1 = %d release
|
||||||
activity.title.releases_n = %d releases
|
activity.title.releases_n = %d releases
|
||||||
activity.title.releases_published_by = %s published by %s
|
activity.title.releases_published_by = %s published by %s
|
||||||
activity.published_release_label = Published
|
activity.published_release_label = Release
|
||||||
|
activity.published_prerelease_label = Pre-release
|
||||||
|
activity.published_tag_label = Tag
|
||||||
activity.no_git_activity = There has not been any commit activity in this period.
|
activity.no_git_activity = There has not been any commit activity in this period.
|
||||||
activity.git_stats_exclude_merges = Excluding merges,
|
activity.git_stats_exclude_merges = Excluding merges,
|
||||||
activity.git_stats_author_1 = %d author
|
activity.git_stats_author_1 = %d author
|
||||||
|
|
|
@ -122,10 +122,18 @@
|
||||||
<div class="list">
|
<div class="list">
|
||||||
{{range .Activity.PublishedReleases}}
|
{{range .Activity.PublishedReleases}}
|
||||||
<p class="desc">
|
<p class="desc">
|
||||||
<span class="ui green label">{{ctx.Locale.Tr "repo.activity.published_release_label"}}</span>
|
{{if .IsTag}}
|
||||||
{{.TagName}}
|
<span class="ui yellow label">{{ctx.Locale.Tr "repo.activity.published_tag_label"}}</span>
|
||||||
{{if not .IsTag}}
|
{{else if .IsPrerelease}}
|
||||||
<a class="title" href="{{$.RepoLink}}/src/{{.TagName | PathEscapeSegments}}">{{.Title | RenderEmoji $.Context | RenderCodeBlock}}</a>
|
<span class="ui orange label">{{ctx.Locale.Tr "repo.activity.published_prerelease_label"}}</span>
|
||||||
|
{{else}}
|
||||||
|
<span class="ui green label">{{ctx.Locale.Tr "repo.activity.published_release_label"}}</span>
|
||||||
|
{{end}}
|
||||||
|
{{if .IsTag}}
|
||||||
|
<a href="{{$.RepoLink}}/src/{{.TagName | PathEscapeSegments}}">{{.TagName}}</a>
|
||||||
|
{{else}}
|
||||||
|
{{.TagName}}
|
||||||
|
<a class="title" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{.Title | RenderEmoji $.Context | RenderCodeBlock}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{TimeSinceUnix .CreatedUnix ctx.Locale}}
|
{{TimeSinceUnix .CreatedUnix ctx.Locale}}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -7,9 +7,11 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
auth_model "code.gitea.io/gitea/models/auth"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
unit_model "code.gitea.io/gitea/models/unit"
|
unit_model "code.gitea.io/gitea/models/unit"
|
||||||
|
@ -19,6 +21,7 @@ import (
|
||||||
repo_service "code.gitea.io/gitea/services/repository"
|
repo_service "code.gitea.io/gitea/services/repository"
|
||||||
"code.gitea.io/gitea/tests"
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
|
"github.com/PuerkitoBio/goquery"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -46,29 +49,50 @@ func TestRepoActivity(t *testing.T) {
|
||||||
testNewIssue(t, session, "user2", "repo1", "Issue 2", "Description 2")
|
testNewIssue(t, session, "user2", "repo1", "Issue 2", "Description 2")
|
||||||
testNewIssue(t, session, "user2", "repo1", "Issue 3", "Description 3")
|
testNewIssue(t, session, "user2", "repo1", "Issue 3", "Description 3")
|
||||||
|
|
||||||
// Create releases (1 new release)
|
// Create releases (1 release, 1 pre-release, 1 release-draft, 1 tag)
|
||||||
createNewRelease(t, session, "/user2/repo1", "v1.0.0", "v1.0.0", false, false)
|
createNewRelease(t, session, "/user2/repo1", "v1.0.0", "v1 Release", false, false)
|
||||||
|
createNewRelease(t, session, "/user2/repo1", "v0.1.0", "v0.1 Pre-release", true, false)
|
||||||
|
createNewRelease(t, session, "/user2/repo1", "v2.0.0", "v2 Release-Draft", false, true)
|
||||||
|
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteRepository)
|
||||||
|
createNewTagUsingAPI(t, token, "user2", "repo1", "v3.0.0", "master", "Tag message")
|
||||||
|
|
||||||
// Open Activity page and check stats
|
// Open Activity page and check stats
|
||||||
req := NewRequest(t, "GET", "/user2/repo1/activity")
|
req := NewRequest(t, "GET", "/user2/repo1/activity")
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
|
||||||
// Should be 1 published release
|
// Should be 3 published releases
|
||||||
list := htmlDoc.doc.Find("#published-releases").Next().Find("p.desc")
|
list := htmlDoc.doc.Find("#published-releases").Next().Find("p.desc")
|
||||||
assert.Len(t, list.Nodes, 1)
|
assert.Len(t, list.Nodes, 3)
|
||||||
|
var labels []string
|
||||||
|
var titles []string
|
||||||
|
list.Each(func(i int, s *goquery.Selection) {
|
||||||
|
labels = append(labels, s.Find(".label").Text())
|
||||||
|
titles = append(titles, s.Find(".title").Text())
|
||||||
|
})
|
||||||
|
sort.Strings(labels)
|
||||||
|
sort.Strings(titles)
|
||||||
|
assert.Equal(t, []string{"Pre-release", "Release", "Tag"}, labels)
|
||||||
|
assert.Equal(t, []string{"", "v0.1 Pre-release", "v1 Release"}, titles)
|
||||||
|
|
||||||
// Should be 1 merged pull request
|
// Should be 1 merged pull request
|
||||||
list = htmlDoc.doc.Find("#merged-pull-requests").Next().Find("p.desc")
|
list = htmlDoc.doc.Find("#merged-pull-requests").Next().Find("p.desc")
|
||||||
assert.Len(t, list.Nodes, 1)
|
assert.Len(t, list.Nodes, 1)
|
||||||
|
assert.Equal(t, "Merged", list.Find(".label").Text())
|
||||||
|
|
||||||
// Should be 2 proposed pull requests
|
// Should be 2 proposed pull requests
|
||||||
list = htmlDoc.doc.Find("#proposed-pull-requests").Next().Find("p.desc")
|
list = htmlDoc.doc.Find("#proposed-pull-requests").Next().Find("p.desc")
|
||||||
assert.Len(t, list.Nodes, 2)
|
assert.Len(t, list.Nodes, 2)
|
||||||
|
assert.Equal(t, "Proposed", list.Find(".label").First().Text())
|
||||||
|
|
||||||
|
// Should be 0 closed issues
|
||||||
|
list = htmlDoc.doc.Find("#closed-issues").Next().Find("p.desc")
|
||||||
|
assert.Empty(t, list.Nodes)
|
||||||
|
|
||||||
// Should be 3 new issues
|
// Should be 3 new issues
|
||||||
list = htmlDoc.doc.Find("#new-issues").Next().Find("p.desc")
|
list = htmlDoc.doc.Find("#new-issues").Next().Find("p.desc")
|
||||||
assert.Len(t, list.Nodes, 3)
|
assert.Len(t, list.Nodes, 3)
|
||||||
|
assert.Equal(t, "Opened", list.Find(".label").First().Text())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue