[IMP] im_livechat, website_livechat: improve live chat bundles
This commit improves the live chat bundles: - `core` - `common`: hold files that are common to every feature - `web` - `standalone`: hold files for the embed live chat and is splitted in 4 sub-bundles: - `common` - `frontend`: should only be added in the Odoo frontend. - `external`: should only be added outside of Odoo environment (e.g. support page). - `cors`: should only be added when the live chat is requested from a different origin. This will make live chat folder structure closer than the one used in mail and avoid code duplication. task-3537697 closes odoo/odoo#138536 Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This commit is contained in:
@@ -64,7 +64,7 @@ Help your customers with this chat, and analyse their feedback.
|
||||
'web.assets_frontend': [
|
||||
'web/static/src/views/fields/file_handler.*',
|
||||
'web/static/src/views/fields/formatters.js',
|
||||
('include', 'im_livechat.assets_core'),
|
||||
('include', 'im_livechat.assets_embed_core'),
|
||||
'im_livechat/static/src/embed/frontend/**/*',
|
||||
],
|
||||
'web.assets_backend': [
|
||||
@@ -72,14 +72,10 @@ Help your customers with this chat, and analyse their feedback.
|
||||
'im_livechat/static/src/js/im_livechat_chatbot_steps_one2many.js',
|
||||
'im_livechat/static/src/js/im_livechat_chatbot_script_answers_m2m.js',
|
||||
'im_livechat/static/src/views/**/*',
|
||||
'im_livechat/static/src/chat_window/**/*',
|
||||
'im_livechat/static/src/composer/**/*',
|
||||
'im_livechat/static/src/core/**/*',
|
||||
'im_livechat/static/src/core_ui/**/*',
|
||||
'im_livechat/static/src/discuss_app/**/*',
|
||||
'im_livechat/static/src/messaging_menu/**/*',
|
||||
'im_livechat/static/src/scss/im_livechat_history.scss',
|
||||
'im_livechat/static/src/scss/im_livechat_form.scss',
|
||||
'im_livechat/static/src/core/common/**/*',
|
||||
'im_livechat/static/src/core/web/**/*',
|
||||
],
|
||||
'web.tests_assets': [
|
||||
'im_livechat/static/tests/helpers/**/*.js',
|
||||
@@ -93,7 +89,7 @@ Help your customers with this chat, and analyse their feedback.
|
||||
'web.assets_tests': [
|
||||
'im_livechat/static/tests/tours/**/*',
|
||||
],
|
||||
'im_livechat.assets_core': [
|
||||
'im_livechat.assets_embed_core': [
|
||||
'web/static/lib/odoo_ui_icons/style.css',
|
||||
'web/static/src/scss/ui.scss',
|
||||
'mail/static/src/core/common/**/*',
|
||||
@@ -102,17 +98,13 @@ Help your customers with this chat, and analyse their feedback.
|
||||
'mail/static/src/discuss/typing/**/*',
|
||||
'mail/static/src/utils/common/**/*',
|
||||
('remove', 'mail/static/src/**/*.dark.scss'),
|
||||
|
||||
'im_livechat/static/src/embed/**/*',
|
||||
'im_livechat/static/src/embed/livechat_data.js',
|
||||
('remove', 'im_livechat/static/src/embed/frontend/**/*'),
|
||||
('remove', 'im_livechat/static/src/embed/external/**/*'),
|
||||
('remove', 'im_livechat/static/src/embed/cors/**/*'),
|
||||
'im_livechat/static/src/core/common/**/*',
|
||||
'im_livechat/static/src/embed/common/**/*',
|
||||
],
|
||||
'im_livechat.assets_embed': [
|
||||
'im_livechat.assets_embed_external': [
|
||||
'web/static/lib/jquery/jquery.js',
|
||||
'web/static/src/libs/fontawesome/css/font-awesome.css',
|
||||
'im_livechat/static/src/embed/scss/bootstrap_overridden.scss',
|
||||
'im_livechat/static/src/embed/common/scss/bootstrap_overridden.scss',
|
||||
('include', 'web._assets_helpers'),
|
||||
('include', 'web._assets_backend_helpers'),
|
||||
'web/static/src/scss/pre_variables.scss',
|
||||
@@ -130,11 +122,11 @@ Help your customers with this chat, and analyse their feedback.
|
||||
'bus/static/src/workers/websocket_worker.js',
|
||||
'bus/static/src/workers/websocket_worker_utils.js',
|
||||
|
||||
('include', 'im_livechat.assets_core'),
|
||||
('include', 'im_livechat.assets_embed_core'),
|
||||
'im_livechat/static/src/embed/external/**/*',
|
||||
],
|
||||
'im_livechat.assets_cors': [
|
||||
('include', 'im_livechat.assets_embed'),
|
||||
'im_livechat.assets_embed_cors': [
|
||||
('include', 'im_livechat.assets_embed_external'),
|
||||
'im_livechat/static/src/embed/cors/**/*',
|
||||
],
|
||||
'im_livechat.embed_test_assets': [
|
||||
@@ -142,9 +134,7 @@ Help your customers with this chat, and analyse their feedback.
|
||||
('remove', 'web/static/tests/mock_server_tests.js'),
|
||||
('remove', 'im_livechat/static/**'),
|
||||
'im_livechat/static/tests/helpers/**',
|
||||
'im_livechat/static/src/embed/**/*',
|
||||
('remove', 'im_livechat/static/src/embed/frontend/**/*'),
|
||||
('remove', 'im_livechat/static/src/embed/external/**/*'),
|
||||
('include', 'im_livechat.assets_embed_core'),
|
||||
],
|
||||
'im_livechat.qunit_embed_suite': [
|
||||
'im_livechat/static/tests/embed/**/*',
|
||||
|
||||
@@ -22,12 +22,9 @@ class LivechatController(http.Controller):
|
||||
serves javascript since the css will be fetched by the shadow
|
||||
DOM of the livechat to avoid conflicts.
|
||||
"""
|
||||
bundle = 'im_livechat.assets_embed'
|
||||
asset = request.env["ir.qweb"]._get_asset_bundle(bundle)
|
||||
if ext == 'css':
|
||||
raise request.not_found()
|
||||
stream = request.env['ir.binary']._get_stream_from(asset.js())
|
||||
return stream.get_response()
|
||||
return self.assets_embed(ext, **kwargs)
|
||||
|
||||
@http.route('/im_livechat/assets_embed.<any(css, js):ext>', type='http', auth='public', cors='*')
|
||||
def assets_embed(self, ext, **kwargs):
|
||||
@@ -35,9 +32,9 @@ class LivechatController(http.Controller):
|
||||
# assets to enable the redirection of routes to the CORS controller.
|
||||
headers = request.httprequest.headers
|
||||
origin_url = urlsplit(headers.get('referer'))
|
||||
bundle = 'im_livechat.assets_embed'
|
||||
bundle = 'im_livechat.assets_embed_external'
|
||||
if origin_url.netloc != headers.get('host') or origin_url.scheme != request.httprequest.scheme:
|
||||
bundle = 'im_livechat.assets_cors'
|
||||
bundle = 'im_livechat.assets_embed_cors'
|
||||
asset = request.env["ir.qweb"]._get_asset_bundle(bundle)
|
||||
if ext not in ('css', 'js'):
|
||||
raise request.not_found()
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
declare module "models" {
|
||||
export interface Thread {
|
||||
operator: Persona,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { Record } from "@mail/core/common/record";
|
||||
import { Thread } from "@mail/core/common/thread_model";
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(Thread, {
|
||||
insert(data) {
|
||||
const thread = super.insert(data);
|
||||
if (thread.type === "livechat") {
|
||||
if (data?.operator_pid) {
|
||||
thread.operator = {
|
||||
type: "partner",
|
||||
id: data.operator_pid[0],
|
||||
name: data.operator_pid[1],
|
||||
};
|
||||
}
|
||||
}
|
||||
return thread;
|
||||
},
|
||||
});
|
||||
|
||||
patch(Thread.prototype, {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.operator = Record.one("Persona");
|
||||
},
|
||||
|
||||
get typesAllowingCalls() {
|
||||
return super.typesAllowingCalls.concat(["livechat"]);
|
||||
},
|
||||
|
||||
get isChatChannel() {
|
||||
return this.type === "livechat" || super.isChatChannel;
|
||||
},
|
||||
});
|
||||
-1
@@ -5,6 +5,5 @@ declare module "models" {
|
||||
export interface Thread {
|
||||
anonymous_country: Object,
|
||||
anonymous_name: String,
|
||||
operator: Persona,
|
||||
}
|
||||
}
|
||||
-20
@@ -1,6 +1,5 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { Record } from "@mail/core/common/record";
|
||||
import { Thread } from "@mail/core/common/thread_model";
|
||||
import { assignIn } from "@mail/utils/common/misc";
|
||||
|
||||
@@ -11,13 +10,6 @@ patch(Thread, {
|
||||
const thread = super.insert(data);
|
||||
if (thread.type === "livechat") {
|
||||
assignIn(thread, data, ["anonymous_name", "anonymous_country"]);
|
||||
if (data?.operator_pid) {
|
||||
thread.operator = {
|
||||
type: "partner",
|
||||
id: data.operator_pid[0],
|
||||
displayName: data.operator_pid[1],
|
||||
};
|
||||
}
|
||||
this.store.discuss.livechat.threads.add(thread);
|
||||
this.env.services["mail.thread"].sortChannels();
|
||||
}
|
||||
@@ -26,22 +18,10 @@ patch(Thread, {
|
||||
});
|
||||
|
||||
patch(Thread.prototype, {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.operator = Record.one("Persona");
|
||||
},
|
||||
get typesAllowingCalls() {
|
||||
return super.typesAllowingCalls.concat(["livechat"]);
|
||||
},
|
||||
|
||||
get hasMemberList() {
|
||||
return this.type === "livechat" || super.hasMemberList;
|
||||
},
|
||||
|
||||
get isChatChannel() {
|
||||
return this.type === "livechat" || super.isChatChannel;
|
||||
},
|
||||
|
||||
get correspondents() {
|
||||
return super.correspondents.filter((correspondent) => !correspondent.is_bot);
|
||||
},
|
||||
-7
@@ -28,13 +28,6 @@ patch(ThreadService.prototype, {
|
||||
return super.canUnpin(thread);
|
||||
},
|
||||
|
||||
getCounter(thread) {
|
||||
if (thread.type === "livechat") {
|
||||
return thread.message_unread_counter;
|
||||
}
|
||||
return super.getCounter(thread);
|
||||
},
|
||||
|
||||
sortChannels() {
|
||||
super.sortChannels();
|
||||
// Live chats are sorted by most recent interest date time in the sidebar.
|
||||
-1
@@ -2,6 +2,5 @@ declare module "models" {
|
||||
export interface Thread {
|
||||
chatbotTypingMessage: Message,
|
||||
livechatWelcomeMessage: Message,
|
||||
operator: Persona,
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -10,8 +10,8 @@ export class AutopopupService {
|
||||
/**
|
||||
* @param {import("@web/env").OdooEnv} env
|
||||
* @param {{
|
||||
* "im_livechat.chatbot": import("@im_livechat/embed/chatbot/chatbot_service").ChatBotService,
|
||||
* "im_livechat.livechat": import("@im_livechat/embed/core/livechat_service").LivechatService,
|
||||
* "im_livechat.chatbot": import("@im_livechat/embed/common/chatbot/chatbot_service").ChatBotService,
|
||||
* "im_livechat.livechat": import("@im_livechat/embed/common/livechat_service").LivechatService,
|
||||
* "mail.thread": import("@mail/core/common/thread_service").ThreadService,
|
||||
* "mail.store": import("@mail/core/common/store_service").Store,
|
||||
* ui: typeof import("@web/core/ui/ui_service").uiService.start,
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { serverUrl } from "@im_livechat/embed/livechat_data";
|
||||
import { serverUrl } from "@im_livechat/embed/common/livechat_data";
|
||||
|
||||
async function loadFont(name, url) {
|
||||
await document.fonts.ready;
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { SESSION_STATE } from "@im_livechat/embed/core/livechat_service";
|
||||
import { FeedbackPanel } from "@im_livechat/embed/feedback_panel/feedback_panel";
|
||||
import { SESSION_STATE } from "@im_livechat/embed/common/livechat_service";
|
||||
import { FeedbackPanel } from "@im_livechat/embed/common/feedback_panel/feedback_panel";
|
||||
|
||||
import { ChatWindow } from "@mail/core/common/chat_window";
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ import { assignDefined } from "@mail/utils/common/misc";
|
||||
* @property {string} chatbot_name
|
||||
* @property {number} chatbot_operator_partner_id
|
||||
* @property {number} chatbot_script_id
|
||||
* @property {import("@im_livechat/embed/chatbot/chatbot_step_model").IChatbotStep[]} chatbot_welcome_steps
|
||||
* @property {import("@im_livechat/embed/common/chatbot/chatbot_step_model").IChatbotStep[]} chatbot_welcome_steps
|
||||
* @property {number} [welcome_step_index]
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@ export class Chatbot {
|
||||
welcomeStepIndex = 0;
|
||||
/** @type {number} */
|
||||
scriptId;
|
||||
/** @type {import("@im_livechat/embed/chatbot/chatbot_step_model").IChatbotStep[]} */
|
||||
/** @type {import("@im_livechat/embed/common/chatbot/chatbot_step_model").IChatbotStep[]} */
|
||||
welcomeSteps = [];
|
||||
|
||||
/**
|
||||
+6
-6
@@ -1,8 +1,8 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { Chatbot } from "@im_livechat/embed/chatbot/chatbot_model";
|
||||
import { ChatbotStep } from "@im_livechat/embed/chatbot/chatbot_step_model";
|
||||
import { SESSION_STATE } from "@im_livechat/embed/core/livechat_service";
|
||||
import { Chatbot } from "@im_livechat/embed/common/chatbot/chatbot_model";
|
||||
import { ChatbotStep } from "@im_livechat/embed/common/chatbot/chatbot_step_model";
|
||||
import { SESSION_STATE } from "@im_livechat/embed/common/livechat_service";
|
||||
|
||||
import { EventBus, markup, reactive } from "@odoo/owl";
|
||||
|
||||
@@ -19,9 +19,9 @@ export class ChatBotService {
|
||||
// Time to wait without user input before considering a multi line
|
||||
// step as completed.
|
||||
MULTILINE_STEP_DEBOUNCE_DELAY = 10_000;
|
||||
/** @type {import("@im_livechat/embed/chatbot/chatbot_model").Chatbot} */
|
||||
/** @type {import("@im_livechat/embed/common/chatbot/chatbot_model").Chatbot} */
|
||||
chatbot;
|
||||
/** @type {import("@im_livechat/embed/chatbot/chatbot_step_model").ChatbotStep} */
|
||||
/** @type {import("@im_livechat/embed/common/chatbot/chatbot_step_model").ChatbotStep} */
|
||||
currentStep;
|
||||
/** @type {number} */
|
||||
nextStepTimeout;
|
||||
@@ -38,7 +38,7 @@ export class ChatBotService {
|
||||
/**
|
||||
* @param {import("@web/env").OdooEnv} env
|
||||
* @param {{
|
||||
* "im_livechat.livechat": import("@im_livechat/embed/core/livechat_service").LivechatService,
|
||||
* "im_livechat.livechat": import("@im_livechat/embed/common/livechat_service").LivechatService,
|
||||
* "mail.message": import("@mail/core/common/message_service").MessageService,
|
||||
* "mail.store": import("@mail/core/common/store_service").Store,
|
||||
* rpc: typeof import("@web/core/network/rpc_service").rpcService.start,
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { options } from "@im_livechat/embed/livechat_data";
|
||||
import { options } from "@im_livechat/embed/common/livechat_data";
|
||||
|
||||
import { Composer } from "@mail/core/common/composer";
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { RATING } from "@im_livechat/embed/core/livechat_service";
|
||||
import { TranscriptSender } from "@im_livechat/embed/feedback_panel/transcript_sender";
|
||||
import { RATING } from "@im_livechat/embed/common/livechat_service";
|
||||
import { TranscriptSender } from "@im_livechat/embed/common/feedback_panel/transcript_sender";
|
||||
|
||||
import { Component, useState } from "@odoo/owl";
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { isValidEmail } from "@im_livechat/embed/core/misc";
|
||||
import { isValidEmail } from "@im_livechat/embed/common/misc";
|
||||
|
||||
import { Component, useState } from "@odoo/owl";
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ export class HistoryService {
|
||||
this.rpc = services.rpc;
|
||||
/** @type {ReturnType<typeof import("@bus/services/bus_service").busService.start>} */
|
||||
this.busService = services.bus_service;
|
||||
/** @type {import("@im_livechat/embed/core/livechat_service").LivechatService} */
|
||||
/** @type {import("@im_livechat/embed/common/livechat_service").LivechatService} */
|
||||
this.livechatService = services["im_livechat.livechat"];
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ export class LivechatButton extends Component {
|
||||
|
||||
setup() {
|
||||
this.store = useState(useService("mail.store"));
|
||||
/** @type {import('@im_livechat/embed/core/livechat_service').LivechatService} */
|
||||
/** @type {import('@im_livechat/embed/common/livechat_service').LivechatService} */
|
||||
this.livechatService = useState(useService("im_livechat.livechat"));
|
||||
/** @type {import('@mail/core/common/thread_service').ThreadService} */
|
||||
this.threadService = useService("mail.thread");
|
||||
+1
-1
@@ -14,7 +14,7 @@ import { session } from "@web/session";
|
||||
* @typedef LivechatRule
|
||||
* @property {"auto_popup"|undefined} [action]
|
||||
* @property {number?} [auto_popup_timer]
|
||||
* @property {import("@im_livechat/embed/chatbot/chatbot_model").IChatbot} [chatbot]
|
||||
* @property {import("@im_livechat/embed/common/chatbot/chatbot_model").IChatbot} [chatbot]
|
||||
*/
|
||||
|
||||
export const RATING = Object.freeze({
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { ChatbotStep } from "@im_livechat/embed/chatbot/chatbot_step_model";
|
||||
import { ChatbotStep } from "@im_livechat/embed/common/chatbot/chatbot_step_model";
|
||||
|
||||
import { Message } from "@mail/core/common/message_model";
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ patch(Message.prototype, {
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {import("@im_livechat/embed/chatbot/chatbot_step_model").StepAnswer} answer
|
||||
* @param {import("@im_livechat/embed/common/chatbot/chatbot_step_model").StepAnswer} answer
|
||||
*/
|
||||
answerChatbot(answer) {
|
||||
return this.threadService.post(this.props.message.originThread, answer.label);
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/* @odoo-module */
|
||||
import { SESSION_STATE } from "@im_livechat/embed/core/livechat_service";
|
||||
import { SESSION_STATE } from "@im_livechat/embed/common/livechat_service";
|
||||
|
||||
import { Messaging } from "@mail/core/common/messaging_service";
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { SESSION_STATE } from "@im_livechat/embed/core/livechat_service";
|
||||
import { SESSION_STATE } from "@im_livechat/embed/common/livechat_service";
|
||||
|
||||
import { threadActionsRegistry } from "@mail/core/common/thread_actions";
|
||||
import "@mail/discuss/call/common/thread_actions";
|
||||
+5
-25
@@ -1,20 +1,19 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { SESSION_STATE } from "@im_livechat/embed/common/livechat_service";
|
||||
|
||||
import { Record } from "@mail/core/common/record";
|
||||
import { Thread } from "@mail/core/common/thread_model";
|
||||
import { onChange } from "@mail/utils/common/misc";
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { session } from "@web/session";
|
||||
import { SESSION_STATE } from "./livechat_service";
|
||||
|
||||
patch(Thread, {
|
||||
insert(data) {
|
||||
const isUnknown = !this.get(data);
|
||||
const thread = super.insert(...arguments);
|
||||
const livechatService = this.env.services["im_livechat.livechat"];
|
||||
const chatbotService = this.env.services["im_livechat.chatbot"];
|
||||
const messageService = this.env.services["mail.message"];
|
||||
if (thread.type === "livechat" && isUnknown) {
|
||||
onChange(
|
||||
thread,
|
||||
@@ -32,16 +31,16 @@ patch(Thread, {
|
||||
}
|
||||
}
|
||||
);
|
||||
if (chatbotService.isChatbotThread(thread)) {
|
||||
if (this.env.services["im_livechat.chatbot"].isChatbotThread(thread)) {
|
||||
thread.chatbotTypingMessage = {
|
||||
id: messageService.getNextTemporaryId(),
|
||||
id: this.env.services["mail.message"].getNextTemporaryId(),
|
||||
res_id: thread.id,
|
||||
model: thread.model,
|
||||
author: thread.operator,
|
||||
};
|
||||
} else {
|
||||
thread.livechatWelcomeMessage = {
|
||||
id: messageService.getNextTemporaryId(),
|
||||
id: this.env.services["mail.message"].getNextTemporaryId(),
|
||||
body: livechatService.options.default_message,
|
||||
res_id: thread.id,
|
||||
model: thread.model,
|
||||
@@ -60,25 +59,6 @@ patch(Thread.prototype, {
|
||||
super.setup();
|
||||
this.chatbotTypingMessage = Record.one("Message");
|
||||
this.livechatWelcomeMessage = Record.one("Message");
|
||||
this.operator = Record.one("Persona");
|
||||
},
|
||||
update(data) {
|
||||
super.update(...arguments);
|
||||
if (data.operator_pid) {
|
||||
this.operator = {
|
||||
type: "partner",
|
||||
id: data.operator_pid[0],
|
||||
name: data.operator_pid[1],
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
get isChatChannel() {
|
||||
return this.type === "livechat" || super.isChatChannel;
|
||||
},
|
||||
|
||||
get typesAllowingCalls() {
|
||||
return super.typesAllowingCalls.concat(["livechat"]);
|
||||
},
|
||||
|
||||
get isLastMessageFromCustomer() {
|
||||
-3
@@ -6,13 +6,10 @@ import { useState } from "@odoo/owl";
|
||||
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { session } from "@web/session";
|
||||
|
||||
patch(Thread.prototype, {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.session = session;
|
||||
this.chatbotService = useState(useService("im_livechat.chatbot"));
|
||||
this.livechatService = useState(useService("im_livechat.livechat"));
|
||||
},
|
||||
});
|
||||
+2
-13
@@ -5,31 +5,20 @@ import { ThreadService, threadService } from "@mail/core/common/thread_service";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { url } from "@web/core/utils/urls";
|
||||
|
||||
threadService.dependencies.push(
|
||||
"im_livechat.livechat",
|
||||
"im_livechat.chatbot",
|
||||
"mail.chat_window",
|
||||
"notification"
|
||||
);
|
||||
threadService.dependencies.push("im_livechat.livechat", "im_livechat.chatbot");
|
||||
|
||||
patch(ThreadService.prototype, {
|
||||
/**
|
||||
* @param {import("@web/env").OdooEnv} env
|
||||
* @param {{
|
||||
* "im_livechat.chatbot": import("@im_livechat/embed/chatbot/chatbot_service").ChatBotService,
|
||||
* "im_livechat.livechat": import("@im_livechat/embed/core/livechat_service").LivechatService,
|
||||
* "mail.chat_window": import("@mail/core/common/chat_window_service").ChatWindowService,
|
||||
* notification: typeof import("@web/core/notifications/notification_service").notificationService.start,
|
||||
* "im_livechat.livechat": import("@im_livechat/embed/common/livechat_service").LivechatService,
|
||||
* }} services
|
||||
*/
|
||||
setup(env, services) {
|
||||
super.setup(env, services);
|
||||
this.livechatService = services["im_livechat.livechat"];
|
||||
this.chatWindowService = services["mail.chat_window"];
|
||||
this.chatbotService = services["im_livechat.chatbot"];
|
||||
this.notification = services.notification;
|
||||
/** @type {Promise<import("models").Thread>?} */
|
||||
this.persistPromise = null;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1,4 +0,0 @@
|
||||
.o_mail_notification {
|
||||
font-style: italic;
|
||||
color: gray;
|
||||
}
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { makeRoot, makeShadow } from "@im_livechat/embed/boot_helpers";
|
||||
import { LivechatButton } from "@im_livechat/embed/core_ui/livechat_button";
|
||||
import { serverUrl } from "@im_livechat/embed/livechat_data";
|
||||
import { makeRoot, makeShadow } from "@im_livechat/embed/common/boot_helpers";
|
||||
import { LivechatButton } from "@im_livechat/embed/common/livechat_button";
|
||||
import { serverUrl } from "@im_livechat/embed/common/livechat_data";
|
||||
|
||||
import { ChatWindowContainer } from "@mail/core/common/chat_window_container";
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
import { busParametersService } from "@bus/bus_parameters_service";
|
||||
|
||||
import { serverUrl } from "@im_livechat/embed/livechat_data";
|
||||
import { serverUrl } from "@im_livechat/embed/common/livechat_data";
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { makeRoot, makeShadow } from "@im_livechat/embed/boot_helpers";
|
||||
import { makeRoot, makeShadow } from "@im_livechat/embed/common/boot_helpers";
|
||||
import { LivechatRoot } from "@im_livechat/embed/frontend/livechat_root";
|
||||
import { serverUrl, isAvailable } from "@im_livechat/embed/livechat_data";
|
||||
import { serverUrl, isAvailable } from "@im_livechat/embed/common/livechat_data";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import { App } from "@odoo/owl";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { LivechatButton } from "@im_livechat/embed/core_ui/livechat_button";
|
||||
import { LivechatButton } from "@im_livechat/embed/common/livechat_button";
|
||||
|
||||
import { ChatWindowContainer } from "@mail/core/common/chat_window_container";
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@ patch(OverlayContainer.prototype, {
|
||||
isVisible(overlay) {
|
||||
const targetInShadow = overlay.props.target?.getRootNode() instanceof ShadowRoot;
|
||||
return targetInShadow ? this.env.inShadow : !this.env.inShadow;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { startServer } from "@bus/../tests/helpers/mock_python_environment";
|
||||
|
||||
import { RATING } from "@im_livechat/embed/core/livechat_service";
|
||||
import { RATING } from "@im_livechat/embed/common/livechat_service";
|
||||
import { loadDefaultConfig, start } from "@im_livechat/../tests/embed/helper/test_utils";
|
||||
|
||||
import { triggerHotkey } from "@web/../tests/helpers/utils";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { getPyEnv } from "@bus/../tests/helpers/mock_python_environment";
|
||||
|
||||
import { LivechatButton } from "@im_livechat/embed/core_ui/livechat_button";
|
||||
import { LivechatButton } from "@im_livechat/embed/common/livechat_button";
|
||||
|
||||
import { ChatWindowContainer } from "@mail/core/common/chat_window_container";
|
||||
import { setupManager } from "@mail/../tests/helpers/webclient_setup";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { startServer } from "@bus/../tests/helpers/mock_python_environment";
|
||||
|
||||
import { loadDefaultConfig, start } from "@im_livechat/../tests/embed/helper/test_utils";
|
||||
import { LivechatButton } from "@im_livechat/embed/core_ui/livechat_button";
|
||||
import { LivechatButton } from "@im_livechat/embed/common/livechat_button";
|
||||
|
||||
import { mockTimeout, nextTick, triggerHotkey } from "@web/../tests/helpers/utils";
|
||||
import { click, contains, insertText } from "@web/../tests/utils";
|
||||
|
||||
@@ -829,7 +829,7 @@ export class ThreadService {
|
||||
if (thread.type === "mailbox") {
|
||||
return thread.counter;
|
||||
}
|
||||
if (thread.type === "chat" || thread.type === "group") {
|
||||
if (thread.isChatChannel) {
|
||||
return thread.message_unread_counter || thread.message_needaction_counter;
|
||||
}
|
||||
return thread.message_needaction_counter;
|
||||
|
||||
@@ -25,8 +25,8 @@ Allow website visitors to chat with the collaborators. This module also brings a
|
||||
'data/website_livechat_chatbot_demo.xml',
|
||||
],
|
||||
'assets': {
|
||||
'im_livechat.assets_core': [
|
||||
'website_livechat/static/src/embed/**/*',
|
||||
'im_livechat.assets_embed_core': [
|
||||
'website_livechat/static/src/embed/common/**/*',
|
||||
],
|
||||
'website.assets_wysiwyg': [
|
||||
'website_livechat/static/src/scss/**/*',
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { LivechatService } from "@im_livechat/embed/core/livechat_service";
|
||||
import { LivechatService } from "@im_livechat/embed/common/livechat_service";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(LivechatService.prototype, {
|
||||
@@ -5,7 +5,7 @@ import { endDiscussion, okRating, feedback, transcript, close } from "./website_
|
||||
import { registry } from "@web/core/registry";
|
||||
|
||||
odoo.loader.bus.addEventListener("module-started", (e) => {
|
||||
if (e.detail.moduleName === "@im_livechat/embed/core/livechat_service") {
|
||||
if (e.detail.moduleName === "@im_livechat/embed/common/livechat_service") {
|
||||
const { LivechatService, ODOO_VERSION_KEY } = e.detail.module;
|
||||
// Livechat sessions are deleted if they come from a different odoo version than
|
||||
// the current one. Since each test is run with a different browser the version
|
||||
@@ -25,12 +25,12 @@ odoo.loader.bus.addEventListener("module-started", (e) => {
|
||||
} catch {
|
||||
// Could be intentional (tour ended successfully while version still loading)
|
||||
}
|
||||
|
||||
|
||||
return super.initialize(...arguments);
|
||||
},
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const chatRequest = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user