feat(web): show monitors as a group tree and limit roles to groups
The dashboard nests groups with an aggregated status, the monitor editor offers the groups one may write to, a page manages groups, and members can be assigned roles limited to a group or a status page. Settings move to their own page to keep the navigation short. Closes #57 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
11482ec6d5
commit
b3f19e20ad
12 files changed
+2727
-1627
No files matched your search
+40
-1
@@ -290,6 +290,11 @@ func (s *Server) membersView(c *gin.Context, p *principal, page web.Page, me web
|
||||
return nil, err
|
||||
}
|
||||
v := web.MembersView{CanManage: p.Grants.Can(authz.MembersManage)}
|
||||
scopeNames, scopes, err := s.scopeOptions(ctx, p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v.Scopes = scopes
|
||||
for _, r := range toWebRoles(roles) {
|
||||
if p.Grants.CanGrant(authz.NewSet(r.Permissions...), nil) {
|
||||
v.Roles = append(v.Roles, r)
|
||||
@@ -299,8 +304,11 @@ func (s *Server) membersView(c *gin.Context, p *principal, page web.Page, me web
|
||||
wm := web.Member{UserID: m.UserID.String(), Email: m.Email, DisplayName: m.DisplayName, IsOwner: m.IsOwner}
|
||||
for _, a := range m.Assignments {
|
||||
wa := web.Assignment{ID: a.ID.String(), RoleName: a.RoleName}
|
||||
if a.ResourceType != nil {
|
||||
if a.ResourceType != nil && a.ResourceID != nil {
|
||||
wa.Scope = i18n.T(ctx, "scope."+*a.ResourceType)
|
||||
if name := scopeNames[*a.ResourceID]; name != "" {
|
||||
wa.Scope += " " + name
|
||||
}
|
||||
}
|
||||
wm.Assignments = append(wm.Assignments, wa)
|
||||
}
|
||||
@@ -495,3 +503,34 @@ func toWebMe(m meView) web.Me {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// scopeOptions lists the monitor groups and status pages assignments can be
|
||||
// limited to, with names for displaying existing assignments.
|
||||
func (s *Server) scopeOptions(ctx context.Context, p *principal) (map[uuid.UUID]string, []web.ScopeOption, error) {
|
||||
names := map[uuid.UUID]string{}
|
||||
var opts []web.ScopeOption
|
||||
t, err := s.loadGroupTree(ctx, p.scope())
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
groupLabel := i18n.T(ctx, "scope.monitor_group")
|
||||
t.walk(func(g store.MonitorGroup, depth int) {
|
||||
names[g.ID] = g.Name
|
||||
opts = append(opts, web.ScopeOption{Value: "monitor_group:" + g.ID.String(), Label: groupLabel + ": " + strings.Repeat("— ", depth) + g.Name})
|
||||
})
|
||||
var pages []store.StatusPage
|
||||
err = s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
|
||||
var err error
|
||||
pages, err = q.ListStatusPages(ctx)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
pageLabel := i18n.T(ctx, "scope.status_page")
|
||||
for _, pg := range pages {
|
||||
names[pg.ID] = pg.Title
|
||||
opts = append(opts, web.ScopeOption{Value: "status_page:" + pg.ID.String(), Label: pageLabel + ": " + pg.Title})
|
||||
}
|
||||
return names, opts, nil
|
||||
}
|
||||
Reference in new issue
Block a user