Skip to content

Provide a helper for linking to another app's route by role #317

Description

@arbrandes

Description

Apps that link to each other's pages currently call getUrlByRouteRole and then hand-roll the same logic: substitute the :courseId param, test whether the result is an internal path or an external URL (a scheme regex), and pick between a react-router Link and a plain anchor with a legacy fallback URL.

This exact pattern is now duplicated verbatim in two apps: frontend-app-gradebook's "Back to Dashboard" link (openedx/frontend-app-gradebook#627) and frontend-app-instructor-dashboard's "View Gradebook" button (openedx/frontend-app-instructor-dashboard#245). Any app that cross-links by role will need the same boilerplate, and the copies will drift.

frontend-base should own this. Options include an isAbsoluteUrl helper plus param substitution, a getUrlByRouteRole variant that also reports whether the result is internal or external, or a RoleLink component that takes a role, params, and a fallback URL and renders the right element. Once available, both apps above should be migrated to it.

Provided by #320, released in 2.0.0-alpha.15, and adopted in:

Activity

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

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions