Astra: security review, left-on-pod ledger, chosen scenarios all run, GL navigation and Create Order popup on 26D, health check (ed9256cd4029)
348eedc verified Download web/src/pages/setup/LeftOnPodPage.tsx from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 8.03 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/pages/setup/LeftOnPodPage.tsx
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/web/src/pages/setup/LeftOnPodPage.tsx
-
curl -L -o LeftOnPodPage.tsx https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/pages/setup/LeftOnPodPage.tsx
8.03 kB
| import { Anchor, Button, Group, Modal, SegmentedControl, Select, Stack, Table, Text, Textarea } from '@mantine/core'; | |
| import { useState } from 'react'; | |
| import { Link, useSearchParams } from 'react-router-dom'; | |
| import { useLeftOnPod, useLeftOnPodActions, usePods, type LeftDoc } from '../../api/hooks'; | |
| import { Can, ErrorAlert, fmtTs, PageHeader } from '../../components/common'; | |
| import { DataTable } from '../../components/states'; | |
| import { shortWhen } from '../../domain/runName'; | |
| import './admin.css'; | |
| /** The kinds of test document a run can leave on a pod (coworker/platform/left_on_pod.py KINDS), in words. */ | |
| export const LEFT_KINDS: Record<string, string> = { | |
| ap_invoice: 'Payables invoice', po_requisition: 'Purchase requisition', po_order: 'Purchase order', po_receipt: 'Receipt of an order', | |
| gl_journal: 'Journal', ar_transaction: 'Receivables transaction', ar_receipt: 'Receivables receipt', | |
| }; | |
| const STATUS_FILTERS = [{ value: 'open', label: 'Open' }, { value: 'done', label: 'Done' }, { value: 'dismissed', label: 'Dismissed' }, { value: 'all', label: 'All' }]; | |
| const CHECK: Record<string, { tone: string; words: string }> = { | |
| still_on_pod: { tone: 'amber', words: 'Still on the pod' }, looks_resolved: { tone: 'green', words: 'Looks resolved' }, unknown: { tone: 'neutral', words: 'Could not tell' }, | |
| }; | |
| function DecideSheet({ doc, decision, onClose }: { doc: LeftDoc | null; decision: 'done' | 'dismiss'; onClose: () => void }) { | |
| const { decide } = useLeftOnPodActions(); | |
| const [note, setNote] = useState(''); | |
| const done = decision === 'done'; | |
| return ( | |
| <Modal opened={!!doc} onClose={onClose} title={done ? 'Mark this document done?' : 'Dismiss this document?'} size={480} centered> | |
| <Stack gap="sm"> | |
| <Text size="sm"><b>{doc ? `${LEFT_KINDS[doc.kind] ?? doc.kind} ${doc.reference}` : ''}</b></Text> | |
| <Text size="sm" c="dimmed"> | |
| {done ? 'Say that it has been dealt with on the pod, or that nothing is needed.' : 'Say that it does not need to be dealt with.'} It leaves the open list; the | |
| name and the time are kept in the audit log. | |
| </Text> | |
| <Textarea label="Note (optional)" description="Kept with the document and in the audit log." autosize minRows={2} maxRows={5} maxLength={1000} | |
| value={note} onChange={(e) => setNote(e.currentTarget.value)} data-autofocus /> | |
| <ErrorAlert error={decide.error} title="Could not save" /> | |
| <div className="trio-sheet-foot"> | |
| <Button variant="default" onClick={onClose}>Not yet</Button><span className="trio-sheet-sp" /> | |
| <Button loading={decide.isPending} data-testid="left-confirm" | |
| onClick={() => doc && decide.mutate({ id: doc.id, decision, note: note.trim() }, { onSuccess: onClose })}>{done ? 'Mark done' : 'Dismiss'}</Button> | |
| </div> | |
| </Stack> | |
| </Modal> | |
| ); | |
| } | |
| export function LeftOnPodPage() { | |
| const pods = usePods(); | |
| const [params] = useSearchParams(); | |
| const [podId, setPodId] = useState<string | null>(() => params.get('pod')); | |
| const [status, setStatus] = useState('open'); | |
| const [kind, setKind] = useState<string | null>(null); | |
| const q = useLeftOnPod({ pod_id: podId ? Number(podId) : undefined, status: status === 'all' ? undefined : (status as LeftDoc['status']), kind: kind ?? undefined }); | |
| const { decide, recheck } = useLeftOnPodActions(); | |
| const [sheet, setSheet] = useState<{ doc: LeftDoc; decision: 'done' | 'dismiss' } | null>(null); | |
| const items = q.data?.items ?? []; | |
| const podOptions = (pods.data ?? []).filter((p) => p.kind !== 'mock').map((p) => ({ value: String(p.id), label: p.name })); | |
| return ( | |
| <Stack gap="md"> | |
| <PageHeader crumbs={[{ label: 'Home', to: '/' }, { label: 'Test environments', to: '/pods' }, { label: 'Left on the pod' }]} title="Left on the pod" | |
| extra={<span className="fpt-pagedesc">Test documents a run created on an Oracle Fusion pod that the co-worker could not undo. Each needs a person: what to do is written next to it.</span>} /> | |
| <Group gap="sm" align="flex-end" wrap="wrap"> | |
| <Select aria-label="Pod" placeholder="All pods" data={podOptions} value={podId} onChange={setPodId} clearable w={220} /> | |
| <Select aria-label="Kind of document" placeholder="All kinds" data={Object.entries(LEFT_KINDS).map(([value, label]) => ({ value, label }))} | |
| value={kind} onChange={setKind} clearable w={220} /> | |
| <SegmentedControl aria-label="Status" value={status} onChange={setStatus} data={STATUS_FILTERS} /> | |
| </Group> | |
| <ErrorAlert error={recheck.error || decide.error} /> | |
| <DataTable label="Test documents left on the pod" q={q} rowCount={items.length} minWidth={960} fz="sm" | |
| columns={['Document', 'Pod and run', 'Why it was left, and what to do', 'On the pod now', { label: 'Actions', width: 190 }]} | |
| empty={status === 'open' ? 'Nothing is left on the pod for a person to deal with.' : 'No documents match.'}> | |
| {items.map((d) => { | |
| const c = d.check_state ? CHECK[d.check_state] : null; | |
| return ( | |
| <Table.Tr key={d.id} data-testid={`left-${d.id}`} data-status={d.status}> | |
| <Table.Td> | |
| <b>{d.reference}</b> | |
| <Text size="xs" c="dimmed">{LEFT_KINDS[d.kind] ?? d.kind}{d.scenario ? `, from "${d.scenario}"` : ''}</Text> | |
| <Text size="xs" c="dimmed" title={fmtTs(d.created_at)}>created {shortWhen(d.created_at)}</Text> | |
| </Table.Td> | |
| <Table.Td> | |
| <Text size="sm">{d.pod_name ?? `Pod ${d.pod_id}`}</Text> | |
| <Anchor component={Link} to={`/runs/${d.run_id}`} size="xs">{d.run_id}</Anchor> | |
| </Table.Td> | |
| <Table.Td> | |
| <Text size="sm">{d.why}.</Text> | |
| <Text size="sm"><b>To do:</b> {d.todo}</Text> | |
| {d.status !== 'open' && ( | |
| <Text size="xs" c="dimmed">{d.status === 'done' ? 'Done' : 'Dismissed'} by {d.decided_by} {d.decided_at ? shortWhen(d.decided_at) : ''}{d.note ? `: ${d.note}` : ''}</Text> | |
| )} | |
| </Table.Td> | |
| <Table.Td> | |
| {c ? <span className="fpt-dotword" data-tone={c.tone} title={d.check_detail ?? undefined}>{c.words}</span> : <Text size="xs" c="dimmed">Not looked at yet</Text>} | |
| {c && <Text size="xs" c="dimmed">{d.check_detail}, {d.checked_at ? shortWhen(d.checked_at) : ''}</Text>} | |
| </Table.Td> | |
| <Table.Td> | |
| <Can perm="left.decide"> | |
| <Group gap={4}> | |
| {d.status === 'open' ? ( | |
| <> | |
| <Button size="compact-xs" onClick={() => setSheet({ doc: d, decision: 'done' })}>Mark done</Button> | |
| <Button size="compact-xs" variant="default" onClick={() => setSheet({ doc: d, decision: 'dismiss' })}>Dismiss</Button> | |
| </> | |
| ) : ( | |
| <Button size="compact-xs" variant="default" loading={decide.isPending} onClick={() => decide.mutate({ id: d.id, decision: 'reopen' })}>Open again</Button> | |
| )} | |
| <Button size="compact-xs" variant="default" loading={recheck.isPending && recheck.variables === d.id} onClick={() => recheck.mutate(d.id)} | |
| title="Looks at the pod again with read-only requests. Nothing on the pod is changed.">Look again</Button> | |
| </Group> | |
| </Can> | |
| </Table.Td> | |
| </Table.Tr> | |
| ); | |
| })} | |
| </DataTable> | |
| <SheetHost sheet={sheet} onClose={() => setSheet(null)} /> | |
| </Stack> | |
| ); | |
| } | |
| // remounted per document, so a note typed for one never shows on another | |
| function SheetHost({ sheet, onClose }: { sheet: { doc: LeftDoc; decision: 'done' | 'dismiss' } | null; onClose: () => void }) { | |
| return <DecideSheet key={sheet ? `${sheet.doc.id}-${sheet.decision}` : 'none'} doc={sheet?.doc ?? null} decision={sheet?.decision ?? 'done'} onClose={onClose} />; | |
| } | |