Skip to content

refactor: port the modules the outline tab shares to frontend-base - #2251

Merged
brian-smith-tcril merged 1 commit into
frontend-basefrom
bsmith/outline-shared-modules
Nov 18, 2026
Merged

brian-smith-tcril merged 1 commit into
frontend-basefrom
bsmith/outline-shared-modules

Conversation

@brian-smith-tcril

@brian-smith-tcril brian-smith-tcril commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The modules Learning's outline tab shares with other pages now live in the frontend-base package: the effort estimate (shared/effort-estimate/), the course start alert and its masquerade banner (alerts/course-start-alert/), and the account activation alert with the request it sends. No user-facing change: no route renders any of it until the outline tab ports in the next layer of this stack, and the legacy tree under src/ is untouched.

Part of #1905. Part of #2191. Stacked above #2249; the outline tab follows as the layer above this one.

Note

For reviewers: the ported files are added under frontend-base/src/ as new files, so this diff cannot show what changed from master. The port-diff script in #2234's description prints that diff, from frontend-base/manifest.tsv. Three of the ported files are identical to master's: course-start-alert/hooks.js, course-start-alert/index.js and effort-estimate/index.js.

What changed

  • The account activation alert reads its cookie domain from the app config. master removes the show-account-activation-popup cookie on process.env.SESSION_COOKIE_DOMAIN. Here the domain is getAppConfig(appId).SESSION_COOKIE_DOMAIN, an app config key that app.ts lists at null: an operator who sets nothing gets the cookie removed on the serving host, as master does with the variable unset. The continue button's site name is getSiteConfig().siteName.
  • sendActivationEmail and the courseware data index. The alert imports its request from courseware/data, so courseware/data/api.js gains sendActivationEmail and courseware/data/index.js ports exporting that one name. The other two names the index re-exports on master, getResumeBlock and getSequenceForUnitDeprecated, are commented out under Port the courseware container and redirects to frontend-base #2195's URL until the courseware container ports them.
  • The course start alert ports whole. The outline tab reads useCourseStartAlert and CourseStartAlert.jsx. useCourseStartMasqueradeBanner and CourseStartMasqueradeBanner.jsx come with them and have no caller until the instructor toolbar ports (Wire up the frontend-base masquerade bar #2194). Both components drop the ?? {} after their metadata read: without metadata the alert throws either way, and the banner is only shown once that metadata is loaded (decision log entry 9).
  • EffortEstimate drops its defaultProps. React warns about them on a function component. The one default was a null class name, which classNames skips the same way it skips an absent one.
  • Lint. The masquerade banner's multi-line FormattedDate value gains parentheses, and the effort estimate's activities message gains a description; its id and default message are untouched.
  • js-cookie is declared at ^3.0.8, the version master installs. The lock gains that one package entry.
  • The test setup's pattern for Paragon's own defaultProps warnings gains four names. AlertModal, ModalDialogBody, ModalDialogFooter and ModalDialogTitle are function components declared in Paragon's src/Modal/, each setting defaultProps there, so they join the pattern under Support for defaultProps will be removed from function components in a future major release. paragon#3043. The pattern for react-bootstrap's components (Deprecation warnings from react-bootstrap 1.x components that Paragon wraps paragon#4523) is untouched.
  • Manifest. Ten lines for the ported files.

Testing

In frontend-base/: lint, the tests, build and build:ci pass. 39 suites, 430 tests passed and 7 skipped (cases kept as it.skip under the issues that port what they render). Lint ran with the package's .jsx files included (openedx/frontend-base#327).

New tests. master has no test file for any of these modules; it covers them through the outline and progress tab suites. Each gets one here, since no route in this layer renders them:

  • EffortEstimate.test.tsx: the time in whole minutes, abbreviated on screen and spelled out for screen readers; the activity count; both together; nothing for a block with neither; the class name it is given.
  • course-start-alert/hooks.test.tsx: the alert's full sentence for a course more than a day away and less than a day away, in the learner's time zone and without one, and nothing for a learner who is not enrolled or a course that has started; the masquerade banner on the progress tab, and nothing on another tab or without masquerading.
  • AccountActivationAlert.test.tsx: the alert opens when the cookie is set and removes it; stays closed without it; removes it on the domain the app config names; closes on the continue button and stays open on Escape; resends the activation email, with a spinner until the request settles and a check after. The cases set the cookie on the document and let js-cookie read and remove it, where master's outline suite replaces the library's functions with mocks.

Coverage. The package is at 100% of lines at this layer, against its 96.15% bar, and every file this layer adds is at 100% of lines. Codecov's first report on this PR showed two partially covered lines, the ?? {} after the metadata read in CourseStartAlert.jsx and CourseStartMasqueradeBanner.jsx; both defaults are dropped (decision log entry 9).

Manual testing. None: no route renders these modules yet. The outline tab layer carries the manual pass.

Decisions

What was decided while building this layer; the scope and the import and config mapping are in #2191.

Full decision log

Decisions: the modules the outline tab shares (#2251)

Decisions made while building this layer of #2191. The scope and the
import and config mapping are in #2191's plan and are not repeated.

  1. The outline tab ports as two layers; this is the bottom one.
    The effort estimate, the course start alert, the account activation
    alert with its request, and the js-cookie dependency, in 13 source
    and test files. Accepted cost: nothing here renders on a route, so
    there is no manual pass, and each module gets a test master does
    not have, since this layer's CI meets the line threshold alone.

  2. courseware/data/index.js ports with one of its three names.
    AccountActivationAlert.jsx imports sendActivationEmail from the
    directory, so the index ports and api.js gains the function. The
    other two names it re-exports on master, getResumeBlock and
    getSequenceForUnitDeprecated, are commented out under Port the courseware container and redirects to frontend-base #2195's URL,
    as the factory indexes carry their unported imports.

  3. The cookie domain is read from the app config, and app.ts lists
    the key at null.
    master reads process.env.SESSION_COOKIE_DOMAIN
    when it removes the show-account-activation-popup cookie; here it is
    getAppConfig(appId).SESSION_COOKIE_DOMAIN. An operator who sets
    nothing gets a cookie removed on the serving host, as master does
    with the variable unset. The site name in the continue button is
    getSiteConfig().siteName.

    • The layer's first version gave the key no bundled default,
      following authn, whose
      src/app.ts
      does not list it. arbrandes's review comment
      (refactor: port the modules the outline tab shares to frontend-base #2251 (comment))
      pointed out that it was the only key the package reads that
      defaultConfig does not list, and that the list is the nearest
      thing an operator has to documentation of what can be set. Brian
      agreed (2026-11-18).
    • null changes no behavior. js-cookie leaves a null attribute out
      as it does an absent one (entry 7). getAppConfig merges
      defaultConfig below the site's commonAppConfig and the app's
      config, so a site sets the key as before.
    • Listing every key the package reads, at null, is the
      defaultConfig rule Port the dates tab to frontend-base #2189 set for this app. authn lists only its
      real defaults and documents this key in its README; this package
      has no such table.
  4. EffortEstimate loses its defaultProps. React warns about them
    on a function component and the suite fails on console output. The
    one default was className: null, which classNames skips the same
    way it skips an absent one, so no default parameter takes its place.

  5. Lint. CourseStartMasqueradeBanner.jsx's multi-line
    FormattedDate value gains parentheses (the autofixer's change).
    shared/effort-estimate/messages.ts's activities message gains the
    description the package's lint requires; its id and default
    message are untouched.

  6. Paragon's own modal defaultProps warnings are silenced by exact
    pattern.
    The account activation alert mounts AlertModal, whose
    parts (AlertModal, ModalDialogBody, ModalDialogFooter,
    ModalDialogTitle) set defaultProps on function components. Their
    names join the setup file's pattern under Support for defaultProps will be removed from function components in a future major release. paragon#3043, the
    issue for defaultProps on Paragon's own components.

  7. The account activation test uses the document's cookie, not a
    mock of js-cookie.
    master covers the alert through the outline
    suite, which replaces Cookies.get and Cookies.remove with mock
    functions. Here the cases set the cookie on jsdom's document and let
    the library read and remove it.

    • The domain case sets SESSION_COOKIE_DOMAIN to a domain that is
      not the test page's. jsdom refuses that write, so the cookie
      remains and the alert stays closed, which is the guard master
      wrote against re-rendering forever; the case asserts the string
      written to document.cookie carries the configured domain.
    • mergeAppConfig cannot remove a key (it merges, and a merge skips
      an undefined value), so the cases restore the key to null;
      js-cookie leaves a null attribute out as it does an unset one.
    • "stays open on Escape" is the only case that runs the modal's
      onClose, which does nothing on master and here.
  8. The course start alert's cases compute dates from the current
    time.
    The alert's text depends on the distance to the start date,
    so each case sets a start relative to now (7 days and an hour, 2
    hours and a minute) and gives the metadata userTimezone: 'UTC', so
    the expected date string does not depend on the machine's time zone.
    No test in the package pins the clock, and none does here.

  9. Both ?? {} after the metadata read are dropped. Both run only
    if the component renders with no course metadata in the cache, and
    the first push of this layer left both branches untaken, which
    codecov showed as two partially covered lines. Each was rendered
    alone without metadata to see what its default does.

  10. js-cookie is declared at ^3.0.8, master's 3.0.8 with a
    caret, as the dates tab layer declared its dependencies. The lock
    gains the one package entry.

  11. Checks at the layer's commit (2026-11-12). npm run lint
    clean, with the package's .jsx files included
    (openedx lint does not lint .jsx files frontend-base#327). npm test: 39 suites, 433 passed, 7 skipped; lines 100,
    statements 99.64, branches 97.65, functions 98.15 for the package.
    Each file this layer adds is at 100 lines, and
    alerts/course-start-alert/ at 100 branches. npm run build and
    npm run build:ci pass; dist/ holds the new modules.

    • After the review changes of entries 3 and 9 (2026-11-18): lint
      clean; npm test, 39 suites, 430 passed, 7 skipped, 100% of lines;
      CourseStartAlert.jsx and CourseStartMasqueradeBanner.jsx at 100%
      of branches; npm run build and npm run build:ci pass.

🤖 Generated with Claude Code

@brian-smith-tcril brian-smith-tcril linked an issue Nov 12, 2026 that may be closed by this pull request
10 tasks
@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.81%. Comparing base (51f5783) to head (c020c52).

Additional details and impacted files
@@                Coverage Diff                @@
##           frontend-base    #2251      +/-   ##
=================================================
+ Coverage          96.77%   96.81%   +0.03%     
=================================================
  Files                478      485       +7     
  Lines               7382     7469      +87     
  Branches            1769     1780      +11     
=================================================
+ Hits                7144     7231      +87     
  Misses               223      223              
  Partials              15       15              
Flag Coverage Δ
frontend-base 99.51% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brian-smith-tcril
brian-smith-tcril force-pushed the bsmith/outline-shared-modules branch from d09cf17 to 47f5333 Compare November 12, 2026 15:25
@brian-smith-tcril
brian-smith-tcril marked this pull request as ready for review November 12, 2026 19:41
@brian-smith-tcril
brian-smith-tcril force-pushed the bsmith/outline-shared-modules branch 2 times, most recently from 29a67cf to 5cdad42 Compare November 12, 2026 20:12

@arbrandes arbrandes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with two suggestions.


const showAccountActivationAlert = Cookies.get('show-account-activation-popup');
if (showAccountActivationAlert !== undefined) {
Cookies.remove('show-account-activation-popup', { path: '/', domain: getAppConfig(appId).SESSION_COOKIE_DOMAIN });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add SESSION_COOKIE_DOMAIN: null to the app's default config (frontend-base/src/app.ts:9-15). It's the only key the package reads that isn't listed there, and that list is the closest thing an operator has to documentation of what can be set.

It matters a bit more than the others: when the LMS sets the cookie on a parent domain and the operator hasn't set this key, the cookie is never removed and the activation alert silently never opens.

Behavior doesn't change with a null default: the new test already resets the key to null and passes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +100 to +105
it('gives today as the start date when the course metadata is gone from the cache', () => {
const { container } = render(<CourseStartMasqueradeBanner payload={{ courseId }} />);

const today = new Intl.DateTimeFormat('en').format(new Date());
expect(container).toHaveTextContent(`The course starts on ${today}.`);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this case is worth pinning (optional). I'd drop the ?? {} and this case together, as the PR already does for the course start alert. The case asserts that staff are told the course starts today, which is wrong, and the banner only shows once the metadata says someone is masquerading, so it can't be reached without metadata anyway.

Fine to leave if you'd rather keep master's line as it is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brian-smith-tcril
brian-smith-tcril force-pushed the bsmith/outline-shared-modules branch 3 times, most recently from 755ccb6 to 5b93f6e Compare November 18, 2026 21:03
Base automatically changed from bsmith/progress-entrance-exam to frontend-base November 18, 2026 21:32
shared/effort-estimate, alerts/course-start-alert and the account
activation alert (alerts/logistration-alert/AccountActivationAlert.jsx,
messages.ts) move to the same paths under frontend-base/src, with
manifest lines. Nothing renders them on a route yet.

The account activation alert's request comes with it: courseware/data/
api.js gains sendActivationEmail, and courseware/data/index.js ports
exporting that one name; getResumeBlock and getSequenceForUnitDeprecated
stay commented out there until #2195. The alert reads the cookie domain
from the app config's SESSION_COOKIE_DOMAIN, which app.ts lists at
null, where master read process.env, and the site name from the site
config. The package declares js-cookie.

course-start-alert ports whole: the outline tab reads the alert, and the
masquerade banner has no caller until #2194. Both components drop the
?? {} after their metadata read. Without metadata the alert throws
either way, so its default only moved the throw. The banner's showed
today's date as the start date, and the banner is only shown once that
metadata says the requester is masquerading.

EffortEstimate drops its defaultProps, a null class name that classNames
skips as it does an absent one. For the package's lint, the masquerade
banner's multi-line date value gains parentheses and the activities
message gains a description.

master covers these modules only through the suites of the outline and
progress tabs. Here each gets a test of its own: EffortEstimate.test.tsx,
course-start-alert/hooks.test.tsx for both hooks and both components, and
AccountActivationAlert.test.tsx, which sets the cookie on the document
and lets js-cookie read and remove it.

The setup file's pattern for Paragon's own defaultProps warnings
(openedx/paragon#3043) gains the four modal
components the account activation alert mounts.

Part of #2191.

Co-Authored-By: Claude <noreply@anthropic.com>
@brian-smith-tcril
brian-smith-tcril force-pushed the bsmith/outline-shared-modules branch from 5b93f6e to c020c52 Compare November 18, 2026 21:32
@brian-smith-tcril
brian-smith-tcril merged commit bd40125 into frontend-base Nov 18, 2026
11 checks passed
@brian-smith-tcril
brian-smith-tcril deleted the bsmith/outline-shared-modules branch November 18, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port the outline tab to frontend-base

2 participants