Skip to main content

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-ui setting: "angular" until feature parity is reached, then "react";
  • on demand, with the URL parameter ?ui=react or ?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.

ModulePathReact coverageDefault
search-engine/searchengineSearchReact
forum/forumMessages, topics under categories, rich editor, sharing, renamingReact
rbs/rbsDay, week and month planning across resources, bookings, moderation, management, availability, sharing, exportReact
calendar/calendarDay, week, month and list views, calendars, shared and external (ICS) calendars, events, sharingReact
pages/pagesSites and pages, search, folders, trash with restore, sharingReact
statistics/statsUsage dashboard: indicators, access by application, granularityReact
competences/competencesSkill frameworks, skill tree, grade report, assessments, grade entryReact
cahier-de-textes/diaryCalendar view of homework and sessions, types, sessions and their publication, progressionsOpt-in
vie-scolaire/viescolaireReference data, periods, services, groupings, exclusions, learner notes, photo roster, bridgesOpt-in
edt/edtTimetable grid, opening on the member's own timetable; lesson creationOpt-in
presences/presencesFull dashboard, attendance register, absences, regularization, exemptions, settingsOpt-in
incidents/incidentsIncidents (search, CSV export, entry, mark as handled), sanctionsOpt-in
massmailing/massmailingBulk mailing (types, thresholds, anomalies), historyOpt-in
statistics-presences/statistics-presencesGlobal indicator: counters and a table of learners by typeOpt-in
community/communityCommunities (management, search, detail, members), sharing directoryOpt-in
timeline-generator/timelinegeneratorTimelines (search), events, sharingOpt-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 keySeparator and nsSeparator, and load the module's translations from /<module>/i18n.
  • XSRF. On some modules, POST, PUT and DELETE require the X-XSRF-TOKEN header, set to the value of the XSRF-TOKEN cookie.
  • 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.