Skip to content

feat: Add V2 of header actions slot - #682

Open
ChrisChV wants to merge 5 commits into
openedx:masterfrom
open-craft:chris/header-actions-slot-v2
Open

feat: Add V2 of header actions slot#682
ChrisChV wants to merge 5 commits into
openedx:masterfrom
open-craft:chris/header-actions-slot-v2

Conversation

@ChrisChV

@ChrisChV ChrisChV commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

The showUserDropdown prop gated both the LearningHeaderActionsSlot and the AuthenticatedUserDropdown, making it impossible to hide the user dropdown without also hiding all the action items, and impossible for third-party plugins attached to that slot to render independently of the user dropdown's visibility.

This PR introduces a new org.openedx.frontend.layout.learning_header_actions.v2 slot:

  • v2 always renders, regardless of showUserDropdown. Use this slot ID for new plugin configurations that should render even when showUserDropdown is false.
  • v2 wraps the existing v1 slot (notifications tray + help link), which keeps its original behavior unchanged — only rendered when showUserDropdown is true — preserving backwards compatibility for existing consumers of v1.

This PR does not change any default, out-of-the-box visual behavior. With no custom plugin configuration,
the header looks and behaves exactly as it does on main, including with showUserDropdown={false}.
The only thing this PR unlocks is the ability for plugin authors to opt into .v2 so their own widgets render
independently of showUserDropdown.

A follow-up DEPR ticket will propose removing v1 once its default content (notifications tray + help link) can move into v2 unconditionally.

Supporting information

Testing instructions

