[FIX] mail: pass props to thread actions

Since [1] thread actions are stored in a specific registry.
Some of those actions require props to be passed to their
component.

Those props are not correctly passed as the `componentProps`
key is in fact a function that returns the props but is
treated as the props themselves.

This commit fixes this issue by transforming `componentProps`
into a getter, so that `action` is internally passed to
`componentProps` definition. The templates using thread
actions can still use `t-props="componentProps"` as getter,
as the active action is deduced by transform automatically.

[1]: odoo#123454

closes odoo/odoo#125120

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Alexandre Kühn
2023-06-15 18:51:48 +02:00
parent 91ba1c211a
commit af21d99a36
2 changed files with 30 additions and 1 deletions
@@ -35,7 +35,9 @@ function transformAction(component, id, action) {
return this.isActive && this.component && this.condition && !this.popover;
},
/** Props to pass to the component of this action. */
componentProps: action.componentProps,
get componentProps() {
return action.componentProps?.(this);
},
/** Condition to display this action. */
get condition() {
return action.condition(component);
@@ -29,6 +29,33 @@ QUnit.test(
}
);
QUnit.test("can invite users in channel from chat window", async (assert) => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({
email: "testpartner@odoo.com",
name: "TestPartner",
});
pyEnv["res.users"].create({ partner_id: partnerId });
pyEnv["discuss.channel"].create({
name: "TestChanel",
channel_member_ids: [
Command.create({ partner_id: pyEnv.currentPartnerId, is_minimized: true }),
],
channel_type: "channel",
});
await start();
await click("[title='More actions']");
await click("[title='Add Users']");
assert.containsOnce($, ".o-discuss-ChannelInvitation");
await click("div:contains(TestPartner) input[type='checkbox']");
await click("[title='Invite to Channel']");
assert.containsNone($, ".o-discuss-ChannelInvitation");
assert.containsOnce(
$,
".o-mail-Thread .o-mail-NotificationMessage:contains(Mitchell Admin invited TestPartner to the channel)"
);
});
QUnit.test(
"should be able to search for a new user to invite from an existing chat",
async (assert) => {