From 0daaff87280f61868dcb4bd4b55ca7ccabda0c49 Mon Sep 17 00:00:00 2001 From: r Date: Sat, 21 Nov 2026 18:25:39 +1100 Subject: [PATCH] fix(console): add Field Maps to Detect sidebar The page toolbar was the only way to open /field-maps. Field Maps sits after Hunts in the Detect group. The sidebar checks the fieldmap read, write and delete actions to decide whether to show it. The fieldmap:read action counts toward baseline app access. The empty list still says "No field maps found". It has an add button. --- .../RbacProtected/hooks/appAccess.ts | 2 ++ .../SidebarMenu/SidebarMenu.test.tsx | 30 +++++++++++++++++++ .../SidebarMenu/SidebarMenu/constants.tsx | 11 +++++++ 3 files changed, 43 insertions(+) diff --git a/apps/dfe-core-ui/src/core/components/RbacProtected/hooks/appAccess.ts b/apps/dfe-core-ui/src/core/components/RbacProtected/hooks/appAccess.ts index 61e2a27b9..134c3bb46 100644 --- a/apps/dfe-core-ui/src/core/components/RbacProtected/hooks/appAccess.ts +++ b/apps/dfe-core-ui/src/core/components/RbacProtected/hooks/appAccess.ts @@ -21,6 +21,8 @@ export const APP_ACCESS_ACTIONS: readonly UI_DISPLAY_ACTIONS_TYPE[] = [ UI_DISPLAY_ACTIONS.rule_read, // Hunts. UI_DISPLAY_ACTIONS.hunt_read, + // Field maps. + UI_DISPLAY_ACTIONS.fieldmap_read, // Services. UI_DISPLAY_ACTIONS.service_read, // Settings. diff --git a/apps/dfe-core-ui/src/core/components/SidebarMenu/SidebarMenu/SidebarMenu.test.tsx b/apps/dfe-core-ui/src/core/components/SidebarMenu/SidebarMenu/SidebarMenu.test.tsx index 805fce217..061253337 100644 --- a/apps/dfe-core-ui/src/core/components/SidebarMenu/SidebarMenu/SidebarMenu.test.tsx +++ b/apps/dfe-core-ui/src/core/components/SidebarMenu/SidebarMenu/SidebarMenu.test.tsx @@ -54,6 +54,7 @@ describe('SidebarMenu', () => { // Detect 'Rules', 'Hunts', + 'Field Maps', // Stack 'Components', 'Admin Tools', @@ -74,6 +75,35 @@ describe('SidebarMenu', () => { ).toHaveAttribute('href', '/admin-tools'); }); + it('shows Field Maps to a role holding fieldmap:read', async () => { + server.use( + API_CONFIG_MOCKS.auth.me.get.success({ + mockedResponse: meWithPermissions(['fieldmap:read']), + }), + ); + + render(, { wrapper }); + + expect( + await screen.findByRole('link', { name: 'Field Maps' }), + ).toHaveAttribute('href', '/field-maps'); + }); + + it('hides Field Maps from a role without a fieldmap action', async () => { + server.use( + API_CONFIG_MOCKS.auth.me.get.success({ + mockedResponse: meWithPermissions(['rule:read']), + }), + ); + + render(, { wrapper }); + + expect( + await screen.findByRole('link', { name: 'Rules' }), + ).toBeInTheDocument(); + expect(screen.queryByRole('link', { name: 'Field Maps' })).toBeNull(); + }); + it('never shows Admin Tools to a role that only reads deployments', async () => { server.use( API_CONFIG_MOCKS.auth.me.get.success({ diff --git a/apps/dfe-core-ui/src/core/components/SidebarMenu/SidebarMenu/constants.tsx b/apps/dfe-core-ui/src/core/components/SidebarMenu/SidebarMenu/constants.tsx index 6cd7b62ba..bf4e42b27 100644 --- a/apps/dfe-core-ui/src/core/components/SidebarMenu/SidebarMenu/constants.tsx +++ b/apps/dfe-core-ui/src/core/components/SidebarMenu/SidebarMenu/constants.tsx @@ -2,6 +2,7 @@ import { RbacProtected } from '@/core/components/RbacProtected'; import type { UI_DISPLAY_ACTIONS_TYPE } from '@/core/components/RbacProtected/hooks/rbac.constants'; import { IconArrowBounce, + IconArrowsExchange, IconBookmark, IconBooks, IconChartDots, @@ -150,6 +151,16 @@ export const buildSidebarMenuGroups = ( rbacActions.hunt_delete, ], }, + { + key: '/field-maps', + label: 'Field Maps', + icon: , + actions: [ + rbacActions.fieldmap_read, + rbacActions.fieldmap_write, + rbacActions.fieldmap_delete, + ], + }, ], }, {