-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Porting notes: 1. Removed notify_default, since it does not pass validation in [1] 2. Modifications to notificaation widgets are removed in prefer of original widget implementation 3. Odoo improved notification usage in [2], so no need to add extra channels that depend on user's id [1] https://github.com/odoo/odoo/blob/21be7ca0c9eef18184d06755ff83337be1e4752e/addons/web/static/src/core/notifications/notification.js#L49 [2] odoo/odoo@543af27
- Loading branch information
Showing
8 changed files
with
61 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
web_notify/static/src/js/services/web_notification_service.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** @odoo-module **/ | ||
|
||
import {registry} from "@web/core/registry"; | ||
|
||
export const webNotificationService = { | ||
dependencies: ["notification"], | ||
|
||
start(env, {notification}) { | ||
const channel_success = "web_notify_success"; | ||
const channel_danger = "web_notify_danger"; | ||
const channel_warning = "web_notify_warning"; | ||
const channel_info = "web_notify_info"; | ||
const channel_default = "web_notify_default"; | ||
const all_channels = [ | ||
channel_success, | ||
channel_danger, | ||
channel_warning, | ||
channel_info, | ||
channel_default, | ||
]; | ||
|
||
function onMessage(message) { | ||
return notification.add(message.message, { | ||
type: message.type, | ||
title: message.title, | ||
sticky: message.sticky, | ||
}); | ||
} | ||
|
||
function onNotification(notifications) { | ||
for (const {type, payload} of notifications) { | ||
if (all_channels.indexOf(type) > -1) { | ||
onMessage(payload); | ||
} | ||
} | ||
} | ||
|
||
env.bus.on("WEB_CLIENT_READY", null, async () => { | ||
const legacyEnv = owl.Component.env; | ||
|
||
legacyEnv.services.bus_service.startPolling(); | ||
legacyEnv.services.bus_service.onNotification(this, onNotification); | ||
}); | ||
}, | ||
}; | ||
|
||
registry.category("services").add("webNotification", webNotificationService); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.