swarm-ui: the moved tabs' redirects come from one table, with tests
The four tab moves each hand-wrote a redirect route. They are one table now, MOVED_ROUTES, and movedHref says where an old address goes with its query kept; /builds?run= still lands on the build's card. The builds page's own redirect helper is gone.
This commit is contained in:
parent
f55f0973eb
commit
c28ca7aab5
1 changed files with 58 additions and 35 deletions
|
|
@ -27,3 +27,22 @@ export function visibleNavItems<T extends { href: string }>(
|
|||
if (!hideDeveloper) return items;
|
||||
return items.filter((item) => !DEVELOPER_ROUTES.includes(item.href));
|
||||
}
|
||||
|
||||
// Tabs that were folded into another one. Each old address redirects to its
|
||||
// new tab, so a bookmark or a link made before the move still lands. The
|
||||
// builds page's `?run=` query rides along, which a swarm-builder commit
|
||||
// status link relies on.
|
||||
export const MOVED_ROUTES: Readonly<Record<string, string>> = {
|
||||
"/alerts": "/reports",
|
||||
"/issues": "/reports",
|
||||
"/builds": "/jobs",
|
||||
"/review": "/jobs",
|
||||
"/schedules": "/messages",
|
||||
};
|
||||
|
||||
/** Where an old address goes, keeping its query; `null` for any other path. */
|
||||
export function movedHref(path: string, search: string): string | null {
|
||||
const to = MOVED_ROUTES[path];
|
||||
if (to === undefined) return null;
|
||||
return search === "" ? to : `${to}?${search}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue