mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 06:03:51 +03:00
[Feat]Add link to show all Issues/PullRequests (#4125)
The Issue and PullRequest list has 3 states: - open: This lists all open Issues/PullRequests - closed: This lists all closed Issues/PullRequests - all: This lists all open and closed Issues/PullRequests If you want to get to the all state, you need to click Open while in open state or Closed while in closed state, which is very unintuitive. This PR adss a third button to get to this state. ![grafik](/attachments/4ff59e4c-e318-40f0-80ba-f921ce098919) I'm not sure if the eye icon fits well, but I couldn't find a better one. Tests will be added once #4124 is merged. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4125 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: JakobDev <jakobdev@gmx.de> Co-committed-by: JakobDev <jakobdev@gmx.de>
This commit is contained in:
parent
80d41ee2e1
commit
1fc5e41592
7 changed files with 43 additions and 10 deletions
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
// IssueStats represents issue statistic information.
|
||||
type IssueStats struct {
|
||||
OpenCount, ClosedCount int64
|
||||
OpenCount, ClosedCount, AllCount int64
|
||||
YourRepositoriesCount int64
|
||||
AssignCount int64
|
||||
CreateCount int64
|
||||
|
@ -104,6 +104,7 @@ func GetIssueStats(ctx context.Context, opts *IssuesOptions) (*IssueStats, error
|
|||
}
|
||||
accum.OpenCount += stats.OpenCount
|
||||
accum.ClosedCount += stats.ClosedCount
|
||||
accum.AllCount += stats.AllCount
|
||||
accum.YourRepositoriesCount += stats.YourRepositoriesCount
|
||||
accum.AssignCount += stats.AssignCount
|
||||
accum.CreateCount += stats.CreateCount
|
||||
|
@ -131,7 +132,13 @@ func getIssueStatsChunk(ctx context.Context, opts *IssuesOptions, issueIDs []int
|
|||
stats.ClosedCount, err = applyIssuesOptions(sess, opts, issueIDs).
|
||||
And("issue.is_closed = ?", true).
|
||||
Count(new(Issue))
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
|
||||
stats.AllCount = stats.OpenCount + stats.ClosedCount
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
func applyIssuesOptions(sess *xorm.Session, opts *IssuesOptions, issueIDs []int64) *xorm.Session {
|
||||
|
|
|
@ -25,6 +25,7 @@ func TestGetIssueStats(t *testing.T) {
|
|||
|
||||
assert.Equal(t, int64(4), stats.OpenCount)
|
||||
assert.Equal(t, int64(1), stats.ClosedCount)
|
||||
assert.Equal(t, int64(5), stats.AllCount)
|
||||
assert.Equal(t, int64(0), stats.YourRepositoriesCount)
|
||||
assert.Equal(t, int64(0), stats.AssignCount)
|
||||
assert.Equal(t, int64(0), stats.CreateCount)
|
||||
|
|
|
@ -1608,6 +1608,7 @@ issues.previous = Previous
|
|||
issues.next = Next
|
||||
issues.open_title = Open
|
||||
issues.closed_title = Closed
|
||||
issues.all_title = All
|
||||
issues.draft_title = Draft
|
||||
issues.num_comments_1 = %d comment
|
||||
issues.num_comments = %d comments
|
||||
|
|
1
release-notes/4125.md
Normal file
1
release-notes/4125.md
Normal file
|
@ -0,0 +1 @@
|
|||
Added link to show all Issues/PullRequests
|
|
@ -456,6 +456,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
|
|||
ctx.Data["IssueStats"] = issueStats
|
||||
ctx.Data["OpenCount"] = issueStats.OpenCount
|
||||
ctx.Data["ClosedCount"] = issueStats.ClosedCount
|
||||
ctx.Data["AllCount"] = issueStats.AllCount
|
||||
linkStr := "%s?q=%s&type=%s&sort=%s&state=%s&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%t"
|
||||
ctx.Data["AllStatesLink"] = fmt.Sprintf(linkStr, ctx.Link,
|
||||
url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "all", url.QueryEscape(selectLabels),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="small-menu-items ui compact tiny menu">
|
||||
<a class="{{if eq .State "open"}}active {{end}}item" href="{{if eq .State "open"}}{{.AllStatesLink}}{{else}}{{.OpenLink}}{{end}}">
|
||||
<a class="{{if eq .State "open"}}active {{end}}item" href="{{.OpenLink}}" data-test-name="open-issue-count">
|
||||
{{if .PageIsMilestones}}
|
||||
{{svg "octicon-milestone" 16 "tw-mr-2"}}
|
||||
{{else if .PageIsPullList}}
|
||||
|
@ -9,8 +9,12 @@
|
|||
{{end}}
|
||||
{{ctx.Locale.PrettyNumber .OpenCount}} {{ctx.Locale.Tr "repo.issues.open_title"}}
|
||||
</a>
|
||||
<a class="{{if eq .State "closed"}}active {{end}}item" href="{{if eq .State "closed"}}{{.AllStatesLink}}{{else}}{{.ClosedLink}}{{end}}">
|
||||
<a class="{{if eq .State "closed"}}active {{end}}item" href="{{.ClosedLink}}" data-test-name="closed-issue-count">
|
||||
{{svg "octicon-check" 16 "tw-mr-2"}}
|
||||
{{ctx.Locale.PrettyNumber .ClosedCount}} {{ctx.Locale.Tr "repo.issues.closed_title"}}
|
||||
</a>
|
||||
<a class="{{if eq .State "all"}}active {{end}}item" href="{{.AllStatesLink}}" data-test-name="all-issue-count">
|
||||
{{svg "octicon-eye" 16 "tw-mr-2"}}
|
||||
{{ctx.Locale.PrettyNumber (.AllCount)}} {{ctx.Locale.Tr "repo.issues.all_title"}}
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -1301,3 +1301,21 @@ func TestIssueUserDashboard(t *testing.T) {
|
|||
htmlDoc.AssertElement(t, sel, true)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueCount(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1/issues")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
openCount := htmlDoc.doc.Find("a[data-test-name='open-issue-count']").Text()
|
||||
assert.Contains(t, openCount, "1\u00a0Open")
|
||||
|
||||
closedCount := htmlDoc.doc.Find("a[data-test-name='closed-issue-count']").Text()
|
||||
assert.Contains(t, closedCount, "1\u00a0Closed")
|
||||
|
||||
allCount := htmlDoc.doc.Find("a[data-test-name='all-issue-count']").Text()
|
||||
assert.Contains(t, allCount, "2\u00a0All")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue