Skip to content

A platform for community discussion. Free, open, simple.

DEV: Display correctly the items in the post action summary (#33330)

Sérgio Saquetim85aad95be98d
diff --git a/app/assets/javascripts/discourse/app/models/post.js b/app/assets/javascripts/discourse/app/models/post.js
index fc809d72010..5413d2ad76b 100644
--- a/app/assets/javascripts/discourse/app/models/post.js
+++ b/app/assets/javascripts/discourse/app/models/post.js
@@ -768,7 +768,7 @@ export default class Post extends RestModel {
postId: this.id,
action: postAction.actionType.name_key,
canUndo: postAction.can_undo,
- description: postAction.translatedDescription,
+ description: postAction.actionType.translatedDescription,
};
});
}
diff --git a/app/assets/javascripts/discourse/app/widgets/actions-summary.js b/app/assets/javascripts/discourse/app/widgets/actions-summary.js
index fe5d934fdea..a4b811445c3 100644
--- a/app/assets/javascripts/discourse/app/widgets/actions-summary.js
+++ b/app/assets/javascripts/discourse/app/widgets/actions-summary.js
@@ -19,5 +19,5 @@ registerWidgetShim(
registerWidgetShim(
"actions-summary",
"section.post-actions",
- hbs`<Post::ActionsSummary @post={{@data}} />`
+ hbs`<Post::ActionsSummary @post={{@data.post}} />`
);
diff --git a/app/assets/javascripts/discourse/app/widgets/post.js b/app/assets/javascripts/discourse/app/widgets/post.js
index 7415d8da939..6b64f6c48dd 100644
--- a/app/assets/javascripts/discourse/app/widgets/post.js
+++ b/app/assets/javascripts/discourse/app/widgets/post.js
@@ -874,13 +874,14 @@ createWidget("post-body", {
tagName: "div.topic-body.clearfix",
html(attrs, state) {
+ const post = this.findAncestorModel();
const postContents = this.attach("post-contents", attrs);
let result = [this.attach("post-meta-data", attrs)];
result = result.concat(
applyDecorators(this, "after-meta-data", attrs, state)
);
result.push(postContents);
- result.push(this.attach("actions-summary", attrs));
+ result.push(this.attach("actions-summary", { post }));
result.push(this.attach("post-links", attrs));
return result;
diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/actions-summary-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/widgets/actions-summary-test.gjs
index 882e86844b1..07563bdb15f 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/actions-summary-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/actions-summary-test.gjs
@@ -1,3 +1,4 @@
+import { getOwner } from "@ember/owner";
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import MountWidget from "discourse/components/mount-widget";
@@ -7,18 +8,28 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
module("Integration | Component | Widget | actions-summary", function (hooks) {
setupRenderingTest(hooks);
- test("post deleted", async function (assert) {
- const args = {
- deletedAt: "2016-01-01",
- deletedBy: {
+ hooks.beforeEach(function () {
+ const store = getOwner(this).lookup("service:store");
+ const topic = store.createRecord("topic", { id: 123 });
+ const post = store.createRecord("post", {
+ id: 1,
+ post_number: 2,
+ topic,
+ deleted_at: "2016-01-01",
+ deleted_by: {
username: "eviltrout",
avatar_template: "/images/avatar.png",
},
- };
+ });
+
+ this.set("post", post);
+ });
+ test("post deleted", async function (assert) {
+ const data = { post: this.post };
await render(
<template>
- <MountWidget @widget="actions-summary" @args={{args}} />
+ <MountWidget @widget="actions-summary" @args={{data}} />
</template>
);