feat: set created_by as the default filter for /issues and /pulls (#5286)
Some checks are pending
/ release (push) Waiting to run
testing / test-remote-cacher (map[image:docker.io/bitnami/valkey:7.2 port:6379]) (push) Blocked by required conditions
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-remote-cacher (map[image:docker.io/bitnami/redis:7.2 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:ghcr.io/microsoft/garnet-alpine:1.0.14 port:6379]) (push) Blocked by required conditions
testing / test-remote-cacher (map[image:registry.redict.io/redict:7.3.0-scratch port:6379]) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions

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:
Shiny Nematoda 2024-09-13 12:55:39 +00:00 committed by 0ko
parent a23ba1c6ac
commit 14abf65269
4 changed files with 27 additions and 8 deletions

View file

@ -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"
}
// --------------------------------------------------------------------------

View file

@ -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())

View file

@ -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>

View file

@ -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)
}
}