feat(fase-13): admin UI + sidebar entry + isServerAdmin store + e2e SA-01..04
13.3 admin UI:
- (admin) route group with own layout + red banner + sidebar (Collectives,
Admins, Audit log, Server). +layout.ts is client-rendered (ssr=false),
same rationale as the (app) group.
- /admin/collectives — paginated list via admin_list_collectives, search
by name, soft-delete / restore / hard-delete modals (hard-delete needs
explicit checkbox; force toggle bypasses the 30-day wait server-side).
- /admin/collectives/[id] — members list with kick action; recent actions
for the collective filtered from admin_actions.
- /admin/admins — list via server_admins join to users (disambiguated by
FK name — there are TWO FKs to users so the embed needs the explicit
server_admins_user_id_fkey); promote modal does an email lookup; revoke
button is replaced by "you (cannot revoke yourself while sole admin)"
when applicable.
- /admin/audit — paginated feed (default 50), action filter.
- /admin/server — server-layer default-section toggles backed by
admin_set_default_section + the new admin_clear_default_section RPC
(added because patching the JSONB to `true` is NOT equivalent to "no
opinion" — `true` explicitly overrides a collective OFF).
13.4 sidebar/drawer entry:
- $isServerAdmin store (writable; +$isServerAdminLoaded for the gate
race) refreshed on every onAuthStateChange in root layout, cleared on
sign-out. Cached so the sidebar tile is synchronous.
- DesktopSidebar + MobileDrawer render the entry only when the store is
true. Distinct red icon so it never blends with normal nav.
Stores wiring:
- features.ts gains serverSectionDefaults writable + enabledSections
derived now reads server > collective > user > default. Loader
piggybacks on loadCurrentUserFeatures so the server layer is fetched
once per sign-in.
- serverAdmin.ts new module — refreshServerAdminFlag() + clearServerAdminFlag().
- Tracks isServerAdminLoaded so the (admin) layout doesn't redirect away
during the millisecond between SIGNED_IN and the RPC resolving (caught
empirically — every hard-load to /admin/* bounced to / without it).
13.5 tests:
- admin.test.ts (SA-01..SA-04) with new loginAsAdmin fixture. Ana is the
seed admin (server_admins seeded via supabase/seed.sql).
- SA-04 + SV-02 reset their server-layer JSONB via the new
admin_clear_default_section RPC so the suites don't leak state into
each other.
Migration 025 adds admin_clear_default_section(text) — same SECURITY DEFINER
+ audit pattern as the rest. pgTAP 017 updated (23 plans, AR-T13b + the
SECURITY DEFINER list now includes the clear RPC).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -240,5 +240,64 @@
|
||||
"section_label_lists": "Lists",
|
||||
"section_label_tasks": "Tasks",
|
||||
"section_label_notes": "Notes",
|
||||
"section_label_search": "Search"
|
||||
"section_label_search": "Search",
|
||||
"admin_banner": "Admin mode — actions are logged",
|
||||
"admin_nav_collectives": "Collectives",
|
||||
"admin_nav_admins": "Admins",
|
||||
"admin_nav_audit": "Audit log",
|
||||
"admin_nav_server": "Server",
|
||||
"admin_menu_entry": "Server admin",
|
||||
"admin_collectives_title": "Collectives",
|
||||
"admin_collectives_search_placeholder": "Search by name…",
|
||||
"admin_collectives_empty": "No collectives match.",
|
||||
"admin_collectives_col_name": "Name",
|
||||
"admin_collectives_col_members": "Members",
|
||||
"admin_collectives_col_created": "Created",
|
||||
"admin_collectives_col_status": "Status",
|
||||
"admin_collectives_status_active": "Active",
|
||||
"admin_collectives_status_deleted": "Soft-deleted",
|
||||
"admin_action_view": "View",
|
||||
"admin_action_soft_delete": "Soft-delete",
|
||||
"admin_action_restore": "Restore",
|
||||
"admin_action_hard_delete": "Hard-delete",
|
||||
"admin_action_remove": "Remove",
|
||||
"admin_modal_soft_delete_title": "Soft-delete collective",
|
||||
"admin_modal_soft_delete_help": "The collective is hidden from members but recoverable for 30 days. Reason is logged.",
|
||||
"admin_modal_reason_label": "Reason",
|
||||
"admin_modal_reason_placeholder": "Why?",
|
||||
"admin_modal_hard_delete_title": "Hard-delete collective",
|
||||
"admin_modal_hard_delete_help": "This is irreversible. All lists, items, tasks, and notes will be deleted.",
|
||||
"admin_modal_hard_delete_confirm": "I understand this is irreversible",
|
||||
"admin_modal_hard_delete_force_label": "Force (bypass 30-day wait)",
|
||||
"admin_modal_cancel": "Cancel",
|
||||
"admin_modal_confirm": "Confirm",
|
||||
"admin_collective_detail_back": "Back to collectives",
|
||||
"admin_collective_detail_members": "Members",
|
||||
"admin_collective_detail_recent_actions": "Recent actions",
|
||||
"admin_modal_remove_member_title": "Remove member",
|
||||
"admin_modal_remove_member_help": "Membership is revoked immediately. Reason is logged.",
|
||||
"admin_admins_title": "Server admins",
|
||||
"admin_admins_promote": "Promote user",
|
||||
"admin_admins_promote_help": "Enter the email of the user to promote.",
|
||||
"admin_admins_email_label": "Email",
|
||||
"admin_admins_email_placeholder": "user@example.com",
|
||||
"admin_admins_email_not_found": "No user with that email.",
|
||||
"admin_admins_revoke_self": "you (cannot revoke yourself while sole admin)",
|
||||
"admin_admins_revoke": "Revoke",
|
||||
"admin_audit_title": "Audit log",
|
||||
"admin_audit_empty": "No actions logged yet.",
|
||||
"admin_audit_col_when": "When",
|
||||
"admin_audit_col_actor": "Actor",
|
||||
"admin_audit_col_action": "Action",
|
||||
"admin_audit_col_target": "Target",
|
||||
"admin_audit_col_payload": "Payload",
|
||||
"admin_server_title": "Server settings",
|
||||
"admin_server_default_sections": "Default section visibility",
|
||||
"admin_server_default_sections_help": "Server-level overrides. ON or OFF here wins over every collective and user override.",
|
||||
"admin_server_section_state_off": "OFF",
|
||||
"admin_server_section_state_on": "ON",
|
||||
"admin_server_section_state_unset": "No opinion",
|
||||
"admin_server_info": "Server info",
|
||||
"admin_error_forbidden": "You don't have access to this area.",
|
||||
"admin_error_unknown": "Something went wrong. Please try again."
|
||||
}
|
||||
|
||||
@@ -240,5 +240,64 @@
|
||||
"section_label_lists": "Listas",
|
||||
"section_label_tasks": "Tareas",
|
||||
"section_label_notes": "Notas",
|
||||
"section_label_search": "Buscar"
|
||||
"section_label_search": "Buscar",
|
||||
"admin_banner": "Modo admin — las acciones se registran",
|
||||
"admin_nav_collectives": "Colectivos",
|
||||
"admin_nav_admins": "Admins",
|
||||
"admin_nav_audit": "Registro",
|
||||
"admin_nav_server": "Servidor",
|
||||
"admin_menu_entry": "Admin del servidor",
|
||||
"admin_collectives_title": "Colectivos",
|
||||
"admin_collectives_search_placeholder": "Buscar por nombre…",
|
||||
"admin_collectives_empty": "Ningún colectivo coincide.",
|
||||
"admin_collectives_col_name": "Nombre",
|
||||
"admin_collectives_col_members": "Miembros",
|
||||
"admin_collectives_col_created": "Creado",
|
||||
"admin_collectives_col_status": "Estado",
|
||||
"admin_collectives_status_active": "Activo",
|
||||
"admin_collectives_status_deleted": "Borrado",
|
||||
"admin_action_view": "Ver",
|
||||
"admin_action_soft_delete": "Soft-delete",
|
||||
"admin_action_restore": "Restaurar",
|
||||
"admin_action_hard_delete": "Eliminar",
|
||||
"admin_action_remove": "Expulsar",
|
||||
"admin_modal_soft_delete_title": "Soft-delete colectivo",
|
||||
"admin_modal_soft_delete_help": "El colectivo queda oculto para los miembros pero recuperable durante 30 días. Se registra el motivo.",
|
||||
"admin_modal_reason_label": "Motivo",
|
||||
"admin_modal_reason_placeholder": "¿Por qué?",
|
||||
"admin_modal_hard_delete_title": "Eliminar colectivo",
|
||||
"admin_modal_hard_delete_help": "Esto es irreversible. Se eliminarán todas las listas, ítems, tareas y notas.",
|
||||
"admin_modal_hard_delete_confirm": "Entiendo que es irreversible",
|
||||
"admin_modal_hard_delete_force_label": "Forzar (saltar espera de 30 días)",
|
||||
"admin_modal_cancel": "Cancelar",
|
||||
"admin_modal_confirm": "Confirmar",
|
||||
"admin_collective_detail_back": "Volver a colectivos",
|
||||
"admin_collective_detail_members": "Miembros",
|
||||
"admin_collective_detail_recent_actions": "Acciones recientes",
|
||||
"admin_modal_remove_member_title": "Expulsar miembro",
|
||||
"admin_modal_remove_member_help": "La membresía se revoca al momento. Se registra el motivo.",
|
||||
"admin_admins_title": "Admins del servidor",
|
||||
"admin_admins_promote": "Promover usuario",
|
||||
"admin_admins_promote_help": "Introduce el email del usuario a promover.",
|
||||
"admin_admins_email_label": "Email",
|
||||
"admin_admins_email_placeholder": "usuario@ejemplo.com",
|
||||
"admin_admins_email_not_found": "No hay ningún usuario con ese email.",
|
||||
"admin_admins_revoke_self": "tú (no puedes auto-revocarte si eres el único admin)",
|
||||
"admin_admins_revoke": "Revocar",
|
||||
"admin_audit_title": "Registro de acciones",
|
||||
"admin_audit_empty": "Aún no hay acciones registradas.",
|
||||
"admin_audit_col_when": "Cuándo",
|
||||
"admin_audit_col_actor": "Actor",
|
||||
"admin_audit_col_action": "Acción",
|
||||
"admin_audit_col_target": "Objetivo",
|
||||
"admin_audit_col_payload": "Payload",
|
||||
"admin_server_title": "Configuración del servidor",
|
||||
"admin_server_default_sections": "Visibilidad por defecto de secciones",
|
||||
"admin_server_default_sections_help": "Override a nivel servidor. ON u OFF aquí prevalece sobre cualquier colectivo o usuario.",
|
||||
"admin_server_section_state_off": "OFF",
|
||||
"admin_server_section_state_on": "ON",
|
||||
"admin_server_section_state_unset": "Sin opinión",
|
||||
"admin_server_info": "Información del servidor",
|
||||
"admin_error_forbidden": "No tienes acceso a esta zona.",
|
||||
"admin_error_unknown": "Algo ha ido mal. Inténtalo de nuevo."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user