DEV: Remove 'htmlSafe' string prototype extensions (#16828)

Context: https://deprecations.emberjs.com/v3.x/#toc_ember-string-prototype_extensions
This commit is contained in:
Isaac Janzen 2022-05-13 16:24:05 -05:00 committed by GitHub
parent 85ceafb4dc
commit 4e622c9fd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 13 deletions

View File

@ -10,6 +10,7 @@ import deprecated from "discourse-common/lib/deprecated";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { getOwner } from "discourse-common/lib/get-owner"; import { getOwner } from "discourse-common/lib/get-owner";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { htmlSafe } from "@ember/template";
const Site = RestModel.extend({ const Site = RestModel.extend({
isReadOnly: alias("is_readonly"), isReadOnly: alias("is_readonly"),
@ -48,7 +49,7 @@ const Site = RestModel.extend({
if (!isEmpty(siteFields)) { if (!isEmpty(siteFields)) {
return siteFields.map((f) => { return siteFields.map((f) => {
let value = fields ? fields[f.id.toString()] : null; let value = fields ? fields[f.id.toString()] : null;
value = value || "—".htmlSafe(); value = value || htmlSafe("—");
return { name: f.name, value }; return { name: f.name, value };
}); });
} }

View File

@ -30,6 +30,7 @@ import { isEmpty } from "@ember/utils";
import { longDate } from "discourse/lib/formatter"; import { longDate } from "discourse/lib/formatter";
import { url } from "discourse/lib/computed"; import { url } from "discourse/lib/computed";
import { userPath } from "discourse/lib/url"; import { userPath } from "discourse/lib/url";
import { htmlSafe } from "@ember/template";
export const SECOND_FACTOR_METHODS = { export const SECOND_FACTOR_METHODS = {
TOTP: 1, TOTP: 1,
@ -176,9 +177,9 @@ const User = RestModel.extend({
@discourseComputed("profile_background_upload_url") @discourseComputed("profile_background_upload_url")
profileBackgroundUrl(bgUrl) { profileBackgroundUrl(bgUrl) {
if (isEmpty(bgUrl) || !this.siteSettings.allow_profile_backgrounds) { if (isEmpty(bgUrl) || !this.siteSettings.allow_profile_backgrounds) {
return "".htmlSafe(); return htmlSafe("");
} }
return ("background-image: url(" + getURLWithCDN(bgUrl) + ")").htmlSafe(); return htmlSafe("background-image: url(" + getURLWithCDN(bgUrl) + ")");
}, },
@discourseComputed() @discourseComputed()

View File

@ -5,6 +5,7 @@ import { findOrResetCachedTopicList } from "discourse/lib/cached-topic-list";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { iconHTML } from "discourse-common/lib/icon-library"; import { iconHTML } from "discourse-common/lib/icon-library";
import getURL from "discourse-common/lib/get-url"; import getURL from "discourse-common/lib/get-url";
import { htmlSafe } from "@ember/template";
export const NEW_FILTER = "new"; export const NEW_FILTER = "new";
export const UNREAD_FILTER = "unread"; export const UNREAD_FILTER = "unread";
@ -85,10 +86,12 @@ export default (inboxType, path, filter) => {
emptyState() { emptyState() {
const title = I18n.t("user.no_messages_title"); const title = I18n.t("user.no_messages_title");
const body = I18n.t("user.no_messages_body", { const body = htmlSafe(
I18n.t("user.no_messages_body", {
aboutUrl: getURL("/about"), aboutUrl: getURL("/about"),
icon: iconHTML("envelope"), icon: iconHTML("envelope"),
}).htmlSafe(); })
);
return { title, body }; return { title, body };
}, },

View File

@ -2,18 +2,21 @@ import UserActivityStreamRoute from "discourse/routes/user-activity-stream";
import { iconHTML } from "discourse-common/lib/icon-library"; import { iconHTML } from "discourse-common/lib/icon-library";
import getURL from "discourse-common/lib/get-url"; import getURL from "discourse-common/lib/get-url";
import I18n from "I18n"; import I18n from "I18n";
import { htmlSafe } from "@ember/template";
export default UserActivityStreamRoute.extend({ export default UserActivityStreamRoute.extend({
userActionType: null, userActionType: null,
emptyState() { emptyState() {
const title = I18n.t("user_activity.no_activity_title"); const title = I18n.t("user_activity.no_activity_title");
const body = I18n.t("user_activity.no_activity_body", { const body = htmlSafe(
I18n.t("user_activity.no_activity_body", {
topUrl: getURL("/top"), topUrl: getURL("/top"),
categoriesUrl: getURL("/categories"), categoriesUrl: getURL("/categories"),
preferencesUrl: getURL("/my/preferences"), preferencesUrl: getURL("/my/preferences"),
heartIcon: iconHTML("heart"), heartIcon: iconHTML("heart"),
}).htmlSafe(); })
);
return { title, body }; return { title, body };
}, },