-
-
Notifications
You must be signed in to change notification settings - Fork 998
[Refactor] Notification plugins #9735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Refactor] Notification plugins #9735
Conversation
- Notifications handled by plugins
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- Ensure plugin slug is correctly attached - Consistent format - Logic fixes
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (83.78%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #9735 +/- ##
==========================================
- Coverage 86.82% 86.78% -0.05%
==========================================
Files 1251 1253 +2
Lines 55398 55331 -67
Branches 2089 2089
==========================================
- Hits 48102 48019 -83
- Misses 6783 6799 +16
Partials 513 513
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH there are so many lost / fundamentally changed mechanisms that I can not compare this to the current implementation as it just shares some entry points and names.
This means a new write of every even slightly complex notification method plugin and refactors for all plugins that trigger notifications.
@matmair fair comments - I'll see if I can adjust this to reduce the number of changes required |
…enTree into notification-plugins
- Actually *use* the notification system - Fix for email template
- Allows plugins to define per-user settings
I think the difference in code coverage here is due to deleted lines in the codebase.... In any case, @matmair this is ready for review now. The key points are:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the notification system to treat notification methods as individual plugins instead of being part of a larger plugin. It implements a new user-specific settings system for plugins, changes the notification architecture to use the NotificationMixin, and replaces the NotificationUserSetting model with PluginUserSetting.
- Splits core notification methods (UI, Email, Slack) into separate plugins
- Introduces plugin-specific user settings through new PluginUserSetting model
- Replaces the legacy notification collection system with plugin-based approach
Reviewed Changes
Copilot reviewed 57 out of 57 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
src/frontend/tests/pui_plugins.spec.ts | Adds new Playwright test for plugin user settings functionality |
src/frontend/src/states/SettingsStates.tsx | Updates plugin settings state to accept endpoint parameter |
src/frontend/src/pages/Index/Settings/UserSettings.tsx | Adds Plugin Settings tab to user settings |
src/frontend/src/pages/Index/Settings/UserPluginSettings.tsx | New component for managing user-specific plugin settings |
src/frontend/src/components/settings/SettingList.tsx | Adds support for plugin user settings and onLoaded callback |
src/frontend/lib/enums/ApiEndpoints.tsx | Adds new API endpoint for plugin user settings |
src/backend/InvenTree/users/ruleset.py | Updates ruleset to reference new PluginUserSetting model |
src/backend/InvenTree/templates/email/*.html | New and updated email templates |
src/backend/InvenTree/plugin/serializers.py | Replaces NotificationUserSetting with PluginUserSetting serializer |
src/backend/InvenTree/plugin/samples/integration/sample.py | Adds example user settings to sample plugin |
src/backend/InvenTree/plugin/registry.py | Updates built-in plugin names for new notification structure |
src/backend/InvenTree/plugin/plugin.py | Adds NOTIFICATION mixin enum |
src/backend/InvenTree/plugin/models.py | Replaces NotificationUserSetting with PluginUserSetting model |
src/backend/InvenTree/plugin/migrations/ | Database migrations for model changes |
src/backend/InvenTree/plugin/builtin/integration/core_notifications.py | Refactors notification methods into separate plugin classes |
src/backend/InvenTree/plugin/base/integration/SettingsMixin.py | Adds user settings support to SettingsMixin |
src/backend/InvenTree/plugin/base/integration/NotificationMixin.py | New mixin for notification plugins |
src/backend/InvenTree/plugin/api.py | Adds API endpoints for plugin user settings |
src/backend/InvenTree/plugin/admin.py | Updates admin interface for new models |
src/backend/InvenTree/common/notifications.py | Refactors notification triggering to use plugin system |
src/backend/InvenTree/build/tasks.py | Updates build notification to use new system |
Multiple test files | Updates tests to work with new notification architecture |
docs/ | Documentation updates for new notification plugins and mixins |
src/backend/InvenTree/plugin/builtin/integration/core_notifications.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
…n.py Co-authored-by: Copilot <[email protected]>
…enTree into notification-plugins
TBH I am still not a fan of this change, I feel like notification settings should be a first-party component just like other settings. Moving them to the plugins makes them far more obscure. |
The new plugin user settings seem to not be covered fully, there seems to be stuff missing on the APIs |
@matmair coverage has been increased across new features, and the notification settings now appear in their own panel |
Breaking Change
This PR represents a breaking change to any custom plugin which implements notification functionality. To continue to function, any such plugin must be reworked to follow the new approach:
NotificationMixin
classDetails
This PR is a refactor of how notification methods are defined and collected.
Currently, it is a separate collection mechanism to plugins, and loading the notification methods is complex and somewhat "brittle" (compared to the plugin registry which has been optimized),
The intent here is to just make each notification method a plugin, which is then in line with our general concept of plugins. It also ensures that notification methods cannot be "collected" from plugins which are installed but not active (which is unfortunately the case currently).
Feature - Plugin User Settings
It introduces a new concept, a "per user" setting structure against plugins. This replaces the "NotificationSetting" which was stored once per user against each type of notification. The new approach is more generic as any plugin can store per-user settings.
Enhancements
Tasks
Related Issues