-
Notifications
You must be signed in to change notification settings - Fork 180
feat: Add HeaderNotificationsSlot to enable notifications tray default ON #663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
dc8c58a
3c51082
89e8053
65d7a88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| # Header Notifications Slot | ||
awais-ansari marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No screenshots are appearing in here when browsing https://github.com/awais-ansari/frontend-component-header/tree/aansari/notifications-79/src/plugin-slots/HeaderNotificationsSlot All of the examples should have screenshots |
||
|
|
||
| ### Slot ID: `org.openedx.frontend.layout.header_notifications_tray.v1` | ||
|
|
||
| ## Description | ||
|
|
||
| This slot renders the notifications tray (bell icon + notification popover) from `@edx/frontend-plugin-notifications` by default. | ||
|
|
||
| **Important:** This slot is **not used standalone** in headers. Instead, it is embedded within the default content of three parent slots: | ||
awais-ansari marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 1. **Desktop Header** — via `org.openedx.frontend.layout.header_desktop_secondary_menu.v1` | ||
| Notifications appear before secondary menu items (e.g., "New", "Help") | ||
|
|
||
| 2. **Learning Header** — via `org.openedx.frontend.layout.learning_header_actions.v1` | ||
| Notifications appear before the help link | ||
|
|
||
| 3. **Studio Header** — via `org.openedx.frontend.layout.studio_header_actions.v1` | ||
| Notifications appear before the search button | ||
|
|
||
| ## Slot Hierarchy | ||
|
|
||
| ``` | ||
| Desktop Header | ||
| └── org.openedx.frontend.layout.header_desktop_secondary_menu.v1 | ||
| ├── org.openedx.frontend.layout.header_notifications_tray.v1 ← This slot | ||
| └── (secondary menu items) | ||
|
|
||
| Learning Header | ||
| └── org.openedx.frontend.layout.learning_header_actions.v1 | ||
| ├── org.openedx.frontend.layout.header_notifications_tray.v1 ← This slot | ||
| └── org.openedx.frontend.layout.header_learning_help.v1 | ||
|
|
||
| Studio Header | ||
| └── org.openedx.frontend.layout.studio_header_actions.v1 | ||
| ├── org.openedx.frontend.layout.header_notifications_tray.v1 ← This slot | ||
| └── org.openedx.frontend.layout.studio_header_search_button_slot.v1 | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Disable Notifications Globally (All Headers) | ||
|
|
||
| The following `env.config.jsx` will hide the notifications tray across all headers: | ||
|
|
||
| ```jsx | ||
| import { PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| 'org.openedx.frontend.layout.header_notifications_tray.v1': { | ||
| keepDefault: true, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Hide, | ||
| widgetId: 'default_contents', | ||
| }, | ||
| ] | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| export default config; | ||
| ``` | ||
|
|
||
| ### Disable Notifications Per Header | ||
|
|
||
| To hide notifications in a specific header only, modify the parent wrapper slot: | ||
|
|
||
| - **Desktop Header:** See [DesktopSecondaryMenuSlot documentation](../DesktopSecondaryMenuSlot/) | ||
| - **Learning Header:** See [LearningHeaderActionsSlot documentation](../LearningHeaderActionsSlot/) | ||
| - **Studio Header:** See [StudioHeaderActionsSlot documentation](../StudioHeaderActionsSlot/) | ||
|
|
||
| ### Replace Notifications with Custom Component (All Headers) | ||
|
|
||
| The following `env.config.jsx` will replace the default notifications tray with a custom component across all headers: | ||
|
|
||
| ```jsx | ||
| import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
| import CustomNotifications from './CustomNotifications'; | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| 'org.openedx.frontend.layout.header_notifications_tray.v1': { | ||
| keepDefault: false, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Insert, | ||
| widget: { | ||
| id: 'custom_notifications_component', | ||
| type: DIRECT_PLUGIN, | ||
| RenderWidget: CustomNotifications, | ||
| }, | ||
| }, | ||
| ] | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| export default config; | ||
| ``` | ||
|
|
||
| ### Add Custom Alert Icon Before Notifications (All Headers) | ||
|
|
||
| The following `env.config.jsx` will insert a custom alert icon before the notifications bell: | ||
|
|
||
| ```jsx | ||
| import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| 'org.openedx.frontend.layout.header_notifications_tray.v1': { | ||
| keepDefault: true, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Insert, | ||
| widget: { | ||
| id: 'custom_alert_icon', | ||
| type: DIRECT_PLUGIN, | ||
| priority: 10, | ||
| RenderWidget: () => ( | ||
| <button aria-label="Alerts">🚨</button> | ||
| ), | ||
| }, | ||
| }, | ||
| ] | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| export default config; | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React from 'react'; | ||
| import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
| import NotificationsTray from '@edx/frontend-plugin-notifications'; | ||
|
|
||
| const HeaderNotificationsSlot = () => ( | ||
| <PluginSlot | ||
| id="org.openedx.frontend.layout.header_notifications_tray.v1" | ||
| > | ||
| <NotificationsTray /> | ||
| </PluginSlot> | ||
| ); | ||
|
|
||
| export default HeaderNotificationsSlot; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # Learning Header Actions Slot | ||
awais-ansari marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The screenshots added to |
||
|
|
||
| ### Slot ID: `org.openedx.frontend.layout.learning_header_actions.v1` | ||
|
|
||
| ## Description | ||
|
|
||
| This slot wraps the notification tray and help link in the Learning header. It provides a single location for operators to customize the action area before the user menu in the Learning (course) header. | ||
|
|
||
| By default, this slot renders: | ||
| 1. **HeaderNotificationsSlot** — The notification bell from `@edx/frontend-plugin-notifications` | ||
| 2. **LearningHelpSlot** — The help link (question mark icon) | ||
|
|
||
| This wrapper slot ensures that: | ||
| - Notifications are enabled by default in the Learning header | ||
| - Operators can customize the entire action area using one slot ID | ||
| - The existing `org.openedx.frontend.layout.header_learning_help.v1` remains functional for backward compatibility | ||
|
|
||
| ## Why This Wrapper Slot? | ||
|
|
||
| The `org.openedx.frontend.layout.header_notifications_tray.v1` slot is rendered in **multiple headers** (Desktop, Learning, and Studio). Modifying that slot directly would impact notifications across all header types. | ||
|
|
||
| This wrapper slot allows operators to: | ||
| - **Hide notifications in Learning header only** — without affecting Desktop or Studio | ||
| - **Customize the action area** — replace or extend both notifications and help link together | ||
| - **Maintain control** — each header type can be configured independently | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Disable Notifications in Learning Header Only | ||
|
|
||
| The following `env.config.jsx` will hide the notification bell in the Learning header while keeping it in Desktop and Studio headers: | ||
awais-ansari marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```jsx | ||
| import { PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| 'org.openedx.frontend.layout.learning_header_actions.v1': { | ||
| keepDefault: true, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Hide, | ||
| widgetId: 'org.openedx.frontend.layout.header_notifications_tray.v1', | ||
| }, | ||
| ] | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| export default config; | ||
| ``` | ||
|
|
||
| ### Replace the Entire Actions Area | ||
|
|
||
| The following `env.config.jsx` will replace both notifications and help link with a custom component: | ||
|
|
||
| ```jsx | ||
| import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; | ||
|
|
||
| const config = { | ||
| pluginSlots: { | ||
| 'org.openedx.frontend.layout.learning_header_actions.v1': { | ||
| keepDefault: false, | ||
| plugins: [ | ||
| { | ||
| op: PLUGIN_OPERATIONS.Insert, | ||
| widget: { | ||
| id: 'custom_learning_actions', | ||
| type: DIRECT_PLUGIN, | ||
| RenderWidget: () => ( | ||
| <div> | ||
| <button>Custom Action 1</button> | ||
| <button>Custom Action 2</button> | ||
| </div> | ||
| ), | ||
| }, | ||
| }, | ||
| ] | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| export default config; | ||
| ``` | ||
|
|
||
| ### Modify Help Link Only | ||
|
|
||
| To customize just the help link while keeping notifications, see the [LearningHelpSlot documentation](../LearningHelpSlot/). | ||
|
|
||
| ## Slot Hierarchy | ||
|
|
||
| This slot contains two child slots: | ||
| - `org.openedx.frontend.layout.header_notifications_tray.v1` (HeaderNotificationsSlot) | ||
| - `org.openedx.frontend.layout.header_learning_help.v1` (LearningHelpSlot) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import React from 'react'; | ||
| import { PluginSlot } from '@openedx/frontend-plugin-framework'; | ||
| import HeaderNotificationsSlot from '../HeaderNotificationsSlot'; | ||
| import LearningHelpSlot from '../LearningHelpSlot'; | ||
|
|
||
| const LearningHeaderActionsSlot = () => ( | ||
| <PluginSlot | ||
| id="org.openedx.frontend.layout.learning_header_actions.v1" | ||
| > | ||
| <HeaderNotificationsSlot /> | ||
| <LearningHelpSlot /> | ||
| </PluginSlot> | ||
| ); | ||
|
|
||
| export default LearningHeaderActionsSlot; |
Uh oh!
There was an error while loading. Please reload this page.