import { ApiOutlined, AppstoreOutlined, CloudServerOutlined, DashboardOutlined, GlobalOutlined, InboxOutlined, KeyOutlined, MailOutlined, ReloadOutlined, SafetyCertificateOutlined, SendOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons'; import { Avatar, Breadcrumb, Button, Dropdown, Layout, Menu, Select, Space, Typography } from 'antd'; import type { ReactNode } from 'react'; import { useI18n } from '../frontend/i18n/react'; import type { User, ViewKey } from '../frontend/types'; const { Header, Sider, Content } = Layout; const navGroups: Array<{ key: string; labelKey: string; items: Array<{ key: ViewKey; labelKey: string; icon: ReactNode; adminOnly?: boolean }>; }> = [ { key: 'overview', labelKey: 'nav.group.overview', items: [ { key: 'dashboard', labelKey: 'nav.dashboard', icon: }, { key: 'domains', labelKey: 'nav.domains', icon: }, { key: 'dns-api', labelKey: 'nav.dnsApi', icon: } ] }, { key: 'delivery', labelKey: 'nav.group.delivery', items: [ { key: 'smtp', labelKey: 'nav.smtp', icon: }, { key: 'inbox', labelKey: 'nav.inbox', icon: }, { key: 'tokens', labelKey: 'nav.tokens', icon: }, { key: 'logs', labelKey: 'nav.logs', icon: }, { key: 'webhooks', labelKey: 'nav.webhooks', icon: } ] }, { key: 'system', labelKey: 'nav.group.system', items: [ { key: 'admin', labelKey: 'nav.admin', icon: , adminOnly: true }, { key: 'settings', labelKey: 'nav.settings', icon: } ] } ]; interface AdminLayoutProps { activeView: ViewKey; breadcrumb: string[]; user: User | null; runtimeLine: string; loading: boolean; children: ReactNode; onViewChange: (view: ViewKey) => void; onRefresh: () => void; onAddDomain: () => void; onLogout: () => void; } export function AdminLayout({ activeView, breadcrumb, user, runtimeLine, loading, children, onViewChange, onRefresh, onAddDomain, onLogout }: AdminLayoutProps) { const { locale, locales, setLocale, t } = useI18n(); const isAdmin = user?.role === 'admin'; const menuItems = navGroups.map((group) => ({ type: 'group' as const, key: group.key, label: t(group.labelKey), children: group.items .filter((item) => !item.adminOnly || isAdmin) .map((item) => ({ key: item.key, icon: item.icon, label: t(item.labelKey) })) })); return (
MH
MailHub
Email Delivery
onViewChange(key as ViewKey)} className="admin-menu" /> {user ? (
} className="sider-user-avatar" />
{user.username || t('common.user')}
{user.role || '—'}
) : null}
({ title }))} className="header-breadcrumb" /> {runtimeLine}