[FIX] im_livechat: hide 'add attachment' button in livechat
Message attachments are not yet supported in livechat for livechat visitors, so the "Add file" button should not be visible. closes #54927 Forward-port-of: #54972 Forward-port-of: #54957 X-original-commit: 91a548a6a7456dfd50833671a3938fcf55ed18c6
This commit is contained in:
@@ -41,6 +41,7 @@ Help your customers with this chat, and analyse their feedback.
|
||||
'depends': ["mail", "rating", "digest"],
|
||||
'qweb': [
|
||||
'static/src/bugfix/bugfix.xml',
|
||||
'static/src/components/composer/composer.xml',
|
||||
'static/src/components/discuss_sidebar/discuss_sidebar.xml',
|
||||
'static/src/components/thread_icon/thread_icon.xml',
|
||||
],
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-inherit="mail.Composer" t-inherit-mode="extension">
|
||||
<xpath expr="//*[hasclass('o_Composer_buttonAttachment')]" position="replace">
|
||||
<t t-if="!composer.thread or composer.thread.channel_type !== 'livechat'">$0</t>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
@@ -0,0 +1,75 @@
|
||||
odoo.define('im_livechat/static/src/components/composer/composer_tests.js', function (require) {
|
||||
'use strict';
|
||||
|
||||
const components = {
|
||||
Composer: require('mail/static/src/components/composer/composer.js'),
|
||||
};
|
||||
const {
|
||||
afterEach,
|
||||
afterNextRender,
|
||||
beforeEach,
|
||||
start,
|
||||
} = require('mail/static/src/utils/test_utils.js');
|
||||
|
||||
QUnit.module('im_livechat', {}, function () {
|
||||
QUnit.module('components', {}, function () {
|
||||
QUnit.module('composer', {}, function () {
|
||||
QUnit.module('composer_tests.js', {
|
||||
beforeEach() {
|
||||
beforeEach(this);
|
||||
|
||||
this.createComposerComponent = async (composer, otherProps) => {
|
||||
const ComposerComponent = components.Composer;
|
||||
ComposerComponent.env = this.env;
|
||||
this.component = new ComposerComponent(null, Object.assign({
|
||||
composerLocalId: composer.localId,
|
||||
}, otherProps));
|
||||
delete ComposerComponent.env;
|
||||
await afterNextRender(() => this.component.mount(this.widget.el));
|
||||
};
|
||||
|
||||
this.start = async params => {
|
||||
let { env, widget } = await start(Object.assign({}, params, {
|
||||
data: this.data,
|
||||
}));
|
||||
this.env = env;
|
||||
this.widget = widget;
|
||||
};
|
||||
},
|
||||
afterEach() {
|
||||
afterEach(this);
|
||||
if (this.component) {
|
||||
this.component.destroy();
|
||||
}
|
||||
if (this.widget) {
|
||||
this.widget.destroy();
|
||||
}
|
||||
this.env = undefined;
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test('livechat: no add attachment button', async function (assert) {
|
||||
// Attachments are not yet supported in livechat, especially from livechat
|
||||
// visitor PoV. This may likely change in the future with task-2029065.
|
||||
assert.expect(2);
|
||||
|
||||
await this.start();
|
||||
const thread = this.env.models['mail.thread'].create({
|
||||
channel_type: 'livechat',
|
||||
id: 10,
|
||||
model: 'mail.channel',
|
||||
});
|
||||
await this.createComposerComponent(thread.composer);
|
||||
assert.containsOnce(document.body, '.o_Composer', "should have a composer");
|
||||
assert.containsNone(
|
||||
document.body,
|
||||
'.o_Composer_buttonAttachment',
|
||||
"composer linked to livechat should not have a 'Add attachment' button"
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -29,6 +29,7 @@
|
||||
<template id="qunit_suite" name="livechat_tests" inherit_id="web.qunit_suite_tests">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/im_livechat/static/src/bugfix/bugfix_tests.js"></script>
|
||||
<script type="text/javascript" src="/im_livechat/static/src/components/composer/composer_tests.js"></script>
|
||||
<script type="text/javascript" src="/im_livechat/static/src/components/discuss/discuss_tests.js"></script>
|
||||
<script type="text/javascript" src="/im_livechat/static/src/components/thread_icon/thread_icon_tests.js"></script>
|
||||
<script type="text/javascript" src="/im_livechat/static/src/components/thread_textual_typing_status/thread_textual_typing_status_tests.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user