DEV: implements actionDecriptionWidget (#15367)

This will allow to have more complex behaviors in post-small-actions, while keeping most of the behavior consistent.
This commit is contained in:
Joffrey JAFFEUX 2021-12-20 14:53:43 +01:00 committed by GitHub
parent d5e380e5c1
commit 40d1bbab5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 13 deletions

View File

@ -128,6 +128,9 @@ export default createWidget("post-small-action", {
})
);
if (attrs.actionDescriptionWidget) {
contents.push(this.attach(attrs.actionDescriptionWidget, attrs));
} else {
const description = actionDescriptionHtml(
attrs.actionCode,
new Date(attrs.created_at),
@ -143,6 +146,7 @@ export default createWidget("post-small-action", {
})
);
}
}
return [
h("div.topic-avatar", iconNode(icons[attrs.actionCode] || "exclamation")),

View File

@ -34,6 +34,19 @@ discourseModule(
},
});
componentTest("uses custom widget if actionDescriptionWidget", {
template: hbs`{{mount-widget widget="post-small-action" args=args}}`,
beforeEach() {
this.set("args", { id: 123, actionDescriptionWidget: "button" });
},
async test(assert) {
assert.ok(
exists(".small-action .widget-button"),
"it adds the custom widget"
);
},
});
componentTest("does not show edit button if canRecover even if canEdit", {
template: hbs`{{mount-widget widget="post-small-action" args=args}}`,
beforeEach() {