[IMP] mail: remove thread rename from discuss sidebar
task-2628751 closes odoo/odoo#75659 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -636,7 +636,7 @@ QUnit.test('sidebar: public/private channel rendering', async function (assert)
|
||||
});
|
||||
|
||||
QUnit.test('sidebar: basic chat rendering', async function (assert) {
|
||||
assert.expect(10);
|
||||
assert.expect(9);
|
||||
|
||||
// expected correspondent, with a random unique id that will be used to link
|
||||
// partner to chat and a random name that will be asserted in the test
|
||||
@@ -685,13 +685,8 @@ QUnit.test('sidebar: basic chat rendering', async function (assert) {
|
||||
);
|
||||
assert.strictEqual(
|
||||
chat.querySelectorAll(`:scope .o_DiscussSidebarCategoryItem_command`).length,
|
||||
2,
|
||||
"should have 2 commands"
|
||||
);
|
||||
assert.strictEqual(
|
||||
chat.querySelectorAll(`:scope .o_DiscussSidebarCategoryItem_commandRename`).length,
|
||||
1,
|
||||
"should have 'rename' command"
|
||||
"should have 1 command"
|
||||
);
|
||||
assert.strictEqual(
|
||||
chat.querySelectorAll(`:scope .o_DiscussSidebarCategoryItem_commandUnpin`).length,
|
||||
@@ -706,7 +701,7 @@ QUnit.test('sidebar: basic chat rendering', async function (assert) {
|
||||
});
|
||||
|
||||
QUnit.test('sidebar: chat rendering with unread counter', async function (assert) {
|
||||
assert.expect(5);
|
||||
assert.expect(4);
|
||||
|
||||
// chat expected to be found in the sidebar
|
||||
this.data['mail.channel'].records.push({
|
||||
@@ -729,13 +724,8 @@ QUnit.test('sidebar: chat rendering with unread counter', async function (assert
|
||||
);
|
||||
assert.strictEqual(
|
||||
chat.querySelectorAll(`:scope .o_DiscussSidebarCategoryItem_command`).length,
|
||||
1,
|
||||
"should have single command"
|
||||
);
|
||||
assert.strictEqual(
|
||||
chat.querySelectorAll(`:scope .o_DiscussSidebarCategoryItem_commandRename`).length,
|
||||
1,
|
||||
"should have 'rename' command"
|
||||
0,
|
||||
"should have no command"
|
||||
);
|
||||
assert.strictEqual(
|
||||
chat.querySelectorAll(`:scope .o_DiscussSidebarCategoryItem_commandUnpin`).length,
|
||||
@@ -886,70 +876,6 @@ QUnit.test('sidebar: chat custom name', async function (assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('sidebar: rename chat', async function (assert) {
|
||||
assert.expect(8);
|
||||
|
||||
// expected correspondent, with a random unique id that will be used to link
|
||||
// partner to chat, and a random name not used in the scope of this test but set for consistency
|
||||
this.data['res.partner'].records.push({ id: 101, name: "Marc Demo" });
|
||||
// chat expected to be found in the sidebar
|
||||
this.data['mail.channel'].records.push({
|
||||
channel_type: 'chat', // testing a chat is the goal of the test
|
||||
custom_channel_name: "Marc", // testing a custom name is the goal of the test
|
||||
members: [this.data.currentPartnerId, 101], // expected partners
|
||||
public: 'private', // expected value for testing a chat
|
||||
});
|
||||
await this.start();
|
||||
const chat = document.querySelector(`.o_DiscussSidebar_categoryChat .o_DiscussSidebarCategory_item`);
|
||||
assert.strictEqual(
|
||||
chat.querySelector(`:scope .o_DiscussSidebarCategoryItem_name`).textContent,
|
||||
"Marc",
|
||||
"chat should have custom name as name"
|
||||
);
|
||||
assert.notOk(
|
||||
chat.querySelector(`:scope .o_DiscussSidebarCategoryItem_name`).classList.contains('o-editable'),
|
||||
"chat name should not be editable"
|
||||
);
|
||||
|
||||
await afterNextRender(() =>
|
||||
chat.querySelector(`:scope .o_DiscussSidebarCategoryItem_commandRename`).click()
|
||||
);
|
||||
assert.ok(
|
||||
chat.querySelector(`:scope .o_DiscussSidebarCategoryItem_name`).classList.contains('o-editable'),
|
||||
"chat should have editable name"
|
||||
);
|
||||
assert.strictEqual(
|
||||
chat.querySelectorAll(`:scope .o_DiscussSidebarCategoryItem_nameInput`).length,
|
||||
1,
|
||||
"chat should have editable name input"
|
||||
);
|
||||
assert.strictEqual(
|
||||
chat.querySelector(`:scope .o_DiscussSidebarCategoryItem_nameInput`).value,
|
||||
"Marc",
|
||||
"editable name input should have custom chat name as value by default"
|
||||
);
|
||||
assert.strictEqual(
|
||||
chat.querySelector(`:scope .o_DiscussSidebarCategoryItem_nameInput`).placeholder,
|
||||
"Marc Demo",
|
||||
"editable name input should have partner name as placeholder"
|
||||
);
|
||||
|
||||
await afterNextRender(() => {
|
||||
chat.querySelector(`:scope .o_DiscussSidebarCategoryItem_nameInput`).value = "Demo";
|
||||
const kevt = new window.KeyboardEvent('keydown', { key: "Enter" });
|
||||
chat.querySelector(`:scope .o_DiscussSidebarCategoryItem_nameInput`).dispatchEvent(kevt);
|
||||
});
|
||||
assert.notOk(
|
||||
chat.querySelector(`:scope .o_DiscussSidebarCategoryItem_name`).classList.contains('o-editable'),
|
||||
"chat should no longer show editable name"
|
||||
);
|
||||
assert.strictEqual(
|
||||
chat.querySelector(`:scope .o_DiscussSidebarCategoryItem_name`).textContent,
|
||||
"Demo",
|
||||
"chat should have renamed name as name"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('default thread rendering', async function (assert) {
|
||||
assert.expect(16);
|
||||
|
||||
|
||||
-19
@@ -56,19 +56,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.o_DiscussSidebarCategoryItem_name {
|
||||
@include text-truncate();
|
||||
margin-left: 10px;
|
||||
|
||||
&.o-editable {
|
||||
margin-right: $o-mail-discuss-sidebar-scrollbar-width;
|
||||
}
|
||||
}
|
||||
|
||||
.o_DiscussSidebarCategoryItem_nameInput {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.o_DiscussSidebarCategoryItem_threadIcon {
|
||||
@include o-position-absolute($bottom: 0, $right: 0);
|
||||
|
||||
@@ -117,9 +104,3 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.o_DiscussSidebarCategoryItem_nameInput{
|
||||
outline: none;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
+3
-20
@@ -15,23 +15,9 @@
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
<t t-if="categoryItem.isRenaming">
|
||||
<span class="o_DiscussSidebarCategoryItem_item o_DiscussSidebarCategoryItem_name o-editable">
|
||||
<EditableText
|
||||
class="o_DiscussSidebarCategoryItem_nameInput"
|
||||
placeholder="categoryItem.channel.correspondent ? categoryItem.channel.correspondent.name : categoryItem.channel.name"
|
||||
value="categoryItem.channel.displayName"
|
||||
t-on-o-cancel="categoryItem.onCancelRenaming"
|
||||
t-on-o-clicked="categoryItem.onClickedEditableText"
|
||||
t-on-o-validate="categoryItem.onValidateEditableText"
|
||||
/>
|
||||
</span>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<span class="o_DiscussSidebarCategoryItem_item o_DiscussSidebarCategoryItem_name" t-att-class="{ 'o-item-unread': categoryItem.isUnread }">
|
||||
<t t-esc="categoryItem.channel.displayName"/>
|
||||
</span>
|
||||
</t>
|
||||
<span class="o_DiscussSidebarCategoryItem_item o_DiscussSidebarCategoryItem_name ml-3 text-truncate" t-att-class="{ 'o-item-unread': categoryItem.isUnread }">
|
||||
<t t-esc="categoryItem.channel.displayName"/>
|
||||
</span>
|
||||
<div class="o-autogrow o_DiscussSidebarCategoryItem_item"/>
|
||||
<div class="o_DiscussSidebarCategoryItem_item o_DiscussSidebarCategoryItem_commands">
|
||||
<t t-if="categoryItem.hasSettingsCommand">
|
||||
@@ -40,9 +26,6 @@
|
||||
<t t-if="categoryItem.hasLeaveCommand">
|
||||
<div class="o_DiscussSidebarCategoryItem_command o_DiscussSidebarCategoryItem_commandLeave fa fa-times" t-on-click="categoryItem.onClickCommandLeave" title="Leave this channel" role="img"/>
|
||||
</t>
|
||||
<t t-if="categoryItem.hasRenameCommand">
|
||||
<div class="o_DiscussSidebarCategoryItem_command o_DiscussSidebarCategoryItem_commandRename fa fa-cog" t-on-click="categoryItem.onClickCommandRename" title="Rename conversation" role="img"/>
|
||||
</t>
|
||||
<t t-if="categoryItem.hasUnpinCommand">
|
||||
<div class="o_DiscussSidebarCategoryItem_command o_DiscussSidebarCategoryItem_commandUnpin fa fa-times" t-on-click="categoryItem.onClickCommandUnpin" title="Unpin Conversation" role="img"/>
|
||||
</t>
|
||||
|
||||
@@ -10,14 +10,6 @@ function factory(dependencies) {
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Public
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @param {mail.thread} thread
|
||||
*/
|
||||
cancelThreadRenaming(thread) {
|
||||
this.update({ renamingThreads: unlink(thread) });
|
||||
}
|
||||
|
||||
clearIsAddingItem() {
|
||||
this.update({
|
||||
@@ -161,15 +153,6 @@ function factory(dependencies) {
|
||||
this.update({ isAddingChannel: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {mail.thread} thread
|
||||
* @param {string} newName
|
||||
*/
|
||||
onValidateEditableText(thread, newName) {
|
||||
this.update({ renamingThreads: unlink(thread) });
|
||||
thread.setCustomName(newName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open thread from init active id. `initActiveId` is used to refer to
|
||||
* a thread that we may not have full data yet, such as when messaging
|
||||
@@ -231,13 +214,6 @@ function factory(dependencies) {
|
||||
this.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {mail.thread} thread
|
||||
*/
|
||||
setThreadRenaming(thread) {
|
||||
this.update({ renamingThreads: link(thread) });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {mail.thread} thread
|
||||
* @returns {string}
|
||||
@@ -465,7 +441,6 @@ function factory(dependencies) {
|
||||
menu_id: attr({
|
||||
default: null,
|
||||
}),
|
||||
renamingThreads: one2many('mail.thread'),
|
||||
/**
|
||||
* The message that is currently selected as being replied to in Inbox.
|
||||
* There is only one reply composer shown at a time, which depends on
|
||||
|
||||
-66
@@ -14,14 +14,10 @@ function factory(dependencies) {
|
||||
* @override
|
||||
*/
|
||||
_created() {
|
||||
this.onCancelRenaming = this.onCancelRenaming.bind(this);
|
||||
this.onClick = this.onClick.bind(this);
|
||||
this.onClickCommandLeave = this.onClickCommandLeave.bind(this);
|
||||
this.onClickCommandRename = this.onClickCommandRename.bind(this);
|
||||
this.onClickCommandSettings = this.onClickCommandSettings.bind(this);
|
||||
this.onClickCommandUnpin = this.onClickCommandUnpin.bind(this);
|
||||
this.onClickedEditableText = this.onClickedEditableText.bind(this);
|
||||
this.onValidateEditableText = this.onValidateEditableText.bind(this);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -82,14 +78,6 @@ function factory(dependencies) {
|
||||
!this.channel.group_based_subscription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @returns {boolean}
|
||||
*/
|
||||
_computeHasRenameCommand() {
|
||||
return this.channelType === 'chat';
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @returns {boolean}
|
||||
@@ -114,14 +102,6 @@ function factory(dependencies) {
|
||||
return this.messaging.discuss && this.channel === this.messaging.discuss.thread;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @returns {boolean}
|
||||
*/
|
||||
_computeIsRenaming() {
|
||||
return this.messaging.discuss && this.hasRenameCommand && this.messaging.discuss.renamingThreads.includes(this.channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @returns {boolean}
|
||||
@@ -149,13 +129,6 @@ function factory(dependencies) {
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
onCancelRenaming(ev) {
|
||||
this.messaging.discuss.cancelThreadRenaming(this.channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
@@ -177,14 +150,6 @@ function factory(dependencies) {
|
||||
this.channel.unsubscribe();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
onClickCommandRename(ev) {
|
||||
ev.stopPropagation();
|
||||
this.messaging.discuss.setThreadRenaming(this.channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirects to channel form page when `settings` command is clicked.
|
||||
*
|
||||
@@ -211,25 +176,6 @@ function factory(dependencies) {
|
||||
this.channel.unsubscribe();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop propagation to prevent selecting this item.
|
||||
*
|
||||
* @param {CustomEvent} ev
|
||||
*/
|
||||
onClickedEditableText(ev) {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CustomEvent} ev
|
||||
* @param {Object} ev.detail
|
||||
* @param {string} ev.detail.newName
|
||||
*/
|
||||
onValidateEditableText(ev) {
|
||||
ev.stopPropagation();
|
||||
this.messaging.discuss.onValidateEditableText(this.channel, ev.detail.newName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @returns {Promise}
|
||||
@@ -276,12 +222,6 @@ function factory(dependencies) {
|
||||
hasLeaveCommand: attr({
|
||||
compute: '_computeHasLeaveCommand',
|
||||
}),
|
||||
/**
|
||||
* Boolean determines whether the item has a "rename" command.
|
||||
*/
|
||||
hasRenameCommand: attr({
|
||||
compute: '_computeHasRenameCommand',
|
||||
}),
|
||||
/**
|
||||
* Boolean determines whether the item has a "settings" command.
|
||||
*/
|
||||
@@ -306,12 +246,6 @@ function factory(dependencies) {
|
||||
isActive: attr({
|
||||
compute: '_computeIsActive',
|
||||
}),
|
||||
/**
|
||||
* Boolean determines whether the item is currently being renamed.
|
||||
*/
|
||||
isRenaming: attr({
|
||||
compute: '_computeIsRenaming',
|
||||
}),
|
||||
/**
|
||||
* Boolean determines whether the item has any unread messages.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user