[FIX] im_livechat, mail: hide call buttons for chat with visitor

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) <seb@odoo.com>
This commit is contained in:
Ipsita Borisagar
2022-04-07 13:23:55 +02:00
parent ff422df492
commit 4853444dca
3 changed files with 42 additions and 1 deletions
@@ -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"
);
});
});
});
@@ -49,7 +49,7 @@
<t t-if="threadViewTopbar.thread and threadViewTopbar.thread === messaging.starred">
<button class="o_ThreadViewTopbar_unstarAllButton btn btn-secondary" t-att-disabled="threadViewTopbar.threadView.messages.length === 0" t-on-click="threadViewTopbar.onClickUnstarAll">Unstar all</button>
</t>
<t t-if="threadViewTopbar.thread and threadViewTopbar.thread.model === 'mail.channel' and threadViewTopbar.thread.rtcSessions.length === 0">
<t t-if="threadViewTopbar.thread and threadViewTopbar.thread.hasCallFeature and threadViewTopbar.thread.rtcSessions.length === 0">
<button class="o_ThreadViewTopbar_callButton o_ThreadViewTopbar_button o-active" t-att-disabled="threadViewTopbar.thread.hasPendingRtcRequest" title="Start a Call" t-on-click="_onClickPhone">
<i class="fa fa-lg fa-phone"/>
</button>
+13
View File
@@ -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.