From 9470adbb8a4f0b55623bc530a53be9fcae547e12 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 1 Mar 2026 19:21:10 +0000 Subject: [PATCH] Improved notifications. --- src/components/Dashboard/common/NoteItem.jsx | 133 +++++++----- .../Dashboard/common/Notification.jsx | 29 ++- .../Dashboard/common/ObjectDisplay.jsx | 46 ++++- .../Dashboard/common/UserNotifierToggle.jsx | 189 ++++++++++-------- .../Dashboard/context/ApiServerContext.jsx | 58 ++++-- .../Dashboard/context/AuthContext.jsx | 2 + .../Dashboard/context/NotificationContext.jsx | 6 + .../Email/EmailNotificationTemplate.jsx | 35 +++- 8 files changed, 336 insertions(+), 162 deletions(-) diff --git a/src/components/Dashboard/common/NoteItem.jsx b/src/components/Dashboard/common/NoteItem.jsx index ee1be3e..93531c2 100644 --- a/src/components/Dashboard/common/NoteItem.jsx +++ b/src/components/Dashboard/common/NoteItem.jsx @@ -22,13 +22,22 @@ import MissingPlaceholder from './MissingPlaceholder' import NewNote from '../Management/Notes/NewNote' import { ApiServerContext } from '../context/ApiServerContext' import ExclamationOctagonIcon from '../../Icons/ExclamationOctagonIcon' +import UserNotifierToggle from './UserNotifierToggle' import { AuthContext } from '../context/AuthContext' import { getModelByName } from '../../../database/ObjectModels' import { useNavigate } from 'react-router-dom' const { Text } = Typography -const NoteItem = ({ note }) => { +const NoteItem = ({ + note, + showCard = true, + showCreatedAt = true, + showChildNotes = true, + showActions = true, + showInfo = true, + largeSpacing = false +}) => { const [childNotes, setChildNotes] = useState([]) const noteModel = getModelByName('note') const infoAction = noteModel.actions.filter( @@ -151,15 +160,8 @@ const NoteItem = ({ note }) => { }) } - return ( - + const noteItem = ( + <> @@ -170,15 +172,25 @@ const NoteItem = ({ note }) => { - + - - - + {showActions && ( + <> + + + + + + )} Type: @@ -194,34 +206,44 @@ const NoteItem = ({ note }) => { showHyperlink={true} /> - - Created At: - - + {showCreatedAt && ( + + Created At: + + + )} - ) + } + case 'newNote': { + console.log('newNote metadata', JSON.stringify(metadata, null, 2)) + const model = getModelByName(metadata?.note?.parentType) + const infoAction = + model.actions?.find((action) => action.name === 'info') ?? null + const url = infoAction + ? infoAction.url(metadata?.note?.parent?._id) + : null + return url ? ( + + ) : null + } } return null } @@ -92,7 +109,11 @@ const EmailNotificationTemplate = () => { {getNotifictionActions()} {email && ( - +