feat: library section and subsection page (#2032)

* Adds section and subsection library pages. 
* Refactors routing to support them and fix routing from collections page to other pages.
* Refactors library context to reliably set component, unit, and other container ids even when the url changes when user goes back in history rapidly.
This commit is contained in:
Navin Karkera
2025-06-04 17:32:29 +00:00
committed by GitHub
parent 99e11d3534
commit dd6780ff41
46 changed files with 1798 additions and 453 deletions

View File

@@ -4,8 +4,6 @@ import {
getLibraryId,
isLibraryKey,
isLibraryV1Key,
getContainerTypeFromId,
ContainerType,
} from './key-utils';
describe('component utils', () => {
@@ -14,6 +12,9 @@ describe('component utils', () => {
['lb:org:lib:html:id', 'html'],
['lb:OpenCraftX:ALPHA:html:571fe018-f3ce-45c9-8f53-5dafcb422fdd', 'html'],
['lb:Axim:beta:problem:571fe018-f3ce-45c9-8f53-5dafcb422fdd', 'problem'],
['lct:org:lib:unit:my-unit-9284e2', 'unit'],
['lct:org:lib:section:my-section-9284e2', 'section'],
['lct:org:lib:subsection:my-section-9284e2', 'subsection'],
]) {
it(`returns '${expected}' for usage key '${input}'`, () => {
expect(getBlockType(input)).toStrictEqual(expected);
@@ -99,16 +100,4 @@ describe('component utils', () => {
});
}
});
describe('getContainerTypeFromId', () => {
for (const [input, expected] of [
['lct:org:lib:unit:my-unit-9284e2', ContainerType.Unit],
['lct:OpenCraftX:ALPHA:my-unit-a3223f', undefined],
['', undefined],
]) {
it(`returns '${expected}' for container key '${input}'`, () => {
expect(getContainerTypeFromId(input!)).toStrictEqual(expected);
});
}
});
});