Manage people and the tenancy tree, from the web and the CLI
Nothing in the tree could be renamed, moved or removed, and an approved person stayed in the project they were first put in — from the web or the CLI. Now: - /admin/users is the tree, each project opening onto its people and keys, with approve, move, suspend, reinstate and remove for people, revoke for keys, and add, rename, move and remove at every level, plus a search over every account. Forms post and get the page back, so it works with no script; htmx 2.0.11 (0BSD, embedded, checked against npm's integrity hash) swaps only the changed part, keeping open projects open. - llmgw org tree/add/rename/move/remove, users move/delete, and keys list --all. - Projects, teams and organizations are named by id, path (Acme/platform/gateway) or unique name; users by id or email. With a single project --project can be left out, instead of defaulting to "default", which a tree built from the web does not have. Moving a person moves the keys they made; operator keys stay with the project. Only empty things are removed, and never a project that had a key, since usage history refers to it. Also: keys init no longer reparents an existing team or project; reinstating an account with no project is refused (a rejected signup used to come back active and fail at its first key); rejecting a signup removes it; keys limits --budget takes whole units like the quotas page. Checked in headless Chrome: a move from an open project updates the page in place, keeps the project open, and the search still filters. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5141e4b138
commit
3104f4b706
21 files changed
+2081
-217
No files matched your search
@@ -96,17 +96,31 @@ func (s *DB) PutOrg(ctx context.Context, o Org) error {
|
||||
}
|
||||
|
||||
// PutTeam upserts a team.
|
||||
//
|
||||
// It will rename a team but not move it: an upsert that rewrote the parent
|
||||
// let `keys init --org B --team platform` take organization A's team without
|
||||
// a word. Moving is MoveTeam, asked for by name.
|
||||
func (s *DB) PutTeam(ctx context.Context, t Team) error {
|
||||
_, err := s.db.ExecContext(ctx,
|
||||
var org string
|
||||
err := s.db.QueryRowContext(ctx, `SELECT org_id FROM teams WHERE id = ?`, t.ID).Scan(&org)
|
||||
if err == nil && org != t.OrgID {
|
||||
return fmt.Errorf("team %s belongs to organization %s; move it rather than redeclare it", t.ID, org)
|
||||
}
|
||||
_, err = s.db.ExecContext(ctx,
|
||||
`INSERT INTO teams (id, org_id, name) VALUES (?, ?, ?)
|
||||
ON CONFLICT (id) DO UPDATE SET org_id = excluded.org_id, name = excluded.name`,
|
||||
t.ID, t.OrgID, t.Name)
|
||||
return err
|
||||
}
|
||||
|
||||
// PutProject upserts a project.
|
||||
// PutProject upserts a project. Like PutTeam, it renames but never moves.
|
||||
func (s *DB) PutProject(ctx context.Context, p Project) error {
|
||||
_, err := s.db.ExecContext(ctx,
|
||||
var team string
|
||||
err := s.db.QueryRowContext(ctx, `SELECT team_id FROM projects WHERE id = ?`, p.ID).Scan(&team)
|
||||
if err == nil && team != p.TeamID {
|
||||
return fmt.Errorf("project %s belongs to team %s; move it rather than redeclare it", p.ID, team)
|
||||
}
|
||||
_, err = s.db.ExecContext(ctx,
|
||||
`INSERT INTO projects (id, team_id, name) VALUES (?, ?, ?)
|
||||
ON CONFLICT (id) DO UPDATE SET team_id = excluded.team_id, name = excluded.name`,
|
||||
p.ID, p.TeamID, p.Name)
|
||||
|
||||
Reference in new issue
Block a user