mirror of
https://github.com/flarum/core.git
synced 2025-08-07 08:56:38 +02:00
feat: JS Notification
extender (#3974)
* feat: JS `Notification` extender * fix
This commit is contained in:
25
framework/core/js/src/common/extenders/Notification.ts
Normal file
25
framework/core/js/src/common/extenders/Notification.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import IExtender, { IExtensionModule } from './IExtender';
|
||||
import type Component from '../Component';
|
||||
import ForumApplication from '../../forum/ForumApplication';
|
||||
import type Application from '../Application';
|
||||
import type { NewComponent } from '../Application';
|
||||
|
||||
export default class Notification implements IExtender {
|
||||
private notificationComponents: Record<string, new () => Component> = {};
|
||||
|
||||
/**
|
||||
* Register a new notification component type.
|
||||
*
|
||||
* @param name The name of the notification type.
|
||||
* @param component The component class to render the notification.
|
||||
*/
|
||||
add(name: string, component: NewComponent<any>): Notification {
|
||||
this.notificationComponents[name] = component;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
extend(app: Application, extension: IExtensionModule): void {
|
||||
Object.assign((app as unknown as ForumApplication).notificationComponents, this.notificationComponents);
|
||||
}
|
||||
}
|
@@ -3,6 +3,7 @@ import PostTypes from './PostTypes';
|
||||
import Routes from './Routes';
|
||||
import Store from './Store';
|
||||
import Search from './Search';
|
||||
import Notification from './Notification';
|
||||
|
||||
const extenders = {
|
||||
Model,
|
||||
@@ -10,6 +11,7 @@ const extenders = {
|
||||
Routes,
|
||||
Store,
|
||||
Search,
|
||||
Notification,
|
||||
};
|
||||
|
||||
export default extenders;
|
||||
|
Reference in New Issue
Block a user