A platform for community discussion. Free, open, simple.
FIX: action_code_path not being loaded for user-stream-item (#18577)
Martin Brennanbeaf009b4a31
diff --git a/app/assets/javascripts/discourse/app/components/user-stream-item.js b/app/assets/javascripts/discourse/app/components/user-stream-item.jsindex 1928eedae62..d64fa25ca97 100644--- a/app/assets/javascripts/discourse/app/components/user-stream-item.js+++ b/app/assets/javascripts/discourse/app/components/user-stream-item.js@@ -28,7 +28,8 @@ export default Component.extend({actionDescription: actionDescription("item.action_code","item.created_at",- "item.action_code_who"+ "item.action_code_who",+ "item.action_code_path"),@discourseComputed("item.draft_username", "item.username")diff --git a/app/assets/javascripts/discourse/app/widgets/post-small-action.js b/app/assets/javascripts/discourse/app/widgets/post-small-action.jsindex eaed3735359..e13857f3311 100644--- a/app/assets/javascripts/discourse/app/widgets/post-small-action.js+++ b/app/assets/javascripts/discourse/app/widgets/post-small-action.js@@ -26,11 +26,21 @@ export function actionDescriptionHtml(actionCode, createdAt, username, path) {return htmlSafe(I18n.t(`action_codes.${actionCode}`, { who, when, path }));}-export function actionDescription(actionCode, createdAt, username) {+export function actionDescription(+ actionCode,+ createdAt,+ username,+ path = null+) {return computed(actionCode, createdAt, function () {const ac = this.get(actionCode);if (ac) {- return actionDescriptionHtml(ac, this.get(createdAt), this.get(username));+ return actionDescriptionHtml(+ ac,+ this.get(createdAt),+ this.get(username),+ path ? this.get(path) : null+ );}});}diff --git a/app/models/user_action.rb b/app/models/user_action.rbindex 4f13a970a9e..25eabac3ff4 100644--- a/app/models/user_action.rb+++ b/app/models/user_action.rb@@ -232,7 +232,7 @@ class UserAction < ActiveRecord::BaseJOIN users au on au.id = a.user_idLEFT JOIN categories c on c.id = t.category_idLEFT JOIN post_custom_fields pc ON pc.post_id = a.target_post_id AND pc.name = 'action_code_who'- LEFT JOIN post_custom_fields pc2 ON pc2.post_id = a.target_post_id AND pc.name = 'action_code_path'+ LEFT JOIN post_custom_fields pc2 ON pc2.post_id = a.target_post_id AND pc2.name = 'action_code_path'/*where*//*order_by*//*offset*/diff --git a/spec/models/user_action_spec.rb b/spec/models/user_action_spec.rbindex d47309c01a4..17a95f01e02 100644--- a/spec/models/user_action_spec.rb+++ b/spec/models/user_action_spec.rb@@ -122,6 +122,7 @@ RSpec.describe UserAction dolog_test_action(action_type: UserAction::ASSIGNED)private_post.custom_fields ||= {}private_post.custom_fields["action_code_who"] = 'testing'+ private_post.custom_fields["action_code_path"] = '/p/1234'private_post.custom_fields["random_field"] = 'random_value'private_post.save!end@@ -133,6 +134,7 @@ RSpec.describe UserAction doexpect(user_action_row.action_type).to eq(UserAction::ASSIGNED)expect(user_action_row.action_code_who).to eq('testing')+ expect(user_action_row.action_code_path).to eq('/p/1234')endend