From 4853444dca392e35ca1f3798d3a45537822e150e Mon Sep 17 00:00:00 2001 From: Ipsita Borisagar Date: Mon, 31 Jan 2022 06:42:46 +0000 Subject: [PATCH] [FIX] im_livechat, mail: hide call buttons for chat with visitor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit: In Discuss topbar, call buttons are added to allow call and video between channel members. Those buttons were also added to live chat channels but any voice call or video call features are not available for visitors. After this commit: Call buttons will not appear in Discuss top bar for live chat channels. Task-2744224 closes odoo/odoo#88105 X-original-commit: 1fd8af1a30abbe65fd4266c2fb4793ea2a06fab5 Signed-off-by: Sébastien Theys (seb) --- .../components/discuss_tests.js | 28 +++++++++++++++++++ .../thread_view_topbar/thread_view_topbar.xml | 2 +- addons/mail/static/src/models/thread.js | 13 +++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/addons/im_livechat/static/tests/qunit_suite_tests/components/discuss_tests.js b/addons/im_livechat/static/tests/qunit_suite_tests/components/discuss_tests.js index 9869ea917c4..14c5445b01e 100644 --- a/addons/im_livechat/static/tests/qunit_suite_tests/components/discuss_tests.js +++ b/addons/im_livechat/static/tests/qunit_suite_tests/components/discuss_tests.js @@ -338,5 +338,33 @@ QUnit.test('invite button should be present on livechat', async function (assert ); }); +QUnit.test('call buttons should not be present on livechat', async function (assert) { + assert.expect(1); + + const pyEnv = await startServer(); + const mailChannelId1 = pyEnv['mail.channel'].create( + { + anonymous_name: "Visitor 11", + channel_type: 'livechat', + livechat_operator_id: pyEnv.currentPartnerId, + channel_partner_ids: [pyEnv.currentPartnerId, pyEnv.publicPartnerId], + }, + ); + await start({ + autoOpenDiscuss: true, + discuss: { + params: { + default_active_id: `mail.channel_${mailChannelId1}`, + }, + }, + hasDiscuss: true, + }); + assert.containsNone( + document.body, + '.o_ThreadViewTopbar_callButton', + "Call buttons should not be visible in top bar when livechat is active thread" + ); +}); + }); }); diff --git a/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml b/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml index 012a7fe9d84..a065e29123c 100644 --- a/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml +++ b/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml @@ -49,7 +49,7 @@ - + diff --git a/addons/mail/static/src/models/thread.js b/addons/mail/static/src/models/thread.js index a7e2206087e..ceda60e6ecd 100644 --- a/addons/mail/static/src/models/thread.js +++ b/addons/mail/static/src/models/thread.js @@ -1264,6 +1264,13 @@ registerModel({ _computeFutureActivities() { return replace(this.activities.filter(activity => activity.state === 'planned')); }, + /** + * @private + * @returns {boolean} + */ + _computeHasCallFeature() { + return ['channel', 'chat', 'group'].includes(this.channel_type); + }, /** * @private * @returns {boolean} @@ -1976,6 +1983,12 @@ registerModel({ hasActivities: attr({ default: false, }), + /** + * Determines whether the RTC call feature should be displayed. + */ + hasCallFeature: attr({ + compute: '_computeHasCallFeature', + }), /** * States whether this thread should has the invite feature. Only makes * sense for channels.