[FIX] im_livechat: disable attachment upload via drag and drop

Before this commit:

Attachments are not properly supported in livechat, so there is no point in
allowing attachments to be uploaded via drag and drop.

After this commit:

Disable attachment upload via drag and drop in livechat channels.

Task-2824502

closes odoo/odoo#95761

X-original-commit: 1aed05eb1c50ee69b974a140b3080e38c802cb2f
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Ipsita Borisagar
2022-07-12 06:20:51 +02:00
parent a6ca15fa9d
commit 3fe33487e1
2 changed files with 35 additions and 0 deletions
@@ -0,0 +1,17 @@
/** @odoo-module **/
import { patchRecordMethods } from '@mail/model/model_core';
import { clear } from '@mail/model/model_field_command';
import '@mail/models/composer_view';
patchRecordMethods('ComposerView', {
/**
* @override
*/
_computeDropZoneView() {
if (this.composer.thread && this.composer.thread.channel_type === 'livechat') {
return clear();
}
return this._super();
},
});
@@ -26,5 +26,23 @@ QUnit.test('livechat: no add attachment button', async function (assert) {
);
});
QUnit.test('livechat: disable attachment upload via drag and drop', async function (assert) {
assert.expect(2);
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].create({
channel_type: 'livechat',
id: 10,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
assert.containsOnce(document.body, '.o_Composer', "should have a composer");
assert.containsNone(
document.body,
'.o_Composer_dropZone',
"composer linked to livechat should not have a dropzone"
);
});
});
});