A platform for community discussion. Free, open, simple.
UX: render description links in badge admin (#37272)
Kris7e9c9d4f174c
diff --git a/frontend/discourse/admin/components/admin-badges-show.gjs b/frontend/discourse/admin/components/admin-badges-show.gjsindex 5080c64f15b..10d0d1ef9ff 100644--- a/frontend/discourse/admin/components/admin-badges-show.gjs+++ b/frontend/discourse/admin/components/admin-badges-show.gjs@@ -4,6 +4,7 @@ import { concat, fn, hash } from "@ember/helper";import { action, getProperties } from "@ember/object";import { LinkTo } from "@ember/routing";import { service } from "@ember/service";+import { htmlSafe } from "@ember/template";import AdminBadgesList from "discourse/admin/components/admin-badges-list";import BadgePreviewModal from "discourse/admin/components/modal/badge-preview";import Form from "discourse/components/form";@@ -14,6 +15,7 @@ import lazyHash from "discourse/helpers/lazy-hash";import { ajax } from "discourse/lib/ajax";import { popupAjaxError } from "discourse/lib/ajax-error";import getURL from "discourse/lib/get-url";+import { sanitize } from "discourse/lib/text";import { i18n } from "discourse-i18n";const FORM_FIELDS = [@@ -78,6 +80,10 @@ export default class AdminBadgesShow extends Component {return `badges.${this.args.badge.i18n_name}.`;}+ sanitizeDescription(text) {+ return htmlSafe(sanitize(text));+ }+hasQuery(query) {return query?.trim?.()?.length > 0;}@@ -347,7 +353,7 @@ export default class AdminBadgesShow extends Component {@title={{i18n "admin.badges.description"}}><span class="readonly-field">- {{@badge.description}}+ {{this.sanitizeDescription @badge.description}}</span><LinkTo@route="adminSiteText"@@ -375,7 +381,7 @@ export default class AdminBadgesShow extends Component {@title={{i18n "admin.badges.long_description"}}><span class="readonly-field">- {{@badge.long_description}}+ {{this.sanitizeDescription @badge.long_description}}</span><LinkTodiff --git a/spec/system/admin_badges_spec.rb b/spec/system/admin_badges_spec.rbindex f911b721228..b1b5878d9b1 100644--- a/spec/system/admin_badges_spec.rb+++ b/spec/system/admin_badges_spec.rb@@ -31,8 +31,12 @@ describe "Admin Badges Page", type: :system doexpect(form.field("icon")).to be_enabledexpect(form.field("icon")).to have_value("user-pen")expect(form.container("name")).to have_content(badge.name.strip)- expect(form.container("description")).to have_content(badge.description.strip)- expect(form.container("long_description")).to have_content(badge.long_description.strip)+ expect(form.container("description")).to have_content(+ Nokogiri::HTML5.fragment(badge.description).text.strip,+ )+ expect(form.container("long_description")).to have_content(+ Nokogiri::HTML5.fragment(badge.long_description).text.strip,+ )endend