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, + ], + }, ], }, {