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
14 changes: 10 additions & 4 deletions pm-stack/aggregator/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1859,6 +1859,7 @@ function roadmapCard(
forecasts?: Map<RefKey, ForecastContract[]>,
spend?: SpendCardsView | null,
epicRollups?: Map<string, EpicRollup>,
showRowNotes = false,
): string {
const refs = allRefs([row]);
const refBadges = refs
Expand All @@ -1870,6 +1871,11 @@ function roadmapCard(
const grist = row.gristUrl ? ` <a class="badge" href="${esc(row.gristUrl)}">Grist ↗</a>` : "";
const repoFile = row.fileUrl ? ` <a class="badge" href="${esc(row.fileUrl)}">Repo file ↗</a>` : "";
const expansion = drill ? roadmapDrilldown(drill, row, forecasts, spend) : "";
// The program timeline has no drill map; keep its Notes visible without
// duplicating the same text when a card already has a drilldown.
const rowNotes = showRowNotes && !drill && row.notes.trim()
? `<p class="notes">${esc(row.notes)}</p>`
: "";
const epicRollup = epicRollups?.get(row.subject);
const rollupHtml = epicRollup ? epicRollupHtml(epicRollup) : "";
const notes = annotations?.get(row.subject) ?? [];
Expand Down Expand Up @@ -1897,7 +1903,7 @@ function roadmapCard(
}
}
}
return `<div class="card"><a href="/item/${encodeURIComponent(row.subject)}">${esc(row.title)}</a>${cmt}<br><span class="badge ${esc(row.status.toLowerCase().replace(/[^a-z]/g, "-"))}">${esc(row.status)}</span> <span class="muted">${esc(row.area)} · ${esc(row.horizon)}</span>${horizonWarning}${statusClash}${refBadges}${grist}${repoFile}${rollupHtml}${annotationHtml}${expansion}${briefPanels}</div>`;
return `<div class="card"><a href="/item/${encodeURIComponent(row.subject)}">${esc(row.title)}</a>${cmt}<br><span class="badge ${esc(row.status.toLowerCase().replace(/[^a-z]/g, "-"))}">${esc(row.status)}</span> <span class="muted">${esc(row.area)} · ${esc(row.horizon)}</span>${horizonWarning}${statusClash}${refBadges}${grist}${repoFile}${rollupHtml}${annotationHtml}${rowNotes}${expansion}${briefPanels}</div>`;
}

