From 4e622c9fd8a14aad5b2bd2fba6f4ca948706c131 Mon Sep 17 00:00:00 2001 From: Isaac Janzen <50783505+janzenisaac@users.noreply.github.com> Date: Fri, 13 May 2022 16:24:05 -0500 Subject: [PATCH] DEV: Remove 'htmlSafe' string prototype extensions (#16828) Context: https://deprecations.emberjs.com/v3.x/#toc_ember-string-prototype_extensions --- .../javascripts/discourse/app/models/site.js | 3 ++- .../javascripts/discourse/app/models/user.js | 5 +++-- .../app/routes/build-private-messages-route.js | 11 +++++++---- .../discourse/app/routes/user-activity-index.js | 15 +++++++++------ 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/discourse/app/models/site.js b/app/assets/javascripts/discourse/app/models/site.js index 50e9ee0196b..4a9725ad377 100644 --- a/app/assets/javascripts/discourse/app/models/site.js +++ b/app/assets/javascripts/discourse/app/models/site.js @@ -10,6 +10,7 @@ import deprecated from "discourse-common/lib/deprecated"; import discourseComputed from "discourse-common/utils/decorators"; import { getOwner } from "discourse-common/lib/get-owner"; import { isEmpty } from "@ember/utils"; +import { htmlSafe } from "@ember/template"; const Site = RestModel.extend({ isReadOnly: alias("is_readonly"), @@ -48,7 +49,7 @@ const Site = RestModel.extend({ if (!isEmpty(siteFields)) { return siteFields.map((f) => { let value = fields ? fields[f.id.toString()] : null; - value = value || "—".htmlSafe(); + value = value || htmlSafe("—"); return { name: f.name, value }; }); } diff --git a/app/assets/javascripts/discourse/app/models/user.js b/app/assets/javascripts/discourse/app/models/user.js index 981b4619e73..646ac080051 100644 --- a/app/assets/javascripts/discourse/app/models/user.js +++ b/app/assets/javascripts/discourse/app/models/user.js @@ -30,6 +30,7 @@ import { isEmpty } from "@ember/utils"; import { longDate } from "discourse/lib/formatter"; import { url } from "discourse/lib/computed"; import { userPath } from "discourse/lib/url"; +import { htmlSafe } from "@ember/template"; export const SECOND_FACTOR_METHODS = { TOTP: 1, @@ -176,9 +177,9 @@ const User = RestModel.extend({ @discourseComputed("profile_background_upload_url") profileBackgroundUrl(bgUrl) { 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() diff --git a/app/assets/javascripts/discourse/app/routes/build-private-messages-route.js b/app/assets/javascripts/discourse/app/routes/build-private-messages-route.js index b625a698ce8..d23ca2aac09 100644 --- a/app/assets/javascripts/discourse/app/routes/build-private-messages-route.js +++ b/app/assets/javascripts/discourse/app/routes/build-private-messages-route.js @@ -5,6 +5,7 @@ import { findOrResetCachedTopicList } from "discourse/lib/cached-topic-list"; import { action } from "@ember/object"; import { iconHTML } from "discourse-common/lib/icon-library"; import getURL from "discourse-common/lib/get-url"; +import { htmlSafe } from "@ember/template"; export const NEW_FILTER = "new"; export const UNREAD_FILTER = "unread"; @@ -85,10 +86,12 @@ export default (inboxType, path, filter) => { emptyState() { const title = I18n.t("user.no_messages_title"); - const body = I18n.t("user.no_messages_body", { - aboutUrl: getURL("/about"), - icon: iconHTML("envelope"), - }).htmlSafe(); + const body = htmlSafe( + I18n.t("user.no_messages_body", { + aboutUrl: getURL("/about"), + icon: iconHTML("envelope"), + }) + ); return { title, body }; }, diff --git a/app/assets/javascripts/discourse/app/routes/user-activity-index.js b/app/assets/javascripts/discourse/app/routes/user-activity-index.js index 435f5a7cbb2..313dcff0a43 100644 --- a/app/assets/javascripts/discourse/app/routes/user-activity-index.js +++ b/app/assets/javascripts/discourse/app/routes/user-activity-index.js @@ -2,18 +2,21 @@ import UserActivityStreamRoute from "discourse/routes/user-activity-stream"; import { iconHTML } from "discourse-common/lib/icon-library"; import getURL from "discourse-common/lib/get-url"; import I18n from "I18n"; +import { htmlSafe } from "@ember/template"; export default UserActivityStreamRoute.extend({ userActionType: null, emptyState() { const title = I18n.t("user_activity.no_activity_title"); - const body = I18n.t("user_activity.no_activity_body", { - topUrl: getURL("/top"), - categoriesUrl: getURL("/categories"), - preferencesUrl: getURL("/my/preferences"), - heartIcon: iconHTML("heart"), - }).htmlSafe(); + const body = htmlSafe( + I18n.t("user_activity.no_activity_body", { + topUrl: getURL("/top"), + categoriesUrl: getURL("/categories"), + preferencesUrl: getURL("/my/preferences"), + heartIcon: iconHTML("heart"), + }) + ); return { title, body }; },