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) <noreply@anthropic.com>
This commit is contained in:
1 parent
fffed716be
commit
febcf251e4
5 files changed
+50
-4
No files matched your search
@@ -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/<id>` 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
|
||||
|
||||
+2
-1
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,8 @@
|
||||
{{- if .Mirror}}
|
||||
<a href="/admin/mirror"{{if eq .Current "mirror"}} aria-current="page"{{end}}>Mirror</a>
|
||||
{{- end}}
|
||||
{{- if .Org}}
|
||||
<a href="/org"{{if eq .Current "org"}} aria-current="page"{{end}}>Organizations</a>
|
||||
{{- end}}
|
||||
{{- /* An organization is a panel of the people page for an administrator;
|
||||
/org is the managers' view, and leads an administrator there. */}}
|
||||
<span class="menu-gap" aria-hidden="true"></span>
|
||||
{{- end}}
|
||||
<a href="/chat"{{if eq .Current "chat"}} aria-current="page"{{end}}>Chat</a>
|
||||
|
||||
Reference in new issue
Block a user