function roadmapAnnotationHtml(annotation: RoadmapAnnotation): string {
Expand All @@ -1913,7 +1919,7 @@ function timelineTable(
briefs?: Map<RefKey, ItemBrief>,
forecasts?: Map<RefKey, ForecastContract[]>,
spend?: SpendCardsView | null,
epicRollups?: Map<string, EpicRollup>,
options?: { epicRollups?: Map<string, EpicRollup>; showRowNotes?: boolean },
): string {
const head = `<tr><th scope="col">Theme</th>${tl.lanes.map((l) => `<th scope="col">${esc(l.label)}</th>`).join("")}</tr>`;
const body = tl.themes
Expand All @@ -1923,7 +1929,7 @@ function timelineTable(
const cells = tl.lanes
.map((lane) => {
const rs = tl.cells.get(theme)?.get(lane.key) ?? [];
return `<td class="tl-cell">${rs.map((r) => roadmapCard(r, items, counts, drill?.get(r.subject), annotations, briefs, forecasts, spend, epicRollups)).join("")}</td>`;
return `<td class="tl-cell">${rs.map((r) => roadmapCard(r, items, counts, drill?.get(r.subject), annotations, briefs, forecasts, spend, options?.epicRollups, options?.showRowNotes)).join("")}</td>`;
})
.join("");
return `<tr><th scope="row">${esc(theme)} <span class="muted theme-rollup">(${done}/${themeRows.length} done)</span></th>${cells}</tr>`;
Expand Down Expand Up @@ -7849,7 +7855,7 @@ export function renderProgramProject(
const rollup = epic ? rollups.get(epic.ref) : undefined;
if (rollup) rowRollups.set(row.subject, rollup);
}
roadmapHtml = `<p class="muted">${detail.roadmapRows.length} row${detail.roadmapRows.length === 1 ? "" : "s"} with area <code>${esc(config.roadmapArea)}</code> in Grist's Program roadmap. Timeline lanes and drill-downs use the shared roadmap renderer; epic rollups are per matched row.</p>${timelineTable(buildTimeline(detail.roadmapRows), items, undefined, undefined, undefined, undefined, undefined, undefined, rowRollups)}`;
roadmapHtml = `<p class="muted">${detail.roadmapRows.length} row${detail.roadmapRows.length === 1 ? "" : "s"} with area <code>${esc(config.roadmapArea)}</code> in Grist's Program roadmap. Timeline lanes and drill-downs use the shared roadmap renderer; epic rollups are per matched row.</p>${timelineTable(buildTimeline(detail.roadmapRows), items, undefined, undefined, undefined, undefined, undefined, undefined, { epicRollups: rowRollups, showRowNotes: true })}`;
}

const repoCardsHtml = detail.repoCards.length
Expand Down
28 changes: 27 additions & 1 deletion pm-stack/aggregator/test/program.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type ProjectRepoCard,
} from "../src/project-config.ts";
import { buildProgramData, buildProgramLive, PROGRAM, programRefs, TRACKED_REFS } from "../src/program.ts";
import { projectsBodyHtml, renderProgram, renderProgramProject } from "../src/render.ts";
import { projectsBodyHtml, renderProgram, renderProgramProject, renderRoadmap } from "../src/render.ts";
import { FIXTURE_ROADMAP, fixtureSource } from "../src/sources/fixtures.ts";

const PROV: Provenance = {
Expand Down Expand Up @@ -496,6 +496,32 @@ describe("project registry", () => {
// --- Per-project pages (#1121) --------------------------------------------------

describe("renderProgramProject", () => {
test("program timeline keeps escaped notes and reference text without changing the shared default (#12078)", () => {
const config = projectConfigById("pm-dashboard")!;
const base = FIXTURE_ROADMAP.find((row) => row.area === config.roadmapArea)!;
const notes = 'See https://github.com/example/widget/pull/42 & <legacy> "notes"';
const escaped = "See https://github.com/example/widget/pull/42 &amp; &lt;legacy&gt; &quot;notes&quot;";
const row = { ...base, notes, links: [] };
const blank = { ...row, id: 9001, subject: "grist:blank", title: "Blank notes row", notes: " " };
const other = { ...row, id: 9002, subject: "grist:other", area: "Other", notes: "Other area notes" };
const items = new Map();
const html = renderProgramProject(buildProjectDetail(config, items, [], [row, blank, other]), items, PROV);

// Oracle: the old project card showed Notes as escaped text, not
// parsed markup or a substitute link badge.
expect(html).toContain("Roadmap timeline by theme");
expect(html).toContain("Blank notes row");
expect(html).toContain('<p class="notes">' + escaped + '</p>');
expect(html.split('<p class="notes">')).toHaveLength(2);
expect(html).not.toContain(notes);
expect(html).not.toContain("Other area notes");
expect(renderRoadmap([row], items, PROV)).not.toContain(escaped);
const drill = new Map([[row.subject, { children: [] }]]);
const sharedHtml = renderRoadmap([row], items, PROV, "quarter", undefined, undefined, undefined, drill);
expect(sharedHtml).toContain('<p class="notes">' + escaped + '</p>');
expect(sharedHtml.split('<p class="notes">')).toHaveLength(2);
});

test("every configured project renders from fixtures, nulls stated honestly", async () => {
const src = fixtureSource();
const items = await src.items(allProjectRefs());
Expand Down