Keep normalized View roots acyclic
This commit is contained in:
@@ -58,7 +58,10 @@ export function viewSurfaceCatalogueForModules(
|
|||||||
for (const surface of module.viewSurfaces ?? []) {
|
for (const surface of module.viewSurfaces ?? []) {
|
||||||
addSurface(surfaces, {
|
addSurface(surfaces, {
|
||||||
...surface,
|
...surface,
|
||||||
parentId: surface.parentId ?? rootId
|
parentId:
|
||||||
|
surface.id === rootId
|
||||||
|
? null
|
||||||
|
: surface.parentId ?? rootId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,6 +128,27 @@ assert(
|
|||||||
"view catalogue should derive route surfaces"
|
"view catalogue should derive route surfaces"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const serverNormalizedCatalogue = viewSurfaceCatalogueForModules([
|
||||||
|
{
|
||||||
|
...viewAwareFiles,
|
||||||
|
viewSurfaces: [
|
||||||
|
{
|
||||||
|
id: "files.module",
|
||||||
|
moduleId: "files",
|
||||||
|
kind: "module",
|
||||||
|
label: "Files",
|
||||||
|
parentId: null
|
||||||
|
},
|
||||||
|
...(viewAwareFiles.viewSurfaces ?? [])
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
assert(
|
||||||
|
serverNormalizedCatalogue.find((surface) => surface.id === "files.module")
|
||||||
|
?.parentId == null,
|
||||||
|
"server-normalized module roots must not become their own parent"
|
||||||
|
);
|
||||||
|
|
||||||
const filesView = {
|
const filesView = {
|
||||||
activeViewId: "view-files",
|
activeViewId: "view-files",
|
||||||
activeRevisionId: "revision-files",
|
activeRevisionId: "revision-files",
|
||||||
|
|||||||
Reference in New Issue
Block a user