DEV: Remove 'htmlSafe' string prototype extensions (#16766)
Context: https://deprecations.emberjs.com/v3.x/#toc_ember-string-prototype_extensions
This commit is contained in:
@@ -6,6 +6,7 @@ import PermissionType from "discourse/models/permission-type";
|
||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
import { isNone } from "@ember/utils";
|
||||
import { setting } from "discourse/lib/computed";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
export default ComboBoxComponent.extend({
|
||||
pluginApiIdentifiers: ["category-chooser"],
|
||||
@@ -33,9 +34,9 @@ export default ComboBoxComponent.extend({
|
||||
const isString = typeof none === "string";
|
||||
return this.defaultItem(
|
||||
null,
|
||||
I18n.t(
|
||||
isString ? this.selectKit.options.none : "category.none"
|
||||
).htmlSafe()
|
||||
htmlSafe(
|
||||
I18n.t(isString ? this.selectKit.options.none : "category.none")
|
||||
)
|
||||
);
|
||||
} else if (
|
||||
this.allowUncategorizedTopics ||
|
||||
@@ -43,7 +44,7 @@ export default ComboBoxComponent.extend({
|
||||
) {
|
||||
return Category.findUncategorized();
|
||||
} else {
|
||||
return this.defaultItem(null, I18n.t("category.choose").htmlSafe());
|
||||
return this.defaultItem(null, htmlSafe(I18n.t("category.choose")));
|
||||
}
|
||||
},
|
||||
|
||||
@@ -54,12 +55,14 @@ export default ComboBoxComponent.extend({
|
||||
set(
|
||||
content,
|
||||
"label",
|
||||
categoryBadgeHTML(category, {
|
||||
link: false,
|
||||
hideParent: category ? !!category.parent_category_id : true,
|
||||
allowUncategorized: true,
|
||||
recursive: true,
|
||||
}).htmlSafe()
|
||||
htmlSafe(
|
||||
categoryBadgeHTML(category, {
|
||||
link: false,
|
||||
hideParent: category ? !!category.parent_category_id : true,
|
||||
allowUncategorized: true,
|
||||
recursive: true,
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import I18n from "I18n";
|
||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
import { computed } from "@ember/object";
|
||||
import { readOnly } from "@ember/object/computed";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
export const NO_CATEGORIES_ID = "no-categories";
|
||||
export const ALL_CATEGORIES_ID = "all-categories";
|
||||
@@ -100,11 +101,13 @@ export default ComboBoxComponent.extend({
|
||||
if (this.value) {
|
||||
const category = Category.findById(this.value);
|
||||
content.title = category.title;
|
||||
content.label = categoryBadgeHTML(category, {
|
||||
link: false,
|
||||
allowUncategorized: true,
|
||||
hideParent: true,
|
||||
}).htmlSafe();
|
||||
content.label = htmlSafe(
|
||||
categoryBadgeHTML(category, {
|
||||
link: false,
|
||||
allowUncategorized: true,
|
||||
hideParent: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return content;
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@ import discourseComputed from "discourse-common/utils/decorators";
|
||||
import layout from "select-kit/templates/components/category-drop/category-drop-header";
|
||||
import { readOnly } from "@ember/object/computed";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
export default ComboBoxSelectBoxHeaderComponent.extend({
|
||||
layout,
|
||||
@@ -43,7 +44,7 @@ export default ComboBoxSelectBoxHeaderComponent.extend({
|
||||
}
|
||||
}
|
||||
}
|
||||
return style.htmlSafe();
|
||||
return htmlSafe(style);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
import { computed } from "@ember/object";
|
||||
import layout from "select-kit/templates/components/category-row";
|
||||
import { setting } from "discourse/lib/computed";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
export default SelectKitRowComponent.extend({
|
||||
layout,
|
||||
@@ -49,22 +50,26 @@ export default SelectKitRowComponent.extend({
|
||||
}),
|
||||
|
||||
badgeForCategory: computed("category", "parentCategory", function () {
|
||||
return categoryBadgeHTML(this.category, {
|
||||
link: this.categoryLink,
|
||||
allowUncategorized:
|
||||
this.allowUncategorizedTopics || this.allowUncategorized,
|
||||
hideParent: !!this.parentCategory,
|
||||
topicCount: this.topicCount,
|
||||
}).htmlSafe();
|
||||
return htmlSafe(
|
||||
categoryBadgeHTML(this.category, {
|
||||
link: this.categoryLink,
|
||||
allowUncategorized:
|
||||
this.allowUncategorizedTopics || this.allowUncategorized,
|
||||
hideParent: !!this.parentCategory,
|
||||
topicCount: this.topicCount,
|
||||
})
|
||||
);
|
||||
}),
|
||||
|
||||
badgeForParentCategory: computed("parentCategory", function () {
|
||||
return categoryBadgeHTML(this.parentCategory, {
|
||||
link: this.categoryLink,
|
||||
allowUncategorized:
|
||||
this.allowUncategorizedTopics || this.allowUncategorized,
|
||||
recursive: true,
|
||||
}).htmlSafe();
|
||||
return htmlSafe(
|
||||
categoryBadgeHTML(this.parentCategory, {
|
||||
link: this.categoryLink,
|
||||
allowUncategorized:
|
||||
this.allowUncategorizedTopics || this.allowUncategorized,
|
||||
recursive: true,
|
||||
})
|
||||
);
|
||||
}),
|
||||
|
||||
parentCategory: computed("parentCategoryId", function () {
|
||||
|
||||
@@ -5,6 +5,7 @@ import MultiSelectComponent from "select-kit/components/multi-select";
|
||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
import { makeArray } from "discourse-common/lib/helpers";
|
||||
import { mapBy } from "@ember/object/computed";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
export default MultiSelectComponent.extend({
|
||||
pluginApiIdentifiers: ["category-selector"],
|
||||
@@ -70,11 +71,13 @@ export default MultiSelectComponent.extend({
|
||||
name: result[0].name,
|
||||
count: subcategoryIds.size - 1,
|
||||
}),
|
||||
label: categoryBadgeHTML(result[0], {
|
||||
link: false,
|
||||
recursive: true,
|
||||
plusSubcategories: subcategoryIds.size - 1,
|
||||
}).htmlSafe(),
|
||||
label: htmlSafe(
|
||||
categoryBadgeHTML(result[0], {
|
||||
link: false,
|
||||
recursive: true,
|
||||
plusSubcategories: subcategoryIds.size - 1,
|
||||
})
|
||||
),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
+12
-9
@@ -1,27 +1,30 @@
|
||||
import SelectKitRowComponent from "select-kit/components/select-kit/select-kit-row";
|
||||
import { computed } from "@ember/object";
|
||||
import layout from "select-kit/templates/components/color-palettes/color-palettes-row";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
export default SelectKitRowComponent.extend({
|
||||
classNames: ["color-palettes-row"],
|
||||
layout,
|
||||
|
||||
palettes: computed("item.colors.[]", function () {
|
||||
return (this.item.colors || [])
|
||||
.filter((color) => color.name !== "secondary")
|
||||
.map((color) => `#${escape(color.hex)}`)
|
||||
.map(
|
||||
(hex) => `<span class="palette" style="background-color:${hex}"></span>`
|
||||
)
|
||||
.join("")
|
||||
.htmlSafe();
|
||||
return htmlSafe(
|
||||
(this.item.colors || [])
|
||||
.filter((color) => color.name !== "secondary")
|
||||
.map((color) => `#${escape(color.hex)}`)
|
||||
.map(
|
||||
(hex) =>
|
||||
`<span class="palette" style="background-color:${hex}"></span>`
|
||||
)
|
||||
.join("")
|
||||
);
|
||||
}),
|
||||
|
||||
backgroundColor: computed("item.colors.[]", function () {
|
||||
const secondary = (this.item.colors || []).findBy("name", "secondary");
|
||||
|
||||
if (secondary && secondary.hex) {
|
||||
return `background-color:#${escape(secondary.hex)}`.htmlSafe();
|
||||
return htmlSafe(`background-color:#${escape(secondary.hex)}`);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
+7
-4
@@ -2,15 +2,18 @@ import SelectedNameComponent from "select-kit/components/selected-name";
|
||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
import { computed } from "@ember/object";
|
||||
import layout from "select-kit/templates/components/multi-select/selected-category";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
export default SelectedNameComponent.extend({
|
||||
classNames: ["selected-category"],
|
||||
layout,
|
||||
|
||||
badge: computed("item", function () {
|
||||
return categoryBadgeHTML(this.item, {
|
||||
allowUncategorized: true,
|
||||
link: false,
|
||||
}).htmlSafe();
|
||||
return htmlSafe(
|
||||
categoryBadgeHTML(this.item, {
|
||||
allowUncategorized: true,
|
||||
link: false,
|
||||
})
|
||||
);
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import SelectedNameComponent from "select-kit/components/selected-name";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
export default SelectedNameComponent.extend({
|
||||
classNames: ["select-kit-selected-color"],
|
||||
|
||||
@discourseComputed("name")
|
||||
footerContent(name) {
|
||||
return `<span class="color-preview" style="background:#${name}"></span>`.htmlSafe();
|
||||
return htmlSafe(
|
||||
`<span class="color-preview" style="background:#${name}"></span>`
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import CategoryRowComponent from "select-kit/components/category-row";
|
||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import layout from "select-kit/templates/components/category-row";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
export default CategoryRowComponent.extend({
|
||||
layout,
|
||||
@@ -9,10 +10,12 @@ export default CategoryRowComponent.extend({
|
||||
|
||||
@discourseComputed("category")
|
||||
badgeForCategory(category) {
|
||||
return categoryBadgeHTML(category, {
|
||||
link: this.categoryLink,
|
||||
allowUncategorized: true,
|
||||
hideParent: true,
|
||||
}).htmlSafe();
|
||||
return htmlSafe(
|
||||
categoryBadgeHTML(category, {
|
||||
link: this.categoryLink,
|
||||
allowUncategorized: true,
|
||||
hideParent: true,
|
||||
})
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { action, computed } from "@ember/object";
|
||||
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
|
||||
import I18n from "I18n";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
const UNPINNED = "unpinned";
|
||||
const PINNED = "pinned";
|
||||
@@ -20,7 +21,7 @@ export default DropdownSelectBoxComponent.extend({
|
||||
const state = pinned ? `pinned${globally}` : UNPINNED;
|
||||
const title = I18n.t(`topic_statuses.${state}.title`);
|
||||
|
||||
content.label = `<span>${title}</span>`.htmlSafe();
|
||||
content.label = htmlSafe(`<span>${title}</span>`);
|
||||
content.title = title;
|
||||
content.name = state;
|
||||
content.icon = `thumbtack${state === UNPINNED ? " unpinned" : ""}`;
|
||||
|
||||
@@ -2,6 +2,7 @@ import layout from "select-kit/templates/components/selected-choice-category";
|
||||
import SelectedChoiceComponent from "select-kit/components/selected-choice";
|
||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
import { computed } from "@ember/object";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
|
||||
export default SelectedChoiceComponent.extend({
|
||||
tagName: "",
|
||||
@@ -9,9 +10,11 @@ export default SelectedChoiceComponent.extend({
|
||||
extraClass: "selected-choice-category",
|
||||
|
||||
badge: computed("item", function () {
|
||||
return categoryBadgeHTML(this.item, {
|
||||
allowUncategorized: true,
|
||||
link: false,
|
||||
}).htmlSafe();
|
||||
return htmlSafe(
|
||||
categoryBadgeHTML(this.item, {
|
||||
allowUncategorized: true,
|
||||
link: false,
|
||||
})
|
||||
);
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user