ultisuite-client/lib/mail-settings/settings-nav.ts
R3D347HR4Y 5304790ed5
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
feat(auth): enhance session management and identity provider settings
- Added SessionGuard component to manage session expiration and online status.
- Updated AuthProvider to streamline session fetching and handling.
- Introduced IdentityProvidersSection for managing OAuth, SAML, and LDAP identity providers.
- Implemented identity provider guides for easier configuration.
- Enhanced mail settings with infinite scroll option for improved user experience.
- Updated global styles and layout components for better consistency across the application.
2026-06-09 09:36:46 +02:00

112 lines
2.7 KiB
TypeScript

import type { LucideIcon } from "lucide-react"
import {
Bell,
Bot,
FolderKanban,
Monitor,
Users,
} from "lucide-react"
export type MailSettingsSectionId =
| "display"
| "accounts"
| "labels"
| "notifications"
| "automation"
export type MailSettingsNavItem = {
id: MailSettingsSectionId
label: string
description: string
href: string
icon: LucideIcon
}
export const MAIL_SETTINGS_NAV: MailSettingsNavItem[] = [
{
id: "display",
label: "Affichage",
description: "Densité, thème, boîte de réception, volet de lecture",
href: "/mail/settings",
icon: Monitor,
},
{
id: "accounts",
label: "Comptes mail",
description: "IMAP, SMTP, identités d'envoi et signatures",
href: "/mail/settings/accounts",
icon: Users,
},
{
id: "labels",
label: "Libellés et dossiers",
description: "Organisation unifiée cross-comptes",
href: "/mail/settings/labels",
icon: FolderKanban,
},
{
id: "notifications",
label: "Notifications",
description: "Alertes desktop, mobile et e-mail",
href: "/mail/settings/notifications",
icon: Bell,
},
{
id: "automation",
label: "Automatisations",
description: "Règles, webhooks, LLM, recherche web, tokens API",
href: "/mail/settings/automation",
icon: Bot,
},
]
export function isMailSettingsNavActive(
pathname: string | null,
item: MailSettingsNavItem
): boolean {
if (item.href === "/mail/settings") {
return (
pathname === "/mail/settings" || pathname === "/mail/settings/display"
)
}
return (
pathname === item.href || Boolean(pathname?.startsWith(`${item.href}/`))
)
}
export function resolveMailSettingsSection(
segments: string[] | undefined
): MailSettingsSectionId {
const slug = segments?.[0]
const match = MAIL_SETTINGS_NAV.find((item) => {
if (item.id === "display") return !slug || slug === "display"
return item.href.endsWith(`/${slug}`)
})
return match?.id ?? "display"
}
const MAIL_SETTINGS_WIDE_LAYOUT_SECTIONS: MailSettingsSectionId[] = [
"display",
"automation",
]
const MAIL_SETTINGS_LEFT_ALIGNED_SECTIONS: MailSettingsSectionId[] = ["accounts"]
export function isMailSettingsWideLayoutPath(pathname: string | null): boolean {
if (!pathname?.startsWith("/mail/settings")) return false
return MAIL_SETTINGS_NAV.some(
(item) =>
MAIL_SETTINGS_WIDE_LAYOUT_SECTIONS.includes(item.id) &&
isMailSettingsNavActive(pathname, item)
)
}
export function isMailSettingsLeftAlignedPath(pathname: string | null): boolean {
if (!pathname?.startsWith("/mail/settings")) return false
return MAIL_SETTINGS_NAV.some(
(item) =>
MAIL_SETTINGS_LEFT_ALIGNED_SECTIONS.includes(item.id) &&
isMailSettingsNavActive(pathname, item)
)
}