A platform for community discussion. Free, open, simple.
FIX: Pass correct params in tool approval card (#41817)
Penar Musarajb20b9a5e51c6
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-tool-approval.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-tool-approval.gjsindex bc5ebaeea09..e52c7470254 100644--- a/plugins/discourse-ai/assets/javascripts/discourse/components/ai-tool-approval.gjs+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/ai-tool-approval.gjs@@ -92,7 +92,7 @@ export default class AiToolApproval extends Component {@actionasync performAction(actionId) {- if (this.performing || !this.reviewable || !this.args.postId) {+ if (this.performing || !this.reviewable) {return;}@@ -102,7 +102,7 @@ export default class AiToolApproval extends Component {await ajax(`/review/${this.args.reviewableId}/perform/${actionId}`, {type: "PUT",data: {- post_id: this.args.postId,+ post_id: this.reviewable.post_id,version: this.reviewable.version,},});diff --git a/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-tool-approval.gjs b/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-tool-approval.gjsindex 22b0295b81e..1440bee45e1 100644--- a/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-tool-approval.gjs+++ b/plugins/discourse-ai/assets/javascripts/discourse/initializers/ai-tool-approval.gjs@@ -27,12 +27,7 @@ function initializeAiToolApproval(api) {helper.renderGlimmer(cardElement,- <template>- <AiToolApproval- @postId={{post.id}}- @reviewableId={{reviewableId}}- />- </template>+ <template><AiToolApproval @reviewableId={{reviewableId}} /></template>);});},diff --git a/plugins/discourse-ai/test/javascripts/integration/components/ai-tool-approval-test.gjs b/plugins/discourse-ai/test/javascripts/integration/components/ai-tool-approval-test.gjsindex 17f09c3a52c..82f0aba3f0a 100644--- a/plugins/discourse-ai/test/javascripts/integration/components/ai-tool-approval-test.gjs+++ b/plugins/discourse-ai/test/javascripts/integration/components/ai-tool-approval-test.gjs@@ -21,6 +21,7 @@ module("Integration | Component | AiToolApproval", function (hooks) {id: 42,version: 0,status: 0,+ post_id: 456,tool_name: "suspend_user",tool_parameters: { username: "baduser", duration_days: 7, reason: "Spam" },payload: { agent_name: "Snorlax" },@@ -33,16 +34,14 @@ module("Integration | Component | AiToolApproval", function (hooks) {pretender.put("/review/42/perform/approve", (request) => {assert.strictEqual(request.requestBody,- "post_id=123&version=0",- "sends the rendered post id with the inline action"+ "post_id=456&version=0",+ "sends the reviewable target post id with the inline action");return response({ reviewable_perform_result: { success: true } });});- await render(- <template><AiToolApproval @postId="123" @reviewableId="42" /></template>- );+ await render(<template><AiToolApproval @reviewableId="42" /></template>);assert.dom(".ai-tool-approval__value").exists("shows the tool's details");assert@@ -71,9 +70,7 @@ module("Integration | Component | AiToolApproval", function (hooks) {const approved = { ...reviewable, status: 1 };pretender.get("/review/42", () => response({ reviewable: approved }));- await render(- <template><AiToolApproval @postId="123" @reviewableId="42" /></template>- );+ await render(<template><AiToolApproval @reviewableId="42" /></template>);assert.dom(".ai-tool-approval__toggle")@@ -94,9 +91,7 @@ module("Integration | Component | AiToolApproval", function (hooks) {pretender.get("/review/42", () => response({ reviewable }));- await render(- <template><AiToolApproval @postId="123" @reviewableId="42" /></template>- );+ await render(<template><AiToolApproval @reviewableId="42" /></template>);assert.dom(".ai-tool-approval__actions")@@ -111,9 +106,7 @@ module("Integration | Component | AiToolApproval", function (hooks) {pretender.get("/review/42", () => response(403, {}));- await render(- <template><AiToolApproval @postId="123" @reviewableId="42" /></template>- );+ await render(<template><AiToolApproval @reviewableId="42" /></template>);assert.dom(".ai-tool-approval__status")