8b3873d676
TopBar: - Add Automation and Agenten to user dropdown menu Settings restructure: - Stammdaten: Firmendaten, Adressen (CRUD), Konten (CRUD), Sonstige Daten - Nutzerverwaltung: Benutzer, Rollen, Gruppen as tabs - System: Menü, Theme, Plugins as tabs - Reduce nav items from 15+ to 8 - Add end prop to all settings NavLinks
73 lines
2.9 KiB
TypeScript
73 lines
2.9 KiB
TypeScript
import React, { useMemo } from 'react';
|
|
import { NavLink, Outlet } from 'react-router-dom';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { usePluginStore } from '@/store/pluginStore';
|
|
import * as LucideIcons from 'lucide-react';
|
|
|
|
export function SettingsPage() {
|
|
const { t } = useTranslation();
|
|
const manifests = usePluginStore(s => s.manifests);
|
|
const pluginSettingsPages = useMemo(
|
|
() => manifests
|
|
.flatMap((m) => m.settings_pages)
|
|
.sort((a, b) => a.order - b.order),
|
|
[manifests]
|
|
);
|
|
|
|
const hardcodedNavItems = [
|
|
{ to: '/settings/stammdaten', label: 'Stammdaten', icon: '\ud83c\udfe2' },
|
|
{ to: '/settings/user-management', label: 'Nutzerverwaltung', icon: '\ud83d\udc65' },
|
|
{ to: '/settings/system', label: 'System', icon: '\u2699\ufe0f' },
|
|
{ to: '/settings/mail', label: t('mail.settings'), icon: '\ud83d\udce7' },
|
|
{ to: '/settings/ai', label: t('nav.aiAssistant'), icon: '\ud83e\udde0' },
|
|
{ to: '/settings/ai-proactive', label: 'Proaktive KI', icon: '\ud83e\udd16' },
|
|
{ to: '/settings/notifications', label: t('settings.notifications'), icon: '\ud83d\udd14' },
|
|
{ to: '/settings/mcp', label: t('settings.mcp', 'MCP'), icon: '\ud83d\udd27' },
|
|
];
|
|
|
|
const existingPaths = new Set(hardcodedNavItems.map(item => item.to));
|
|
const pluginNavItems = pluginSettingsPages
|
|
.filter(p => !existingPaths.has(`/settings/${p.path}`))
|
|
.map(p => ({
|
|
to: `/settings/${p.path}`,
|
|
label: t(p.label_key, p.label),
|
|
icon: (() => {
|
|
const Icon = (LucideIcons as any)[p.icon];
|
|
return Icon ? React.createElement(Icon, { className: 'w-4 h-4' }) : '\ud83d\udce6';
|
|
})(),
|
|
}));
|
|
|
|
const navItems = [...hardcodedNavItems, ...pluginNavItems];
|
|
|
|
return (
|
|
<div className="flex max-w-7xl mx-auto" data-testid="settings-page">
|
|
<aside className="w-64 flex-shrink-0 border-r border-secondary-200 p-4 min-h-[calc(100vh-4rem)]">
|
|
<h1 className="text-xl font-bold text-secondary-900 mb-6">{t('settings.title')}</h1>
|
|
<nav className="space-y-1" role="navigation" aria-label={t('settings.title')}>
|
|
{navItems.map((item) => (
|
|
<NavLink
|
|
key={item.to}
|
|
to={item.to}
|
|
end
|
|
className={({ isActive }) =>
|
|
`flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${
|
|
isActive
|
|
? 'bg-primary-100 text-primary-700'
|
|
: 'text-secondary-600 hover:bg-secondary-100 hover:text-secondary-900'
|
|
}`
|
|
}
|
|
data-testid={`settings-nav-${item.to.split('/').pop()}`}
|
|
>
|
|
<span aria-hidden="true">{item.icon}</span>
|
|
{item.label}
|
|
</NavLink>
|
|
))}
|
|
</nav>
|
|
</aside>
|
|
<main className="flex-1 p-6" data-testid="settings-content">
|
|
<Outlet />
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|