Files
twenty/packages/twenty-front/src/modules/settings/hooks/useSettingsNavigationItems.tsx
T
neo773 5bedd5b8cc feat(email-group): communications UX, per-record DNS status (#23002)
- Rename Communications label to singular, remove docs-home banner
- Provision unsubscribe Cloudflare records at domain creation and
surface per-record status badges; skip Cloudflare when not configured
- Move sending-domain status into the section header and only show the
records table when a record is unverified
- Reply to the original recipients when replying to your own message
- Fix DNS records table column/badge alignment; emit synthetic records
in the log driver for local testing

<img width="1496" height="849" alt="Screenshot 2026-07-17 at 7 47 24 PM"
src="https://github.com/user-attachments/assets/a5a59adb-2df4-4154-98b2-acf87a8008da"
/>
2026-07-17 22:41:25 +02:00

228 lines
6.8 KiB
TypeScript

import { FeatureFlagKey, SettingsPath } from 'twenty-shared/types';
import { useAuth } from '@/auth/hooks/useAuth';
import { currentUserState } from '@/auth/states/currentUserState';
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
import { billingState } from '@/client-config/states/billingState';
import { supportChatState } from '@/client-config/states/supportChatState';
import { usePermissionFlagMap } from '@/settings/roles/hooks/usePermissionFlagMap';
import { getDocumentationUrl } from '@/support/utils/getDocumentationUrl';
import {
type NavigationDrawerItemIndentationLevel,
type NavigationDrawerItemModifier,
} from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { t } from '@lingui/core/macro';
import { isNonEmptyString } from '@sniptt/guards';
import {
IconApps,
IconAt,
IconCalendarEvent,
IconColorSwatch,
type IconComponent,
IconCurrencyDollar,
IconDoorEnter,
IconHelpCircle,
IconHierarchy2,
IconLayout,
IconMail,
IconMessage,
IconMessageCircle,
IconPlug,
IconServer,
IconSettings,
IconSparkles,
IconUserCircle,
IconUsers,
} from 'twenty-ui/icon';
import { PermissionFlagType } from '~/generated-metadata/graphql';
export type SettingsNavigationSection = {
label: string;
items: SettingsNavigationItem[];
isAdvanced?: boolean;
};
export type SettingsNavigationItem = {
label: string;
path?: SettingsPath;
onClick?: () => void;
Icon: IconComponent;
indentationLevel?: NavigationDrawerItemIndentationLevel;
matchSubPages?: boolean;
isHidden?: boolean;
subItems?: SettingsNavigationItem[];
isAdvanced?: boolean;
modifier?: NavigationDrawerItemModifier;
};
const useSettingsNavigationItems = (): SettingsNavigationSection[] => {
const billing = useAtomStateValue(billingState);
const { signOut } = useAuth();
const supportChat = useAtomStateValue(supportChatState);
const currentWorkspaceMember = useAtomStateValue(currentWorkspaceMemberState);
const isBillingEnabled = billing?.isBillingEnabled ?? false;
const currentUser = useAtomStateValue(currentUserState);
const isAdminEnabled =
(currentUser?.canImpersonate || currentUser?.canAccessFullAdminPanel) ??
false;
const isSupportChatConfigured =
supportChat?.supportDriver === 'FRONT' &&
isNonEmptyString(supportChat.supportFrontChatId);
const permissionMap = usePermissionFlagMap();
const isEmailGroupFeatureEnabled = useIsFeatureEnabled(
FeatureFlagKey.IS_EMAIL_GROUP_ENABLED,
);
return [
{
label: t`User`,
items: [
{
label: t`Profile`,
path: SettingsPath.ProfilePage,
Icon: IconUserCircle,
},
{
label: t`Experience`,
path: SettingsPath.Experience,
Icon: IconColorSwatch,
},
{
label: t`Accounts`,
path: SettingsPath.Accounts,
Icon: IconAt,
isHidden: !permissionMap[PermissionFlagType.CONNECTED_ACCOUNTS],
subItems: [
{
label: t`Emails`,
path: SettingsPath.AccountsEmails,
Icon: IconMail,
isHidden: !permissionMap[PermissionFlagType.CONNECTED_ACCOUNTS],
indentationLevel: 2,
},
{
label: t`Calendars`,
path: SettingsPath.AccountsCalendars,
Icon: IconCalendarEvent,
isHidden: !permissionMap[PermissionFlagType.CONNECTED_ACCOUNTS],
indentationLevel: 2,
},
],
},
],
},
{
label: t`Workspace`,
items: [
{
label: t`General`,
path: SettingsPath.General,
Icon: IconSettings,
isHidden: !permissionMap[PermissionFlagType.WORKSPACE],
},
{
label: t`Data model`,
path: SettingsPath.Objects,
Icon: IconHierarchy2,
isHidden: !permissionMap[PermissionFlagType.DATA_MODEL],
},
{
label: t`Layout`,
path: SettingsPath.Layout,
Icon: IconLayout,
isHidden: !permissionMap[PermissionFlagType.LAYOUTS],
},
{
label: t`Members`,
path: SettingsPath.WorkspaceMembersPage,
Icon: IconUsers,
isHidden: !permissionMap[PermissionFlagType.WORKSPACE_MEMBERS],
},
{
label: t`Billing`,
path: SettingsPath.Billing,
Icon: IconCurrencyDollar,
isHidden:
!isBillingEnabled || !permissionMap[PermissionFlagType.WORKSPACE],
},
{
label: t`MCP & APIs`,
path: SettingsPath.ApiWebhooks,
Icon: IconPlug,
isHidden: !permissionMap[PermissionFlagType.API_KEYS_AND_WEBHOOKS],
},
// TODO: Re-enable when integrations page is ready
// {
// label: t`Integrations`,
// path: SettingsPath.Integrations,
// Icon: IconApps,
// isHidden: !permissionMap[PermissionFlagType.API_KEYS_AND_WEBHOOKS],
// },
{
label: t`Apps`,
path: SettingsPath.Applications,
Icon: IconApps,
isHidden: !permissionMap[PermissionFlagType.APPLICATIONS],
},
{
label: t`AI`,
path: SettingsPath.AI,
Icon: IconSparkles,
isHidden: !permissionMap[PermissionFlagType.AI_SETTINGS],
},
{
label: t`Communication`,
path: SettingsPath.WorkspaceCommunications,
Icon: IconMessageCircle,
isHidden:
!isEmailGroupFeatureEnabled ||
!permissionMap[PermissionFlagType.WORKSPACE],
},
],
},
{
label: t`Other`,
items: [
{
label: t`Admin Panel`,
path: SettingsPath.AdminPanel,
Icon: IconServer,
isHidden: !isAdminEnabled,
},
{
label: t`Community`,
path: SettingsPath.Community,
Icon: IconUsers,
isHidden: !permissionMap[PermissionFlagType.WORKSPACE],
},
{
label: t`Support`,
onClick: () => window.FrontChat?.('show'),
Icon: IconMessage,
isHidden: !isSupportChatConfigured,
},
{
label: t`Documentation`,
onClick: () =>
window.open(
getDocumentationUrl({ locale: currentWorkspaceMember?.locale }),
'_blank',
),
Icon: IconHelpCircle,
},
{
label: t`Logout`,
onClick: signOut,
Icon: IconDoorEnter,
matchSubPages: false,
},
],
},
];
};
export { useSettingsNavigationItems };