feat(ui): set your_repositories as the default filter for org dashboards (#5593)
Some checks are pending
/ release (push) Waiting to run
testing / security-check (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-e2e (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:docker.io/bitnami/valkey: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

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5593
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Reviewed-by: Otto <otto@codeberg.org>
Reviewed-by: Shiny Nematoda <snematoda@noreply.codeberg.org>
This commit is contained in:
0ko 2024-10-17 13:24:41 +00:00
parent 67ca1bebc4
commit 19ca039486
2 changed files with 36 additions and 5 deletions

View file

@ -380,9 +380,11 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
}
var (
viewType string
sortType = ctx.FormString("sort")
filterMode int
viewType string
sortType = ctx.FormString("sort")
filterMode int
defaultFilterMode int
defaultViewType string
)
// Default to recently updated, unlike repository issues list
@ -403,6 +405,18 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
// TODO: distinguish during routing
// Default to created_by on /pulls and /issues
// because it is most relevant to the user in the global context
if ctx.Org == nil || ctx.Org.Organization == nil {
defaultFilterMode = issues_model.FilterModeCreate
defaultViewType = "created_by"
} else {
// Default to your_repositories on /org/*/pulls and /org/*/issues
// because it is the most relevant to the user in the context of an org
defaultFilterMode = issues_model.FilterModeYourRepositories
defaultViewType = "your_repositories"
}
viewType = ctx.FormString("type")
switch viewType {
case "assigned":
@ -418,8 +432,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
case "created_by":
fallthrough
default:
filterMode = issues_model.FilterModeCreate
viewType = "created_by"
filterMode = defaultFilterMode
viewType = defaultViewType
}
// --------------------------------------------------------------------------

View file

@ -1302,6 +1302,23 @@ func TestIssueUserDashboard(t *testing.T) {
}
}
func TestIssueOrgDashboard(t *testing.T) {
defer tests.PrepareTestEnv(t)()
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
session := loginUser(t, user.Name)
// assert 'your_repositories' is the default filter for org dashboards
const sel = ".dashboard .ui.list-header.dropdown .ui.menu a.active.item[href^='?type=your_repositories']"
for _, path := range []string{"/org/org3/issues", "/org/org3/pulls"} {
req := NewRequest(t, "GET", path)
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
htmlDoc.AssertElement(t, sel, true)
}
}
func TestIssueCount(t *testing.T) {
defer tests.PrepareTestEnv(t)()