Compare commits

..

6 Commits

Author SHA1 Message Date
SagarRajput-7
32112ef8d2 feat: updated test case 2026-03-05 04:07:11 +05:30
SagarRajput-7
04563833d2 feat: refactored code 2026-03-05 03:50:06 +05:30
SagarRajput-7
1528c6cfe1 feat: added test cases 2026-03-05 03:02:00 +05:30
SagarRajput-7
c140043f6e Merge branch 'main' into SIG-1783-settings-nav 2026-03-05 02:55:58 +05:30
SagarRajput-7
a08170bb09 feat: settings nav categorisation 2026-03-05 02:11:15 +05:30
SagarRajput-7
4ff2d44188 feat: revamped the settings nav and setting dropdown 2026-03-05 02:05:25 +05:30
10 changed files with 460 additions and 173 deletions

View File

@@ -674,7 +674,7 @@ function GeneralSettings({
return (
<div className="general-settings-page">
<div className="general-settings-header">
<span className="general-settings-title">General</span>
<span className="general-settings-title">Workspace</span>
<span className="general-settings-subtitle">
Manage your workspace settings.
</span>

View File

@@ -161,7 +161,7 @@ function MySettings(): JSX.Element {
<div className="my-settings-container">
<div className="user-info-section">
<div className="user-info-section-header">
<div className="user-info-section-title">General </div>
<div className="user-info-section-title">Account </div>
<div className="user-info-section-subtitle">
Manage your account settings.

View File

@@ -1057,21 +1057,20 @@
gap: 8px;
.user-settings-dropdown-label-text {
color: var(--bg-slate-50, #62687c);
color: var(--l3-foreground);
font-family: Inter;
font-size: 10px;
font-family: Inter;
font-weight: 600;
font-size: var(--uppercase-small-500-font-size);
font-weight: var(--uppercase-small-500-font-weight);
font-style: normal;
line-height: 18px; /* 163.636% */
line-height: 18px;
letter-spacing: 0.88px;
text-transform: uppercase;
}
.user-settings-dropdown-label-email {
color: var(--bg-vanilla-400, #c0c1c3);
color: var(--l1-foreground);
font-family: Inter;
font-size: 12px;
font-size: var(--font-size-xs);
font-style: normal;
line-height: normal;
letter-spacing: 0.14px;
@@ -1079,7 +1078,7 @@
}
.ant-dropdown-menu-item-divider {
background-color: var(--bg-slate-500, #161922) !important;
background-color: var(--secondary) !important;
}
.ant-dropdown-menu-item-disabled {
@@ -1095,6 +1094,14 @@
.help-support-dropdown {
.ant-dropdown-menu-item {
min-height: 32px;
.ant-dropdown-menu-title-content {
color: var(--l1-foreground) !important;
}
.user-settings-dropdown-logout-section {
color: var(--danger-background);
}
}
}
@@ -1271,7 +1278,7 @@
}
.help-support-dropdown li.ant-dropdown-menu-item-divider {
background-color: var(--bg-slate-500, #161922) !important;
background-color: var(--secondary) !important;
}
.lightMode {
@@ -1431,22 +1438,6 @@
}
}
.settings-dropdown {
.user-settings-dropdown-logged-in-section {
.user-settings-dropdown-label-text {
color: var(--bg-ink-400);
}
.user-settings-dropdown-label-email {
color: var(--bg-ink-300);
}
}
.ant-dropdown-menu-item-divider {
background-color: var(--bg-vanilla-300) !important;
}
}
.reorder-shortcut-nav-items-modal {
.ant-modal-content {
border: 1px solid var(--bg-vanilla-300);
@@ -1503,10 +1494,6 @@
color: var(--bg-ink-400);
}
}
.help-support-dropdown li.ant-dropdown-menu-item-divider {
background-color: var(--bg-vanilla-300) !important;
}
}
.version-tooltip-overlay {

View File

@@ -69,6 +69,7 @@ import { routeConfig } from './config';
import { getQueryString } from './helper';
import {
defaultMoreMenuItems,
getUserSettingsDropdownMenuItems,
helpSupportDropdownMenuItems as DefaultHelpSupportDropdownMenuItems,
helpSupportMenuItem,
primaryMenuItems,
@@ -485,48 +486,12 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
const userSettingsDropdownMenuItems: MenuProps['items'] = useMemo(
() =>
[
{
key: 'label',
label: (
<div className="user-settings-dropdown-logged-in-section">
<span className="user-settings-dropdown-label-text">LOGGED IN AS</span>
<span className="user-settings-dropdown-label-email">{user.email}</span>
</div>
),
disabled: true,
dataTestId: 'logged-in-as-nav-item',
},
{ type: 'divider' as const },
{
key: 'account',
label: 'Account Settings',
dataTestId: 'account-settings-nav-item',
},
{
key: 'workspace',
label: 'Workspace Settings',
disabled: isWorkspaceBlocked,
dataTestId: 'workspace-settings-nav-item',
},
...(isEnterpriseSelfHostedUser || isCommunityEnterpriseUser
? [
{
key: 'license',
label: 'Manage License',
dataTestId: 'manage-license-nav-item',
},
]
: []),
{ type: 'divider' as const },
{
key: 'logout',
label: (
<span className="user-settings-dropdown-logout-section">Sign out</span>
),
dataTestId: 'logout-nav-item',
},
].filter(Boolean),
getUserSettingsDropdownMenuItems({
userEmail: user.email,
isWorkspaceBlocked,
isEnterpriseSelfHostedUser,
isCommunityEnterpriseUser,
}),
[
isEnterpriseSelfHostedUser,
isCommunityEnterpriseUser,
@@ -856,9 +821,6 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
});
switch (item.key) {
case ROUTES.SHORTCUTS:
history.push(ROUTES.SHORTCUTS);
break;
case 'invite-collaborators':
history.push(`${ROUTES.ORG_SETTINGS}#invite-team-members`);
break;
@@ -878,7 +840,7 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
};
const handleSettingsMenuItemClick = (info: SidebarItem): void => {
const item = userSettingsDropdownMenuItems.find(
const item = (userSettingsDropdownMenuItems ?? []).find(
(item) => item?.key === info.key,
);
let menuLabel = '';
@@ -904,6 +866,9 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
case 'license':
history.push(ROUTES.LIST_LICENSES);
break;
case 'keyboard-shortcuts':
history.push(ROUTES.SHORTCUTS);
break;
case 'logout':
Logout();
break;

View File

@@ -0,0 +1,74 @@
import { getUserSettingsDropdownMenuItems } from 'container/SideNav/menuItems';
const BASE_PARAMS = {
userEmail: 'test@signoz.io',
isWorkspaceBlocked: false,
isEnterpriseSelfHostedUser: false,
isCommunityEnterpriseUser: false,
};
describe('getUserSettingsDropdownMenuItems', () => {
it('always includes logged-in-as label, workspace, account, keyboard shortcuts, and sign out', () => {
const items = getUserSettingsDropdownMenuItems(BASE_PARAMS);
const keys = items?.map((item) => item?.key);
expect(keys).toContain('label');
expect(keys).toContain('workspace');
expect(keys).toContain('account');
expect(keys).toContain('keyboard-shortcuts');
expect(keys).toContain('logout');
// workspace item is enabled when workspace is not blocked
const workspaceItem = items?.find(
(item: any) => item.key === 'workspace',
) as any;
expect(workspaceItem?.disabled).toBe(false);
// does not include license item for regular cloud user
expect(keys).not.toContain('license');
});
it('includes manage license item for enterprise self-hosted users', () => {
const items = getUserSettingsDropdownMenuItems({
...BASE_PARAMS,
isEnterpriseSelfHostedUser: true,
});
const keys = items?.map((item) => item?.key);
expect(keys).toContain('license');
});
it('includes manage license item for community enterprise users', () => {
const items = getUserSettingsDropdownMenuItems({
...BASE_PARAMS,
isCommunityEnterpriseUser: true,
});
const keys = items?.map((item) => item?.key);
expect(keys).toContain('license');
});
it('workspace item is disabled when workspace is blocked', () => {
const items = getUserSettingsDropdownMenuItems({
...BASE_PARAMS,
isWorkspaceBlocked: true,
});
const workspaceItem = items?.find(
(item: any) => item.key === 'workspace',
) as any;
expect(workspaceItem?.disabled).toBe(true);
});
it('returns items in correct order: label, divider, workspace, account, ..., shortcuts, divider, logout', () => {
const items = getUserSettingsDropdownMenuItems(BASE_PARAMS) ?? [];
const keys = items.map((item: any) => item.key ?? item.type);
expect(keys[0]).toBe('label');
expect(keys[1]).toBe('divider');
expect(keys[2]).toBe('workspace');
expect(keys[3]).toBe('account');
expect(keys[keys.length - 1]).toBe('logout');
});
});

View File

@@ -1,4 +1,6 @@
import { RocketOutlined } from '@ant-design/icons';
import { Style } from '@signozhq/design-tokens';
import { MenuProps } from 'antd';
import ROUTES from 'constants/routes';
import {
ArrowUpRight,
@@ -8,6 +10,7 @@ import {
Book,
Boxes,
BugIcon,
Building2,
ChartArea,
Cloudy,
DraftingCompass,
@@ -20,6 +23,7 @@ import {
Layers2,
LayoutGrid,
ListMinus,
LogOut,
MessageSquareText,
Plus,
Receipt,
@@ -34,7 +38,11 @@ import {
UserPlus,
} from 'lucide-react';
import { SecondaryMenuItemKey, SidebarItem } from './sideNav.types';
import {
SecondaryMenuItemKey,
SettingsNavSection,
SidebarItem,
} from './sideNav.types';
export const getStartedMenuItem = {
key: ROUTES.GET_STARTED,
@@ -296,77 +304,87 @@ export const defaultMoreMenuItems: SidebarItem[] = [
},
];
export const settingsMenuItems: SidebarItem[] = [
export const settingsNavSections: SettingsNavSection[] = [
{
key: ROUTES.SETTINGS,
label: 'General',
icon: <Settings size={16} />,
isEnabled: true,
itemKey: 'general',
},
{
key: ROUTES.BILLING,
label: 'Billing',
icon: <Receipt size={16} />,
isEnabled: false,
itemKey: 'billing',
},
{
key: ROUTES.ROLES_SETTINGS,
label: 'Roles',
icon: <Shield size={16} />,
isEnabled: false,
itemKey: 'roles',
},
{
key: ROUTES.ORG_SETTINGS,
label: 'Members & SSO',
icon: <User size={16} />,
isEnabled: false,
itemKey: 'members-sso',
key: 'general',
items: [
{
key: ROUTES.SETTINGS,
label: 'Workspace',
icon: <Settings size={16} />,
isEnabled: true,
itemKey: 'workspace',
},
{
key: ROUTES.MY_SETTINGS,
label: 'Account',
icon: <User size={16} />,
isEnabled: true,
itemKey: 'account',
},
{
key: ROUTES.ALL_CHANNELS,
label: 'Notification Channels',
icon: <FileKey2 size={16} />,
isEnabled: true,
itemKey: 'notification-channels',
},
{
key: ROUTES.BILLING,
label: 'Billing',
icon: <Receipt size={16} />,
isEnabled: false,
itemKey: 'billing',
},
{
key: ROUTES.INTEGRATIONS,
label: 'Integrations',
icon: <Unplug size={16} />,
isEnabled: false,
itemKey: 'integrations',
},
],
},
{
key: ROUTES.INTEGRATIONS,
label: 'Integrations',
icon: <Unplug size={16} />,
isEnabled: false,
itemKey: 'integrations',
key: 'identity-access',
title: 'Identity & Access',
items: [
{
key: ROUTES.ROLES_SETTINGS,
label: 'Roles',
icon: <Shield size={16} />,
isEnabled: false,
itemKey: 'roles',
},
{
key: ROUTES.API_KEYS,
label: 'API Keys',
icon: <Key size={16} />,
isEnabled: false,
itemKey: 'api-keys',
},
{
key: ROUTES.INGESTION_SETTINGS,
label: 'Ingestion',
icon: <RocketOutlined rotate={45} />,
isEnabled: false,
itemKey: 'ingestion',
},
],
},
{
key: ROUTES.ALL_CHANNELS,
label: 'Notification Channels',
icon: <FileKey2 size={16} />,
isEnabled: true,
itemKey: 'notification-channels',
},
{
key: ROUTES.API_KEYS,
label: 'API Keys',
icon: <Key size={16} />,
isEnabled: false,
itemKey: 'api-keys',
},
{
key: ROUTES.INGESTION_SETTINGS,
label: 'Ingestion',
icon: <RocketOutlined rotate={45} />,
isEnabled: false,
itemKey: 'ingestion',
},
{
key: ROUTES.MY_SETTINGS,
label: 'Account Settings',
icon: <User size={16} />,
isEnabled: true,
itemKey: 'account-settings',
},
{
key: ROUTES.SHORTCUTS,
label: 'Keyboard Shortcuts',
icon: <Layers2 size={16} />,
isEnabled: true,
itemKey: 'keyboard-shortcuts',
key: 'authentication',
title: 'Authentication',
items: [
{
key: ROUTES.ORG_SETTINGS,
label: 'Members & SSO',
icon: <User size={16} />,
isEnabled: false,
itemKey: 'members-sso',
},
],
},
];
@@ -417,12 +435,6 @@ export const helpSupportDropdownMenuItems: SidebarItem[] = [
icon: <MessageSquareText size={14} />,
itemKey: 'chat-support',
},
{
key: ROUTES.SHORTCUTS,
label: 'Keyboard Shortcuts',
icon: <Keyboard size={14} />,
itemKey: 'keyboard-shortcuts',
},
{
key: 'invite-collaborators',
label: 'Invite a Team Member',
@@ -431,6 +443,78 @@ export const helpSupportDropdownMenuItems: SidebarItem[] = [
},
];
export interface UserSettingsMenuItemsParams {
userEmail: string;
isWorkspaceBlocked: boolean;
isEnterpriseSelfHostedUser: boolean;
isCommunityEnterpriseUser: boolean;
}
export const getUserSettingsDropdownMenuItems = ({
userEmail,
isWorkspaceBlocked,
isEnterpriseSelfHostedUser,
isCommunityEnterpriseUser,
}: UserSettingsMenuItemsParams): MenuProps['items'] =>
[
{
key: 'label',
label: (
<div className="user-settings-dropdown-logged-in-section">
<span className="user-settings-dropdown-label-text">LOGGED IN AS</span>
<span className="user-settings-dropdown-label-email">{userEmail}</span>
</div>
),
disabled: true,
dataTestId: 'logged-in-as-nav-item',
},
{ type: 'divider' as const },
{
key: 'workspace',
label: 'Workspace Settings',
icon: <Building2 size={14} color={Style.L1_FOREGROUND} />,
disabled: isWorkspaceBlocked,
dataTestId: 'workspace-settings-nav-item',
},
{
key: 'account',
label: 'Account Settings',
icon: <User size={14} color={Style.L1_FOREGROUND} />,
dataTestId: 'account-settings-nav-item',
},
...(isEnterpriseSelfHostedUser || isCommunityEnterpriseUser
? [
{
key: 'license',
label: 'Manage License',
icon: <Shield size={14} color={Style.L1_FOREGROUND} />,
dataTestId: 'manage-license-nav-item',
},
]
: []),
{
key: 'keyboard-shortcuts',
label: 'Keyboard Shortcuts',
icon: <Keyboard size={14} color={Style.L1_FOREGROUND} />,
dataTestId: 'keyboard-shortcuts-nav-item',
},
{ type: 'divider' as const },
{
key: 'logout',
label: (
<span className="user-settings-dropdown-logout-section">Sign out</span>
),
icon: (
<LogOut
size={14}
className="user-settings-dropdown-logout-section"
color={Style.DANGER_BACKGROUND}
/>
),
dataTestId: 'logout-nav-item',
},
].filter(Boolean);
/** Mapping of some newly added routes and their corresponding active sidebar menu key */
export const NEW_ROUTES_MENU_ITEM_KEY_MAP: Record<string, string> = {
[ROUTES.TRACE]: ROUTES.TRACES_EXPLORER,

View File

@@ -24,6 +24,12 @@ export interface SidebarItem {
export const CHANGELOG_LABEL = 'Full Changelog';
export interface SettingsNavSection {
title?: string;
items: SidebarItem[];
key: string;
}
export interface DropdownSeparator {
type: 'divider' | 'group';
label?: ReactNode;

View File

@@ -31,9 +31,28 @@
.settings-page-sidenav {
width: 240px;
height: calc(100vh - 48px);
border-right: 1px solid var(--Slate-500, #161922);
background: var(--Ink-500, #0b0c0e);
margin-top: 4px;
border-right: 1px solid var(--secondary);
background: var(--sidebar-primary-foreground);
padding-top: var(--padding-1);
display: flex;
flex-direction: column;
gap: var(--spacing-12);
overflow-y: auto;
.settings-nav-section {
display: flex;
flex-direction: column;
}
.settings-nav-section-title {
font-size: var(--uppercase-small-600-font-size);
font-weight: var(--uppercase-small-600-font-weight);
letter-spacing: 0.88px;
text-transform: uppercase;
color: var(--l3-foreground);
margin-bottom: var(--margin-2);
padding: var(--padding-1) var(--padding-3);
}
.nav-item {
.nav-item-data {

View File

@@ -7,7 +7,7 @@ import { FeatureKeys } from 'constants/features';
import ROUTES from 'constants/routes';
import { routeConfig } from 'container/SideNav/config';
import { getQueryString } from 'container/SideNav/helper';
import { settingsMenuItems as defaultSettingsMenuItems } from 'container/SideNav/menuItems';
import { settingsNavSections } from 'container/SideNav/menuItems';
import NavItem from 'container/SideNav/NavItem/NavItem';
import { SidebarItem } from 'container/SideNav/sideNav.types';
import useComponentPermission from 'hooks/useComponentPermission';
@@ -33,7 +33,7 @@ function SettingsPage(): JSX.Element {
const { isCloudUser, isEnterpriseSelfHostedUser } = useGetTenantLicense();
const [settingsMenuItems, setSettingsMenuItems] = useState<SidebarItem[]>(
defaultSettingsMenuItems,
settingsNavSections.flatMap((section) => section.items),
);
const isAdmin = user.role === USER_ROLES.ADMIN;
@@ -252,25 +252,40 @@ function SettingsPage(): JSX.Element {
<div className="settings-page-content-container">
<div className="settings-page-sidenav" data-testid="settings-page-sidenav">
{settingsMenuItems
.filter((item) => item.isEnabled)
.map((item) => (
<NavItem
key={item.key}
item={item}
isActive={isActiveNavItem(item.key as string)}
isDisabled={false}
showIcon={false}
onClick={(event): void => {
logEvent('Settings V2: Menu clicked', {
menuLabel: item.label,
menuRoute: item.key,
});
handleMenuItemClick((event as unknown) as MouseEvent, item);
}}
dataTestId={item.itemKey}
/>
))}
{settingsNavSections.map((section) => {
const enabledItems = section.items.filter((sectionItem) =>
settingsMenuItems.some(
(item) => item.key === sectionItem.key && item.isEnabled,
),
);
if (enabledItems.length === 0) {
return null;
}
return (
<div key={section.key} className="settings-nav-section">
{section.title && (
<div className="settings-nav-section-title">{section.title}</div>
)}
{enabledItems.map((item) => (
<NavItem
key={item.key}
item={item}
isActive={isActiveNavItem(item.key as string)}
isDisabled={false}
showIcon={false}
onClick={(event): void => {
logEvent('Settings V2: Menu clicked', {
menuLabel: item.label,
menuRoute: item.key,
});
handleMenuItemClick((event as unknown) as MouseEvent, item);
}}
dataTestId={item.itemKey}
/>
))}
</div>
);
})}
</div>
<div className="settings-page-content">

View File

@@ -0,0 +1,137 @@
import React from 'react';
import SettingsPage from 'pages/Settings/Settings';
import { render, screen, within } from 'tests/test-utils';
import { LicensePlatform } from 'types/api/licensesV3/getActive';
import { USER_ROLES } from 'types/roles';
jest.mock('components/MarkdownRenderer/MarkdownRenderer', () => ({
__esModule: true,
default: ({ children }: { children: React.ReactNode }): React.ReactNode =>
children,
}));
jest.mock('api/common/logEvent', () => ({
__esModule: true,
default: jest.fn(),
}));
jest.mock('lib/history', () => ({
push: jest.fn(),
listen: jest.fn(() => jest.fn()),
location: { pathname: '/settings', search: '' },
}));
const getCloudAdminOverrides = (): any => ({
activeLicense: {
key: 'test-key',
platform: LicensePlatform.CLOUD,
},
});
const getSelfHostedAdminOverrides = (): any => ({
activeLicense: {
key: 'test-key',
platform: LicensePlatform.SELF_HOSTED,
},
});
describe('SettingsPage nav sections', () => {
describe('Cloud Admin', () => {
beforeEach(() => {
render(<SettingsPage />, undefined, {
role: USER_ROLES.ADMIN,
appContextOverrides: getCloudAdminOverrides(),
initialRoute: '/settings',
});
});
it.each([
'settings-page-sidenav',
'workspace',
'account',
'notification-channels',
'billing',
'roles',
'api-keys',
'members-sso',
'integrations',
'ingestion',
])('renders "%s" element', (id) => {
expect(screen.getByTestId(id)).toBeInTheDocument();
});
it.each(['Identity & Access', 'Authentication'])(
'renders "%s" section title',
(text) => {
expect(screen.getByText(text)).toBeInTheDocument();
},
);
});
describe('Cloud Viewer', () => {
beforeEach(() => {
render(<SettingsPage />, undefined, {
role: USER_ROLES.VIEWER,
appContextOverrides: getCloudAdminOverrides(),
initialRoute: '/settings',
});
});
it.each(['workspace', 'account'])('renders "%s" element', (id) => {
expect(screen.getByTestId(id)).toBeInTheDocument();
});
it.each(['billing', 'roles', 'api-keys'])(
'does not render "%s" element',
(id) => {
expect(screen.queryByTestId(id)).not.toBeInTheDocument();
},
);
});
describe('Self-hosted Admin', () => {
beforeEach(() => {
render(<SettingsPage />, undefined, {
role: USER_ROLES.ADMIN,
appContextOverrides: getSelfHostedAdminOverrides(),
initialRoute: '/settings',
});
});
it.each(['roles', 'api-keys', 'integrations', 'members-sso', 'ingestion'])(
'renders "%s" element',
(id) => {
expect(screen.getByTestId(id)).toBeInTheDocument();
},
);
});
describe('section structure', () => {
it('renders items in correct sections for cloud admin', () => {
const { container } = render(<SettingsPage />, undefined, {
role: USER_ROLES.ADMIN,
appContextOverrides: getCloudAdminOverrides(),
initialRoute: '/settings',
});
const sidenav = within(container).getByTestId('settings-page-sidenav');
const sections = sidenav.querySelectorAll('.settings-nav-section');
// Should have at least 2 sections (general + identity-access) for cloud admin
expect(sections.length).toBeGreaterThanOrEqual(2);
});
it('hides section entirely when all items in it are disabled', () => {
// Community user has very limited access — identity section should be hidden
render(<SettingsPage />, undefined, {
role: USER_ROLES.VIEWER,
appContextOverrides: {
activeLicense: null,
},
initialRoute: '/settings',
});
expect(screen.queryByText('IDENTITY & ACCESS')).not.toBeInTheDocument();
});
});
});