feat(admin): staff nav + dashboard/site-mode (M10 Phase 3, part 1)
Add the staff-operations surface scaffolding and the first group. Session gains isStaff/isModerator/isAdmin; the menu gains STAFF (admin/editor/moderator) and MODERATOR (admin/moderator) access levels, plus a StaffGate mirroring PlayerGate. Dashboard group (over the existing /api/v1/admin, bearer-authed, role re-checked every request): AdminApi/AdminDto/AdminRepository for GET /admin/dashboard and PUT /admin/site-mode; AdminDashboardScreen shows site mode, summary counts, and recent admin activity, with an admin-only maintenance/live toggle. Verified on emulator against the dev backend: an admin sees the Dashboard entry (a player does not); counts + audit log render from real data; the site-mode toggle flips /public/status to maintenance and back to live. MenuAccessTest +2 (8 total), assembleDebug + lint green. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -64,4 +64,24 @@ class MenuAccessTest {
|
||||
assertTrue(visibleEntries(entries, signedIn(Role.ADMIN)).isEmpty())
|
||||
assertTrue(visibleEntries(entries, Session.SignedOut).isEmpty())
|
||||
}
|
||||
|
||||
@Test fun staffSeeTheAdminDashboardButPlayersDoNot() {
|
||||
// STAFF entries (M10) show for every staff role, never for a player or anon.
|
||||
for (role in listOf(Role.ADMIN, Role.EDITOR, Role.MODERATOR)) {
|
||||
assertTrue("$role should see the dashboard", routes(signedIn(role)).contains(Routes.ADMIN_DASHBOARD))
|
||||
}
|
||||
assertFalse(routes(signedIn(Role.PLAYER)).contains(Routes.ADMIN_DASHBOARD))
|
||||
assertFalse(routes(Session.SignedOut).contains(Routes.ADMIN_DASHBOARD))
|
||||
}
|
||||
|
||||
@Test fun moderatorAccessIsAdminAndModeratorOnly() {
|
||||
// A synthetic MODERATOR-gated entry (moderation / support) is visible to
|
||||
// admin + moderator, but NOT editor, player, or anon.
|
||||
val entries = listOf(MenuEntry("mod", 0, MenuAccess.MODERATOR))
|
||||
assertTrue(visibleEntries(entries, signedIn(Role.ADMIN)).isNotEmpty())
|
||||
assertTrue(visibleEntries(entries, signedIn(Role.MODERATOR)).isNotEmpty())
|
||||
assertTrue(visibleEntries(entries, signedIn(Role.EDITOR)).isEmpty())
|
||||
assertTrue(visibleEntries(entries, signedIn(Role.PLAYER)).isEmpty())
|
||||
assertTrue(visibleEntries(entries, Session.SignedOut).isEmpty())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user