From 14abf652697b597723aaedd3e5336c14c0452ceb Mon Sep 17 00:00:00 2001 From: Shiny Nematoda Date: Fri, 13 Sep 2024 12:55:39 +0000 Subject: [PATCH] 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 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Shiny Nematoda Co-committed-by: Shiny Nematoda --- routers/web/user/home.go | 8 ++++---- routers/web/user/home_test.go | 2 ++ templates/user/dashboard/issues.tmpl | 8 ++++---- tests/integration/issue_test.go | 17 +++++++++++++++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 1ac2ec8e5f..4b249e9696 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -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" } // -------------------------------------------------------------------------- diff --git a/routers/web/user/home_test.go b/routers/web/user/home_test.go index f6e91b6219..e1c8ca9a79 100644 --- a/routers/web/user/home_test.go +++ b/routers/web/user/home_test.go @@ -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()) diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index 052536296e..09d282b029 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -38,6 +38,10 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}}