diff --git a/app/assets/javascripts/discourse/app/widgets/post-small-action.js b/app/assets/javascripts/discourse/app/widgets/post-small-action.js index f7a0bb6df75..94c032d3820 100644 --- a/app/assets/javascripts/discourse/app/widgets/post-small-action.js +++ b/app/assets/javascripts/discourse/app/widgets/post-small-action.js @@ -128,20 +128,24 @@ export default createWidget("post-small-action", { }) ); - const description = actionDescriptionHtml( - attrs.actionCode, - new Date(attrs.created_at), - attrs.actionCodeWho, - attrs.actionCodePath - ); - contents.push(new RawHtml({ html: `

${description}

` })); - - if (attrs.cooked) { - contents.push( - new RawHtml({ - html: `
${attrs.cooked}
`, - }) + if (attrs.actionDescriptionWidget) { + contents.push(this.attach(attrs.actionDescriptionWidget, attrs)); + } else { + const description = actionDescriptionHtml( + attrs.actionCode, + new Date(attrs.created_at), + attrs.actionCodeWho, + attrs.actionCodePath ); + contents.push(new RawHtml({ html: `

${description}

` })); + + if (attrs.cooked) { + contents.push( + new RawHtml({ + html: `
${attrs.cooked}
`, + }) + ); + } } return [ diff --git a/app/assets/javascripts/discourse/tests/integration/widgets/post-small-action-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/post-small-action-test.js index 087835ab12e..e50ddc735e6 100644 --- a/app/assets/javascripts/discourse/tests/integration/widgets/post-small-action-test.js +++ b/app/assets/javascripts/discourse/tests/integration/widgets/post-small-action-test.js @@ -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() {