1
0
mirror of https://github.com/flarum/core.git synced 2025-08-08 17:36:38 +02:00

feat: JS Notification extender (#3974)

* feat: JS `Notification` extender

* fix
This commit is contained in:
Sami Mazouz
2024-05-14 21:10:07 +01:00
committed by GitHub
parent d273b1920f
commit 29ede5aa27
12 changed files with 53 additions and 22 deletions

View File

@@ -3,10 +3,16 @@ import User from 'flarum/common/models/User';
import Model from 'flarum/common/Model';
import commonExtend from '../common/extend';
import UserSuspendedNotification from './components/UserSuspendedNotification';
import UserUnsuspendedNotification from './components/UserUnsuspendedNotification';
export default [
...commonExtend,
new Extend.Notification() //
.add('userSuspended', UserSuspendedNotification)
.add('userUnsuspended', UserUnsuspendedNotification),
new Extend.Model(User)
.attribute<Date | null | undefined, string | null | undefined>('suspendedUntil', Model.transformDate)
.attribute<string | null | undefined>('suspendReason')

View File

@@ -6,16 +6,11 @@ import Badge from 'flarum/common/components/Badge';
import User from 'flarum/common/models/User';
import SuspendUserModal from './components/SuspendUserModal';
import UserSuspendedNotification from './components/UserSuspendedNotification';
import UserUnsuspendedNotification from './components/UserUnsuspendedNotification';
import checkForSuspension from './checkForSuspension';
export { default as extend } from './extend';
app.initializers.add('flarum-suspend', () => {
app.notificationComponents.userSuspended = UserSuspendedNotification;
app.notificationComponents.userUnsuspended = UserUnsuspendedNotification;
extend(UserControls, 'moderationControls', (items, user) => {
if (user.canSuspend()) {
items.add(