Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | 1x 1x 1x 1x 614x 214x 205x 1x 26x 121x 5x 35x 4x 27x 3x 1x 960x 39x 39x 18x 18x 1199x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 9x 450x 18x 3x 3x 3x 3x 18x 9x 9x 9x 9x 9x 8x 80x 8x 88x 80x 232x 8x 8x 8x 8x 8x 8x 8x 2x 8x 8x 8x 1x 1x 1x 9x 9x 9x 9x 9x 18x 10x 10x 29x 10x 11x 18x 1x 1x 1x 1x 1x 1x 1x 18x 8x 8x 8x 18x 13x 13x 18x 18x 18x 18x 18x 18x 18x 72x 1x 54x 1x 1x 1x 3x 1x 3x 4x 1x 1x 12x 1x 3x 9x 3x 1x 4x | "use client";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
ExternalLink,
Maximize2,
Minimize2,
Pencil,
X,
ZoomIn,
ZoomOut,
} from "lucide-react";
import type {
DataGroup,
DataItem,
Timeline,
TimelineOptions,
} from "vis-timeline";
import type { DataSet } from "vis-data";
import "vis-timeline/styles/vis-timeline-graph2d.min.css";
import { LinkedText } from "@/components/docs/LinkedText";
import {
EPICS,
ITEMS,
LANES,
MILESTONES,
ROADMAP_PROJECT,
STATUS_LABEL,
epicStatus,
epicTaskId,
epicWindow,
issueUrl,
itemTaskId,
milestoneTaskId,
roadmapTargets,
type Milestone,
type Priority,
type RoadmapEpic,
type RoadmapItem,
type Status,
type Translate,
} from "@/lib/docs/roadmap";
import { translate } from "@/lib/i18n/translate";
import { useLanguage } from "@/lib/use-language";
const DAY = 24 * 60 * 60 * 1000;
/** moment's month names for the axis, loaded only for the language picked. */
const MOMENT_LOCALES: Record<string, () => Promise<unknown>> = {
de: () => import("moment/locale/de"),
fr: () => import("moment/locale/fr"),
nl: () => import("moment/locale/nl"),
es: () => import("moment/locale/es"),
};
const itemId = (i: RoadmapItem) => itemTaskId(i.issue);
const milestoneId = (m: Milestone) => milestoneTaskId(m.id);
const epicId = (e: RoadmapEpic) => epicTaskId(e.issue);
const PRIORITIES = ["P1", "P2", "P3"] as const;
type Selected =
| { kind: "item"; item: RoadmapItem }
| { kind: "epic"; epic: RoadmapEpic }
| { kind: "milestone"; milestone: Milestone };
function find(id: string | null): Selected | null {
if (!id) return null;
const item = ITEMS.find((i) => itemId(i) === id);
if (item) return { kind: "item", item };
const epic = EPICS.find((e) => epicId(e) === id);
if (epic) return { kind: "epic", epic };
const milestone = MILESTONES.find((m) => milestoneId(m) === id);
return milestone ? { kind: "milestone", milestone } : null;
}
const esc = (s: string) =>
s.replace(
/[&<>"]/g,
(c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]!,
);
/** What a filter leaves bright: the rest is dimmed, so the lanes keep their shape. */
function matches(
i: { issue: number; short: string; title: string; priority: Priority },
itemStatus: Status,
status: Status | "",
priority: Priority | "",
query: string,
tr: Translate,
): boolean {
const q = query.trim().toLowerCase();
return (
(!status || itemStatus === status) &&
(!priority || i.priority === priority) &&
(!q ||
`${i.issue} ${i.short} ${tr(i.short)} ${i.title} ${tr(i.title)}`
.toLowerCase()
.includes(q))
);
}
/**
* The roadmap as an interactive timeline (vis-timeline): a lane per driver,
* a hatched bar per epic at the top of its lane, a bar per dated issue, a
* diamond per date set by law or by a programme. Drag to
* pan, Ctrl or ⌘ and the wheel to zoom; a click shows the details with every
* source the note cites, a double click opens the issue or the source, and
* #i934 in the address selects #934. Full screen takes the whole block. The
* plan is edited in the GitHub Project (ROADMAP_PROJECT).
*/
export default function RoadmapTimeline() {
const lang = useLanguage();
const tr = useCallback<Translate>(
(text, vars) => translate(lang, "docsCommon", text, vars),
[lang],
);
const frameRef = useRef<HTMLDivElement>(null);
const chartRef = useRef<HTMLDivElement>(null);
const timelineRef = useRef<Timeline | null>(null);
const itemsRef = useRef<DataSet<DataItem> | null>(null);
const [selected, setSelected] = useState<string | null>(null);
const [status, setStatus] = useState<Status | "">("");
const [priority, setPriority] = useState<Priority | "">("");
const [query, setQuery] = useState("");
const [full, setFull] = useState(false);
const [copied, setCopied] = useState(false);
const tooltips = useMemo(
() =>
new Map(
roadmapTargets(lang === "en" ? undefined : tr).map((t) => [
t.taskId,
t.label,
]),
),
[lang, tr],
);
const select = useCallback((id: string | null) => {
setSelected(id);
setCopied(false);
const url = `${location.pathname}${location.search}${id ? `#${id}` : ""}`;
history.replaceState(null, "", url);
}, []);
// The chart is drawn again when the language changes; the selection stays.
useEffect(() => {
let cancelled = false;
let timeline: Timeline | null = null;
(async () => {
const [{ Timeline }, { DataSet }] = await Promise.all([
import("vis-timeline/peer"),
import("vis-data/peer"),
// The axis names its months in the page's language.
lang !== "en" ? MOMENT_LOCALES[lang]?.() : undefined,
]);
if (cancelled || !chartRef.current) return;
const groups = new DataSet<DataGroup>(
LANES.map((l, order) => ({
id: l.id,
order,
content: `<div class="rt-lane"><b>${esc(tr(l.label))}</b></div>`,
})),
);
const rows: DataItem[] = [
...MILESTONES.map((m, order) => ({
id: milestoneId(m),
order,
group: m.lane,
start: m.date,
type: "point" as const,
className: "rt-milestone",
content: esc(tr(m.label)),
title: esc(tooltips.get(milestoneId(m)) ?? ""),
})),
...EPICS.map((e, order) => ({
id: epicId(e),
order: 50 + order,
group: e.lane,
...epicWindow(e),
type: "range" as const,
className: `rt-epic rt-${epicStatus(e)}`,
content: `<span class="rt-prio rt-${e.priority}">${
e.priority
}</span>${esc(tr("Epic"))} ${e.issue} ${esc(tr(e.short))}`,
title: esc(tooltips.get(epicId(e)) ?? ""),
})),
...ITEMS.map((i, order) => ({
id: itemId(i),
order: 100 + order,
group: i.lane,
start: i.start,
end: i.end,
type: "range" as const,
className: `rt-${i.status}`,
content: `<span class="rt-prio rt-${i.priority}">${
i.priority
}</span>${i.issue} ${esc(tr(i.short))}`,
title: esc(tooltips.get(itemId(i)) ?? ""),
})),
];
const items = new DataSet<DataItem>(rows);
const now = new Date();
const options: TimelineOptions = {
stack: true,
showCurrentTime: true,
zoomKey: "ctrlKey",
horizontalScroll: true,
verticalScroll: true,
height: "100%",
orientation: { axis: "both", item: "top" },
margin: { item: { horizontal: 4, vertical: 6 } },
min: "2026-01-01",
max: "2032-01-01",
zoomMin: 14 * DAY,
zoomMax: 6 * 365 * DAY,
start: new Date(now.getFullYear(), now.getMonth() - 2, 1),
end: new Date(now.getFullYear() + 2, now.getMonth(), 1),
tooltip: { followMouse: true, overflowMethod: "cap", delay: 250 },
groupOrder: "order",
order: (a: DataItem, b: DataItem) =>
Number((a as { order?: number }).order) -
Number((b as { order?: number }).order),
locale: lang,
xss: {
disabled: false,
filterOptions: {
whiteList: { span: ["class"], div: ["class"], b: [] },
},
},
};
timeline = new Timeline(chartRef.current, items, groups, options);
timelineRef.current = timeline;
itemsRef.current = items;
timeline.on("select", (p: { items: string[] }) =>
select(p.items[0] ?? null),
);
timeline.on("doubleClick", (p: { item: string | null }) => {
const s = find(p.item);
if (!s) return;
window.open(
s.kind === "item"
? issueUrl(s.item.issue)
: s.kind === "epic"
? issueUrl(s.epic.issue)
: s.milestone.href,
"_blank",
"noopener,noreferrer",
);
});
const fromHash = location.hash.slice(1);
if (find(fromHash)) {
timeline.setSelection([fromHash]);
timeline.focus(fromHash, { animation: false });
setSelected(fromHash);
}
})();
return () => {
cancelled = true;
timeline?.destroy();
timelineRef.current = null;
itemsRef.current = null;
};
}, [lang, tr, tooltips, select]);
// Filters dim the bars that do not match, and the diamonds while one is set.
useEffect(() => {
const filtered = Boolean(status || priority || query.trim());
itemsRef.current?.update([
...ITEMS.map((i) => ({
id: itemId(i),
className: `rt-${i.status}${
matches(i, i.status, status, priority, query, tr) ? "" : " rt-dim"
}`,
})),
...EPICS.map((e) => ({
id: epicId(e),
className: `rt-epic rt-${epicStatus(e)}${
matches(e, epicStatus(e), status, priority, query, tr)
? ""
: " rt-dim"
}`,
})),
...MILESTONES.map((m) => ({
id: milestoneId(m),
className: `rt-milestone${filtered ? " rt-dim" : ""}`,
})),
]);
}, [status, priority, query, tr, lang]);
// Full screen takes the whole block; where the browser refuses it (an
// embedded view), the block fills the window instead.
const toggleFull = useCallback(async () => {
const frame = frameRef.current;
Iif (!frame) return;
Iif (document.fullscreenElement) await document.exitFullscreen();
else Iif (full) setFull(false);
else {
try {
await frame.requestFullscreen();
} catch {
setFull(true);
}
}
}, [full]);
useEffect(() => {
const sync = () => setFull(Boolean(document.fullscreenElement));
document.addEventListener("fullscreenchange", sync);
return () => document.removeEventListener("fullscreenchange", sync);
}, []);
useEffect(() => {
const t = setTimeout(() => timelineRef.current?.redraw(), 50);
return () => clearTimeout(t);
}, [full, selected]);
const zoom = (by: number) =>
by > 0
? timelineRef.current?.zoomIn(0.4)
: timelineRef.current?.zoomOut(0.4);
const showYears = (years: number | "all") => {
const t = timelineRef.current;
if (!t) return;
if (years === "all") return t.fit();
const now = new Date();
const start = new Date(now.getFullYear(), now.getMonth() - 1, 1);
t.setWindow(
start,
new Date(start.getFullYear() + years, start.getMonth(), 1),
);
};
const onKey = (e: React.KeyboardEvent) => {
if ((e.target as HTMLElement).matches("input, select")) return;
if (e.key === "f") void toggleFull();
else if (e.key === "+" || e.key === "=") zoom(1);
else if (e.key === "-") zoom(-1);
else if (e.key === "Escape") {
if (full && !document.fullscreenElement) setFull(false);
else {
timelineRef.current?.setSelection([]);
select(null);
}
}
};
const shown = find(selected);
const button =
"inline-flex items-center gap-1 rounded-md border border-(--border-ui) px-2.5 py-1 text-xs hover:border-(--accent)";
const field =
"rounded-md border border-(--border-ui) bg-(--surface-card) px-2 py-1 text-xs";
return (
<div
ref={frameRef}
data-testid="roadmap-timeline"
className={`roadmap-timeline flex flex-col gap-2 bg-(--bg) ${
full ? "rt-full" : ""
}`}
onKeyDown={onKey}
>
<div
role="toolbar"
aria-label={tr("Roadmap controls")}
className="flex flex-wrap items-center gap-2"
>
<button
type="button"
className={button}
onClick={() => zoom(1)}
aria-label={tr("Zoom in")}
title={tr("Zoom in")}
>
<ZoomIn size={14} aria-hidden="true" />
</button>
<button
type="button"
className={button}
onClick={() => zoom(-1)}
aria-label={tr("Zoom out")}
title={tr("Zoom out")}
>
<ZoomOut size={14} aria-hidden="true" />
</button>
<button
type="button"
className={button}
onClick={() => timelineRef.current?.moveTo(new Date())}
>
{tr("Today")}
</button>
<button type="button" className={button} onClick={() => showYears(1)}>
{tr("1 year")}
</button>
<button type="button" className={button} onClick={() => showYears(3)}>
{tr("3 years")}
</button>
<button
type="button"
className={button}
onClick={() => showYears("all")}
>
{tr("To 2031")}
</button>
<select
className={field}
aria-label={tr("Filter by status")}
value={status}
onChange={(e) => setStatus(e.target.value as Status | "")}
>
<option value="">{tr("All statuses")}</option>
{(Object.keys(STATUS_LABEL) as Status[]).map((s) => (
<option key={s} value={s}>
{tr(STATUS_LABEL[s])}
</option>
))}
</select>
<select
className={field}
aria-label={tr("Filter by priority")}
value={priority}
onChange={(e) => setPriority(e.target.value as Priority | "")}
>
<option value="">{tr("All priorities")}</option>
{(["P1", "P2", "P3"] as const).map((p) => (
<option key={p}>{p}</option>
))}
</select>
<input
type="search"
className={`${field} w-48`}
placeholder={tr("Search an issue or a title")}
aria-label={tr("Search an issue or a title")}
value={query}
onChange={(e) => setQuery(e.target.value)}
/>
<span className="ml-auto flex flex-wrap gap-2">
<a
href={ROADMAP_PROJECT}
target="_blank"
rel="noopener noreferrer"
className={button}
>
<Pencil size={14} aria-hidden="true" />{" "}
{tr("Edit in the GitHub Project")}
</a>
<button
type="button"
className={button}
onClick={() => void toggleFull()}
aria-pressed={full}
>
{full ? (
<Minimize2 size={14} aria-hidden="true" />
) : (
<Maximize2 size={14} aria-hidden="true" />
)}{" "}
{full ? tr("Exit full screen") : tr("Full screen")}
</button>
</span>
</div>
<div className="rt-stage flex min-h-0 flex-1 gap-3">
<div
ref={chartRef}
className="rt-chart min-w-0 flex-1 overflow-hidden rounded-lg border border-(--border)"
role="region"
aria-label={tr("Roadmap timeline")}
/>
{shown && (
<aside
aria-live="polite"
data-testid="roadmap-detail"
className="rt-detail w-80 shrink-0 overflow-auto rounded-lg border border-(--border) bg-(--surface) p-4 text-sm"
>
<button
type="button"
className="float-right p-1 text-(--text-secondary) hover:text-(--text-primary)"
aria-label={tr("Close")}
onClick={() => {
timelineRef.current?.setSelection([]);
select(null);
}}
>
<X size={16} aria-hidden="true" />
</button>
{shown.kind === "item" ? (
<>
<p className="text-xs text-(--text-secondary)">
#{shown.item.issue} ·{" "}
{tr(LANES.find((l) => l.id === shown.item.lane)!.label)}
</p>
<p className="mt-1 mb-2 font-semibold text-(--text-primary)">
<LinkedText
area="docsCommon"
text={shown.item.title}
links={shown.item.links}
/>
</p>
<p className="mb-2 flex flex-wrap gap-1 text-xs">
<span className="rounded-full border border-(--border-ui) px-2">
{shown.item.priority}
</span>
<span className="rounded-full border border-(--border-ui) px-2">
{tr(STATUS_LABEL[shown.item.status])}
</span>
<span className="rounded-full border border-(--border-ui) px-2">
{tr("{start} to {end}", {
start: shown.item.start,
end: shown.item.end,
})}
</span>
</p>
<p className="text-(--text-secondary)">
<LinkedText
area="docsCommon"
text={shown.item.note}
links={shown.item.links}
/>
</p>
</>
) : shown.kind === "epic" ? (
<EpicDetail epic={shown.epic} tr={tr} />
) : (
<>
<p className="text-xs text-(--text-secondary)">
{tr("Milestone")} · {shown.milestone.date}
</p>
<p className="mt-1 mb-2 font-semibold text-(--text-primary)">
{tr(shown.milestone.label)}
</p>
<p className="text-(--text-secondary)">
{tr(shown.milestone.detail)}
</p>
</>
)}
<p className="mt-3 flex flex-wrap gap-2">
<a
href={
shown.kind === "item"
? issueUrl(shown.item.issue)
: shown.kind === "epic"
? issueUrl(shown.epic.issue)
: shown.milestone.href
}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1 rounded-md bg-(--accent) px-2.5 py-1 text-xs text-(--bg)"
>
{shown.kind === "item"
? tr("Open issue #{n}", { n: shown.item.issue })
: shown.kind === "epic"
? tr("Open epic #{n}", { n: shown.epic.issue })
: tr("Open the source")}{" "}
<ExternalLink size={12} aria-hidden="true" />
</a>
<button
type="button"
className={button}
onClick={() => {
void navigator.clipboard?.writeText(location.href);
setCopied(true);
}}
>
{copied ? tr("Copied") : tr("Copy link")}
</button>
</p>
</aside>
)}
</div>
<p className="text-center text-xs italic text-(--text-secondary)">
{tr(
"Drag to pan, Ctrl or ⌘ and the wheel to zoom. Click a bar or a diamond for its details; a double click opens its issue or source. The red line is today.",
)}
</p>
</div>
);
}
/** An epic in the detail panel: its window, its progress and its issues by
* priority, each a link; a click on one of the dated ones selects its bar. */
function EpicDetail({ epic, tr }: { epic: RoadmapEpic; tr: Translate }) {
const w = epicWindow(epic);
const open = PRIORITIES.flatMap((p) => epic.open[p]);
const lane = LANES.find((l) => l.id === epic.lane)!;
return (
<>
<p className="text-xs text-(--text-secondary)">
{tr("Epic")} #{epic.issue} · {tr(lane.label)}
</p>
<p className="mt-1 mb-2 font-semibold text-(--text-primary)">
{tr(epic.title)}
</p>
<p className="mb-2 flex flex-wrap gap-1 text-xs">
<span className="rounded-full border border-(--border-ui) px-2">
{epic.priority}
</span>
<span className="rounded-full border border-(--border-ui) px-2">
{tr("{done} of {total} done", {
done: epic.done.length,
total: open.length + epic.done.length,
})}
</span>
<span className="rounded-full border border-(--border-ui) px-2">
{tr("{start} to {end}", w)}
</span>
</p>
<p className="mb-2 text-(--text-secondary)">
<LinkedText area="docsCommon" text={epic.note} links={epic.links} />
</p>
<EpicIssues epic={epic} tr={tr} />
</>
);
}
/** An epic's issues by priority, each a link to GitHub; closed ones last. */
function EpicIssues({ epic, tr }: { epic: RoadmapEpic; tr: Translate }) {
const link = (n: number, done = false) => (
<a
key={n}
href={issueUrl(n)}
target="_blank"
rel="noopener noreferrer"
className={`text-(--accent) underline ${done ? "line-through" : ""}`}
>
#{n}
</a>
);
const rows = [
...PRIORITIES.filter((p) => epic.open[p].length).map((p) => ({
label: p,
links: epic.open[p].map((n) => link(n)),
})),
...(epic.done.length
? [{ label: tr("Done"), links: epic.done.map((n) => link(n, true)) }]
: []),
];
return (
<dl className="grid grid-cols-[auto_1fr] gap-x-2 gap-y-1 text-xs">
{rows.map((r) => (
<div key={r.label} className="contents">
<dt className="font-medium text-(--text-secondary)">{r.label}</dt>
<dd className="flex flex-wrap gap-x-2">{r.links}</dd>
</div>
))}
</dl>
);
}
|