From a74c67169ac66ff0d07ad5a3e65c5e0afe2d457e Mon Sep 17 00:00:00 2001 From: "Louis Wicket (wil)" Date: Mon, 13 Dec 2021 14:11:49 +0000 Subject: [PATCH] [IMP] mail: rename channel command model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename javascript model `mail.channel_command` to `ChannelCommand` in order to distinguish javascript models from python models. Part of task-2701674. closes odoo/odoo#81320 Signed-off-by: Sébastien Theys (seb) --- .../composer_suggestion/composer_suggestion.js | 2 +- .../tests/composer_suggestion_command_tests.js | 12 ++++++------ .../src/models/channel_command/channel_command.js | 4 ++-- .../static/src/models/composer_view/composer_view.js | 6 +++--- addons/mail/static/src/models/messaging/messaging.js | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js b/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js index 8a94ad41b20..9aac81d3a18 100644 --- a/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js +++ b/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js @@ -36,7 +36,7 @@ export class ComposerSuggestion extends Component { } get isCommand() { - return this.props.modelName === "mail.channel_command"; + return this.props.modelName === "ChannelCommand"; } get isPartner() { diff --git a/addons/mail/static/src/components/composer_suggestion/tests/composer_suggestion_command_tests.js b/addons/mail/static/src/components/composer_suggestion/tests/composer_suggestion_command_tests.js index 9128c1df082..8ee88079dba 100644 --- a/addons/mail/static/src/components/composer_suggestion/tests/composer_suggestion_command_tests.js +++ b/addons/mail/static/src/components/composer_suggestion/tests/composer_suggestion_command_tests.js @@ -31,14 +31,14 @@ QUnit.test('command suggestion displayed', async function (assert) { id: 20, model: 'mail.channel', }); - const command = this.messaging.models['mail.channel_command'].create({ + const command = this.messaging.models['ChannelCommand'].create({ methodName: '', name: 'whois', help: "Displays who it is", }); await createComposerSuggestionComponent(thread.composer, { isActive: true, - modelName: 'mail.channel_command', + modelName: 'ChannelCommand', recordLocalId: command.localId, }); @@ -58,14 +58,14 @@ QUnit.test('command suggestion correct data', async function (assert) { id: 20, model: 'mail.channel', }); - const command = this.messaging.models['mail.channel_command'].create({ + const command = this.messaging.models['ChannelCommand'].create({ methodName: '', name: 'whois', help: "Displays who it is", }); await createComposerSuggestionComponent(thread.composer, { isActive: true, - modelName: 'mail.channel_command', + modelName: 'ChannelCommand', recordLocalId: command.localId, }); @@ -105,14 +105,14 @@ QUnit.test('command suggestion active', async function (assert) { id: 20, model: 'mail.channel', }); - const command = this.messaging.models['mail.channel_command'].create({ + const command = this.messaging.models['ChannelCommand'].create({ methodName: '', name: 'whois', help: "Displays who it is", }); await createComposerSuggestionComponent(thread.composer, { isActive: true, - modelName: 'mail.channel_command', + modelName: 'ChannelCommand', recordLocalId: command.localId, }); diff --git a/addons/mail/static/src/models/channel_command/channel_command.js b/addons/mail/static/src/models/channel_command/channel_command.js index a677e5f5c6d..3eb88e6f2fb 100644 --- a/addons/mail/static/src/models/channel_command/channel_command.js +++ b/addons/mail/static/src/models/channel_command/channel_command.js @@ -5,7 +5,7 @@ import { attr } from '@mail/model/model_field'; import { cleanSearchTerm } from '@mail/utils/utils'; registerModel({ - name: 'mail.channel_command', + name: 'ChannelCommand', identifyingFields: ['name'], modelMethods: { /** @@ -66,7 +66,7 @@ registerModel({ * @param {Object} [options={}] * @param {mail.thread} [options.thread] prioritize and/or restrict * result in the context of given thread - * @returns {[mail.channel_command[], mail.channel_command[]]} + * @returns {[ChannelCommand[], ChannelCommand[]]} */ searchSuggestions(searchTerm, { thread } = {}) { if (thread.model !== 'mail.channel') { 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 49c58bf8ce3..cfeabc8a044 100644 --- a/addons/mail/static/src/models/composer_view/composer_view.js +++ b/addons/mail/static/src/models/composer_view/composer_view.js @@ -71,7 +71,7 @@ registerModel({ return; // not supported for guests } if ( - this.suggestionModelName === 'mail.channel_command' || + this.suggestionModelName === 'ChannelCommand' || this._getCommandFromText(this.composer.textInputContent) ) { return; @@ -574,7 +574,7 @@ registerModel({ case ':': return 'mail.canned_response'; case '/': - return 'mail.channel_command'; + return 'ChannelCommand'; case '#': return 'mail.thread'; default: @@ -691,7 +691,7 @@ registerModel({ /** * @private * @param {string} content html content - * @returns {mail.channel_command|undefined} command, if any in the content + * @returns {ChannelCommand|undefined} command, if any in the content */ _getCommandFromText(content) { if (content.startsWith('/')) { diff --git a/addons/mail/static/src/models/messaging/messaging.js b/addons/mail/static/src/models/messaging/messaging.js index 426c2a85d14..4e88190ccba 100644 --- a/addons/mail/static/src/models/messaging/messaging.js +++ b/addons/mail/static/src/models/messaging/messaging.js @@ -238,7 +238,7 @@ registerModel({ isCausal: true, readonly: true, }), - commands: one2many('mail.channel_command'), + commands: one2many('ChannelCommand'), companyName: attr(), currentGuest: one2one('Guest'), currentPartner: one2one('mail.partner'),