Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 78 additions & 26 deletions projects/compass.web/packages/pages/src/BlamesScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ function Tiles({ reports }: { readonly reports: readonly DocumentSummary[] }): R
<dl className="grid grid-cols-2 gap-2 sm:grid-cols-4" data-testid="blames-tiles">
{tiles.map((tile) => (
<div key={tile.key} className="rounded-chip border border-line px-3 py-2">
<dd className="text-2xl tabular-nums text-ink" data-testid={`blames-tile-${tile.key}`}>
<dd
className="text-2xl tabular-nums text-ink"
data-testid={`blames-tile-${tile.key}`}
>
{tile.value}
</dd>
<dt className="text-xs text-ink-faint">{t(`blames.tiles.${tile.key}`)}</dt>
Expand All @@ -67,15 +70,25 @@ function Tiles({ reports }: { readonly reports: readonly DocumentSummary[] }): R
);
}

function Bars({ entries }: { readonly entries: readonly (readonly [string, number])[] }): ReactNode {
function Bars({
entries,
}: {
readonly entries: readonly (readonly [string, number])[];
}): ReactNode {
const top = Math.max(...entries.map(([, n]) => n), 1);
return (
<ul className="grid gap-1.5">
{entries.map(([label, n]) => (
<li key={label} className="grid grid-cols-[7rem_minmax(0,1fr)_2rem] items-center gap-2 text-xs">
<li
key={label}
className="grid grid-cols-[7rem_minmax(0,1fr)_2rem] items-center gap-2 text-xs"
>
<span className="truncate text-ink-muted">{label}</span>
<span className="h-2 overflow-hidden rounded-chip bg-bg-raised">
<span className="block h-full rounded-chip bg-accent" style={{ width: `${(n / top) * 100}%` }} />
<span
className="block h-full rounded-chip bg-accent"
style={{ width: `${(n / top) * 100}%` }}
/>
</span>
<span className="text-right tabular-nums text-ink">{n}</span>
</li>
Expand All @@ -98,7 +111,13 @@ export function BlamesScreen({ environment }: { readonly environment: string }):
const wanted = params.get('view') ?? 'sprint';
const view: View = (VIEWS as readonly string[]).includes(wanted) ? (wanted as View) : 'sprint';
const reports = useQuery({
queryKey: ['compass', inputs.httpBase, 'documents', environment, { type, state, limit: LIMIT }],
queryKey: [
'compass',
inputs.httpBase,
'documents',
environment,
{ type, state, limit: LIMIT },
],
queryFn: ({ signal }) =>
client.documents(
{
Expand All @@ -117,7 +136,8 @@ export function BlamesScreen({ environment }: { readonly environment: string }):
});
const all = reports.data?.documents ?? [];
const open = all.filter((d) => !closed(d.state));
const visible = state === 'all' ? all : state === 'addressed' ? all.filter((d) => closed(d.state)) : open;
const visible =
state === 'all' ? all : state === 'addressed' ? all.filter((d) => closed(d.state)) : open;
const href = (next: { readonly state?: string; readonly view?: string }) => {
const out = new URLSearchParams();
out.set('type', type);
Expand All @@ -139,29 +159,38 @@ export function BlamesScreen({ environment }: { readonly environment: string }):
list.push(d);
sprints.set(d.sprint, list);
}
const ordered = [...sprints.entries()].sort((a, b) => b[0].localeCompare(a[0], 'en', { numeric: true }));
const ordered = [...sprints.entries()].sort((a, b) =>
b[0].localeCompare(a[0], 'en', { numeric: true }),
);
const owners = new Map<string, DocumentSummary[]>();
for (const d of [...open].sort((a, b) => (ageOf(b) ?? 0) - (ageOf(a) ?? 0))) {
const owner = d.owner === '' ? t('blames.noOwner') : d.owner;
const list = owners.get(owner) ?? [];
list.push(d);
owners.set(owner, list);
}
const ownerLoad = [...all.reduce((m, d) => {
const key = d.owner === '' ? t('blames.noOwner') : d.owner;
m.set(key, (m.get(key) ?? 0) + 1);
return m;
}, new Map<string, number>())].sort((a, b) => b[1] - a[1]);
const filed = [...all.reduce((m, d) => {
const day = d.created === '' ? '?' : d.created;
m.set(day, (m.get(day) ?? 0) + 1);
return m;
}, new Map<string, number>())].sort((a, b) => a[0].localeCompare(b[0]));
const ownerLoad = [
...all.reduce((m, d) => {
const key = d.owner === '' ? t('blames.noOwner') : d.owner;
m.set(key, (m.get(key) ?? 0) + 1);
return m;
}, new Map<string, number>()),
].sort((a, b) => b[1] - a[1]);
const filed = [
...all.reduce((m, d) => {
const day = d.created === '' ? '?' : d.created;
m.set(day, (m.get(day) ?? 0) + 1);
return m;
}, new Map<string, number>()),
].sort((a, b) => a[0].localeCompare(b[0]));

return (
<div className="grid max-w-240 gap-5">
<Tiles reports={all} />
<nav className="flex flex-wrap gap-1 border-b border-line text-sm" aria-label={t('blames.views.label')}>
<nav
className="flex flex-wrap gap-1 border-b border-line text-sm"
aria-label={t('blames.views.label')}
>
{VIEWS.map((key) => (
<Link
key={key}
Expand All @@ -181,7 +210,11 @@ export function BlamesScreen({ environment }: { readonly environment: string }):

{view === 'sprint' ? (
<div className="grid gap-3">
<div className="flex flex-wrap items-center gap-2" role="group" aria-label={t('blames.filter')}>
<div
className="flex flex-wrap items-center gap-2"
role="group"
aria-label={t('blames.filter')}
>
{(['open', 'addressed', 'all'] as const).map((key) => (
<Link
key={key}
Expand All @@ -208,14 +241,25 @@ export function BlamesScreen({ environment }: { readonly environment: string }):
) : (
<div className="grid gap-5" data-testid="blames">
{ordered.map(([sprint, rows]) => (
<section key={sprint === '' ? 'none' : sprint} className="grid gap-1.5">
<section
key={sprint === '' ? 'none' : sprint}
className="grid gap-1.5"
>
<h2 className="flex items-baseline gap-2 text-xs font-medium uppercase tracking-wide text-ink-faint">
{sprint === '' ? t('blames.noSprint') : sprint.replace(/_/g, ' ')}
<span className="normal-case text-ink-faint">{rows.length}</span>
{sprint === ''
? t('blames.noSprint')
: sprint.replace(/_/g, ' ')}
<span className="normal-case text-ink-faint">
{rows.length}
</span>
</h2>
<ul className="grid divide-y divide-line-subtle">
{rows.map((d) => (
<ReportRow key={d.path} environment={environment} report={d} />
<ReportRow
key={d.path}
environment={environment}
report={d}
/>
))}
</ul>
</section>
Expand All @@ -234,11 +278,17 @@ export function BlamesScreen({ environment }: { readonly environment: string }):
<section key={owner} className="grid gap-1.5">
<h2 className="flex items-baseline gap-2 text-xs font-medium uppercase tracking-wide text-ink-faint">
{owner}
<span className="normal-case text-ink-faint">{rows.length}</span>
<span className="normal-case text-ink-faint">
{rows.length}
</span>
</h2>
<ul className="grid divide-y divide-line-subtle">
{rows.map((d) => (
<ReportRow key={d.path} environment={environment} report={d} />
<ReportRow
key={d.path}
environment={environment}
report={d}
/>
))}
</ul>
</section>
Expand Down Expand Up @@ -319,7 +369,9 @@ function ReportRow({
{t('blames.foundBy', { name: d.found_by })}
</span>
)}
{age === null ? null : <span className="text-ink-faint">{t('blames.age', { days: age })}</span>}
{age === null ? null : (
<span className="text-ink-faint">{t('blames.age', { days: age })}</span>
)}
<span
className={d.answered ? 'text-accent' : 'text-ink-faint'}
data-testid="blames-answered"
Expand Down
14 changes: 10 additions & 4 deletions projects/compass.web/packages/pages/src/blames.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import { compassRoutes } from './pages.js';
const inputs: CompassInputs = {
httpBase: '/',
linkTo: (place) =>
'document' in place ? `/${place.environment}/docs/${place.document}` : `/${place.environment}/${place.screen ?? ''}`,
'document' in place
? `/${place.environment}/docs/${place.document}`
: `/${place.environment}/${place.screen ?? ''}`,
onDenied: () => undefined,
};

Expand All @@ -57,9 +59,11 @@ const report = (id: string, title: string, state: string, sprint: string, path:
});

const documents = {
documents: [report('B1', 'Blame: the first', 'STARTED', 'sprint_31', 'doc/sprint_31/blame/a.org'),
documents: [
report('B1', 'Blame: the first', 'STARTED', 'sprint_31', 'doc/sprint_31/blame/a.org'),
report('B2', 'Blame: the second', 'DONE', 'sprint_31', 'doc/sprint_31/blame/b.org'),
report('B0', 'Blame: the earlier', 'STARTED', 'sprint_30', 'doc/sprint_30/blame/c.org')],
report('B0', 'Blame: the earlier', 'STARTED', 'sprint_30', 'doc/sprint_30/blame/c.org'),
],
total: 3,
synced_at: '2026-12-05T09:00:00Z',
};
Expand Down Expand Up @@ -88,7 +92,9 @@ describe('the blames screen', () => {
expect(html).toMatch(/data-testid="blames-tile-total"[^>]*>\s*3\s*</);
expect(html).toMatch(/data-testid="blames-tile-open"[^>]*>\s*2\s*</);
expect(html).toMatch(/data-testid="blames-tile-addressed"[^>]*>\s*1\s*</);
expect(html).toContain('href="/compass/blames?type=blame_report&amp;state=all&amp;view=outstanding"');
expect(html).toContain(
'href="/compass/blames?type=blame_report&amp;state=all&amp;view=outstanding"',
);
expect(html).toContain('view=analysis');
});

Expand Down
20 changes: 16 additions & 4 deletions projects/compass.web/packages/pages/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,24 @@ export const en: Catalogue = {
filter: { all: 'All', open: 'Open', addressed: 'Addressed' },
empty: 'No report matches this filter.',
noSprint: 'No sprint',
views: { label: 'Views', sprint: 'By sprint', outstanding: 'Outstanding', analysis: 'Analysis' },
tiles: { total: 'reports', open: 'still open', addressed: 'addressed', unowned: 'with no owner named' },
views: {
label: 'Views',
sprint: 'By sprint',
outstanding: 'Outstanding',
analysis: 'Analysis',
},
tiles: {
total: 'reports',
open: 'still open',
addressed: 'addressed',
unowned: 'with no owner named',
},
outstanding: { empty: 'Nothing outstanding.' },
analysis: { owners: 'Who owes what', states: 'Open and addressed', filed: 'Filed by day' },
owner: 'owner {owner}',
age: '{days}d old',
noOwner: 'no owner', foundBy: 'found by {name}',
noOwner: 'no owner',
foundBy: 'found by {name}',
answered: 'answered',
awaiting: 'no response',
},
Expand Down Expand Up @@ -560,7 +571,8 @@ export const en: Catalogue = {
title: 'Documents',
task: 'Read a document in the browser',
what: 'the document view: its metadata, its org rendered in the browser, its links, anchors, images and backlinks',
}, blames: {
},
blames: {
title: 'Blames',
task: 'Serve the open blame reports',
what: 'the reports a project keeps open, by sprint, the open ones first, each opening in the document view',
Expand Down
30 changes: 23 additions & 7 deletions projects/compass.web/packages/pages/src/i18n/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,33 @@ const fr: Catalogue = {
},
blames: {
loading: 'Lecture des rapports…',
failed: 'compass.http n\'a pas répondu aux rapports : {reason}',
failed: "compass.http n'a pas répondu aux rapports : {reason}",
count: { one: '{count} rapport', other: '{count} rapports' },
filter: { all: 'Tous', open: 'Ouverts', addressed: 'Traités' },
empty: 'Aucun rapport ne correspond à ce filtre.',
noSprint: 'Sans sprint',
views: { label: 'Vues', sprint: 'Par sprint', outstanding: 'En cours', analysis: 'Analyse' },
tiles: { total: 'rapports', open: 'encore ouverts', addressed: 'traités', unowned: 'sans propriétaire' },
views: {
label: 'Vues',
sprint: 'Par sprint',
outstanding: 'En cours',
analysis: 'Analyse',
},
tiles: {
total: 'rapports',
open: 'encore ouverts',
addressed: 'traités',
unowned: 'sans propriétaire',
},
outstanding: { empty: 'Rien en cours.' },
analysis: { owners: 'Qui doit quoi', states: 'Ouverts et traités', filed: 'Déposés par jour' },
analysis: {
owners: 'Qui doit quoi',
states: 'Ouverts et traités',
filed: 'Déposés par jour',
},
owner: 'propriétaire {owner}',
age: '{days} j',
noOwner: 'sans propriétaire', foundBy: 'trouvé par {name}',
noOwner: 'sans propriétaire',
foundBy: 'trouvé par {name}',
answered: 'répondu',
awaiting: 'sans réponse',
},
Expand Down Expand Up @@ -574,10 +589,11 @@ const fr: Catalogue = {
title: 'Documents',
task: 'Read a document in the browser',
what: 'la vue du document : ses métadonnées, son org rendu dans le navigateur, ses liens, ancres, images et rétroliens',
}, blames: {
},
blames: {
title: 'Blâmes',
task: 'Serve the open blame reports',
what: 'les rapports qu\'un projet garde ouverts, par sprint, les ouverts d\'abord, chacun s\'ouvrant dans la vue document',
what: "les rapports qu'un projet garde ouverts, par sprint, les ouverts d'abord, chacun s'ouvrant dans la vue document",
},
sprint: {
title: 'Sprint',
Expand Down
26 changes: 21 additions & 5 deletions projects/compass.web/packages/pages/src/i18n/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,28 @@ const pt: Catalogue = {
filter: { all: 'Todos', open: 'Abertos', addressed: 'Tratados' },
empty: 'Nenhum relatório corresponde a este filtro.',
noSprint: 'Sem sprint',
views: { label: 'Vistas', sprint: 'Por sprint', outstanding: 'Em curso', analysis: 'Análise' },
tiles: { total: 'relatórios', open: 'ainda abertos', addressed: 'tratados', unowned: 'sem dono' },
views: {
label: 'Vistas',
sprint: 'Por sprint',
outstanding: 'Em curso',
analysis: 'Análise',
},
tiles: {
total: 'relatórios',
open: 'ainda abertos',
addressed: 'tratados',
unowned: 'sem dono',
},
outstanding: { empty: 'Nada em curso.' },
analysis: { owners: 'Quem deve o quê', states: 'Abertos e tratados', filed: 'Registados por dia' },
analysis: {
owners: 'Quem deve o quê',
states: 'Abertos e tratados',
filed: 'Registados por dia',
},
owner: 'dono {owner}',
age: '{days} d',
noOwner: 'sem dono', foundBy: 'encontrado por {name}',
noOwner: 'sem dono',
foundBy: 'encontrado por {name}',
answered: 'respondido',
awaiting: 'sem resposta',
},
Expand Down Expand Up @@ -569,7 +584,8 @@ const pt: Catalogue = {
title: 'Documentos',
task: 'Read a document in the browser',
what: 'a vista do documento: os seus metadados, o seu org desenhado no browser, as suas ligações, âncoras, imagens e ligações de entrada',
}, blames: {
},
blames: {
title: 'Acusações',
task: 'Serve the open blame reports',
what: 'os relatórios que um projeto mantém abertos, por sprint, os abertos primeiro, cada um a abrir na vista do documento',
Expand Down
10 changes: 9 additions & 1 deletion projects/compass.web/packages/pages/src/screens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ import { TestingScreen } from './TestingScreen.js';
* table; a screen's catalogue entries are `screens.<key>.title`, `.task` (the
* task that builds it) and `.what` (what that task builds).
*/
export const SCREEN_KEYS = ['search', 'documents', 'blames', 'sprint', 'testing', 'graph', 'agent'] as const;
export const SCREEN_KEYS = [
'search',
'documents',
'blames',
'sprint',
'testing',
'graph',
'agent',
] as const;

export type ScreenKey = (typeof SCREEN_KEYS)[number];

Expand Down
4 changes: 2 additions & 2 deletions projects/compass.web/packages/web/e2e/shell.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test('compass serve opens the shell with its environments, its logo and no sign-
expect(await served.text()).toContain('<title id="title">compass-ng</title>');

const menu = page.getByRole('navigation', { name: 'Main' });
await expect(menu.getByRole('link')).toHaveCount(6);
await expect(menu.getByRole('link')).toHaveCount(7);
await expect(page.getByTestId('screen-environment')).toHaveText(`Environment ${latest}`);
if (screenshots !== undefined) {
await page.screenshot({ path: join(screenshots, 'shell_search.png') });
Expand Down Expand Up @@ -106,7 +106,7 @@ test('the shell fits a phone, with every screen still in the menu', async ({ pag
]);
expect(scrolled).toBe(viewport);
const menu = page.getByRole('navigation', { name: 'Main' });
await expect(menu.getByRole('link')).toHaveCount(6);
await expect(menu.getByRole('link')).toHaveCount(7);
await menu.getByRole('link', { name: /Agent/ }).click();
await expect(page.getByRole('heading', { level: 1 })).toHaveText('Agent');
});
Expand Down
Loading