mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-28 09:21:13 -05:00
feat: set created_by as the default filter for /issues and /pulls (#5286)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5286 Reviewed-by: Otto <otto@codeberg.org> Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Shiny Nematoda <snematoda.751k2@aleeas.com> Co-committed-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
This commit is contained in:
parent
a23ba1c6ac
commit
14abf65269
4 changed files with 27 additions and 8 deletions
|
@ -407,8 +407,6 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
|
|||
switch viewType {
|
||||
case "assigned":
|
||||
filterMode = issues_model.FilterModeAssign
|
||||
case "created_by":
|
||||
filterMode = issues_model.FilterModeCreate
|
||||
case "mentioned":
|
||||
filterMode = issues_model.FilterModeMention
|
||||
case "review_requested":
|
||||
|
@ -416,10 +414,12 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
|
|||
case "reviewed_by":
|
||||
filterMode = issues_model.FilterModeReviewed
|
||||
case "your_repositories":
|
||||
filterMode = issues_model.FilterModeYourRepositories
|
||||
case "created_by":
|
||||
fallthrough
|
||||
default:
|
||||
filterMode = issues_model.FilterModeYourRepositories
|
||||
viewType = "your_repositories"
|
||||
filterMode = issues_model.FilterModeCreate
|
||||
viewType = "created_by"
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
|
|
@ -28,6 +28,7 @@ func TestArchivedIssues(t *testing.T) {
|
|||
ctx, _ := contexttest.MockContext(t, "issues")
|
||||
contexttest.LoadUser(t, ctx, 30)
|
||||
ctx.Req.Form.Set("state", "open")
|
||||
ctx.Req.Form.Set("type", "your_repositories")
|
||||
|
||||
// Assume: User 30 has access to two Repos with Issues, one of the Repos being archived.
|
||||
repos, _, _ := repo_model.GetUserRepositories(db.DefaultContext, &repo_model.SearchRepoOptions{Actor: ctx.Doer})
|
||||
|
@ -73,6 +74,7 @@ func TestPulls(t *testing.T) {
|
|||
ctx, _ := contexttest.MockContext(t, "pulls")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
ctx.Req.Form.Set("state", "open")
|
||||
ctx.Req.Form.Set("type", "your_repositories")
|
||||
Pulls(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
||||
</span>
|
||||
<div class="ui menu">
|
||||
<a class="{{if eq .ViewType "created_by"}}active{{end}} item" href="?type=created_by&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
|
||||
<div class="ui circular mini label tw-ml-0">{{CountFmt .IssueStats.CreateCount}}</div>
|
||||
{{ctx.Locale.Tr "repo.issues.filter_type.created_by_you"}}
|
||||
</a>
|
||||
<a class="{{if eq .ViewType "your_repositories"}}active{{end}} item" href="?type=your_repositories&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
|
||||
<div class="ui circular mini label tw-ml-0">{{CountFmt .IssueStats.YourRepositoriesCount}}</div>
|
||||
{{ctx.Locale.Tr "home.issues.in_your_repos"}}
|
||||
|
@ -46,10 +50,6 @@
|
|||
<div class="ui circular mini label tw-ml-0">{{CountFmt .IssueStats.AssignCount}}</div>
|
||||
{{ctx.Locale.Tr "repo.issues.filter_type.assigned_to_you"}}
|
||||
</a>
|
||||
<a class="{{if eq .ViewType "created_by"}}active{{end}} item" href="?type=created_by&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
|
||||
<div class="ui circular mini label tw-ml-0">{{CountFmt .IssueStats.CreateCount}}</div>
|
||||
{{ctx.Locale.Tr "repo.issues.filter_type.created_by_you"}}
|
||||
</a>
|
||||
{{if .PageIsPulls}}
|
||||
<a class="{{if eq .ViewType "review_requested"}}active{{end}} item" href="?type=review_requested&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
|
||||
<div class="ui circular mini label tw-ml-0">{{CountFmt .IssueStats.ReviewRequestedCount}}</div>
|
||||
|
|
|
@ -1284,3 +1284,20 @@ func TestIssueLabelList(t *testing.T) {
|
|||
htmlDoc.AssertElement(t, ".labels.list .no-select."+hiddenClass, true)
|
||||
})
|
||||
}
|
||||
|
||||
func TestIssueUserDashboard(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||
session := loginUser(t, user.Name)
|
||||
|
||||
// assert 'created_by' is the default filter
|
||||
const sel = ".dashboard .ui.list-header.dropdown .ui.menu a.active.item[href^='?type=created_by']"
|
||||
|
||||
for _, path := range []string{"/issues", "/pulls"} {
|
||||
req := NewRequest(t, "GET", path)
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
htmlDoc.AssertElement(t, sel, true)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue