mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 21:55:40 +08:00
FIX: Add missing string for reviewables in user menu when reviewable post is deleted (#18295)
This commit is contained in:
parent
ea27079ffa
commit
3d2de7ca03
@ -1,6 +1,7 @@
|
|||||||
import ReviewableTypeBase from "discourse/lib/reviewable-types/base";
|
import ReviewableTypeBase from "discourse/lib/reviewable-types/base";
|
||||||
import { htmlSafe } from "@ember/template";
|
import { htmlSafe } from "@ember/template";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
import { emojiUnescape } from "discourse/lib/text";
|
||||||
|
|
||||||
export default class extends ReviewableTypeBase {
|
export default class extends ReviewableTypeBase {
|
||||||
get description() {
|
get description() {
|
||||||
@ -10,11 +11,11 @@ export default class extends ReviewableTypeBase {
|
|||||||
return htmlSafe(
|
return htmlSafe(
|
||||||
I18n.t("user_menu.reviewable.post_number_with_topic_title", {
|
I18n.t("user_menu.reviewable.post_number_with_topic_title", {
|
||||||
post_number: postNumber,
|
post_number: postNumber,
|
||||||
title,
|
title: emojiUnescape(title),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return I18n.t("user_menu.reviewable.delete_post");
|
return I18n.t("user_menu.reviewable.deleted_post");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import { test } from "qunit";
|
||||||
|
import { createRenderDirector } from "discourse/tests/helpers/reviewable-types-helper";
|
||||||
|
import { htmlSafe } from "@ember/template";
|
||||||
|
import { emojiUnescape } from "discourse/lib/text";
|
||||||
|
import UserMenuReviewable from "discourse/models/user-menu-reviewable";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
|
function getReviewable(overrides = {}) {
|
||||||
|
return UserMenuReviewable.create(
|
||||||
|
Object.assign(
|
||||||
|
{
|
||||||
|
flagger_username: "sayo2",
|
||||||
|
id: 17,
|
||||||
|
pending: false,
|
||||||
|
type: "ReviewableFlaggedPost",
|
||||||
|
topic_fancy_title: "anything hello world",
|
||||||
|
post_number: 1,
|
||||||
|
},
|
||||||
|
overrides
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
discourseModule("Unit | Reviewable Items | flagged-post", function () {
|
||||||
|
test("description", function (assert) {
|
||||||
|
const reviewable = getReviewable({
|
||||||
|
topic_fancy_title: "This is safe title <a> :heart:",
|
||||||
|
});
|
||||||
|
const director = createRenderDirector(
|
||||||
|
reviewable,
|
||||||
|
"ReviewableFlaggedPost",
|
||||||
|
this.siteSettings
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
director.description,
|
||||||
|
htmlSafe(
|
||||||
|
I18n.t("user_menu.reviewable.post_number_with_topic_title", {
|
||||||
|
title: `This is safe title <a> ${emojiUnescape(":heart:")}`,
|
||||||
|
post_number: 1,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
"contains the fancy title without escaping because it's already safe"
|
||||||
|
);
|
||||||
|
|
||||||
|
delete reviewable.topic_fancy_title;
|
||||||
|
delete reviewable.post_number;
|
||||||
|
assert.deepEqual(
|
||||||
|
director.description,
|
||||||
|
I18n.t("user_menu.reviewable.deleted_post"),
|
||||||
|
"falls back to generic string when the post/topic is deleted"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
@ -2610,6 +2610,7 @@ en:
|
|||||||
view_all: "view all review items"
|
view_all: "view all review items"
|
||||||
queue: "Queue"
|
queue: "Queue"
|
||||||
deleted_user: "(deleted user)"
|
deleted_user: "(deleted user)"
|
||||||
|
deleted_post: "(deleted post)"
|
||||||
post_number_with_topic_title: "post #%{post_number} - %{title}"
|
post_number_with_topic_title: "post #%{post_number} - %{title}"
|
||||||
new_post_in_topic: "new post in %{title}"
|
new_post_in_topic: "new post in %{title}"
|
||||||
user_requires_approval: "%{username} requires approval"
|
user_requires_approval: "%{username} requires approval"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user