Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('SidebarMenu', () => {
// Detect
'Rules',
'Hunts',
'Field Maps',
// Stack
'Components',
'Admin Tools',
Expand All @@ -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(<SidebarMenu collapsed={false} />, { 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(<SidebarMenu collapsed={false} />, { 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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -150,6 +151,16 @@ export const buildSidebarMenuGroups = (
rbacActions.hunt_delete,
],
},
{
key: '/field-maps',
label: 'Field Maps',
icon: <IconArrowsExchange />,
actions: [
rbacActions.fieldmap_read,
rbacActions.fieldmap_write,
rbacActions.fieldmap_delete,
],
},
],
},
{
Expand Down
Loading