Skip to content

feat: resolve routes by role and link to them in the client - #320

Merged
arbrandes merged 1 commit into
openedx:mainfrom
arbrandes:arbrandes/role-links
Sep 22, 2026
Merged

arbrandes merged 1 commit into
openedx:mainfrom
arbrandes:arbrandes/role-links

Conversation

@arbrandes

@arbrandes arbrandes commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

LinkMenuItem rendered every variant as a plain anchor, so a header link whose role an installed app provides, such as Account once openedx/frontend-app-account#1470 lands, reloaded the whole shell instead of navigating within it; Logo did the same for the home role. Both now spread getLinkProps, which renders a react-router Link for a path in this site and a plain anchor otherwise, the way the Login and Register buttons have since #305. The helper moves out of the anonymous menu into runtime/routing, together with isInternalUrl and a new resolveRouteByRole(role, params) that returns the resolved url with isInternal. An app route's path has its params filled and a trailing splat dropped the way react-router's generatePath does, so an omitted optional param disappears and a missing required one throws; an external URL is returned as configured. This replaces the logic frontend-app-gradebook and frontend-app-instructor-dashboard each hand-rolled for their cross-app links. All three are exported from the runtime and documented in the migration how-to, which also had the export misspelled as getUrlForRouteRole.

The navLink variant keeps its active computation, and a link is still hidden when nothing provides its role. Tests cover the helpers and every LinkMenuItem variant navigating in the client for an app route and through an anchor for an external one; the Logo tests now render inside a router, as the component does in the shell.

Follow-ups: migrate the two apps above to resolveRouteByRole (the copies came in with openedx/frontend-app-gradebook#627 and openedx/frontend-app-instructor-dashboard#246), and #318 for a pending indicator, now that header links soft-navigate into lazily loaded apps.

Closes #317. Closes #319.

LLM usage notice

Built with assistance from Claude.

Closes openedx#317 and openedx#319.

Co-Authored-By: Claude <noreply@anthropic.com>
@arbrandes
arbrandes merged commit 83a1752 into openedx:main Sep 22, 2026
5 checks passed
@arbrandes
arbrandes deleted the arbrandes/role-links branch September 22, 2026 21:19
@openedx-semantic-release-bot

Copy link
Copy Markdown

🎉 This PR is included in version 2.0.0-alpha.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Header links to in-site routes trigger full page loads Provide a helper for linking to another app's route by role

2 participants