Important: Before starting, ensure you have a Tutor environment with the Learning MFE in development mode running.

  1. Clone the repo. From the main branch, run npm ci && npm run build.
  2. From the Learning MFE, run npm install "../path/to/this/repo" --legacy-peer-deps.
  3. Add the following to frontend-app-learning/env.config.jsx to set showUserDropdown: false:
   import { PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';

   const hideUserMenu = (widget) => {
    widget.content = {
      ...widget.content,
      showUserDropdown: false,
    };
    return widget;
  };

   export default {
     pluginSlots: {
       'org.openedx.frontend.layout.header_learning.v1': {
         keepDefault: true,
         plugins: [
           {
             op: PLUGIN_OPERATIONS.Modify,
             widgetId: 'default_contents',
             fn: hideUserMenu,
           },
         ],
       },
     },
   };
  1. Add the following to frontend-app-learning/module.config.js:
module.exports = {
  localModules: [
    {
      moduleName: '@edx/frontend-component-header',
      dir: '../frontend-component-header', // adjust this relative to your repo
    },
  ],
};
  1. Run the Learning MFE in dev mode with main checked out on this repo. Confirm that with showUserDropdown: false, the user dropdown, notifications, and "Help" link are hidden (pre-PR behavior).
  2. Switch this repo to this PR's branch and run npm run build
  3. Confirm the header still looks the same as step 5 — no regression.

Introduce a v2 version of LearningHeaderActionsSlot that always mounts,
wrapping the existing v1 slot (HeaderNotificationsSlot and
LearningHelpSlot) which stays gated behind showUserDropdown. This
preserves the v1 slot API contract for existing plugin consumers while
allowing new plugins to attach to v2 unconditionally.

Note: HeaderNotificationsSlot/LearningHelpSlot remain hidden when
showUserDropdown is false. Fully decoupling them from showUserDropdown
requires deprecating v1 first, and is left for a
follow-up once the DEPR lands.
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 25, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @ChrisChV!

This repository is currently maintained by @openedx/committers-frontend.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.56%. Comparing base (e380431) to head (daa487e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #682      +/-   ##
==========================================
+ Coverage   73.07%   74.56%   +1.49%     
==========================================
  Files          60       61       +1     
  Lines         520      523       +3     
  Branches      110      110              
==========================================
+ Hits          380      390      +10     
+ Misses        137      130       -7     
  Partials        3        3              

☔ 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.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Aug 26, 2026
@mphilbrick211
mphilbrick211 requested a review from a team August 26, 2026 18:51
@arbrandes arbrandes linked an issue Aug 27, 2026 that may be closed by this pull request

@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.

Looks great, for the most part! Just a couple of change requests and a few non-blocking nits.

Comment thread src/learning-header/LearningHeader.jsx Outdated
Comment on lines 40 to 49
{authenticatedUser && (
<>
<LearningHeaderActionsSlot />
<AuthenticatedUserDropdown
username={authenticatedUser.username}
/>
<LearningHeaderActionsSlot showUserDropdown={showUserDropdown} />
{showUserDropdown && (
<AuthenticatedUserDropdown
username={authenticatedUser.username}
/>
)}
</>
)}

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.

v2 should render for anonymous users.

Hoist the slot out of the authenticatedUser guard, folding the gate into the prop it passes down. Rename that prop while you are there (v2/index.jsx:6): it no longer tracks the dropdown, only whether v1's default contents render.

Suggested change
{authenticatedUser && (
<>
<LearningHeaderActionsSlot />
<AuthenticatedUserDropdown
username={authenticatedUser.username}
/>
<LearningHeaderActionsSlot showUserDropdown={showUserDropdown} />
{showUserDropdown && (
<AuthenticatedUserDropdown
username={authenticatedUser.username}
/>
)}
</>
)}
<LearningHeaderActionsSlot showDefaultActions={showUserDropdown && !!authenticatedUser} />
{authenticatedUser && showUserDropdown && (
<AuthenticatedUserDropdown
username={authenticatedUser.username}
/>
)}

Default output stays identical in all four combinations of the two flags, and .v2 plugins gain the anonymous header.

Anonymous learners do reach this header: frontend-app-learning authenticates no route, and GoalUnsubscribe.jsx, its only caller passing showUserDropdown={false}, is explicitly anonymous-friendly. PageNotFound.jsx and CourseAccessErrorPage.jsx likewise.

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.

Updated: 26b1919

- **Notification Tray** (via `HeaderNotificationsSlot`) — Rendered before the help link
- **Help Link** (via `LearningHelpSlot`)

> **Note:** This slot is only rendered when `showUserDropdown` is `true`. To render content regardless of `showUserDropdown`, use the parent [`v2` slot](../v2/).

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.

v1's docs omit the authenticatedUser gate.

v1 stays gated on both flags, so "only rendered when showUserDropdown is true" needs "and a user is authenticated" here, in LearningHeaderActionsSlot/README.md:6, and in the hierarchy diagram at HeaderNotificationsSlot/README.md:31. v2's own "always renders" wording becomes accurate once the change to LearningHeader.jsx lands.

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.

Updated: 5650a8e

Comment on lines +30 to +35
it('hides the user dropdown and the header actions when showUserDropdown is false', () => {
render(<Header showUserDropdown={false} />);

expect(screen.queryByText(authenticatedUser.username)).not.toBeInTheDocument();
expect(screen.queryByText('Help')).not.toBeInTheDocument();
});

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.

This test passes unchanged on master.

I ran it against the base files and all three cases pass, so it guards pre-existing hiding behavior and covers no new path. Add a case with a widget configured on .v2 and showUserDropdown={false}, asserting the widget appears, plus one for the anonymous case. That needs a mergeConfig({ pluginSlots: { ... } }) setup, which this repo has no precedent for.

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.

Updated: 3ae9441

### Learning Header
* [`org.openedx.frontend.layout.header_learning_course_info.v1`](./CourseInfoSlot/)
* [`org.openedx.frontend.layout.learning_header_actions.v1`](./LearningHeaderActionsSlot/)
* [`org.openedx.frontend.layout.learning_header_actions.v1`](./LearningHeaderActionsSlot/v1/)

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.

v1 is not marked deprecated.

Two lines, here and in v1/README.md, and the DEPR (#681) defers it to a follow-up. Worth doing here so the index does not present both versions as equal choices.

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.

@arbrandes The OEP-21, indicates that it is only marked as deprecated after the plan is approved. That's the reason why I didn't include it. I want to confirm whether you think we should still include it.

Comment on lines +18 to +20
LearningHeaderActionsSlot.defaultProps = {
showUserDropdown: true,
};

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.

Nit: use a destructuring default instead. React 18.3 deprecates defaultProps on function components, and DesktopSecondaryMenuSlot/v2 declares propTypes only.

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.

Updated: daa487e

Comment on lines +7 to +9
<PluginSlot
id="org.openedx.frontend.layout.learning_header_actions.v2"
>

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.

Nit: pluginProps={{ showUserDropdown }}, as DesktopSecondaryMenuSlot/v2 does for menu. Addable later without a version bump.

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.

Updated: daa487e

Notifications appear before secondary menu items (e.g., "New", "Help")

2. **Learning Header** — via `org.openedx.frontend.layout.learning_header_actions.v1`
2. **Learning Header** — via `org.openedx.frontend.layout.learning_header_actions.v2` (nests `.v1` — see [LearningHeaderActionsSlot](../LearningHeaderActionsSlot/v2/))

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.

Nit: reads as a direct parent, which it is for the desktop entry above but not here. The parenthetical and the diagram below get it right, so this is cosmetic.

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.

Updated: 5650a8e

@ChrisChV
ChrisChV requested a review from arbrandes September 4, 2026 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

Learning Header's user menu slots can't fully hide/replace it.

5 participants