feat(workflows): make approval rows clickable to open the underlying document

Each approval asks the admin to confirm/deny, but they couldn't see what they
were approving. The row's prompt/meta area is now a clickable button that
navigates to the run entity's detail page (quote -> /admin/quotes/:id, invoice
-> /admin/bills/:id, event/contract/customer likewise) so the admin can review
before deciding. Confirm/Deny stay as separate buttons; rows whose entity has no
detail route (or no entity) render as plain, non-clickable text. Adds the
approvals.openEntity tooltip string (en + de).
This commit is contained in:
Luca
2026-06-27 01:03:31 +02:00
parent 9414b42b7f
commit 7727b6714b
3 changed files with 42 additions and 12 deletions
+1
View File
@@ -238,6 +238,7 @@
"defaultPrompt": "Ein Workflow benötigt deine Bestätigung.", "defaultPrompt": "Ein Workflow benötigt deine Bestätigung.",
"pendingTitle": "Offene Freigaben", "pendingTitle": "Offene Freigaben",
"viewAll": "Alle Freigaben ansehen", "viewAll": "Alle Freigaben ansehen",
"openEntity": "{{type}} #{{id}} öffnen",
"acted": "Erledigt" "acted": "Erledigt"
}, },
"editor": { "editor": {
+1
View File
@@ -238,6 +238,7 @@
"defaultPrompt": "A workflow needs your confirmation.", "defaultPrompt": "A workflow needs your confirmation.",
"pendingTitle": "Pending approvals", "pendingTitle": "Pending approvals",
"viewAll": "View all approvals", "viewAll": "View all approvals",
"openEntity": "Open {{type}} #{{id}}",
"acted": "Done" "acted": "Done"
}, },
"editor": { "editor": {
@@ -36,6 +36,17 @@ export const WorkflowApprovalsPage: React.FC = () => {
const promptOf = (a: WorkflowApproval) => (a.payload && (a.payload.prompt as string)) || t('workflows.approvals.defaultPrompt', 'A workflow needs your confirmation.'); const promptOf = (a: WorkflowApproval) => (a.payload && (a.payload.prompt as string)) || t('workflows.approvals.defaultPrompt', 'A workflow needs your confirmation.');
// The admin detail route for the run's entity, so a row click opens the
// document they're being asked to approve. `invoice` lives under /bills.
const entityHref = (a: WorkflowApproval): string | null => {
if (!a.entity_type || a.entity_id == null) return null;
const base: Record<string, string> = {
quote: 'quotes', invoice: 'bills', event: 'events', contract: 'contracts', customer: 'customers',
};
const seg = base[a.entity_type];
return seg ? `/admin/${seg}/${a.entity_id}` : null;
};
return ( return (
<div className="space-y-6"> <div className="space-y-6">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
@@ -55,16 +66,32 @@ export const WorkflowApprovalsPage: React.FC = () => {
<div className="p-10 text-center text-neutral-500 dark:text-neutral-400">{t('workflows.approvals.empty', 'Nothing waiting for you right now.')}</div> <div className="p-10 text-center text-neutral-500 dark:text-neutral-400">{t('workflows.approvals.empty', 'Nothing waiting for you right now.')}</div>
) : ( ) : (
<ul className="divide-y divide-neutral-200 dark:divide-neutral-700"> <ul className="divide-y divide-neutral-200 dark:divide-neutral-700">
{approvals.map((a) => ( {approvals.map((a) => {
<li key={a.id} className="flex items-center gap-3 px-4 py-3"> const href = entityHref(a);
<div className="min-w-0 flex-1"> const meta = (
<>
<div className="text-sm text-neutral-900 dark:text-neutral-100">{promptOf(a)}</div> <div className="text-sm text-neutral-900 dark:text-neutral-100">{promptOf(a)}</div>
<div className="text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"> <div className="text-xs text-neutral-500 dark:text-neutral-400 mt-0.5">
{a.workflow_name} {a.workflow_name}
{a.entity_type ? ` · ${a.entity_type} #${a.entity_id}` : ''} {a.entity_type ? ` · ${a.entity_type} #${a.entity_id}` : ''}
{a.created_at ? ` · ${formatDateTime(a.created_at)}` : ''} {a.created_at ? ` · ${formatDateTime(a.created_at)}` : ''}
</div> </div>
</div> </>
);
return (
<li key={a.id} className="flex items-center gap-3 px-4 py-3">
{href ? (
<button
type="button"
onClick={() => navigate(href)}
className="min-w-0 flex-1 text-left rounded -mx-1 px-1 py-0.5 hover:bg-neutral-50 dark:hover:bg-neutral-800/60 transition-colors cursor-pointer"
title={t('workflows.approvals.openEntity', 'Open {{type}} #{{id}}', { type: a.entity_type, id: a.entity_id }) as string}
>
{meta}
</button>
) : (
<div className="min-w-0 flex-1">{meta}</div>
)}
<Button variant="outline" size="sm" isLoading={actMutation.isPending} onClick={() => actMutation.mutate({ id: a.id, action: 'confirm' })} leftIcon={<Check className="w-4 h-4" />}> <Button variant="outline" size="sm" isLoading={actMutation.isPending} onClick={() => actMutation.mutate({ id: a.id, action: 'confirm' })} leftIcon={<Check className="w-4 h-4" />}>
{t('workflows.approvals.confirm', 'Confirm')} {t('workflows.approvals.confirm', 'Confirm')}
</Button> </Button>
@@ -72,7 +99,8 @@ export const WorkflowApprovalsPage: React.FC = () => {
{t('workflows.approvals.deny', 'Deny')} {t('workflows.approvals.deny', 'Deny')}
</Button> </Button>
</li> </li>
))} );
})}
</ul> </ul>
)} )}
</Card> </Card>