fix: resolve menu duplicates, route prefix conflicts, API path bugs, permissions.deleted_at, remove test plugin from production

This commit is contained in:
Agent Zero
2026-07-24 08:19:45 +02:00
parent c5588e64f6
commit 924d28cbf2
12 changed files with 61 additions and 134 deletions
+2 -2
View File
@@ -73,7 +73,7 @@ export function useUploadPlugin() {
const formData = new FormData();
formData.append('file', file);
const { default: apiClient } = await import('./client');
const res = await apiClient.post('/api/v1/plugins/upload', formData, {
const res = await apiClient.post('/plugins/upload', formData, {
headers: { 'Content-Type': 'multipart/form-data' },
});
return res.data;
@@ -89,7 +89,7 @@ export function useInstallPluginFromUrl() {
return useMutation({
mutationFn: async (url: string) => {
const { default: apiClient } = await import('./client');
const res = await apiClient.post('/api/v1/plugins/install-url', { url });
const res = await apiClient.post('/plugins/install-url', { url });
return res.data;
},
onSuccess: () => {
+3 -3
View File
@@ -16,7 +16,7 @@ export interface SearchResponse {
}
export async function search(query: string, entityTypes?: string[], limit = 20): Promise<SearchResponse> {
const r = await apiClient.post('/api/v1/search', {
const r = await apiClient.post('/search', {
query,
entity_types: entityTypes,
limit,
@@ -25,12 +25,12 @@ export async function search(query: string, entityTypes?: string[], limit = 20):
}
export async function searchSuggest(q: string): Promise<string[]> {
const r = await apiClient.get('/api/v1/search/suggest', { params: { q } });
const r = await apiClient.get('/search/suggest', { params: { q } });
return r.data.suggestions;
}
export async function searchSimilar(entityType: string, entityId: string): Promise<SearchResult[]> {
const r = await apiClient.post('/api/v1/search/similar', {
const r = await apiClient.post('/search/similar', {
entity_type: entityType,
entity_id: entityId,
});
+13 -108
View File
@@ -3,21 +3,10 @@ import clsx from 'clsx';
import { NavLink, useLocation } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { useUIStore } from '@/store/uiStore';
import { Calendar, ChevronRight, FileText, Home, Mail, Monitor, Users } from 'lucide-react';
import { ChevronRight, FileText, Home, Settings, Users } from 'lucide-react';
import { usePluginStore } from '@/store/pluginStore';
import * as LucideIcons from 'lucide-react';
interface NavLeaf {
to: string;
labelKey: string;
}
interface NavTreeItem {
labelKey: string;
icon: React.ReactNode;
children: NavLeaf[];
}
interface NavSingleItem {
to: string;
labelKey: string;
@@ -33,40 +22,16 @@ function getIcon(name: string): React.ReactNode {
return Icon ? <Icon className="h-4 w-4" /> : <LucideIcons.FileText className="h-4 w-4" />;
}
// Only non-plugin items: dashboard, contacts, settings.
// All other menu entries (calendar, dms, mail, ai-assistant, automation, reports, tasks, communication)
// are provided by plugin manifests via usePluginStore(s => s.getAllMenuItems()).
const singleItems: NavSingleItem[] = [
{ to: '/dashboard', labelKey: 'nav.dashboard', icon: <Home className="w-5 h-5 flex-shrink-0" aria-hidden="true" strokeWidth={2} /> },
{ to: '/contacts', labelKey: 'nav.contacts', icon: <Users className="w-5 h-5 flex-shrink-0" aria-hidden="true" strokeWidth={2} /> },
];
const treeItems: NavTreeItem[] = [
{
labelKey: 'nav.calendar',
icon: <Calendar className="w-5 h-5 flex-shrink-0" aria-hidden="true" strokeWidth={2} />,
children: [
{ to: '/calendar', labelKey: 'nav.calendar' },
{ to: '/calendar/kanban', labelKey: 'nav.calendarKanban' },
],
},
{
labelKey: 'nav.files',
icon: <FileText className="w-5 h-5 flex-shrink-0" aria-hidden="true" strokeWidth={2} />,
children: [
{ to: '/dms', labelKey: 'nav.files' },
{ to: '/dms/trash', labelKey: 'nav.filesTrash' },
],
},
{
labelKey: 'nav.email',
icon: <Mail className="w-5 h-5 flex-shrink-0" aria-hidden="true" strokeWidth={2} />,
children: [
{ to: '/mail', labelKey: 'nav.email' },
{ to: '/mail/settings', labelKey: 'nav.emailSettings' },
],
},
];
const bottomItems: NavSingleItem[] = [
{ to: '/ai-assistant', labelKey: 'nav.aiAssistant', icon: <Monitor className="w-5 h-5 flex-shrink-0" aria-hidden="true" strokeWidth={2} /> },
{ to: '/settings', labelKey: 'nav.settings', icon: <Settings className="w-5 h-5 flex-shrink-0" aria-hidden="true" strokeWidth={2} /> },
];
export function Sidebar() {
@@ -75,21 +40,20 @@ export function Sidebar() {
const location = useLocation();
const pluginMenuItems = usePluginStore(s => s.getAllMenuItems());
const initialExpanded = treeItems
.filter((item) => item.children.some((child) => location.pathname.startsWith(child.to)))
.map((item) => item.labelKey);
const [expandedItems, setExpandedItems] = useState<Set<string>>(new Set(initialExpanded));
const [expandedItems, setExpandedItems] = useState<Set<string>>(new Set());
useEffect(() => {
setExpandedItems((prev) => {
const next = new Set(prev);
treeItems.forEach((item) => {
const isActive = item.children.some((child) => location.pathname.startsWith(child.to));
if (isActive) next.add(item.labelKey);
});
// Auto-expand plugin groups whose child route is active
for (const item of pluginMenuItems) {
if (item.group && location.pathname.startsWith(item.path)) {
next.add(`plugin-group-${item.group}`);
}
}
return next;
});
}, [location.pathname]);
}, [location.pathname, pluginMenuItems]);
const toggleExpand = (labelKey: string) => {
setExpandedItems((prev) => {
@@ -100,9 +64,6 @@ export function Sidebar() {
});
};
const isChildActive = (children: NavLeaf[]) =>
children.some((child) => location.pathname.startsWith(child.to));
return (
<>
{sidebarOpen && (
@@ -148,62 +109,6 @@ export function Sidebar() {
</li>
))}
{treeItems.map((item) => {
const expanded = expandedItems.has(item.labelKey);
const childActive = isChildActive(item.children);
return (
<li key={item.labelKey}>
<div
className={clsx(
'flex items-center gap-2 px-3 py-2.5 rounded-md text-sm font-medium min-h-touch',
'motion-safe:transition-colors cursor-pointer select-none',
childActive
? 'text-white'
: 'text-secondary-300 hover:bg-secondary-800 hover:text-white'
)}
onClick={() => toggleExpand(item.labelKey)}
role="button"
tabIndex={0}
aria-expanded={expanded}
aria-label={t(item.labelKey)}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
toggleExpand(item.labelKey);
}
}}
>
{item.icon}
<span className="flex-1 truncate">{t(item.labelKey)}</span>
{chevronIcon(expanded)}
</div>
{expanded && (
<ul className="mt-1 ml-4 space-y-1 border-l border-secondary-700 pl-2" role="group">
{item.children.map((child) => (
<li key={child.to}>
<NavLink
to={child.to}
className={({ isActive }) =>
clsx(
'flex items-center gap-2 px-3 py-2 rounded-md text-sm min-h-touch',
'motion-safe:transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500',
isActive
? 'bg-primary-600 text-white font-medium'
: 'text-secondary-400 hover:bg-secondary-800 hover:text-white'
)
}
aria-label={t(child.labelKey)}
>
<span className="truncate">{t(child.labelKey)}</span>
</NavLink>
</li>
))}
</ul>
)}
</li>
);
})}
{pluginMenuItems.length > 0 && (
<>
<li className="px-3 pt-4 pb-1">