Repository navigation
PageNotification
PageNotification is a shared generic component that renders a Carbon InlineNotification for page-level or feature-level events. It subscribes to the notification event bus via useScopedNotification and displays a dismissible inline alert when an active event matches the provided eventTarget.
Use PageNotification when a page or feature needs a consistent, auto-wired inline notification without duplicating subscription logic. The component abstracts useScopedNotification and eventIconDescription behind a stable public interface, keeping notification rendering declarative.
- Source:
frontend/src/components/core/PageNotification/index.tsx - Tests:
frontend/src/components/core/PageNotification/index.unit.test.tsx - Barrel:
frontend/src/components/core/index.ts
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
eventTarget |
string |
Yes | — | Unique scope identifier used to match dispatched notification events. |
className |
string |
No | — | Optional CSS class applied to the notification container. |
interface PageNotificationProps {
readonly eventTarget: string;
readonly className?: string;
}- Subscribes to notifications for the given
eventTargetviauseScopedNotification(eventTarget). - Returns
nullwheneventNotificationis undefined oreventNotification.titleis falsy. - Renders a Carbon
InlineNotificationwithlowContrast. - Sets
kindtoeventNotification.eventType(error,warning,info, etc.). - Sets
title,subtitlefromeventNotification.titleandeventNotification.description. - Sets
statusIconDescriptionviaeventIconDescription(eventNotification). - Aria label is
Closes ${eventNotification.eventType} notification. -
onCloseandonCloseButtonClickboth callclearNotificationto dismiss the event.
- Automatic subscription / unsubscription to the scoped notification bus.
- No internal state; rendering is driven entirely by the event bus.
- Dismissible via Carbon's close button; dismissal clears the scoped event.
- Accepts an optional
classNamefor layout overrides without wrapping markup.
import PageNotification from '@/components/core/PageNotification';
<PageNotification eventTarget="waste-search" />The component renders an inline alert when a notification is dispatched with eventTarget: 'waste-search'.
import PageNotification from '@/components/core/PageNotification';
<PageNotification eventTarget="ru-details" className="notification-column" />Useful when the notification must sit in a specific grid column beside page content.
Current unit coverage verifies:
- Null render when event notification is undefined or title is empty
-
eventTargetis passed touseScopedNotification - Title and subtitle render from event notification
-
classNameis applied and does not produceundefinedclass - Aria label contains event type
-
kindclass reflectserror,warning,info -
eventIconDescriptionis called with current event - Close button triggers
clearNotification
- Renders only when a notification with a non-empty title is active for the scope.
- Relies on
useScopedNotificationand the global notification event bus; no manual state can force a render. -
classNameis forwarded directly toInlineNotification; it does not scope styles.
-
codes/frontend/Components.md— catalog entry points to this page. -
architecture/frontend/Frontend Architecture Overview.md— notification pattern reference.
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository