feat: move reply/forward/flag/event buttons to plugin toolbar

- Toolbar now includes context-aware mail action buttons
- Reply, Forward, Flag, Create Event disabled when no mail selected
- Buttons grouped: account | search | compose | mail-actions | tools
This commit is contained in:
Agent Zero
2026-07-15 12:55:41 +02:00
parent 56f624a073
commit d82ca27fdc
+42 -4
View File
@@ -284,6 +284,7 @@ export function MailPage() {
// Register toolbar items // Register toolbar items
const { registerItems, unregisterPlugin } = usePluginToolbarStore(); const { registerItems, unregisterPlugin } = usePluginToolbarStore();
useEffect(() => { useEffect(() => {
const hasMail = !!selectedMail;
registerItems('mail', [ registerItems('mail', [
{ {
id: 'account-select', id: 'account-select',
@@ -308,15 +309,52 @@ export function MailPage() {
id: 'compose', id: 'compose',
plugin: 'mail', plugin: 'mail',
label: 'Verfassen', label: 'Verfassen',
group: 'actions', group: 'compose',
icon: <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" /></svg>, icon: <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" /></svg>,
onClick: handleCompose, onClick: handleCompose,
}, },
{
id: 'reply',
plugin: 'mail',
label: 'Antworten',
group: 'mail-actions',
disabled: !hasMail,
icon: <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6" /></svg>,
onClick: () => selectedMail && handleReply(selectedMail),
},
{
id: 'forward',
plugin: 'mail',
label: 'Weiterleiten',
group: 'mail-actions',
disabled: !hasMail,
icon: <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 10H11a8 8 0 00-8 8v2m18-10l-6 6m6-6l-6-6" /></svg>,
onClick: () => selectedMail && handleForward(selectedMail),
},
{
id: 'flag',
plugin: 'mail',
label: 'Flagge',
group: 'mail-actions',
disabled: !hasMail,
active: selectedMail?.is_flagged,
icon: <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 21v-4m0 0V5a2 2 0 012-2h6.5l1 1H21l-3 6 3 6h-8.5l-1-1H5a2 2 0 00-2 2zm9-13.5V9" /></svg>,
onClick: () => selectedMail && handleToggleFlag(selectedMail),
},
{
id: 'create-event',
plugin: 'mail',
label: 'Termin',
group: 'mail-actions',
disabled: !hasMail,
icon: <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>,
onClick: () => selectedMail && handleCreateEvent(selectedMail),
},
{ {
id: 'sync', id: 'sync',
plugin: 'mail', plugin: 'mail',
label: 'Sync', label: 'Sync',
group: 'actions', group: 'tools',
icon: <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" /></svg>, icon: <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" /></svg>,
onClick: () => { /* sync trigger */ }, onClick: () => { /* sync trigger */ },
}, },
@@ -324,13 +362,13 @@ export function MailPage() {
id: 'settings', id: 'settings',
plugin: 'mail', plugin: 'mail',
label: 'Einstellungen', label: 'Einstellungen',
group: 'actions', group: 'tools',
icon: <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /></svg>, icon: <svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /></svg>,
onClick: () => window.location.href = '/mail/settings', onClick: () => window.location.href = '/mail/settings',
}, },
]); ]);
return () => unregisterPlugin('mail'); return () => unregisterPlugin('mail');
}, [registerItems, unregisterPlugin, accounts, selectedAccountId, handleAccountSwitch, handleSearch, handleCompose]); }, [registerItems, unregisterPlugin, accounts, selectedAccountId, selectedMail, handleAccountSwitch, handleSearch, handleCompose, handleReply, handleForward, handleToggleFlag, handleCreateEvent]);
if (loadingAccounts) { if (loadingAccounts) {
return ( return (