Migrating AngularJS modules to React
The interfaces of older modules are being moved from AngularJS to React. The migration is progressive and non-breaking: the Java server is unchanged, with the same REST routes, and both interfaces coexist during the transition.
Principle
Each migrated module exposes a React interface (Vite, React 18, @open-ent/react,
@open-ent/bootstrap, @open-ent/client, @tanstack/react-query, react-i18next) mounted
under the existing server route of the module. The controller chooses which view to render:
- by default, the interface set by the
frontend-uisetting:"angular"until feature parity is reached, then"react"; - on demand, with the URL parameter
?ui=reactor?ui=angular. The fallback is always available.
final String uiParam = request.params().get("ui");
final String frontendUi = "react".equals(config.getString("frontend-ui", "angular")) ? "react" : "angular";
final String ui = ("react".equals(uiParam) || "angular".equals(uiParam)) ? uiParam : frontendUi;
if ("react".equals(ui)) {
renderView(request, new JsonObject(), "<module>-react.html", null);
} else {
renderView(request); // AngularJS view
}
The React bundle is served at /<module>/public/index.js. The AngularJS bundle, usually
/<module>/public/dist/application.js, stays untouched. Rebuilding the server does not touch the
interface, and the reverse is true.
Incremental migration and switching the default
A module is migrated in increments, one set of features at a time. Until parity with the
AngularJS interface is reached, React is opt-in (?ui=react) and members are served
AngularJS. Once parity is reached, the default switches to React (frontend-ui: "react"), and
?ui=angular remains as a fallback.
Status
Sixteen modules have a React interface.
| Module | Path | React coverage | Default |
|---|---|---|---|
search-engine | /searchengine | Search | React |
forum | /forum | Messages, topics under categories, rich editor, sharing, renaming | React |
rbs | /rbs | Day, week and month planning across resources, bookings, moderation, management, availability, sharing, export | React |
calendar | /calendar | Day, week, month and list views, calendars, shared and external (ICS) calendars, events, sharing | React |
pages | /pages | Sites and pages, search, folders, trash with restore, sharing | React |
statistics | /stats | Usage dashboard: indicators, access by application, granularity | React |
competences | /competences | Skill frameworks, skill tree, grade report, assessments, grade entry | React |
cahier-de-textes | /diary | Calendar view of homework and sessions, types, sessions and their publication, progressions | Opt-in |
vie-scolaire | /viescolaire | Reference data, periods, services, groupings, exclusions, learner notes, photo roster, bridges | Opt-in |
edt | /edt | Timetable grid, opening on the member's own timetable; lesson creation | Opt-in |
presences | /presences | Full dashboard, attendance register, absences, regularization, exemptions, settings | Opt-in |
incidents | /incidents | Incidents (search, CSV export, entry, mark as handled), sanctions | Opt-in |
massmailing | /massmailing | Bulk mailing (types, thresholds, anomalies), history | Opt-in |
statistics-presences | /statistics-presences | Global indicator: counters and a table of learners by type | Opt-in |
community | /community | Communities (management, search, detail, members), sharing directory | Opt-in |
timeline-generator | /timelinegenerator | Timelines (search), events, sharing | Opt-in |
Opt-in modules switch to React by default as they are consolidated, with ?ui=angular kept as a
fallback.
Good practice
- Hash router (
createHashRouter). The module is served by a single server route, so navigation happens in the fragment (#/...). This avoids a 404 when a sub-route is refreshed. - Flat translation keys. Platform keys contain dots, so disable
keySeparatorandnsSeparator, and load the module's translations from/<module>/i18n. - XSRF. On some modules,
POST,PUTandDELETErequire theX-XSRF-TOKENheader, set to the value of theXSRF-TOKENcookie. - Stable, distinct bundle names. Keep fixed file names, since the server view references them, and keep them distinct from the AngularJS bundle to avoid any collision.