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:
Description
Apps that link to each other's pages currently call
getUrlByRouteRoleand then hand-roll the same logic: substitute the:courseIdparam, test whether the result is an internal path or an external URL (a scheme regex), and pick between a react-routerLinkand 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
isAbsoluteUrlhelper plus param substitution, agetUrlByRouteRolevariant that also reports whether the result is internal or external, or aRoleLinkcomponent 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: