From 6a93e77a17795166d315a1188c979cee0e6dcefd Mon Sep 17 00:00:00 2001 From: JM Date: Tue, 5 May 2026 18:48:30 +0200 Subject: [PATCH] alles aber noch ohne npm! --- extend.php | 13 ++++++----- js/src/forum/addTeamsSettings.js | 39 ++++++++++++++++++++++++++++++++ js/src/forum/index.js | 5 ++++ locale/en.yml | 10 +++++++- 4 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 js/src/forum/addTeamsSettings.js create mode 100644 js/src/forum/index.js diff --git a/extend.php b/extend.php index f3632cf..00a906d 100644 --- a/extend.php +++ b/extend.php @@ -5,22 +5,23 @@ declare(strict_types=1); use Flarum\Extend; use SbpJm\FlarumMSTeamsWebhook\Console\TestTeamsUserCommand; use SbpJm\FlarumMSTeamsWebhook\Listener\MirrorAlertsToTeams; -use SbpJm\FlarumMSTeamsWebhook\Notification\TeamsDriver; return [ (new Extend\Locales(__DIR__ . '/locale')), + // Admin UI (Settings etc.) (new Extend\Frontend('admin')) ->js(__DIR__ . '/js/dist/admin.js'), + // Forum UI (User notification settings – Teams checkbox) + (new Extend\Frontend('forum')) + ->js(__DIR__ . '/js/dist/forum.js'), + + // CLI test command (new Extend\Console()) ->command(TestTeamsUserCommand::class), - // ✅ EXISTING hook (unchanged) + // ✅ EINZIGER Notification-Hook (richtig für Flarum 1.8.x) (new Extend\Notification()) ->beforeSending(MirrorAlertsToTeams::class), - - // ✅ NEW: Microsoft Teams notification driver - (new Extend\Notification()) - ->driver('teams', TeamsDriver::class), ]; \ No newline at end of file diff --git a/js/src/forum/addTeamsSettings.js b/js/src/forum/addTeamsSettings.js new file mode 100644 index 0000000..945d7db --- /dev/null +++ b/js/src/forum/addTeamsSettings.js @@ -0,0 +1,39 @@ +import app from 'flarum/forum/app'; +import { extend } from 'flarum/common/extend'; +import NotificationGrid from 'flarum/forum/components/NotificationGrid'; + +export default function addTeamsSettings() { + extend(NotificationGrid.prototype, 'notificationTypes', function (items) { + + items.add('teams-header', { + name: 'teams-header', + label: app.translator.trans('sbp-jm-msteams.forum.teams.header'), + children: [], + }); + + items.add('teams-newPost', { + name: 'teams-newPost', + label: app.translator.trans('sbp-jm-msteams.forum.teams.newPost'), + settings: { + teams: 'sbp-jm-msteams.types.newPost', + }, + }); + + items.add('teams-postMentioned', { + name: 'teams-postMentioned', + label: app.translator.trans('sbp-jm-msteams.forum.teams.postMentioned'), + settings: { + teams: 'sbp-jm-msteams.types.postMentioned', + }, + }); + + items.add('teams-userMentioned', { + name: 'teams-userMentioned', + label: app.translator.trans('sbp-jm-msteams.forum.teams.userMentioned'), + settings: { + teams: 'sbp-jm-msteams.types.userMentioned', + }, + }); + + }); +} \ No newline at end of file diff --git a/js/src/forum/index.js b/js/src/forum/index.js new file mode 100644 index 0000000..0750318 --- /dev/null +++ b/js/src/forum/index.js @@ -0,0 +1,5 @@ +import addTeamsSettings from './addTeamsSettings'; + +export default function () { + addTeamsSettings(); +} \ No newline at end of file diff --git a/locale/en.yml b/locale/en.yml index c9ca0d5..0bceccb 100644 --- a/locale/en.yml +++ b/locale/en.yml @@ -4,4 +4,12 @@ sbp-jm-msteams-webhook: description: Mirror Flarum web notifications to Microsoft Teams. notification: drivers: - teams: Microsoft Teams \ No newline at end of file + teams: Microsoft Teams + +sbp-jm-msteams: + forum: + teams: + header: Microsoft Teams + newPost: Someone replies to a discussion I am following + postMentioned: Someone mentions me in a post + userMentioned: Someone mentions me \ No newline at end of file