From febcf251e47977841b0e97dc4805a6009b71e446 Mon Sep 17 00:00:00 2001 From: Ilker Manap Date: Sat, 3 Oct 2026 19:15:25 +0200 Subject: [PATCH] Send an administrator from /org to the people page's panel An organization's members, limits and use are a panel of the people page, where they can also be changed, so the administrator's menu loses its Organizations entry and /org redirects there. Managers keep /org. Co-Authored-By: Claude Opus 5.5 (1M context) --- CHANGELOG.md | 4 ++++ docs/onboarding.md | 3 ++- internal/web/org_page.go | 23 +++++++++++++++++++++++ internal/web/org_page_test.go | 19 +++++++++++++++++++ internal/web/templates/nav.html | 5 ++--- 5 files changed, 50 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e032cb00..609bbcdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,10 @@ budget, its per-member limit, its capacity quota, and its requests, tokens and spend over the last week, drawn. Its limits can be set or changed there, and the answer comes back to the same panel. +The administrator's menu no longer has an Organizations entry beside it: `/org` +and `/org/` send an administrator to that organization's panel here. The +page stays as it was for an organization's managers, who cannot see this one. + ### The chat page says whether a GPU or a CPU answered A model can have replicas on a card and on CPUs at once, and the two answer diff --git a/docs/onboarding.md b/docs/onboarding.md index b11ec8c1..fbf6672b 100644 --- a/docs/onboarding.md +++ b/docs/onboarding.md @@ -191,7 +191,8 @@ project or person, the teams and projects with their limits and spend, and every member. Only what was spent in that organization's projects is on it; what its people do elsewhere is not. The page is read-only — a manager is not an administrator of the cluster, and limits and memberships stay with those who -are. +are. An administrator following `/org` lands on the same organization's panel +on the people page instead, where all of that can be changed. `llmgw keys init` still works for provisioning scripts and is idempotent, but it will no longer move a team or project that already exists under another parent; diff --git a/internal/web/org_page.go b/internal/web/org_page.go index 08e9a49b..9a84a65b 100644 --- a/internal/web/org_page.go +++ b/internal/web/org_page.go @@ -3,6 +3,7 @@ package web import ( "context" "net/http" + "net/url" "sort" "time" @@ -70,6 +71,9 @@ type orgPageData struct { func (p *AccountPages) RegisterOrgPages(mux *http.ServeMux, s OrgViewer, priced Priced) { p.orgs = s mux.HandleFunc("GET /org", p.orgGuard(func(w http.ResponseWriter, r *http.Request, user store.User) { + if p.toPeople(w, r, user, "") { + return + } orgs, err := p.viewableOrgs(r.Context(), s, user) if err == nil && len(orgs) == 0 && user.IsAdmin { // Said, not a 404: an administrator following the link on a @@ -89,6 +93,9 @@ func (p *AccountPages) RegisterOrgPages(mux *http.ServeMux, s OrgViewer, priced })) mux.HandleFunc("GET /org/{id}", p.orgGuard(func(w http.ResponseWriter, r *http.Request, user store.User) { id := r.PathValue("id") + if p.toPeople(w, r, user, id) { + return + } if !user.IsAdmin { ok, err := s.ManagesOrg(r.Context(), user.ID, id) if err != nil || !ok { @@ -102,6 +109,22 @@ func (p *AccountPages) RegisterOrgPages(mux *http.ServeMux, s OrgViewer, priced })) } +// toPeople sends an administrator to the people page, which shows an +// organization's members, limits and use beside the whole tree and can change +// them; this page stays for the managers who may not see that one. It says +// whether it did. +func (p *AccountPages) toPeople(w http.ResponseWriter, r *http.Request, user store.User, orgID string) bool { + if !user.IsAdmin || p.peopleStore == nil { + return false + } + to := "/admin/users" + if orgID != "" { + to += "?sel=org:" + url.QueryEscape(orgID) + } + http.Redirect(w, r, to, http.StatusSeeOther) + return true +} + // viewableOrgs is every organization an administrator may look at, or the // ones a person manages. func (p *AccountPages) viewableOrgs(ctx context.Context, s OrgViewer, user store.User) ([]store.Org, error) { diff --git a/internal/web/org_page_test.go b/internal/web/org_page_test.go index 721b4aa4..c424e4c3 100644 --- a/internal/web/org_page_test.go +++ b/internal/web/org_page_test.go @@ -124,3 +124,22 @@ func TestWithNoOrganizationsAnAdministratorIsToldSo(t *testing.T) { t.Error("the menu links to organizations when there are none") } } + +func TestAnAdministratorIsSentToThePeoplePageForAnOrganization(t *testing.T) { + // Its members, limits and use are a panel there, beside the whole tree + // and changeable; /org stays for the managers who cannot see that page. + p := NewAccountPages(fakeAccounts{user: store.User{ID: "a", IsAdmin: true}}, nil, nil, "v0", + slog.New(slog.NewTextHandler(io.Discard, nil))) + mux := http.NewServeMux() + p.RegisterAdminUsers(mux, &fakeAdmin{}) + p.RegisterOrgPages(mux, fakeOrgs{}, nil) + for path, to := range map[string]string{"/org": "/admin/users", "/org/org-s": "/admin/users?sel=org:org-s"} { + w := mirrorGet(t, mux, path) + if w.Code != http.StatusSeeOther || w.Header().Get("Location") != to { + t.Errorf("%s: %d to %q, want %s", path, w.Code, w.Header().Get("Location"), to) + } + } + if menu := menuRe.FindString(mirrorGet(t, mux, "/admin/users").Body.String()); strings.Contains(menu, `href="/org"`) { + t.Error("the administrator's menu still offers /org beside People") + } +} diff --git a/internal/web/templates/nav.html b/internal/web/templates/nav.html index 39c97186..6e4d43d5 100644 --- a/internal/web/templates/nav.html +++ b/internal/web/templates/nav.html @@ -13,9 +13,8 @@ {{- if .Mirror}} Mirror {{- end}} - {{- if .Org}} - Organizations - {{- end}} + {{- /* An organization is a panel of the people page for an administrator; + /org is the managers' view, and leads an administrator there. */}} {{- end}} Chat