EnergyVenom's picture
Tidy the web app: pages by area, CSS in load order, web/README.md (b2a039d)
fb43301 verified
Raw History Blame Contribute Delete
3.25 kB
import { Group, Text, Tooltip } from '@mantine/core';
import { IconAlertTriangle, IconArrowRight, IconCircleCheck, IconCircleDashed, IconMinus, IconX } from '@/components/icons';
import type { ReactNode } from 'react';
import type { ProcessStep } from '../api/types';
import { STEP_STATE } from '../domain/glossary';
const ICON: Record<string, ReactNode> = {
failing: <IconX size={12} aria-hidden />, gap: <IconAlertTriangle size={12} aria-hidden />, not_tested: <IconCircleDashed size={12} aria-hidden />,
passed: <IconCircleCheck size={12} aria-hidden />, not_affected: <IconMinus size={12} aria-hidden />,
};
function detail(s: ProcessStep) {
const parts = [STEP_STATE[s.state]?.label ?? s.state];
if (s.scenarios) parts.push(`${s.scenarios} scenario(s) in this test run: ${s.passed} passed${s.flaky ? `, ${s.flaky} passed on retry` : ''}${s.failed ? `, ${s.failed} failing` : ''}${s.not_run ? `, ${s.not_run} not run yet` : ''}`);
else parts.push(`${s.library} scenario(s) in the library`);
if (s.touched) parts.push('changed by this patch');
return parts.join(' · ');
}
export function StepChip({ s }: { s: ProcessStep }) {
const st = STEP_STATE[s.state] ?? { label: s.state, tone: 'neutral' };
return (
<Tooltip label={detail(s)} multiline w={280} withArrow>
<span className="fpt-pill" data-tone={st.tone} tabIndex={0} role="listitem" aria-label={`${s.name}: ${detail(s)}`}
data-testid={`step-${s.name}`} data-state={s.state} style={{ padding: '4px 10px', fontSize: 12 }}>
{ICON[s.state]}{s.name}
{s.scenarios > 0 && <span style={{ opacity: 0.75, fontWeight: 400 }}>{s.passed + s.flaky}/{s.scenarios}</span>}
</span>
</Tooltip>
);
}
/** A module's business process: the flow steps in order (from the coverage map), cross-cutting steps beside it. */
export function ProcessFlow({ steps, mainOnly = false }: { steps: ProcessStep[]; mainOnly?: boolean }) {
const flow = steps.filter((s) => !s.cross_cutting && !s.group);
const addon = steps.filter((s) => !s.cross_cutting && s.group);
const cross = steps.filter((s) => s.cross_cutting);
const row = (list: ProcessStep[], arrows: boolean) => (
<div role="list" style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 6 }}>
{list.map((s, i) => (
<span key={s.key} style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}>
{arrows && i > 0 && <IconArrowRight size={12} color="var(--fpt-dim)" aria-hidden />}
<StepChip s={s} />
</span>
))}
</div>
);
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{row(flow, true)}
{!mainOnly && addon.length > 0 && <div><Text size="xs" c="dimmed" mb={4}>{addon[0].group}</Text>{row(addon, false)}</div>}
{!mainOnly && cross.length > 0 && <div><Text size="xs" c="dimmed" mb={4}>Across the whole process</Text>{row(cross, false)}</div>}
</div>
);
}
export function StepLegend() {
return (
<Group gap={6} aria-label="legend">
{Object.entries(STEP_STATE).map(([k, v]) => <span key={k} className="fpt-pill" data-tone={v.tone}>{ICON[k]}{v.label}</span>)}
</Group>
);
}