From 9dbeb68515f2c8afaf4bb13de58f3a98128ee102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Tue, 16 Nov 2021 14:19:02 +0000 Subject: [PATCH] [FIX] mail: send button on mail channel show 'send' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes odoo/odoo#79898 X-original-commit: 665f22de5ba6d73c28cc090a67d1179f8a6d99f0 Signed-off-by: Sébastien Theys (seb) Signed-off-by: Alexandre Kühn (aku) --- addons/mail/i18n/mail.pot | 4 ++-- .../src/components/composer/composer.xml | 5 ++--- .../composer/tests/composer_tests.js | 17 ++++++++++++++ .../src/models/composer_view/composer_view.js | 22 +++++++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/addons/mail/i18n/mail.pot b/addons/mail/i18n/mail.pot index e056c44d17b..82c906ef14c 100644 --- a/addons/mail/i18n/mail.pot +++ b/addons/mail/i18n/mail.pot @@ -3729,7 +3729,7 @@ msgstr "" #. module: mail #. openerp-web -#: code:addons/mail/static/src/components/composer/composer.xml:0 +#: code:addons/mail/static/src/models/composer_view/composer_view.js:0 #: code:addons/mail/static/src/xml/web_kanban_activity.xml:0 #: code:addons/mail/static/src/xml/web_kanban_activity.xml:0 #: model_terms:ir.ui.view,arch_db:mail.email_compose_message_wizard_form @@ -5898,7 +5898,7 @@ msgstr "" #. module: mail #. openerp-web -#: code:addons/mail/static/src/components/composer/composer.xml:0 +#: code:addons/mail/static/src/models/composer_view/composer_view.js:0 #: model_terms:ir.ui.view,arch_db:mail.email_compose_message_wizard_form #, python-format msgid "Send" diff --git a/addons/mail/static/src/components/composer/composer.xml b/addons/mail/static/src/components/composer/composer.xml index 1e62f32b675..c703120cacd 100644 --- a/addons/mail/static/src/components/composer/composer.xml +++ b/addons/mail/static/src/components/composer/composer.xml @@ -153,8 +153,6 @@ diff --git a/addons/mail/static/src/components/composer/tests/composer_tests.js b/addons/mail/static/src/components/composer/tests/composer_tests.js index f7675ba91d1..12bc14fb5ca 100644 --- a/addons/mail/static/src/components/composer/tests/composer_tests.js +++ b/addons/mail/static/src/components/composer/tests/composer_tests.js @@ -2141,6 +2141,23 @@ QUnit.test('[technical] does not crash when an attachment is removed before its ); }); +QUnit.test('send button on mail.channel should have "Send" as label', async function (assert) { + assert.expect(1); + + this.data['mail.channel'].records.push({ id: 20 }); + const { createComposerComponent } = await this.start(); + const thread = this.messaging.models['mail.thread'].findFromIdentifyingData({ + id: 20, + model: 'mail.channel', + }); + await createComposerComponent(thread.composer); + assert.strictEqual( + document.querySelector('.o_Composer_buttonSend').textContent, + "Send", + "Send button of mail.channel composer should have 'Send' as label", + ); +}); + }); }); }); diff --git a/addons/mail/static/src/models/composer_view/composer_view.js b/addons/mail/static/src/models/composer_view/composer_view.js index 6bce7914ec4..d1f60e766c9 100644 --- a/addons/mail/static/src/models/composer_view/composer_view.js +++ b/addons/mail/static/src/models/composer_view/composer_view.js @@ -546,6 +546,22 @@ function factory(dependencies) { } } + /** + * @private + * @returns {string} + */ + _computeSendButtonText() { + if ( + this.composer && + this.composer.isLog && + this.composer.activeThread && + this.composer.activeThread.model !== 'mail.channel' + ) { + return this.env._t("Log"); + } + return this.env._t("Send"); + } + /** * @private * @returns {string} @@ -931,6 +947,12 @@ function factory(dependencies) { inverse: 'composerViewInEditing', readonly: true, }), + /** + * Determines the label on the send button of this composer view. + */ + sendButtonText: attr({ + compute: '_computeSendButtonText', + }), /** * States which type of suggestion is currently in progress, if any. * The value of this field contains the magic char that corresponds to