feat: plugin ribbon toolbar + mail response fixes
- Add pluginToolbarStore for plugin toolbar item registration - Add PluginToolbar component (slim ribbon bar under TopBar) - Update AppShell to render PluginToolbar between TopBar and content - Mail page registers toolbar items (account select, search, compose, sync, settings) - Remove old mail top bar, use plugin toolbar instead - Fix mail response: arrays for addresses, add from_name/body_html/sanitized_html/date
This commit is contained in:
@@ -2,6 +2,7 @@ import React from 'react';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import { Sidebar } from './Sidebar';
|
||||
import { TopBar } from './TopBar';
|
||||
import { PluginToolbar } from './PluginToolbar';
|
||||
import { ToastContainer } from '@/components/ui/Toast';
|
||||
|
||||
export function AppShell() {
|
||||
@@ -10,6 +11,7 @@ export function AppShell() {
|
||||
<Sidebar />
|
||||
<div className="flex-1 flex flex-col overflow-hidden">
|
||||
<TopBar />
|
||||
<PluginToolbar />
|
||||
<main
|
||||
className="flex-1 overflow-y-auto focus:outline-none"
|
||||
tabIndex={-1}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import React from 'react';
|
||||
import { usePluginToolbarStore, type ToolbarItem } from '@/store/pluginToolbarStore';
|
||||
|
||||
function ToolbarButton({ item }: { item: ToolbarItem }) {
|
||||
return (
|
||||
<button
|
||||
onClick={item.onClick}
|
||||
disabled={item.disabled}
|
||||
className={`
|
||||
inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium
|
||||
transition-colors duration-100
|
||||
${item.active ? 'bg-primary-100 text-primary-700' : 'text-secondary-600 hover:bg-secondary-100 hover:text-secondary-900'}
|
||||
${item.disabled ? 'opacity-40 cursor-not-allowed' : 'cursor-pointer'}
|
||||
`}
|
||||
title={item.label}
|
||||
>
|
||||
{item.icon && <span className="w-3.5 h-3.5 flex-shrink-0">{item.icon}</span>}
|
||||
<span className="hidden sm:inline">{item.label}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
function ToolbarSearch({ item }: { item: ToolbarItem }) {
|
||||
return (
|
||||
<input
|
||||
type="text"
|
||||
placeholder={item.searchPlaceholder || 'Suchen...'}
|
||||
onChange={(e) => item.onSearch?.(e.target.value)}
|
||||
className="w-40 px-2 py-1 text-xs border border-secondary-200 rounded
|
||||
focus:outline-none focus:border-primary-400 focus:ring-1 focus:ring-primary-300
|
||||
placeholder:text-secondary-400"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function ToolbarSelect({ item }: { item: ToolbarItem }) {
|
||||
return (
|
||||
<select
|
||||
value={item.selectValue || ''}
|
||||
onChange={(e) => item.onSelect?.(e.target.value)}
|
||||
className="px-2 py-1 text-xs border border-secondary-200 rounded
|
||||
focus:outline-none focus:border-primary-400 focus:ring-1 focus:ring-primary-300
|
||||
bg-white cursor-pointer"
|
||||
>
|
||||
{item.selectOptions?.map((opt) => (
|
||||
<option key={opt.value} value={opt.value}>{opt.label}</option>
|
||||
))}
|
||||
</select>
|
||||
);
|
||||
}
|
||||
|
||||
export function PluginToolbar() {
|
||||
const { items, activePlugin } = usePluginToolbarStore();
|
||||
const visibleItems = items.filter((i) => i.plugin === activePlugin);
|
||||
|
||||
if (visibleItems.length === 0) return null;
|
||||
|
||||
// Group items by group field
|
||||
const groups: Record<string, ToolbarItem[]> = {};
|
||||
for (const item of visibleItems) {
|
||||
const g = item.group || 'default';
|
||||
if (!groups[g]) groups[g] = [];
|
||||
groups[g].push(item);
|
||||
}
|
||||
const groupNames = Object.keys(groups);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="flex items-center gap-1 px-3 py-1 bg-white border-b border-secondary-200 min-h-[36px]"
|
||||
data-testid="plugin-toolbar"
|
||||
>
|
||||
{groupNames.map((groupName, gi) => (
|
||||
<React.Fragment key={groupName}>
|
||||
{gi > 0 && <div className="w-px h-5 bg-secondary-200 mx-1" />}
|
||||
<div className="flex items-center gap-1">
|
||||
{groups[groupName].map((item) => {
|
||||
if (item.type === 'search') return <ToolbarSearch key={item.id} item={item} />;
|
||||
if (item.type === 'select') return <ToolbarSelect key={item.id} item={item} />;
|
||||
return <ToolbarButton key={item.id} item={item} />;
|
||||
})}
|
||||
</div>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user