FIX: action_code_path not being loaded for user-stream-item (#18577)

This commit fixes an issue where we had a typo in the
UserAction.stream query which meant that action_code_path
was not loaded correctly. Once that was fixed, we were also
not actually using the action_code_path in the user-stream-item,
so that has been fixed here too.

The bug this caused was that, when the link for the action was
clicked within the user-stream-item, the user would be redirected
to a URL ending with `[missing%20%%7Bpath%7D%20value]` because
the I18n call did not have the path present.
This commit is contained in:
Martin Brennan
2022-10-13 19:10:18 +10:00
committed by GitHub
parent c16cb0e00b
commit beaf009b4a
4 changed files with 17 additions and 4 deletions

View File

@@ -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")

View File

@@ -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
);
}
});
}