A platform for community discussion. Free, open, simple.
DEV: [gjs-codemod] merge js and hbs
David Taylore401d795c619
diff --cc app/assets/javascripts/discourse/app/components/anonymous-topic-footer-buttons.gjsindex 79c32e97f75,73a2703ef66..304d0929a85--- a/app/assets/javascripts/discourse/app/components/anonymous-topic-footer-buttons.gjs+++ b/app/assets/javascripts/discourse/app/components/anonymous-topic-footer-buttons.gjs@@@ -1,24 -1,20 +1,45 @@@+ import Component from "@ember/component";+ import { computed } from "@ember/object";+ import { attributeBindings } from "@ember-decorators/component";+ import { getTopicFooterButtons } from "discourse/lib/register-topic-footer-button";++ @attributeBindings("role")+ export default class AnonymousTopicFooterButtons extends Component {+ elementId = "topic-footer-buttons";+ role = "region";++ @getTopicFooterButtons() allButtons;++ @computed("allButtons.[]")+ get buttons() {+ return this.allButtons+ .filterBy("anonymousOnly", true)+ .sortBy("priority")+ .reverse();+ }+ }+++<div class="topic-footer-main-buttons">+ {{#each this.buttons as |button|}}+ <DButton+ @action={{button.action}}+ @icon={{button.icon}}+ @translatedLabel={{button.label}}+ @translatedTitle={{button.title}}+ @translatedAriaLabel={{button.ariaLabel}}+ @disabled={{button.disabled}}+ id={{concat "topic-footer-button-" button.id}}+ class={{concatClass+ "btn-default"+ "topic-footer-button"+ button.classNames+ }}+ />+ {{/each}}+ <DButton+ @icon="reply"+ @action={{route-action "showLogin"}}+ @label="topic.reply.title"+ class="btn-primary"+ />+</div>diff --cc app/assets/javascripts/discourse/app/components/edit-category-panel.gjsindex 58c53a53d3c,4573a5cb90d..af59213910a--- a/app/assets/javascripts/discourse/app/components/edit-category-panel.gjs+++ b/app/assets/javascripts/discourse/app/components/edit-category-panel.gjs@@@ -1,6 -1,17 +1,24 @@@+ import Component from "@ember/component";+ import { equal } from "@ember/object/computed";+ import { classNameBindings } from "@ember-decorators/component";++ export default class EditCategoryPanel extends Component {}++ export function buildCategoryPanel(tab) {+ @classNameBindings(+ ":edit-category-tab",+ "activeTab:active",+ `:edit-category-tab-${tab}`+ )+ class BuiltCategoryPanel extends EditCategoryPanel {+ @equal("selectedTab", tab) activeTab;+ }+ return BuiltCategoryPanel;+ }+++{{component+ this.customComponent+ tab=this.tab+ selectedTab=this.selectedTab+ category=this.category+}}diff --cc app/assets/javascripts/discourse/app/components/modal/customize-form-template-view.gjsindex ce1ee6128d9,387d553763d..da08330735b--- a/app/assets/javascripts/discourse/app/components/modal/customize-form-template-view.gjs+++ b/app/assets/javascripts/discourse/app/components/modal/customize-form-template-view.gjs@@@ -1,37 -1,45 +1,83 @@@+ import Component from "@glimmer/component";+ import { tracked } from "@glimmer/tracking";+ import { action } from "@ember/object";+ import { service } from "@ember/service";+ import { ajax } from "discourse/lib/ajax";+ import { popupAjaxError } from "discourse/lib/ajax-error";+ import { i18n } from "discourse-i18n";++ export default class CustomizeFormTemplateViewModal extends Component {+ @service router;+ @service dialog;++ @tracked showPreview = false;++ @action+ togglePreview() {+ this.showPreview = !this.showPreview;+ }++ @action+ editTemplate() {+ this.router.transitionTo(+ "adminCustomizeFormTemplates.edit",+ this.args.model+ );+ }++ @action+ deleteTemplate() {+ return this.dialog.yesNoConfirm({+ message: i18n("admin.form_templates.delete_confirm", {+ template_name: this.args.model.name,+ }),+ didConfirm: () => {+ ajax(`/admin/customize/form-templates/${this.args.model.id}.json`, {+ type: "DELETE",+ })+ .then(() => {+ this.args.refreshModel();+ })+ .catch(popupAjaxError);+ },+ });+ }+ }+++<DModal+ @title={{@model.name}}+ @closeModal={{@closeModal}}+ class="customize-form-template-view-modal"+>+ <:body>+ <div class="control-group">+ <DToggleSwitch+ class="form-templates__preview-toggle"+ @state={{this.showPreview}}+ @label="admin.form_templates.view_template.toggle_preview"+ {{on "click" this.togglePreview}}+ />+ </div>+ {{#if this.showPreview}}+ <FormTemplateField::Wrapper @id={{@model.id}} />+ {{else}}+ <HighlightedCode @lang="yaml" @code={{@model.template}} />+ {{/if}}+ </:body>++ <:footer>+ <DButton+ class="btn-primary"+ @action={{this.editTemplate}}+ @icon="pencil"+ @label="admin.form_templates.view_template.edit"+ />+ <DModalCancel @close={{@closeModal}} />+ <DButton+ class="btn-danger"+ @action={{this.deleteTemplate}}+ @icon="trash-can"+ @label="admin.form_templates.view_template.delete"+ />+ </:footer>+</DModal>diff --cc app/assets/javascripts/discourse/app/components/reviewable-item.gjsindex 9d32880d2dd,3638c92752d..1c2ef531952--- a/app/assets/javascripts/discourse/app/components/reviewable-item.gjs+++ b/app/assets/javascripts/discourse/app/components/reviewable-item.gjs@@@ -1,153 -1,522 +1,676 @@@+ import { tracked } from "@glimmer/tracking";+ import Component from "@ember/component";+ import { action, set } from "@ember/object";+ import { alias } from "@ember/object/computed";+ import { getOwner } from "@ember/owner";+ import { service } from "@ember/service";+ import { classify, dasherize } from "@ember/string";+ import { tagName } from "@ember-decorators/component";+ import ExplainReviewableModal from "discourse/components/modal/explain-reviewable";+ import RejectReasonReviewableModal from "discourse/components/modal/reject-reason-reviewable";+ import ReviseAndRejectPostReviewable from "discourse/components/modal/revise-and-reject-post-reviewable";+ import { ajax } from "discourse/lib/ajax";+ import { popupAjaxError } from "discourse/lib/ajax-error";+ import discourseComputed, { bind } from "discourse/lib/decorators";+ import optionalService from "discourse/lib/optional-service";+ import Category from "discourse/models/category";+ import Composer from "discourse/models/composer";+ import Topic from "discourse/models/topic";+ import { i18n } from "discourse-i18n";++ let _components = {};++ const pluginReviewableParams = {};++ // The mappings defined here are default core mappings, and cannot be overridden+ // by plugins.+ const defaultActionModalClassMap = {+ revise_and_reject_post: ReviseAndRejectPostReviewable,+ };+ const actionModalClassMap = { ...defaultActionModalClassMap };++ export function addPluginReviewableParam(reviewableType, param) {+ pluginReviewableParams[reviewableType]+ ? pluginReviewableParams[reviewableType].push(param)+ : (pluginReviewableParams[reviewableType] = [param]);+ }++ export function registerReviewableActionModal(actionName, modalClass) {+ if (Object.keys(defaultActionModalClassMap).includes(actionName)) {+ throw new Error(+ `Cannot override default action modal class for ${actionName} (mapped to ${defaultActionModalClassMap[actionName].name})!`+ );+ }+ actionModalClassMap[actionName] = modalClass;+ }++ @tagName("")+ export default class ReviewableItem extends Component {+ @service dialog;+ @service modal;+ @service siteSettings;+ @service currentUser;+ @service composer;+ @service store;+ @service toasts;+ @optionalService adminTools;++ @tracked disabled = false;++ @alias("reviewable.claimed_by.automatic") autoClaimed;++ updating = null;+ editing = false;+ _updates = null;++ constructor() {+ super(...arguments);+ this.messageBus.subscribe("/reviewable_claimed", this._updateClaimedBy);+ this.messageBus.subscribe("/reviewable_action", this._updateStatus);+ }++ willDestroy() {+ super.willDestroy(...arguments);+ this.messageBus.unsubscribe("/reviewable_claimed", this._updateClaimedBy);+ this.messageBus.unsubscribe("/reviewable_action", this._updateStatus);+ }++ @discourseComputed(+ "reviewable.type",+ "reviewable.last_performing_username",+ "siteSettings.blur_tl0_flagged_posts_media",+ "reviewable.target_created_by_trust_level",+ "reviewable.deleted_at"+ )+ customClasses(+ type,+ lastPerformingUsername,+ blurEnabled,+ trustLevel,+ deletedAt+ ) {+ let classes = dasherize(type);++ if (lastPerformingUsername) {+ classes = `${classes} reviewable-stale`;+ }++ if (blurEnabled && trustLevel === 0) {+ classes = `${classes} blur-images`;+ }++ if (deletedAt) {+ classes = `${classes} reviewable-deleted`;+ }++ return classes;+ }++ @discourseComputed(+ "reviewable.created_from_flag",+ "reviewable.status",+ "claimOptional",+ "claimRequired",+ "reviewable.claimed_by"+ )+ displayContextQuestion(+ createdFromFlag,+ status,+ claimOptional,+ claimRequired,+ claimedBy+ ) {+ return (+ createdFromFlag &&+ status === 0 &&+ (claimOptional || (claimRequired && claimedBy !== null))+ );+ }++ @discourseComputed(+ "reviewable.topic",+ "reviewable.topic_id",+ "reviewable.removed_topic_id"+ )+ topicId(topic, topicId, removedTopicId) {+ return (topic && topic.id) || topicId || removedTopicId;+ }++ @discourseComputed(+ "siteSettings.reviewable_claiming",+ "topicId",+ "reviewable.claimed_by.automatic"+ )+ claimEnabled(claimMode, topicId, autoClaimed) {+ return (claimMode !== "disabled" || autoClaimed) && !!topicId;+ }++ @discourseComputed("siteSettings.reviewable_claiming", "claimEnabled")+ claimOptional(claimMode, claimEnabled) {+ return !claimEnabled || claimMode === "optional";+ }++ @discourseComputed("siteSettings.reviewable_claiming", "claimEnabled")+ claimRequired(claimMode, claimEnabled) {+ return claimEnabled && claimMode === "required";+ }++ @discourseComputed(+ "claimEnabled",+ "siteSettings.reviewable_claiming",+ "reviewable.claimed_by"+ )+ canPerform(claimEnabled, claimMode, claimedBy) {+ if (!claimEnabled) {+ return true;+ }++ if (claimedBy) {+ return claimedBy.user.id === this.currentUser.id;+ }++ return claimMode !== "required";+ }++ @discourseComputed(+ "siteSettings.reviewable_claiming",+ "reviewable.claimed_by"+ )+ claimHelp(claimMode, claimedBy) {+ if (claimedBy) {+ if (claimedBy.user.id === this.currentUser.id) {+ return i18n("review.claim_help.claimed_by_you");+ } else if (claimedBy.automatic) {+ return i18n("review.claim_help.automatically_claimed_by", {+ username: claimedBy.user.username,+ });+ } else {+ return i18n("review.claim_help.claimed_by_other", {+ username: claimedBy.user.username,+ });+ }+ }++ return claimMode === "optional"+ ? i18n("review.claim_help.optional")+ : i18n("review.claim_help.required");+ }++ // Find a component to render, if one exists. For example:+ // `ReviewableUser` will return `reviewable-user`+ @discourseComputed("reviewable.type")+ reviewableComponent(type) {+ if (_components[type] !== undefined) {+ return _components[type];+ }++ const dasherized = dasherize(type);+ const owner = getOwner(this);+ const componentExists =+ owner.hasRegistration(`component:${dasherized}`) ||+ owner.hasRegistration(`template:components/${dasherized}`);+ _components[type] = componentExists ? dasherized : null;+ return _components[type];+ }++ @discourseComputed("_updates.category_id", "reviewable.category.id")+ tagCategoryId(updatedCategoryId, categoryId) {+ return updatedCategoryId || categoryId;+ }++ @discourseComputed("reviewable.type", "reviewable.target_created_by")+ showIpLookup(reviewableType) {+ return (+ reviewableType !== "ReviewableUser" &&+ this.currentUser.staff &&+ this.reviewable.target_created_by+ );+ }++ @bind+ _updateClaimedBy(data) {+ const user = data.user ? this.store.createRecord("user", data.user) : null;++ if (data.topic_id === this.reviewable.topic.id) {+ if (user) {+ this.reviewable.set("claimed_by", { user, automatic: data.automatic });+ } else {+ this.reviewable.set("claimed_by", null);+ }+ }+ }++ @bind+ _updateStatus(data) {+ if (data.remove_reviewable_ids.includes(this.reviewable.id)) {+ delete data.remove_reviewable_ids;+ this._performResult(data, {}, this.reviewable);+ }+ }++ @bind+ async _performConfirmed(performableAction, additionalData = {}) {+ let reviewable = this.reviewable;++ let performAction = async () => {+ this.disabled = true;++ let version = reviewable.get("version");+ this.set("updating", true);++ const data = {+ send_email: reviewable.sendEmail,+ reject_reason: reviewable.rejectReason,+ ...additionalData,+ };++ (pluginReviewableParams[reviewable.type] || []).forEach((param) => {+ if (reviewable[param]) {+ data[param] = reviewable[param];+ }+ });++ return ajax(+ `/review/${reviewable.id}/perform/${performableAction.server_action}?version=${version}`,+ {+ type: "PUT",+ dataType: "json",+ data,+ }+ )+ .then((result) =>+ this._performResult(+ result.reviewable_perform_result,+ performableAction,+ reviewable+ )+ )+ .catch(popupAjaxError)+ .finally(() => {+ this.set("updating", false);+ this.disabled = false;+ });+ };++ if (performableAction.client_action) {+ let actionMethod =+ this[`client${classify(performableAction.client_action)}`];+ if (actionMethod) {+ if (await this.#claimReviewable()) {+ await actionMethod.call(this, reviewable, performAction);+ }+ } else {+ // eslint-disable-next-line no-console+ console.error(+ `No handler for ${performableAction.client_action} found`+ );+ }+ } else {+ await performAction();+ }++ return this.#unclaimAutomaticReviewable();+ }++ _performResult(result, performableAction, reviewable) {+ // "fast track" to update the current user's reviewable count before the message bus finds out.+ if (result.reviewable_count !== undefined) {+ this.currentUser.updateReviewableCount(result.reviewable_count);+ }++ if (result.unseen_reviewable_count !== undefined) {+ this.currentUser.set(+ "unseen_reviewable_count",+ result.unseen_reviewable_count+ );+ }++ if (performableAction.completed_message) {+ this.toasts.success({+ data: { message: performableAction.completed_message },+ });+ }++ if (this.remove && result.remove_reviewable_ids) {+ this.remove(result.remove_reviewable_ids);+ } else {+ return this.store.find("reviewable", reviewable.id);+ }+ }++ clientSuspend(reviewable, performAction) {+ return this._penalize("showSuspendModal", reviewable, performAction);+ }++ clientSilence(reviewable, performAction) {+ return this._penalize("showSilenceModal", reviewable, performAction);+ }++ async clientEdit(reviewable, performAction) {+ if (!this.currentUser) {+ return this.dialog.alert(i18n("post.controls.edit_anonymous"));+ }+ const post = await this.store.find("post", reviewable.post_id);+ const topic_json = await Topic.find(post.topic_id, {});++ const topic = Topic.create(topic_json);+ post.set("topic", topic);++ if (!post.can_edit) {+ return false;+ }++ const opts = {+ post,+ action: Composer.EDIT,+ draftKey: post.get("topic.draft_key"),+ draftSequence: post.get("topic.draft_sequence"),+ skipJumpOnSave: true,+ };++ this.composer.open(opts);++ return performAction();+ }++ _penalize(adminToolMethod, reviewable, performAction) {+ let adminTools = this.adminTools;+ if (adminTools) {+ let createdBy = reviewable.get("target_created_by");+ let postId = reviewable.get("post_id");+ let postEdit = reviewable.get("raw");++ return adminTools[adminToolMethod](createdBy, {+ postId,+ postEdit,+ before: performAction,+ });+ }+ }++ async #claimReviewable() {+ if (!this.reviewable.topic) {+ // We can't claim a reviewable without a topic, so treat it as claimed+ return true;+ }++ if (!this.reviewable.claimed_by) {+ const claim = this.store.createRecord("reviewable-claimed-topic");++ try {+ await claim.save({+ topic_id: this.reviewable.topic.id,+ automatic: true,+ });+ this.reviewable.set("claimed_by", {+ user: this.currentUser,+ automatic: true,+ });+ } catch (e) {+ popupAjaxError(e);+ return false;+ }+ }++ return this.reviewable.claimed_by?.user?.id === this.currentUser.id;+ }++ async #unclaimAutomaticReviewable() {+ if (!this.reviewable.topic || !this.reviewable.claimed_by?.automatic) {+ return;+ }++ try {+ await ajax(`/reviewable_claimed_topics/${this.reviewable.topic.id}`, {+ type: "DELETE",+ data: { automatic: true },+ });+ this.reviewable.set("claimed_by", null);+ } catch (e) {+ popupAjaxError(e);+ }+ }++ @action+ explainReviewable(reviewable, event) {+ event.preventDefault();+ this.modal.show(ExplainReviewableModal, {+ model: { reviewable },+ });+ }++ @action+ edit() {+ this.set("editing", true);+ this.set("_updates", { payload: {} });+ }++ @action+ cancelEdit() {+ this.set("editing", false);+ }++ @action+ saveEdit() {+ let updates = this._updates;++ // Remove empty objects+ Object.keys(updates).forEach((name) => {+ let attr = updates[name];+ if (typeof attr === "object" && Object.keys(attr).length === 0) {+ delete updates[name];+ }+ });++ this.set("updating", true);+ return this.reviewable+ .update(updates)+ .then(() => this.set("editing", false))+ .catch(popupAjaxError)+ .finally(() => this.set("updating", false));+ }++ @action+ categoryChanged(categoryId) {+ let category = Category.findById(categoryId);++ if (!category) {+ category = Category.findUncategorized();+ }++ set(this._updates, "category_id", category.id);+ }++ @action+ valueChanged(fieldId, event) {+ set(this._updates, fieldId, event.target.value);+ }++ @action+ async perform(performableAction) {+ if (this.updating) {+ return;+ }++ const message = performableAction.get("confirm_message");+ const requireRejectReason = performableAction.get("require_reject_reason");+ const actionModalClass = requireRejectReason+ ? RejectReasonReviewableModal+ : actionModalClassMap[performableAction.server_action];++ if (message) {+ if (await this.#claimReviewable()) {+ this.dialog.confirm({+ message,+ didConfirm: () => this._performConfirmed(performableAction),+ });+ }+ } else if (actionModalClass) {+ if (await this.#claimReviewable()) {+ this.modal.show(actionModalClass, {+ model: {+ reviewable: this.reviewable,+ performConfirmed: this._performConfirmed,+ action: performableAction,+ },+ });+ }+ } else {+ return this._performConfirmed(performableAction);+ }+ }+ }+++<div+ data-reviewable-id={{this.reviewable.id}}+ class="reviewable-item {{this.customClasses}}"+>+ <div class="reviewable-meta-data">+ <span+ class={{concat-class "reviewable-type" this.reviewable.humanTypeCssClass}}+ >{{this.reviewable.humanType}}</span>+ {{#if this.reviewable.reply_count}}+ <span class="reply-count">{{i18n+ "review.replies"+ count=this.reviewable.reply_count+ }}</span>+ {{/if}}+ <span class="created-at">+ <LinkTo+ @route="review.show"+ @model={{this.reviewable.id}}+ >{{age-with-tooltip this.reviewable.created_at}}</LinkTo>+ </span>+ <span class="status">+ {{reviewable-status this.reviewable.status this.reviewable.type}}+ </span>+ <a+ href+ {{on "click" (fn this.explainReviewable this.reviewable)}}+ title={{i18n "review.explain.why"}}+ class="explain"+ >+ {{d-icon "circle-question"}}+ </a>+ </div>++ <div class="reviewable-contents">+ {{#if this.editing}}+ <div class="editable-fields">+ {{#if this.reviewable.created_by}}+ <div class="editable-created-by">+ {{avatar this.reviewable.created_by imageSize="tiny"}}+ <ReviewableCreatedByName @user={{this.reviewable.created_by}} />+ </div>+ {{/if}}++ {{#each this.reviewable.editable_fields as |f|}}+ <div class="editable-field {{dasherize f.id}}">+ {{component+ (concat "reviewable-field-" f.type)+ tagName=""+ value=(editable-value this.reviewable f.id)+ tagCategoryId=this.tagCategoryId+ valueChanged=(action "valueChanged" f.id)+ categoryChanged=(action "categoryChanged")+ }}+ </div>+ {{/each}}+ </div>+ {{else}}+ {{#let+ (component+ this.reviewableComponent reviewable=this.reviewable tagName=""+ )+ as |ReviewableComponent|+ }}+ {{! template-lint-disable no-shadowed-elements }}{{! (seems to be a false positive) }}+ <ReviewableComponent>+ <ReviewableScores @reviewable={{this.reviewable}} @tagName="" />+ </ReviewableComponent>+ {{/let}}+ {{/if}}+ </div>++ {{#if this.displayContextQuestion}}+ <h3 class="reviewable-item__context-question">+ {{this.reviewable.flaggedReviewableContextQuestion}}+ </h3>+ {{/if}}++ <div class="reviewable-actions">+ {{#unless this.reviewable.last_performing_username}}+ {{#if this.canPerform}}+ {{#if this.editing}}+ <DButton+ @disabled={{this.disabled}}+ @icon="check"+ @action={{action "saveEdit"}}+ @label="review.save"+ class="btn-primary reviewable-action save-edit"+ />+ <DButton+ @disabled={{this.disabled}}+ @icon="xmark"+ @action={{action "cancelEdit"}}+ @label="review.cancel"+ class="btn-danger reviewable-action cancel-edit"+ />+ {{else}}+ {{#each this.reviewable.bundled_actions as |bundle|}}+ <ReviewableBundledAction+ @bundle={{bundle}}+ @performAction={{action "perform"}}+ @reviewableUpdating={{this.disabled}}+ />+ {{/each}}++ {{#if this.reviewable.can_edit}}+ <DButton+ @disabled={{this.disabled}}+ @icon="pencil"+ @action={{action "edit"}}+ @label="review.edit"+ class="reviewable-action btn-default edit"+ />+ {{/if}}+ {{/if}}+ {{/if}}+ {{/unless}}++ {{#if this.reviewable.last_performing_username}}+ <div class="stale-help">{{html-safe+ (i18n+ "review.stale_help"+ username=this.reviewable.last_performing_username+ )+ }}</div>+ {{else}}+ {{#if this.claimEnabled}}+ <div class="claimed-actions">+ <span class="help">{{html-safe this.claimHelp}}</span>+ {{#unless this.autoClaimed}}+ <ReviewableClaimedTopic+ @topicId={{this.topicId}}+ @claimedBy={{this.reviewable.claimed_by}}+ @onClaim={{fn (mut this.reviewable.claimed_by)}}+ />+ {{/unless}}+ </div>+ {{/if}}+ {{/if}}++ {{#if this.showIpLookup}}+ <IpLookup+ @ip="adminLookup"+ @userId={{this.reviewable.target_created_by.id}}+ />+ {{/if}}++ <PluginOutlet+ @name="reviewable-item-actions"+ @connectorTagName="div"+ @outletArgs={{hash reviewable=this.reviewable}}+ />+ </div>+</div>diff --cc app/assets/javascripts/discourse/app/components/user-menu/items-list.gjsindex fd5ba9d8d02,8ccef079c71..8a9d0c9eb9f--- a/app/assets/javascripts/discourse/app/components/user-menu/items-list.gjs+++ b/app/assets/javascripts/discourse/app/components/user-menu/items-list.gjs@@@ -1,58 -1,89 +1,148 @@@+ import Component from "@glimmer/component";+ import { tracked } from "@glimmer/tracking";+ import { action } from "@ember/object";+ import { service } from "@ember/service";++ export default class UserMenuItemsList extends Component {+ @service session;++ @tracked loading = false;+ @tracked items = [];++ constructor() {+ super(...arguments);+ this.#load();+ }++ get itemsCacheKey() {}++ get showAllHref() {}++ get showAllTitle() {}++ get showDismiss() {+ return false;+ }++ get dismissTitle() {}++ get emptyStateComponent() {+ return "user-menu/items-list-empty-state";+ }++ get renderDismissConfirmation() {+ return false;+ }++ async fetchItems() {+ throw new Error(+ `the fetchItems method must be implemented in ${this.constructor.name}`+ );+ }++ async refreshList() {+ await this.#load();+ }++ async #load() {+ const cached = this.#getCachedItems();+ if (cached?.length) {+ this.items = cached;+ } else {+ this.loading = true;+ }+ try {+ const items = await this.fetchItems();+ this.#setCachedItems(items);+ this.items = items;+ } catch (err) {+ // eslint-disable-next-line no-console+ console.error(+ `an error occurred when loading items for ${this.constructor.name}`,+ err+ );+ } finally {+ this.loading = false;+ }+ }++ #getCachedItems() {+ const key = this.itemsCacheKey;+ if (key) {+ return this.session[`user-menu-items:${key}`];+ }+ }++ #setCachedItems(newItems) {+ const key = this.itemsCacheKey;+ if (key) {+ this.session.set(`user-menu-items:${key}`, newItems);+ }+ }++ @action+ dismissButtonClick() {+ throw new Error(+ `dismissButtonClick must be implemented in ${this.constructor.name}.`+ );+ }+ }+++<PluginOutlet+ @name="before-panel-body"+ @outletArgs={{hash closeUserMenu=@closeUserMenu}}+/>+{{#if this.loading}}+ <div class="spinner-container">+ <div class="spinner"></div>+ </div>+{{else if this.items.length}}+ <ul aria-labelledby={{@ariaLabelledby}}>+ {{#each this.items as |item|}}+ <UserMenu::MenuItem @item={{item}} @closeUserMenu={{@closeUserMenu}} />+ {{/each}}+ </ul>+ <div class="panel-body-bottom">+ {{#if this.showAllHref}}+ <DButton+ class="btn-default show-all"+ @href={{this.showAllHref}}+ @translatedAriaLabel={{this.showAllTitle}}+ @translatedTitle={{this.showAllTitle}}+ >+ {{d-icon "chevron-down" aria-label=this.showAllTitle}}+ </DButton>+ {{/if}}+ {{#if this.showDismiss}}+ <button+ type="button"+ class="btn btn-default notifications-dismiss btn-icon-text"+ title={{this.dismissTitle}}+ {{on "click" this.dismissButtonClick}}+ >+ {{d-icon "check"}}+ {{i18n "user.dismiss"}}+ </button>+ {{/if}}+ <PluginOutlet+ @name="panel-body-bottom"+ @outletArgs={{hash+ itemsCacheKey=this.itemsCacheKey+ closeUserMenu=@closeUserMenu+ showDismiss=this.showDismiss+ dismissButtonClick=this.dismissButtonClick+ }}+ />+ </div>+{{else}}+ <PluginOutlet+ @name="user-menu-items-list-empty-state"+ @outletArgs={{hash model=this}}+ >+ {{component this.emptyStateComponent}}+ </PluginOutlet>+{{/if}}+<PluginOutlet+ @name="after-panel-body"+ @outletArgs={{hash closeUserMenu=@closeUserMenu}}+/>diff --cc app/assets/javascripts/discourse/app/static/wizard/components/fields/image.gjsindex de3591c9827,d3f3a127ef8..f6dc3365e38--- a/app/assets/javascripts/discourse/app/static/wizard/components/fields/image.gjs+++ b/app/assets/javascripts/discourse/app/static/wizard/components/fields/image.gjs@@@ -1,29 -1,95 +1,125 @@@+ import Component from "@ember/component";+ import { warn } from "@ember/debug";+ import { service } from "@ember/service";+ import { dasherize } from "@ember/string";+ import { classNames } from "@ember-decorators/component";+ import Uppy from "@uppy/core";+ import DropTarget from "@uppy/drop-target";+ import XHRUpload from "@uppy/xhr-upload";+ import discourseComputed from "discourse/lib/decorators";+ import getUrl from "discourse/lib/get-url";+ import { i18n } from "discourse-i18n";+ import imagePreviews from "./image-previews";++ @classNames("wizard-container__image-upload")+ export default class Image extends Component {+ @service dialog;++ uploading = false;++ @discourseComputed("field.id")+ previewComponent(id) {+ return imagePreviews[dasherize(id)] ?? imagePreviews.generic;+ }++ didInsertElement() {+ super.didInsertElement(...arguments);+ this.setupUploads();+ }++ @discourseComputed("uploading", "field.value")+ hasUpload() {+ return (+ !this.uploading &&+ this.field.value &&+ !this.field.value.includes("discourse-logo-sketch-small.png")+ );+ }++ setupUploads() {+ const id = this.field.id;+ this._uppyInstance = new Uppy({+ id: `wizard-field-image-${id}`,+ meta: { upload_type: `wizard_${id}` },+ autoProceed: true,+ });++ this._uppyInstance.use(XHRUpload, {+ endpoint: getUrl("/uploads.json"),+ headers: {+ "X-CSRF-Token": this.session.csrfToken,+ },+ });++ this._uppyInstance.use(DropTarget, { target: this.element });++ this._uppyInstance.on("upload", () => {+ this.set("uploading", true);+ });++ this._uppyInstance.on("upload-success", (file, response) => {+ this.set("field.value", response.body.url);+ this.set("uploading", false);+ });++ this._uppyInstance.on("upload-error", (file, error, response) => {+ let message = i18n("wizard.upload_error");+ if (response.body.errors) {+ message = response.body.errors.join("\n");+ }++ this.dialog.alert(message);+ this.set("uploading", false);+ });++ this.element+ .querySelector(".wizard-hidden-upload-field")+ .addEventListener("change", (event) => {+ const files = Array.from(event.target.files);+ files.forEach((file) => {+ try {+ this._uppyInstance.addFile({+ source: `${this.id} file input`,+ name: file.name,+ type: file.type,+ data: file,+ });+ } catch (err) {+ warn(`error adding files to uppy: ${err}`, {+ id: "discourse.upload.uppy-add-files-error",+ });+ }+ });+ });+ }+ }+++<label+ class={{concatClass+ "wizard-container__button wizard-container__button-upload"+ (if this.uploading "disabled")+ (if this.hasUpload "has-upload")+ }}+>+ {{#if this.uploading}}+ {{i18n "wizard.uploading"}}+ {{else}}+ {{i18n "wizard.upload"}}+ {{/if}}++ <input+ class="wizard-hidden-upload-field"+ disabled={{this.uploading}}+ type="file"+ accept="image/*"+ />+</label>++{{#if this.field.value}}+ {{component+ this.previewComponent+ field=this.field+ fieldClass=this.fieldClass+ wizard=this.wizard+ }}+{{/if}}diff --cc app/assets/javascripts/select-kit/addon/components/category-drop/category-drop-header.gjsindex e6c991ce88a,dbfbe445555..9dcd65acd92--- a/app/assets/javascripts/select-kit/addon/components/category-drop/category-drop-header.gjs+++ b/app/assets/javascripts/select-kit/addon/components/category-drop/category-drop-header.gjs@@@ -1,12 -1,19 +1,32 @@@+ import { reads } from "@ember/object/computed";+ import { classNames } from "@ember-decorators/component";+ import discourseComputed from "discourse/lib/decorators";+ import ComboBoxSelectBoxHeaderComponent from "select-kit/components/combo-box/combo-box-header";++ @classNames("category-drop-header")+ export default class CategoryDropHeader extends ComboBoxSelectBoxHeaderComponent {+ @reads("selectKit.options.shouldDisplayIcon") shouldDisplayIcon;++ @discourseComputed("selectedContent.color")+ categoryBackgroundColor(categoryColor) {+ return categoryColor || "#e9e9e9";+ }++ @discourseComputed("selectedContent.text_color")+ categoryTextColor(categoryTextColor) {+ return categoryTextColor || "#333";+ }+ }+++<div class="select-kit-header-wrapper">+ {{component+ this.selectKit.options.selectedNameComponent+ tabindex=this.tabindex+ item=this.selectedContent+ selectKit=this.selectKit+ shouldDisplayIcon=this.shouldDisplayIcon+ shouldDisplayClearableButton=this.shouldDisplayClearableButton+ }}++ {{d-icon this.caretIcon class="caret-icon"}}+</div>diff --cc app/assets/javascripts/select-kit/addon/components/combo-box/combo-box-header.gjsindex 84d185e2ecd,c10426eab5b..317cff83e58--- a/app/assets/javascripts/select-kit/addon/components/combo-box/combo-box-header.gjs+++ b/app/assets/javascripts/select-kit/addon/components/combo-box/combo-box-header.gjs@@@ -1,21 -1,17 +1,39 @@@+ import { computed } from "@ember/object";+ import { and, reads } from "@ember/object/computed";+ import { classNames } from "@ember-decorators/component";+ import SingleSelectHeaderComponent from "select-kit/components/select-kit/single-select-header";++ @classNames("combo-box-header")+ export default class ComboBoxHeader extends SingleSelectHeaderComponent {+ @reads("selectKit.options.clearable") clearable;+ @reads("selectKit.options.caretUpIcon") caretUpIcon;+ @reads("selectKit.options.caretDownIcon") caretDownIcon;+ @and("clearable", "value") shouldDisplayClearableButton;++ @computed("selectKit.isExpanded", "caretUpIcon", "caretDownIcon")+ get caretIcon() {+ return this.selectKit.isExpanded ? this.caretUpIcon : this.caretDownIcon;+ }+ }+++<div class="select-kit-header-wrapper">+ {{#each this.icons as |icon|}} {{d-icon icon}} {{/each}}++ {{component+ this.selectKit.options.selectedNameComponent+ tabindex=this.tabindex+ item=this.selectedContent+ selectKit=this.selectKit+ }}++ {{#if this.shouldDisplayClearableButton}}+ <DButton+ @icon="xmark"+ @action={{this.selectKit.onClearSelection}}+ @ariaLabel="clear_input"+ class="btn-clear"+ />+ {{/if}}++ {{d-icon this.caretIcon class="caret-icon"}}+</div>diff --cc app/assets/javascripts/select-kit/addon/components/dropdown-select-box/dropdown-select-box-header.gjsindex f9a68e025a3,59bf4ec2ab6..34e7c28ea79--- a/app/assets/javascripts/select-kit/addon/components/dropdown-select-box/dropdown-select-box-header.gjs+++ b/app/assets/javascripts/select-kit/addon/components/dropdown-select-box/dropdown-select-box-header.gjs@@@ -1,17 -1,29 +1,47 @@@+ import { computed } from "@ember/object";+ import { readOnly } from "@ember/object/computed";+ import { classNameBindings, classNames } from "@ember-decorators/component";+ import SingleSelectHeaderComponent from "select-kit/components/select-kit/single-select-header";++ @classNames("dropdown-select-box-header")+ @classNameBindings("btnClassName", "btnStyleClass", "btnCustomClasses")+ export default class DropdownSelectBoxHeader extends SingleSelectHeaderComponent {+ @readOnly("selectKit.options.showFullTitle") showFullTitle;+ @readOnly("selectKit.options.customStyle") customStyle;+ @readOnly("selectKit.options.btnCustomClasses") btnCustomClasses;+ @readOnly("selectKit.options.caretUpIcon") caretUpIcon;+ @readOnly("selectKit.options.caretDownIcon") caretDownIcon;++ @computed("showFullTitle")+ get btnClassName() {+ return `btn ${this.showFullTitle ? "btn-icon-text" : "no-text btn-icon"}`;+ }++ @computed("customStyle")+ get btnStyleClass() {+ return `${this.customStyle ? "" : "btn-default"}`;+ }++ @computed("selectKit.isExpanded", "caretUpIcon", "caretDownIcon")+ get caretIcon() {+ return this.selectKit.isExpanded ? this.caretUpIcon : this.caretDownIcon;+ }+ }+++<div class="select-kit-header-wrapper">+ {{#each this.icons as |icon|}} {{d-icon icon}} {{/each}}++ {{component+ this.selectKit.options.selectedNameComponent+ tabindex=this.tabindex+ item=this.selectedContent+ selectKit=this.selectKit+ shouldDisplayClearableButton=this.shouldDisplayClearableButton+ }}++ {{#if this.selectKit.options.showCaret}}+ {{d-icon this.caretIcon class="caret-icon"}}+ {{/if}}+ ​+ {{! Zero-width space character, so icon-only button height = regular button height }}+</div>diff --cc app/assets/javascripts/select-kit/addon/components/future-date-input-selector/future-date-input-selector-header.gjsindex 04efb6bb286,5ea539b97ca..a27ceb47aab--- a/app/assets/javascripts/select-kit/addon/components/future-date-input-selector/future-date-input-selector-header.gjs+++ b/app/assets/javascripts/select-kit/addon/components/future-date-input-selector/future-date-input-selector-header.gjs@@@ -1,22 -1,5 +1,28 @@@+ import { classNames } from "@ember-decorators/component";+ import ComboBoxHeaderComponent from "select-kit/components/combo-box/combo-box-header";++ @classNames("future-date-input-selector-header")+ export default class FutureDateInputSelectorHeader extends ComboBoxHeaderComponent {}+++<div class="select-kit-header-wrapper">+ {{#if this.icons}}+ <div class="future-date-input-selector-icons">+ {{#each this.icons as |icon|}} {{d-icon icon}} {{/each}}+ </div>+ {{/if}}++ {{component+ this.selectKit.options.selectedNameComponent+ tabindex=this.tabindex+ item=this.selectedContent+ selectKit=this.selectKit+ }}++ {{#if this.selectedContent.timeFormatted}}+ <span class="future-date-input-selector-datetime">+ {{this.selectedContent.timeFormatted}}+ </span>+ {{/if}}++ {{d-icon this.caretIcon class="caret-icon"}}+</div>diff --cc app/assets/javascripts/select-kit/addon/components/multi-select.gjsindex abf2ba3a999,b49c8273d31..1903e81a3a4--- a/app/assets/javascripts/select-kit/addon/components/multi-select.gjs+++ b/app/assets/javascripts/select-kit/addon/components/multi-select.gjs@@@ -1,57 -1,196 +1,254 @@@+ import { computed } from "@ember/object";+ import { next } from "@ember/runloop";+ import { isPresent } from "@ember/utils";+ import { classNames } from "@ember-decorators/component";+ import { makeArray } from "discourse/lib/helpers";+ import SelectKitComponent, {+ pluginApiIdentifiers,+ selectKitOptions,+ } from "select-kit/components/select-kit";++ @classNames("multi-select")+ @selectKitOptions({+ none: "select_kit.default_header_text",+ clearable: true,+ filterable: true,+ filterIcon: null,+ closeOnChange: false,+ autoInsertNoneItem: false,+ headerComponent: "multi-select/multi-select-header",+ filterComponent: "multi-select/multi-select-filter",+ autoFilterable: true,+ caretDownIcon: "caretIcon",+ caretUpIcon: "caretIcon",+ useHeaderFilter: false,+ })+ @pluginApiIdentifiers(["multi-select"])+ export default class MultiSelect extends SelectKitComponent {+ multiSelect = true;++ @computed("value.[]")+ get caretIcon() {+ const maximum = this.selectKit.options.maximum;+ return maximum && makeArray(this.value).length >= parseInt(maximum, 10)+ ? null+ : "plus";+ }++ search(filter) {+ return super+ .search(filter)+ .filter((content) => !makeArray(this.selectedContent).includes(content));+ }++ append(values) {+ const existingItems = values+ .map((value) => {+ const defaultItem = this.defaultItem(value, value);+ const existingItem =+ this.findValue(this.mainCollection, defaultItem) ||+ this.findName(this.mainCollection, defaultItem);+ if (!existingItem) {+ if (this.validateCreate(value, this.content)) {+ return value;+ }+ } else if (this.validateSelect(existingItem)) {+ return this.getValue(existingItem);+ }+ })+ .filter(Boolean);++ const newValues = makeArray(this.value).concat(existingItems);+ const newContent = makeArray(this.selectedContent).concat(+ makeArray(existingItems)+ );++ this.selectKit.change(newValues, newContent);+ }++ deselect(item) {+ this.clearErrors();++ const newContent = this.selectedContent.filter(+ (content) => this.getValue(item) !== this.getValue(content)+ );++ this.selectKit.change(+ this.valueProperty ? newContent.mapBy(this.valueProperty) : newContent,+ newContent+ );+ }++ select(value, item) {+ if (this.selectKit.hasSelection && this.selectKit.options.maximum === 1) {+ this.selectKit.deselectByValue(+ this.getValue(this.selectedContent.firstObject)+ );+ next(() => {+ this.selectKit.select(value, item);+ });+ return;+ }++ if (!isPresent(value)) {+ if (!this.validateSelect(this.selectKit.highlighted)) {+ return;+ }++ this.selectKit.change(+ makeArray(this.value).concat(+ makeArray(this.getValue(this.selectKit.highlighted))+ ),+ makeArray(this.selectedContent).concat(+ makeArray(this.selectKit.highlighted)+ )+ );+ } else {+ const existingItem = this.findValue(+ this.mainCollection,+ this.selectKit.valueProperty ? item : value+ );+ if (existingItem) {+ if (!this.validateSelect(item)) {+ return;+ }+ }++ const newValues = makeArray(this.value).concat(makeArray(value));+ const newContent = makeArray(this.selectedContent).concat(+ makeArray(item)+ );++ this.selectKit.change(+ [...new Set(newValues)],+ newContent.length+ ? newContent+ : makeArray(this.defaultItem(value, value))+ );+ }+ }++ @computed("value.[]", "content.[]", "selectKit.noneItem")+ get selectedContent() {+ const value = makeArray(this.value).map((v) =>+ this.selectKit.options.castInteger && this._isNumeric(v) ? Number(v) : v+ );++ if (value.length) {+ let content = [];++ value.forEach((v) => {+ if (this.selectKit.valueProperty) {+ const c = makeArray(this.content).findBy(+ this.selectKit.valueProperty,+ v+ );+ if (c) {+ content.push(c);+ }+ } else {+ if (makeArray(this.content).includes(v)) {+ content.push(v);+ }+ }+ });++ return this.selectKit.modifySelection(content);+ }++ return null;+ }++ _onKeydown(event) {+ if (+ event.code === "Enter" &&+ event.target.classList.contains("selected-name")+ ) {+ event.stopPropagation();+ this.selectKit.deselectByValue(event.target.dataset.value);+ return false;+ }++ if (event.code === "Backspace") {+ event.stopPropagation();++ const input = this.getFilterInput();+ if (input && input.value.length === 0) {+ const selected = this.element.querySelectorAll(+ ".select-kit-header .choice.select-kit-selected-name"+ );++ if (selected.length) {+ const lastSelected = selected[selected.length - 1];+ if (lastSelected) {+ if (lastSelected === document.activeElement) {+ this.deselect(this.selectedContent.lastObject);+ } else {+ lastSelected.focus();+ }+ }+ }+ }+ }++ return true;+ }+ }+++{{#unless this.selectKit.isHidden}}+ {{component+ this.selectKit.options.headerComponent+ tabindex=this.tabindex+ value=this.value+ selectedContent=this.selectedContent+ selectKit=this.selectKit+ id=(concat this.selectKit.uniqueID "-header")+ }}++ <SelectKit::SelectKitBody+ @selectKit={{this.selectKit}}+ @id={{concat this.selectKit.uniqueID "-body"}}+ >+ {{#unless this.selectKit.options.useHeaderFilter}}+ {{component+ this.selectKit.options.filterComponent+ selectKit=this.selectKit+ id=(concat this.selectKit.uniqueID "-filter")+ }}++ {{#if this.selectedContent.length}}+ <div class="selected-content">+ {{#each this.selectedContent as |item|}}+ {{component+ this.selectKit.options.selectedChoiceComponent+ item=item+ selectKit=this.selectKit+ mandatoryValues=@mandatoryValues+ }}+ {{/each}}+ </div>+ {{/if}}+ {{/unless}}++ {{#each this.collections as |collection|}}+ {{component+ (component-for-collection collection.identifier this.selectKit)+ collection=collection+ selectKit=this.selectKit+ value=this.value+ }}+ {{/each}}++ {{#if this.selectKit.filter}}+ {{#if (and this.selectKit.hasNoContent (not this.selectKit.isLoading))}}+ <span class="no-content" role="alert">+ {{i18n "select_kit.no_content"}}+ </span>+ {{else}}+ <span class="results-count" role="alert">+ {{i18n "select_kit.results_count" count=this.mainCollection.length}}+ </span>+ {{/if}}+ {{/if}}+ </SelectKit::SelectKitBody>+{{/unless}}diff --cc app/assets/javascripts/select-kit/addon/components/multi-select/multi-select-header.gjsindex 3bff6e9a7e3,426de7c599a..c9acbe5dcd5--- a/app/assets/javascripts/select-kit/addon/components/multi-select/multi-select-header.gjs+++ b/app/assets/javascripts/select-kit/addon/components/multi-select/multi-select-header.gjs@@@ -1,33 -1,22 +1,56 @@@+ import { computed } from "@ember/object";+ import { reads } from "@ember/object/computed";+ import {+ attributeBindings,+ classNames,+ tagName,+ } from "@ember-decorators/component";+ import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";++ @tagName("summary")+ @classNames("multi-select-header")+ @attributeBindings("ariaLabel:aria-label")+ export default class MultiSelectHeader extends SelectKitHeaderComponent {+ @reads("selectKit.options.caretUpIcon") caretUpIcon;+ @reads("selectKit.options.caretDownIcon") caretDownIcon;+ @reads("selectKit.options.headerAriaLabel") ariaLabel;++ @computed("selectKit.isExpanded", "caretUpIcon", "caretDownIcon")+ get caretIcon() {+ return this.selectKit.isExpanded ? this.caretUpIcon : this.caretDownIcon;+ }+ }+++<div class="select-kit-header-wrapper">+ {{#each this.icons as |icon|}}+ {{d-icon icon}}+ {{/each}}++ {{#if this.selectKit.options.useHeaderFilter}}+ <div class="select-kit-header--filter">+ {{#if this.selectedContent.length}}+ {{#each this.selectedContent as |item|}}+ {{component+ this.selectKit.options.selectedChoiceComponent+ item=item+ selectKit=this.selectKit+ }}+ {{/each}}+ {{/if}}++ {{component+ this.selectKit.options.filterComponent+ selectKit=this.selectKit+ id=(concat this.selectKit.uniqueID "-filter")+ hidePlaceholderWithSelection=true+ }}+ </div>+ {{else}}+ <MultiSelect::FormatSelectedContent+ @content={{or this.selectedContent this.selectKit.noneItem}}+ @selectKit={{this.selectKit}}+ />++ {{d-icon this.caretIcon class="caret-icon"}}+ {{/if}}+</div>diff --cc app/assets/javascripts/select-kit/addon/components/pinned-button.gjsindex 2c7d128a706,7ba06b6e383..3e2111ac5d7--- a/app/assets/javascripts/select-kit/addon/components/pinned-button.gjs+++ b/app/assets/javascripts/select-kit/addon/components/pinned-button.gjs@@@ -1,8 -1,26 +1,35 @@@+ import Component from "@ember/component";+ import { classNameBindings, classNames } from "@ember-decorators/component";+ import discourseComputed from "discourse/lib/decorators";+ import { i18n } from "discourse-i18n";+ import { pluginApiIdentifiers } from "select-kit/components/select-kit";++ @classNames("pinned-button")+ @classNameBindings("isHidden")+ @pluginApiIdentifiers("pinned-button")+ export default class PinnedButton extends Component {+ descriptionKey = "help";+ appendReason = true;++ @discourseComputed("topic.pinned_globally", "pinned")+ reasonText(pinnedGlobally, pinned) {+ const globally = pinnedGlobally ? "_globally" : "";+ const pinnedKey = pinned ? `pinned${globally}` : "unpinned";+ const key = `topic_statuses.${pinnedKey}.help`;+ return i18n(key);+ }++ @discourseComputed("pinned", "topic.deleted", "topic.unpinned")+ isHidden(pinned, deleted, unpinned) {+ return deleted || (!pinned && !unpinned);+ }+ }+++{{#if this.appendReason}}+ <p class="reason">+ <PinnedOptions @value={{this.pinned}} @topic={{this.topic}} />+ <span class="text">{{html-safe this.reasonText}}</span>+ </p>+{{else}}+ <PinnedOptions @value={{this.pinned}} @topic={{this.topic}} />+{{/if}}diff --cc app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-collection.gjsindex 9c45720672a,cf9ec5c3eeb..44412b7c979--- a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-collection.gjs+++ b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-collection.gjs@@@ -1,18 -1,34 +1,53 @@@+ import Component from "@ember/component";+ import { service } from "@ember/service";+ import { tagName } from "@ember-decorators/component";+ import { modifier } from "ember-modifier";+ import {+ disableBodyScroll,+ enableBodyScroll,+ locks,+ } from "discourse/lib/body-scroll-lock";++ @tagName("")+ export default class SelectKitCollection extends Component {+ @service site;++ bodyScrollLock = modifier((element) => {+ if (!this.site.mobileView) {+ return;+ }++ const isChildOfLock = locks.some((lock) =>+ lock.targetElement.contains(element)+ );++ if (isChildOfLock) {+ disableBodyScroll(element);+ }++ return () => {+ if (isChildOfLock) {+ enableBodyScroll(element);+ }+ };+ });+ }+++{{#if this.collection.content.length}}+ <ul+ class="select-kit-collection"+ aria-live="polite"+ role="menu"+ {{this.bodyScrollLock}}+ >+ {{#each this.collection.content as |item index|}}+ {{component+ (component-for-row this.collection.identifier item this.selectKit)+ index=index+ item=item+ value=this.value+ selectKit=this.selectKit+ }}+ {{/each}}+ </ul>+{{/if}}diff --cc app/assets/javascripts/select-kit/addon/components/select-kit/single-select-header.gjsindex e97ec452d8f,29a7433aa84..9d313011818--- a/app/assets/javascripts/select-kit/addon/components/select-kit/single-select-header.gjs+++ b/app/assets/javascripts/select-kit/addon/components/select-kit/single-select-header.gjs@@@ -1,9 -1,37 +1,47 @@@+ import { computed } from "@ember/object";+ import { or } from "@ember/object/computed";+ import {+ attributeBindings,+ classNames,+ tagName,+ } from "@ember-decorators/component";+ import { i18n } from "discourse-i18n";+ import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";++ @tagName("summary")+ @classNames("single-select-header")+ @attributeBindings("name", "ariaLabel:aria-label")+ export default class SingleSelectHeader extends SelectKitHeaderComponent {+ @or("selectKit.options.headerAriaLabel", "name") ariaLabel;++ focusIn(event) {+ event.stopImmediatePropagation();++ document.querySelectorAll(".select-kit-header").forEach((header) => {+ if (header !== event.target) {+ header.parentNode.open = false;+ }+ });+ }++ @computed("selectedContent.name")+ get name() {+ if (this.selectedContent) {+ return i18n("select_kit.filter_by", {+ name: this.getName(this.selectedContent),+ });+ } else {+ return i18n("select_kit.select_to_filter");+ }+ }+ }+++<div class="select-kit-header-wrapper">+ {{#each this.icons as |icon|}} {{d-icon icon}} {{/each}}++ {{component+ this.selectKit.options.selectedNameComponent+ item=this.selectedContent+ selectKit=this.selectKit+ }}+</div>diff --cc app/assets/javascripts/select-kit/addon/components/selected-choice-category.gjsindex a86219beb9a,5e3368f9194..a480e25fdf3--- a/app/assets/javascripts/select-kit/addon/components/selected-choice-category.gjs+++ b/app/assets/javascripts/select-kit/addon/components/selected-choice-category.gjs@@@ -1,7 -1,20 +1,28 @@@+ import { computed } from "@ember/object";+ import { htmlSafe } from "@ember/template";+ import { tagName } from "@ember-decorators/component";+ import { categoryBadgeHTML } from "discourse/helpers/category-link";+ import SelectedChoiceComponent from "select-kit/components/selected-choice";++ @tagName("")+ export default class SelectedChoiceCategory extends SelectedChoiceComponent {+ extraClass = "selected-choice-category";++ @computed("item")+ get badge() {+ return htmlSafe(+ categoryBadgeHTML(this.item, {+ allowUncategorized: true,+ link: false,+ })+ );+ }+ }+++<SelectedChoice+ @item={{this.item}}+ @selectKit={{this.selectKit}}+ @extraClass={{this.extraClass}}+>+ {{this.badge}}+</SelectedChoice>diff --cc app/assets/javascripts/select-kit/addon/components/single-select.gjsindex d77c7852b8a,a3f6916ee7d..4f6b00b30e1--- a/app/assets/javascripts/select-kit/addon/components/single-select.gjs+++ b/app/assets/javascripts/select-kit/addon/components/single-select.gjs@@@ -1,43 -1,45 +1,89 @@@+ import { computed } from "@ember/object";+ import { isEmpty } from "@ember/utils";+ import { classNames } from "@ember-decorators/component";+ import SelectKitComponent, {+ pluginApiIdentifiers,+ selectKitOptions,+ } from "select-kit/components/select-kit";++ @classNames("single-select")+ @selectKitOptions({+ headerComponent: "select-kit/single-select-header",+ })+ @pluginApiIdentifiers(["single-select"])+ export default class SingleSelect extends SelectKitComponent {+ singleSelect = true;++ @computed("value", "content.[]", "selectKit.noneItem")+ get selectedContent() {+ if (!isEmpty(this.value)) {+ let content;++ const value =+ this.selectKit.options.castInteger && this._isNumeric(this.value)+ ? Number(this.value)+ : this.value;++ if (this.selectKit.valueProperty) {+ content = (this.content || []).findBy(+ this.selectKit.valueProperty,+ value+ );++ return this.selectKit.modifySelection(+ content || this.defaultItem(value, value)+ );+ } else {+ return this.selectKit.modifySelection(+ (this.content || []).filter((c) => c === value)+ );+ }+ } else {+ return this.selectKit.noneItem;+ }+ }+ }+++{{#unless this.selectKit.isHidden}}+ {{component+ this.selectKit.options.headerComponent+ tabindex=this.tabindex+ value=this.value+ selectedContent=this.selectedContent+ selectKit=this.selectKit+ id=(concat this.selectKit.uniqueID "-header")+ }}++ <SelectKit::SelectKitBody+ @selectKit={{this.selectKit}}+ @id={{concat this.selectKit.uniqueID "-body"}}+ >+ {{component+ this.selectKit.options.filterComponent+ selectKit=this.selectKit+ id=(concat this.selectKit.uniqueID "-filter")+ }}++ {{#each this.collections as |collection|}}+ {{component+ (component-for-collection collection.identifier this.selectKit)+ collection=collection+ selectKit=this.selectKit+ value=this.value+ }}+ {{/each}}++ {{#if this.selectKit.filter}}+ {{#if (and this.selectKit.hasNoContent (not this.selectKit.isLoading))}}+ <span class="no-content" role="alert">+ {{i18n "select_kit.no_content"}}+ </span>+ {{else}}+ <span class="results-count" role="alert">+ {{i18n "select_kit.results_count" count=this.mainCollection.length}}+ </span>+ {{/if}}+ {{/if}}++ </SelectKit::SelectKitBody>+{{/unless}}diff --cc app/assets/javascripts/select-kit/addon/components/tag-drop/tag-drop-header.gjsindex 549e1f30788,1bd8b564f8b..e330158095a--- a/app/assets/javascripts/select-kit/addon/components/tag-drop/tag-drop-header.gjs+++ b/app/assets/javascripts/select-kit/addon/components/tag-drop/tag-drop-header.gjs@@@ -1,11 -1,5 +1,17 @@@+ import { classNames } from "@ember-decorators/component";+ import ComboBoxSelectBoxHeaderComponent from "select-kit/components/combo-box/combo-box-header";++ @classNames("tag-drop-header")+ export default class TagDropHeader extends ComboBoxSelectBoxHeaderComponent {}+++<div class="select-kit-header-wrapper">+ {{component+ this.selectKit.options.selectedNameComponent+ tabindex=this.tabindex+ item=this.selectedContent+ selectKit=this.selectKit+ shouldDisplayClearableButton=this.shouldDisplayClearableButton+ }}++ {{d-icon this.caretIcon class="caret-icon"}}+</div>diff --cc plugins/chat/assets/javascripts/discourse/components/user-menu/chat-notifications-list-empty-state.gjsindex 47a8d9119b3,742bb3c18ef..3f3193efd97--- a/plugins/chat/assets/javascripts/discourse/components/user-menu/chat-notifications-list-empty-state.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/user-menu/chat-notifications-list-empty-state.gjs@@@ -1,15 -1,3 +1,19 @@@+ import templateOnly from "@ember/component/template-only";++ export default templateOnly();+++<div class="empty-state">+ <span class="empty-state-title">+ {{i18n "user_menu.no_chat_notifications_title"}}+ </span>+ <div class="empty-state-body">+ <p>+ {{html-safe+ (i18n+ "user_menu.no_chat_notifications_body"+ preferencesUrl=(get-url "/my/preferences/notifications")+ )+ }}+ </p>+ </div>+</div>