Registry: let an add-on add routes under another add-on's layout
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- developer-experience, frontend
Research direction
Start by reading the route registration and generation code that produces .plone/registry.routes.json, then compare it with the layout route in packages/publicui/index.ts. Work out how parent ids, load order, and missing-parent behavior should fit the registry; done means add-ons can register child routes by parent id without depending on configuration order, with the missing-parent behavior documented or reported clearly.
Written by the indexing model from the issue text.
Description
Summary
An add-on can register a route at the top of the tree, but it cannot add one under a layout another add-on registered. A page registered with registerRoute renders without the site's frame: no header, no navigation, no user tools, so no way back. To get the frame, a page has to be a child of @plone/publicui's layout route (packages/publicui/index.ts), and the registry has no way to add one.
The use case
pas.plugins.identity, ported to Aurora in collective/pas-plugins-identity#132, adds signed-in pages: /identities (sign-in methods), /applications (authorized OAuth applications), /confirm-email, /complete-profile and /oauth-consent.
They belong inside the site's frame, beside publicui's own search page. They are reached from links in the header's authenticatedTools slot, and the header is how the user gets back.
The add-on finds publicui's layout entry by its file and pushes its routes into its children:
// pas.plugins.identity, frontend/packages/aurora-identity/lib/routes.ts
export function addRouteUnder(routes, layoutFile, route): boolean {
for (const entry of routes) {
if (entry.type === 'layout' && entry.file === layoutFile) {
entry.children.push(route);
return true;
}
if ('children' in entry && entry.children) {
if (addRouteUnder(entry.children, layoutFile, route)) return true;
}
}
return false;
}
addRouteUnder(config.routes, '@plone/publicui/routes/index.tsx', IDENTITIES_ROUTE);
(source)
It falls back to registerRoute at the top when publicui is not there.
The same problems as replacing a route:
- It depends on another package's file path.
- It depends on that package being configured first.
- It is a mutation of the registry's own array that nothing records.
What it depends on in React Router. The page's path (identities) is static, so React Router ranks it above publicui's * catch-all. Without that, the order of children would matter, and the add-on would have to insert before the catch-all.
Proposal
Let registerRoute name a parent:
config.registerRoute({
parent: 'publicui-layout', // the layout route's options.id
type: 'route',
path: 'identities',
file: '@plone-collective/aurora-identity/routes/identities.tsx',
options: { id: 'identity-identities' },
});
The pieces it needs:
- Stable, documented ids for the layouts add-ons are expected to extend: publicui's site layout and cmsui's layout at least.
- Load order handled by the registry. Children are attached when
.plone/registry.routes.jsonis generated, after every add-on has been configured, so registration order does not matter. - A clear error when the named parent does not exist. Or a documented fallback to the top level, which is what an add-on that should work with or without publicui wants.
An alternative is a well-known slot of routes in the site layout, but routes registered by id compose better with route replacement (plone/aurora#224).
Related
- plone/aurora#224: replacing a registered route.
- plone/aurora#226: add-on expansions of the content request.
- plone/aurora#223: app-wide toasts.
- plone/aurora#221:
@plone/clientendpoints for add-ons.
- Dominant language
- JavaScript
- Stars
- 10
- Forks
- 9
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 54
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from plone/aurora
-
01 type: bug 41 lvl: easy
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
Edit content TabList: selected tab's icon/label are hidden by its own selection indicator - a11yOpen01 type: bug 99 tag: UX Accessibility
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 2 days
-
01 type: bug 30 needs: triage
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 2 days
-
01 type: bug 99 tag: UX Accessibility
Difficulty 1/5 Under an hour Newbie friendliness 76/100
Maintainers usually reply within 2 days
-
01 type: bug 30 needs: triage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 2 days
Similar issues
-
accessibility bug dark-mode dashboards
Difficulty 1/5 Under an hour Newbie friendliness 84/100
quarto-dev/quarto-cli#15447 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
521xueweihan/HelloGitHub#4655 ·
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount duePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
bug CRIT-3
Difficulty 1/5 Under an hour Newbie friendliness 70/100
NASA-AMMOS/anms#426 ·