A platform for community discussion. Free, open, simple.
DEV: [gjs-codemod] Convert final core components/routes to gjs
David Taylore41897a30661
diff --git a/app/assets/javascripts/discourse/app/components/anonymous-topic-footer-buttons.gjs b/app/assets/javascripts/discourse/app/components/anonymous-topic-footer-buttons.gjsindex 304d0929a85..2de99730c8d 100644--- 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,6 +1,10 @@import Component from "@ember/component";+import { concat } from "@ember/helper";import { computed } from "@ember/object";import { attributeBindings } from "@ember-decorators/component";+import DButton from "discourse/components/d-button";+import concatClass from "discourse/helpers/concat-class";+import routeAction from "discourse/helpers/route-action";import { getTopicFooterButtons } from "discourse/lib/register-topic-footer-button";@attributeBindings("role")@@ -17,29 +21,31 @@ export default class AnonymousTopicFooterButtons extends Component {.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>\ No newline at end of file+ <template>+ <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={{routeAction "showLogin"}}+ @label="topic.reply.title"+ class="btn-primary"+ />+ </div>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/edit-category-panel.gjs b/app/assets/javascripts/discourse/app/components/edit-category-panel.gjsindex af59213910a..8ff2469a6cd 100644--- a/app/assets/javascripts/discourse/app/components/edit-category-panel.gjs+++ b/app/assets/javascripts/discourse/app/components/edit-category-panel.gjs@@ -1,8 +1,21 @@import Component from "@ember/component";import { equal } from "@ember/object/computed";+import { getOwner } from "@ember/owner";import { classNameBindings } from "@ember-decorators/component";-export default class EditCategoryPanel extends Component {}+export default class EditCategoryPanel extends Component {+ get resolvedComponent() {+ return getOwner(this).resolveRegistration(this.customComponent);+ }++ <template>+ <this.resolvedComponent+ @tab={{this.tab}}+ @selectedTab={{this.selectedTab}}+ @category={{this.category}}+ />+ </template>+}export function buildCategoryPanel(tab) {@classNameBindings(@@ -15,10 +28,3 @@ export function buildCategoryPanel(tab) {}return BuiltCategoryPanel;}--{{component- this.customComponent- tab=this.tab- selectedTab=this.selectedTab- category=this.category-}}\ No newline at end of filediff --git 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.gjsindex da08330735b..4f408eb01de 100644--- 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,10 +1,17 @@import Component from "@glimmer/component";import { tracked } from "@glimmer/tracking";+import { on } from "@ember/modifier";import { action } from "@ember/object";import { service } from "@ember/service";+import DButton from "discourse/components/d-button";+import DModal from "discourse/components/d-modal";+import DModalCancel from "discourse/components/d-modal-cancel";+import DToggleSwitch from "discourse/components/d-toggle-switch";+import Wrapper from "discourse/components/form-template-field/wrapper";import { ajax } from "discourse/lib/ajax";import { popupAjaxError } from "discourse/lib/ajax-error";import { i18n } from "discourse-i18n";+import HighlightedCode from "admin/components/highlighted-code";export default class CustomizeFormTemplateViewModal extends Component {@service router;@@ -42,42 +49,44 @@ export default class CustomizeFormTemplateViewModal extends Component {},});}-}-<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>+ <template>+ <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}}+ <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>\ No newline at end of file+ <: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>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/modal/tag-upload.gjs b/app/assets/javascripts/discourse/app/components/modal/tag-upload.gjsindex ea1d3c72d82..a19293dd378 100644--- a/app/assets/javascripts/discourse/app/components/modal/tag-upload.gjs+++ b/app/assets/javascripts/discourse/app/components/modal/tag-upload.gjs@@ -1,9 +1,19 @@-<DModal @title={{i18n "tagging.upload"}} @closeModal={{@closeModal}}>- <:body>- <TagsUploader- @refresh={{route-action "triggerRefresh"}}- @closeModal={{@closeModal}}- @id="tags-uploader"- />- </:body>-</DModal>\ No newline at end of file+import DModal from "discourse/components/d-modal";+import routeAction from "discourse/helpers/route-action";+import { optionalRequire } from "discourse/lib/utilities";+import { i18n } from "discourse-i18n";++const TagsUploader = optionalRequire("admin/components/tags-uploader");++const TagUpload = <template>+ <DModal @title={{i18n "tagging.upload"}} @closeModal={{@closeModal}}>+ <:body>+ <TagsUploader+ @refresh={{routeAction "triggerRefresh"}}+ @closeModal={{@closeModal}}+ @id="tags-uploader"+ />+ </:body>+ </DModal>+</template>;+export default TagUpload;diff --git a/app/assets/javascripts/discourse/app/components/reviewable-item.gjs b/app/assets/javascripts/discourse/app/components/reviewable-item.gjsindex 1c2ef531952..9ce2e2d2713 100644--- a/app/assets/javascripts/discourse/app/components/reviewable-item.gjs+++ b/app/assets/javascripts/discourse/app/components/reviewable-item.gjs@@ -1,22 +1,42 @@import { tracked } from "@glimmer/tracking";import Component from "@ember/component";+import { concat, fn, hash } from "@ember/helper";+import { on } from "@ember/modifier";import { action, set } from "@ember/object";import { alias } from "@ember/object/computed";import { getOwner } from "@ember/owner";+import { LinkTo } from "@ember/routing";import { service } from "@ember/service";import { classify, dasherize } from "@ember/string";import { tagName } from "@ember-decorators/component";+import DButton from "discourse/components/d-button";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 PluginOutlet from "discourse/components/plugin-outlet";+import ReviewableBundledAction from "discourse/components/reviewable-bundled-action";+import ReviewableClaimedTopic from "discourse/components/reviewable-claimed-topic";+import ReviewableCreatedByName from "discourse/components/reviewable-created-by-name";+import ageWithTooltip from "discourse/helpers/age-with-tooltip";+import avatar from "discourse/helpers/avatar";+import concatClass from "discourse/helpers/concat-class";+import icon from "discourse/helpers/d-icon";+import dasherizeHelper from "discourse/helpers/dasherize";+import editableValue from "discourse/helpers/editable-value";+import htmlSafe from "discourse/helpers/html-safe";+import reviewableStatus from "discourse/helpers/reviewable-status";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 { optionalRequire } from "discourse/lib/utilities";import Category from "discourse/models/category";import Composer from "discourse/models/composer";import Topic from "discourse/models/topic";import { i18n } from "discourse-i18n";+import ReviewableScores from "./reviewable-scores";++const IpLookup = optionalRequire("admin/components/ip-lookup");let _components = {};@@ -44,6 +64,10 @@ export function registerReviewableActionModal(actionName, modalClass) {actionModalClassMap[actionName] = modalClass;}+function lookupComponent(context, name) {+ return getOwner(context).resolveRegistration(`component:${name}`);+}+@tagName("")export default class ReviewableItem extends Component {@service dialog;@@ -519,158 +543,164 @@ export default class ReviewableItem extends Component {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"+ <template>+ <div+ data-reviewable-id={{this.reviewable.id}}+ class="reviewable-item {{this.customClasses}}">- {{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>+ <div class="reviewable-meta-data">+ <span+ class={{concatClass+ "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}}+ >{{ageWithTooltip this.reviewable.created_at}}</LinkTo>+ </span>+ <span class="status">+ {{reviewableStatus this.reviewable.status this.reviewable.type}}+ </span>+ <a+ href+ {{on "click" (fn this.explainReviewable this.reviewable)}}+ title={{i18n "review.explain.why"}}+ class="explain"+ >+ {{icon "circle-question"}}+ </a>+ </div>- {{#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 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 {{dasherizeHelper f.id}}">+ {{#let+ (lookupComponent this (concat "reviewable-field-" f.type))+ as |FieldComponent|+ }}+ <FieldComponent+ @tagName=""+ @value={{editableValue this.reviewable f.id}}+ @tagCategoryId={{this.tagCategoryId}}+ @valueChanged={{action "valueChanged" f.id}}+ @categoryChanged={{action "categoryChanged"}}+ />+ {{/let}}+ </div>+ {{/each}}</div>- {{/each}}+ {{else}}+ {{#let+ (lookupComponent this this.reviewableComponent)+ as |ReviewableComponent|+ }}+ <ReviewableComponent @reviewable={{this.reviewable}} @tagName="">+ <ReviewableScores @reviewable={{this.reviewable}} @tagName="" />+ </ReviewableComponent>+ {{/let}}+ {{/if}}</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"- />++ {{#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">{{htmlSafe+ (i18n+ "review.stale_help"+ username=this.reviewable.last_performing_username+ )+ }}</div>{{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 this.claimEnabled}}+ <div class="claimed-actions">+ <span class="help">{{htmlSafe 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}}- {{/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>\ No newline at end of file+ {{#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>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/user-menu/items-list.gjs b/app/assets/javascripts/discourse/app/components/user-menu/items-list.gjsindex 8a9d0c9eb9f..2479839f24e 100644--- 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,7 +1,15 @@import Component from "@glimmer/component";import { tracked } from "@glimmer/tracking";+import { hash } from "@ember/helper";+import { on } from "@ember/modifier";import { action } from "@ember/object";+import { getOwner } from "@ember/owner";import { service } from "@ember/service";+import DButton from "discourse/components/d-button";+import PluginOutlet from "discourse/components/plugin-outlet";+import MenuItem from "discourse/components/user-menu/menu-item";+import icon from "discourse/helpers/d-icon";+import { i18n } from "discourse-i18n";export default class UserMenuItemsList extends Component {@service session;@@ -30,6 +38,15 @@ export default class UserMenuItemsList extends Component {return "user-menu/items-list-empty-state";}+ get resolvedEmptyStateComponent() {+ const component = this.emptyStateComponent;+ if (typeof component === "string") {+ return getOwner(this).resolveRegistration(`component:${component}`);+ } else {+ return component;+ }+ }+get renderDismissConfirmation() {return false;}@@ -86,63 +103,65 @@ export default class UserMenuItemsList extends Component {`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}}+ <template>+ <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|}}+ <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}}+ >+ {{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}}+ >+ {{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}}>- {{d-icon "check"}}- {{i18n "user.dismiss"}}- </button>+ <this.resolvedEmptyStateComponent />+ </PluginOutlet>{{/if}}<PluginOutlet- @name="panel-body-bottom"- @outletArgs={{hash- itemsCacheKey=this.itemsCacheKey- closeUserMenu=@closeUserMenu- showDismiss=this.showDismiss- dismissButtonClick=this.dismissButtonClick- }}+ @name="after-panel-body"+ @outletArgs={{hash closeUserMenu=@closeUserMenu}}/>- </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}}-/>\ No newline at end of file+ </template>+}diff --git a/app/assets/javascripts/discourse/app/static/wizard/components/fields/image.gjs b/app/assets/javascripts/discourse/app/static/wizard/components/fields/image.gjsindex f6dc3365e38..028140d2034 100644--- 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,11 +1,13 @@import Component from "@ember/component";import { warn } from "@ember/debug";+import { getOwner } from "@ember/owner";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 concatClass from "discourse/helpers/concat-class";import discourseComputed from "discourse/lib/decorators";import getUrl from "discourse/lib/get-url";import { i18n } from "discourse-i18n";@@ -19,7 +21,8 @@ export default class Image extends Component {@discourseComputed("field.id")previewComponent(id) {- return imagePreviews[dasherize(id)] ?? imagePreviews.generic;+ const name = imagePreviews[dasherize(id)] ?? imagePreviews.generic;+ return getOwner(this).resolveRegistration(`component:${name}`);}didInsertElement() {@@ -92,34 +95,35 @@ export default class Image extends Component {});});}-}-<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}}\ No newline at end of file+ <template>+ <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}}+ <this.previewComponent+ @field={{this.field}}+ @fieldClass={{this.fieldClass}}+ @wizard={{this.wizard}}+ />+ {{/if}}+ </template>+}diff --git a/app/assets/javascripts/discourse/app/templates/edit-category-tabs.gjs b/app/assets/javascripts/discourse/app/templates/edit-category-tabs.gjsindex 7dd3f710372..8a13e0d9366 100644--- a/app/assets/javascripts/discourse/app/templates/edit-category-tabs.gjs+++ b/app/assets/javascripts/discourse/app/templates/edit-category-tabs.gjs@@ -1,132 +1,151 @@-<div class="edit-category {{if this.expandedMenu 'expanded-menu'}}">- <div class="edit-category-title-bar">- <div class="edit-category-title">- <h2>{{this.title}}</h2>- {{#if this.model.id}}- <BreadCrumbs- @categories={{this.breadcrumbCategories}}- @category={{this.model}}- @noSubcategories={{this.model.noSubcategories}}- @editingCategory={{true}}- @editingCategoryTab={{this.selectedTab}}- />- {{/if}}- </div>- {{#if (and this.site.desktopView this.model.id)}}- <DButton- @action={{action "goBack"}}- @label="category.back"- @icon="caret-left"- class="category-back"- />- {{/if}}- </div>+import { fn } from "@ember/helper";+import { getOwner } from "@ember/owner";+import RouteTemplate from "ember-route-template";+import { and, not } from "truth-helpers";+import BreadCrumbs from "discourse/components/bread-crumbs";+import DButton from "discourse/components/d-button";+import EditCategoryTab from "discourse/components/edit-category-tab";+import Form from "discourse/components/form";+import htmlSafe from "discourse/helpers/html-safe";++function lookupComponent(context, name) {+ return getOwner(context).resolveRegistration(`component:${name}`);+}- <div class="edit-category-nav">- <ul class="nav nav-stacked">- <EditCategoryTab- @panels={{this.panels}}- @selectedTab={{this.selectedTab}}- @params={{this.parentParams}}- @tab="general"- />- <EditCategoryTab- @panels={{this.panels}}- @selectedTab={{this.selectedTab}}- @params={{this.parentParams}}- @tab="security"- />- <EditCategoryTab- @panels={{this.panels}}- @selectedTab={{this.selectedTab}}- @params={{this.parentParams}}- @tab="settings"- />- <EditCategoryTab- @panels={{this.panels}}- @selectedTab={{this.selectedTab}}- @params={{this.parentParams}}- @tab="images"- />- <EditCategoryTab- @panels={{this.panels}}- @selectedTab={{this.selectedTab}}- @params={{this.parentParams}}- @tab="topic-template"- />- {{#if this.siteSettings.tagging_enabled}}- <EditCategoryTab- @panels={{this.panels}}- @selectedTab={{this.selectedTab}}- @params={{this.parentParams}}- @tab="tags"- />- {{/if}}+export default RouteTemplate(+ <template>+ <div class="edit-category {{if @controller.expandedMenu 'expanded-menu'}}">+ <div class="edit-category-title-bar">+ <div class="edit-category-title">+ <h2>{{@controller.title}}</h2>+ {{#if @controller.model.id}}+ <BreadCrumbs+ @categories={{@controller.breadcrumbCategories}}+ @category={{@controller.model}}+ @noSubcategories={{@controller.model.noSubcategories}}+ @editingCategory={{true}}+ @editingCategoryTab={{@controller.selectedTab}}+ />+ {{/if}}+ </div>+ {{#if (and @controller.site.desktopView @controller.model.id)}}+ <DButton+ @action={{@controller.goBack}}+ @label="category.back"+ @icon="caret-left"+ class="category-back"+ />+ {{/if}}+ </div>- {{#if this.siteSettings.experimental_content_localization}}- <EditCategoryTab- @panels={{this.panels}}- @selectedTab={{this.selectedTab}}- @params={{this.parentParams}}- @tab="localizations"- />- {{/if}}- </ul>- </div>+ <div class="edit-category-nav">+ <ul class="nav nav-stacked">+ <EditCategoryTab+ @panels={{@controller.panels}}+ @selectedTab={{@controller.selectedTab}}+ @params={{@controller.parentParams}}+ @tab="general"+ />+ <EditCategoryTab+ @panels={{@controller.panels}}+ @selectedTab={{@controller.selectedTab}}+ @params={{@controller.parentParams}}+ @tab="security"+ />+ <EditCategoryTab+ @panels={{@controller.panels}}+ @selectedTab={{@controller.selectedTab}}+ @params={{@controller.parentParams}}+ @tab="settings"+ />+ <EditCategoryTab+ @panels={{@controller.panels}}+ @selectedTab={{@controller.selectedTab}}+ @params={{@controller.parentParams}}+ @tab="images"+ />+ <EditCategoryTab+ @panels={{@controller.panels}}+ @selectedTab={{@controller.selectedTab}}+ @params={{@controller.parentParams}}+ @tab="topic-template"+ />+ {{#if @controller.siteSettings.tagging_enabled}}+ <EditCategoryTab+ @panels={{@controller.panels}}+ @selectedTab={{@controller.selectedTab}}+ @params={{@controller.parentParams}}+ @tab="tags"+ />+ {{/if}}- <Form- @data={{this.formData}}- @onDirtyCheck={{this.isLeavingForm}}- as |form transientData|- >- <form.Section- @title={{this.selectedTabTitle}}- class="edit-category-content"- >- {{#each this.panels as |tab|}}- {{component- tab- selectedTab=this.selectedTab- category=this.model- action=this.registerValidator- transientData=transientData- form=form- }}- {{/each}}- </form.Section>+ {{#if @controller.siteSettings.experimental_content_localization}}+ <EditCategoryTab+ @panels={{@controller.panels}}+ @selectedTab={{@controller.selectedTab}}+ @params={{@controller.parentParams}}+ @tab="localizations"+ />+ {{/if}}+ </ul>+ </div>- {{#if this.showDeleteReason}}- <form.Alert @type="warning" class="edit-category-delete-warning">- {{html-safe this.model.cannot_delete_reason}}- </form.Alert>- {{/if}}+ <Form+ @data={{@controller.formData}}+ @onDirtyCheck={{@controller.isLeavingForm}}+ as |form transientData|+ >+ <form.Section+ @title={{@controller.selectedTabTitle}}+ class="edit-category-content"+ >+ {{#each @controller.panels as |tabName|}}+ {{#let (lookupComponent @controller tabName) as |Tab|}}+ <Tab+ @selectedTab={{@controller.selectedTab}}+ @category={{@controller.model}}+ @action={{@controller.registerValidator}}+ @transientData={{transientData}}+ @form={{form}}+ />+ {{/let}}+ {{/each}}+ </form.Section>- <form.Actions class="edit-category-footer">- <form.Button- @disabled={{not (this.canSaveForm transientData)}}- @action={{fn this.saveCategory transientData}}- @label={{this.saveLabel}}- id="save-category"- class="btn-primary"- />+ {{#if @controller.showDeleteReason}}+ <form.Alert @type="warning" class="edit-category-delete-warning">+ {{htmlSafe @controller.model.cannot_delete_reason}}+ </form.Alert>+ {{/if}}- {{#if this.model.can_delete}}- <form.Button- @disabled={{this.deleteDisabled}}- @action={{this.deleteCategory}}- @icon="trash-can"- @label="category.delete"- class="btn-danger"- />- {{else if this.model.id}}- <form.Button- @disabled={{this.deleteDisabled}}- @action={{this.toggleDeleteTooltip}}- @icon="circle-question"- @label="category.delete"- class="btn-default"- />- {{/if}}- </form.Actions>- </Form>-</div>\ No newline at end of file+ <form.Actions class="edit-category-footer">+ <form.Button+ @disabled={{not (@controller.canSaveForm transientData)}}+ @action={{fn @controller.saveCategory transientData}}+ @label={{@controller.saveLabel}}+ id="save-category"+ class="btn-primary"+ />++ {{#if @controller.model.can_delete}}+ <form.Button+ @disabled={{@controller.deleteDisabled}}+ @action={{@controller.deleteCategory}}+ @icon="trash-can"+ @label="category.delete"+ class="btn-danger"+ />+ {{else if @controller.model.id}}+ <form.Button+ @disabled={{@controller.deleteDisabled}}+ @action={{@controller.toggleDeleteTooltip}}+ @icon="circle-question"+ @label="category.delete"+ class="btn-default"+ />+ {{/if}}+ </form.Actions>+ </Form>+ </div>+ </template>+);diff --git 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.gjsindex 9dcd65acd92..9981dc6ea5b 100644--- 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,7 +1,9 @@import { reads } from "@ember/object/computed";import { classNames } from "@ember-decorators/component";+import icon from "discourse/helpers/d-icon";import discourseComputed from "discourse/lib/decorators";import ComboBoxSelectBoxHeaderComponent from "select-kit/components/combo-box/combo-box-header";+import { resolveComponent } from "select-kit/components/select-kit";@classNames("category-drop-header")export default class CategoryDropHeader extends ComboBoxSelectBoxHeaderComponent {@@ -16,17 +18,23 @@ export default class CategoryDropHeader extends ComboBoxSelectBoxHeaderComponentcategoryTextColor(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- }}+ <template>+ <div class="select-kit-header-wrapper">+ {{#let+ (resolveComponent this this.selectKit.options.selectedNameComponent)+ as |SelectedNameComponent|+ }}+ <SelectedNameComponent+ @tabindex={{this.tabindex}}+ @item={{this.selectedContent}}+ @selectKit={{this.selectKit}}+ @shouldDisplayIcon={{this.shouldDisplayIcon}}+ @shouldDisplayClearableButton={{this.shouldDisplayClearableButton}}+ />+ {{/let}}- {{d-icon this.caretIcon class="caret-icon"}}-</div>\ No newline at end of file+ {{icon this.caretIcon class="caret-icon"}}+ </div>+ </template>+}diff --git 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.gjsindex 317cff83e58..16be296d349 100644--- 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,6 +1,9 @@import { computed } from "@ember/object";import { and, reads } from "@ember/object/computed";import { classNames } from "@ember-decorators/component";+import DButton from "discourse/components/d-button";+import icon from "discourse/helpers/d-icon";+import { resolveComponent } from "select-kit/components/select-kit";import SingleSelectHeaderComponent from "select-kit/components/select-kit/single-select-header";@classNames("combo-box-header")@@ -14,26 +17,32 @@ export default class ComboBoxHeader extends SingleSelectHeaderComponent {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}}+ <template>+ <div class="select-kit-header-wrapper">+ {{#each this.icons as |iconName|}} {{icon iconName}} {{/each}}- {{component- this.selectKit.options.selectedNameComponent- tabindex=this.tabindex- item=this.selectedContent- selectKit=this.selectKit- }}+ {{#let+ (resolveComponent this this.selectKit.options.selectedNameComponent)+ as |SelectedNameComponent|+ }}+ <SelectedNameComponent+ @tabindex={{this.tabindex}}+ @item={{this.selectedContent}}+ @selectKit={{this.selectKit}}+ />+ {{/let}}- {{#if this.shouldDisplayClearableButton}}- <DButton- @icon="xmark"- @action={{this.selectKit.onClearSelection}}- @ariaLabel="clear_input"- class="btn-clear"- />- {{/if}}+ {{#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>\ No newline at end of file+ {{icon this.caretIcon class="caret-icon"}}+ </div>+ </template>+}diff --git 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.gjsindex 34e7c28ea79..3c28d37ca87 100644--- 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,6 +1,8 @@import { computed } from "@ember/object";import { readOnly } from "@ember/object/computed";import { classNameBindings, classNames } from "@ember-decorators/component";+import icon from "discourse/helpers/d-icon";+import { resolveComponent } from "select-kit/components/select-kit";import SingleSelectHeaderComponent from "select-kit/components/select-kit/single-select-header";@classNames("dropdown-select-box-header")@@ -26,22 +28,28 @@ export default class DropdownSelectBoxHeader extends SingleSelectHeaderComponentget caretIcon() {return this.selectKit.isExpanded ? this.caretUpIcon : this.caretDownIcon;}-}-<div class="select-kit-header-wrapper">- {{#each this.icons as |icon|}} {{d-icon icon}} {{/each}}+ <template>+ <div class="select-kit-header-wrapper">+ {{#each this.icons as |iconName|}} {{icon iconName}} {{/each}}- {{component- this.selectKit.options.selectedNameComponent- tabindex=this.tabindex- item=this.selectedContent- selectKit=this.selectKit- shouldDisplayClearableButton=this.shouldDisplayClearableButton- }}+ {{#let+ (resolveComponent this this.selectKit.options.selectedNameComponent)+ as |SelectedNameComponent|+ }}+ <SelectedNameComponent+ @tabindex={{this.tabindex}}+ @item={{this.selectedContent}}+ @selectKit={{this.selectKit}}+ @shouldDisplayClearableButton={{this.shouldDisplayClearableButton}}+ />+ {{/let}}- {{#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>\ No newline at end of file+ {{#if this.selectKit.options.showCaret}}+ {{icon this.caretIcon class="caret-icon"}}+ {{/if}}+ ​+ {{! Zero-width space character, so icon-only button height = regular button height }}+ </div>+ </template>+}diff --git 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.gjsindex a27ceb47aab..8eea6f66c29 100644--- 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,28 +1,36 @@import { classNames } from "@ember-decorators/component";+import icon from "discourse/helpers/d-icon";import ComboBoxHeaderComponent from "select-kit/components/combo-box/combo-box-header";+import { resolveComponent } from "select-kit/components/select-kit";@classNames("future-date-input-selector-header")-export default class FutureDateInputSelectorHeader extends ComboBoxHeaderComponent {}+export default class FutureDateInputSelectorHeader extends ComboBoxHeaderComponent {+ <template>+ <div class="select-kit-header-wrapper">+ {{#if this.icons}}+ <div class="future-date-input-selector-icons">+ {{#each this.icons as |iconName|}} {{icon iconName}} {{/each}}+ </div>+ {{/if}}-<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- }}+ {{#let+ (resolveComponent this this.selectKit.options.selectedNameComponent)+ as |SelectedNameComponent|+ }}+ <SelectedNameComponent+ @tabindex={{this.tabindex}}+ @item={{this.selectedContent}}+ @selectKit={{this.selectKit}}+ />+ {{/let}}- {{#if this.selectedContent.timeFormatted}}- <span class="future-date-input-selector-datetime">- {{this.selectedContent.timeFormatted}}- </span>- {{/if}}+ {{#if this.selectedContent.timeFormatted}}+ <span class="future-date-input-selector-datetime">+ {{this.selectedContent.timeFormatted}}+ </span>+ {{/if}}- {{d-icon this.caretIcon class="caret-icon"}}-</div>\ No newline at end of file+ {{icon this.caretIcon class="caret-icon"}}+ </div>+ </template>+}diff --git a/app/assets/javascripts/select-kit/addon/components/multi-select.gjs b/app/assets/javascripts/select-kit/addon/components/multi-select.gjsindex 1903e81a3a4..8bd18e1c6c6 100644--- a/app/assets/javascripts/select-kit/addon/components/multi-select.gjs+++ b/app/assets/javascripts/select-kit/addon/components/multi-select.gjs@@ -1,12 +1,18 @@+import { concat } from "@ember/helper";import { computed } from "@ember/object";import { next } from "@ember/runloop";import { isPresent } from "@ember/utils";import { classNames } from "@ember-decorators/component";+import { and, not } from "truth-helpers";+import componentForCollection from "discourse/helpers/component-for-collection";import { makeArray } from "discourse/lib/helpers";+import { i18n } from "discourse-i18n";import SelectKitComponent, {pluginApiIdentifiers,+ resolveComponent,selectKitOptions,} from "select-kit/components/select-kit";+import SelectKitBody from "select-kit/components/select-kit/select-kit-body";@classNames("multi-select")@selectKitOptions({@@ -193,62 +199,89 @@ export default class MultiSelect extends SelectKitComponent {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")+ <template>+ {{#unless this.selectKit.isHidden}}+ {{#let+ (resolveComponent this this.selectKit.options.headerComponent)+ as |HeaderComponent|}}+ <HeaderComponent+ @tabindex={{this.tabindex}}+ @value={{this.value}}+ @selectedContent={{this.selectedContent}}+ @selectKit={{this.selectKit}}+ @id={{concat this.selectKit.uniqueID "-header"}}+ />+ {{/let}}- {{#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}}+ <SelectKitBody+ @selectKit={{this.selectKit}}+ @id={{concat this.selectKit.uniqueID "-body"}}+ >+ {{#unless this.selectKit.options.useHeaderFilter}}+ {{#let+ (resolveComponent this this.selectKit.options.filterComponent)+ as |FilterComponent|+ }}+ <FilterComponent+ @selectKit={{this.selectKit}}+ @id={{concat this.selectKit.uniqueID "-filter"}}+ />+ {{/let}}- {{#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}}\ No newline at end of file+ {{#if this.selectedContent.length}}+ <div class="selected-content">+ {{#let+ (resolveComponent+ this this.selectKit.options.selectedChoiceComponent+ )+ as |SelectedChoiceComponent|+ }}+ {{#each this.selectedContent as |item|}}+ <SelectedChoiceComponent+ @item={{item}}+ @selectKit={{this.selectKit}}+ @mandatoryValues={{@mandatoryValues}}+ />+ {{/each}}+ {{/let}}+ </div>+ {{/if}}+ {{/unless}}++ {{#each this.collections as |collection|}}+ {{#let+ (resolveComponent+ this (componentForCollection collection.identifier this.selectKit)+ )+ as |CollectionComponent|+ }}+ <CollectionComponent+ @collection={{collection}}+ @selectKit={{this.selectKit}}+ @value={{this.value}}+ />+ {{/let}}+ {{/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}}+ </SelectKitBody>+ {{/unless}}+ </template>+}diff --git 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.gjsindex c9acbe5dcd5..b8816a3d4cd 100644--- 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,3 +1,4 @@+import { concat } from "@ember/helper";import { computed } from "@ember/object";import { reads } from "@ember/object/computed";import {@@ -5,6 +6,10 @@ import {classNames,tagName,} from "@ember-decorators/component";+import { or } from "truth-helpers";+import icon from "discourse/helpers/d-icon";+import FormatSelectedContent from "select-kit/components/multi-select/format-selected-content";+import { resolveComponent } from "select-kit/components/select-kit";import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";@tagName("summary")@@ -19,38 +24,50 @@ export default class MultiSelectHeader extends SelectKitHeaderComponent {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}}+ <template>+ <div class="select-kit-header-wrapper">+ {{#each this.icons as |iconName|}}+ {{icon iconName}}+ {{/each}}++ {{#if this.selectKit.options.useHeaderFilter}}+ <div class="select-kit-header--filter">+ {{#if this.selectedContent.length}}+ {{#let+ (resolveComponent+ this this.selectKit.options.selectedChoiceComponent+ )+ as |SelectedChoiceComponent|+ }}+ {{#each this.selectedContent as |item|}}+ <SelectedChoiceComponent+ @selectKit={{this.selectKit}}+ @item={{item}}+ />+ {{/each}}+ {{/let}}+ {{/if}}- {{#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+ {{#let+ (resolveComponent this this.selectKit.options.filterComponent)+ as |FilterComponent|}}- {{/each}}- {{/if}}+ <FilterComponent+ @selectKit={{this.selectKit}}+ @id={{concat this.selectKit.uniqueID "-filter"}}+ @hidePlaceholderWithSelection={{true}}+ />+ {{/let}}+ </div>+ {{else}}+ <FormatSelectedContent+ @content={{or this.selectedContent this.selectKit.noneItem}}+ @selectKit={{this.selectKit}}+ />- {{component- this.selectKit.options.filterComponent- selectKit=this.selectKit- id=(concat this.selectKit.uniqueID "-filter")- hidePlaceholderWithSelection=true- }}+ {{icon this.caretIcon class="caret-icon"}}+ {{/if}}</div>- {{else}}- <MultiSelect::FormatSelectedContent- @content={{or this.selectedContent this.selectKit.noneItem}}- @selectKit={{this.selectKit}}- />-- {{d-icon this.caretIcon class="caret-icon"}}- {{/if}}-</div>\ No newline at end of file+ </template>+}diff --git a/app/assets/javascripts/select-kit/addon/components/pinned-button.gjs b/app/assets/javascripts/select-kit/addon/components/pinned-button.gjsindex 3e2111ac5d7..23b4a7ede9e 100644--- a/app/assets/javascripts/select-kit/addon/components/pinned-button.gjs+++ b/app/assets/javascripts/select-kit/addon/components/pinned-button.gjs@@ -1,7 +1,9 @@import Component from "@ember/component";+import { htmlSafe } from "@ember/template";import { classNameBindings, classNames } from "@ember-decorators/component";import discourseComputed from "discourse/lib/decorators";import { i18n } from "discourse-i18n";+import PinnedOptions from "select-kit/components/pinned-options";import { pluginApiIdentifiers } from "select-kit/components/select-kit";@classNames("pinned-button")@@ -23,13 +25,15 @@ export default class PinnedButton extends Component {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}}\ No newline at end of file+ <template>+ {{#if this.appendReason}}+ <p class="reason">+ <PinnedOptions @value={{this.pinned}} @topic={{this.topic}} />+ <span class="text">{{htmlSafe this.reasonText}}</span>+ </p>+ {{else}}+ <PinnedOptions @value={{this.pinned}} @topic={{this.topic}} />+ {{/if}}+ </template>+}diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit.js b/app/assets/javascripts/select-kit/addon/components/select-kit.jsindex b89b5610f6c..2240958205c 100644--- a/app/assets/javascripts/select-kit/addon/components/select-kit.js+++ b/app/assets/javascripts/select-kit/addon/components/select-kit.js@@ -1,6 +1,7 @@import Component from "@ember/component";import EmberObject, { computed, get } from "@ember/object";import { guidFor } from "@ember/object/internals";+import { getOwner } from "@ember/owner";import { bind, cancel, next, throttle } from "@ember/runloop";import { service } from "@ember/service";import { isEmpty, isNone, isPresent } from "@ember/utils";@@ -65,6 +66,16 @@ export function pluginApiIdentifiers(identifiers) {};}+export function resolveComponent(context, component) {+ const owner = getOwner(context);++ if (typeof component === "string") {+ return owner.resolveRegistration(`component:${component}`);+ }++ return component;+}+// Decorator which converts a field into a prototype property.// This allows the value to be overridden in subclasses, even if they're still// using the legacy Ember `.extend()` syntax.diff --git 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.gjsindex 44412b7c979..be1bd0e5dd2 100644--- 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@@ -2,11 +2,13 @@ import Component from "@ember/component";import { service } from "@ember/service";import { tagName } from "@ember-decorators/component";import { modifier } from "ember-modifier";+import componentForRow from "discourse/helpers/component-for-row";import {disableBodyScroll,enableBodyScroll,locks,} from "discourse/lib/body-scroll-lock";+import { resolveComponent } from "select-kit/components/select-kit";@tagName("")export default class SelectKitCollection extends Component {@@ -31,23 +33,32 @@ export default class SelectKitCollection extends Component {}};});-}-{{#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}}\ No newline at end of file+ <template>+ {{#if this.collection.content.length}}+ <ul+ class="select-kit-collection"+ aria-live="polite"+ role="menu"+ {{this.bodyScrollLock}}+ >+ {{#each this.collection.content as |item index|}}+ {{#let+ (resolveComponent+ this+ (componentForRow this.collection.identifier item this.selectKit)+ )+ as |RowComponent|+ }}+ <RowComponent+ @item={{item}}+ @index={{index}}+ @value={{this.value}}+ @selectKit={{this.selectKit}}+ />+ {{/let}}+ {{/each}}+ </ul>+ {{/if}}+ </template>+}diff --git 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.gjsindex 9d313011818..17cd1ee192d 100644--- 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@@ -5,7 +5,9 @@ import {classNames,tagName,} from "@ember-decorators/component";+import icon from "discourse/helpers/d-icon";import { i18n } from "discourse-i18n";+import { resolveComponent } from "select-kit/components/select-kit";import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";@tagName("summary")@@ -34,14 +36,20 @@ export default class SingleSelectHeader extends SelectKitHeaderComponent {return i18n("select_kit.select_to_filter");}}-}-<div class="select-kit-header-wrapper">- {{#each this.icons as |icon|}} {{d-icon icon}} {{/each}}+ <template>+ <div class="select-kit-header-wrapper">+ {{#each this.icons as |iconName|}} {{icon iconName}} {{/each}}- {{component- this.selectKit.options.selectedNameComponent- item=this.selectedContent- selectKit=this.selectKit- }}-</div>\ No newline at end of file+ {{#let+ (resolveComponent this this.selectKit.options.selectedNameComponent)+ as |SelectedNameComponent|+ }}+ <SelectedNameComponent+ @item={{this.selectedContent}}+ @selectKit={{this.selectKit}}+ />+ {{/let}}+ </div>+ </template>+}diff --git a/app/assets/javascripts/select-kit/addon/components/selected-choice-category.gjs b/app/assets/javascripts/select-kit/addon/components/selected-choice-category.gjsindex a480e25fdf3..11554cf0413 100644--- a/app/assets/javascripts/select-kit/addon/components/selected-choice-category.gjs+++ b/app/assets/javascripts/select-kit/addon/components/selected-choice-category.gjs@@ -17,12 +17,14 @@ export default class SelectedChoiceCategory extends SelectedChoiceComponent {}));}-}-<SelectedChoice- @item={{this.item}}- @selectKit={{this.selectKit}}- @extraClass={{this.extraClass}}->- {{this.badge}}-</SelectedChoice>\ No newline at end of file+ <template>+ <SelectedChoiceComponent+ @item={{this.item}}+ @selectKit={{this.selectKit}}+ @extraClass={{this.extraClass}}+ >+ {{this.badge}}+ </SelectedChoiceComponent>+ </template>+}diff --git a/app/assets/javascripts/select-kit/addon/components/single-select.gjs b/app/assets/javascripts/select-kit/addon/components/single-select.gjsindex 4f6b00b30e1..b236f0385ea 100644--- a/app/assets/javascripts/select-kit/addon/components/single-select.gjs+++ b/app/assets/javascripts/select-kit/addon/components/single-select.gjs@@ -1,10 +1,16 @@+import { concat } from "@ember/helper";import { computed } from "@ember/object";import { isEmpty } from "@ember/utils";import { classNames } from "@ember-decorators/component";+import { and, not } from "truth-helpers";+import componentForCollection from "discourse/helpers/component-for-collection";+import { i18n } from "discourse-i18n";import SelectKitComponent, {pluginApiIdentifiers,+ resolveComponent,selectKitOptions,} from "select-kit/components/select-kit";+import SelectKitBody from "select-kit/components/select-kit/select-kit-body";@classNames("single-select")@selectKitOptions({@@ -42,48 +48,69 @@ export default class SingleSelect extends SelectKitComponent {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")- }}+ <template>+ {{#unless this.selectKit.isHidden}}+ {{#let+ (resolveComponent this this.selectKit.options.headerComponent)+ as |HeaderComponent|+ }}+ <HeaderComponent+ @tabindex={{this.tabindex}}+ @value={{this.value}}+ @selectedContent={{this.selectedContent}}+ @selectKit={{this.selectKit}}+ @id={{concat this.selectKit.uniqueID "-header"}}+ />+ {{/let}}- <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")- }}+ <SelectKitBody+ @selectKit={{this.selectKit}}+ @id={{concat this.selectKit.uniqueID "-body"}}+ >+ {{#let+ (resolveComponent this this.selectKit.options.filterComponent)+ as |FilterComponent|+ }}+ <FilterComponent+ @selectKit={{this.selectKit}}+ @id={{concat this.selectKit.uniqueID "-filter"}}+ />+ {{/let}}- {{#each this.collections as |collection|}}- {{component- (component-for-collection collection.identifier this.selectKit)- collection=collection- selectKit=this.selectKit- value=this.value- }}- {{/each}}+ {{#each this.collections as |collection|}}+ {{#let+ (resolveComponent+ this (componentForCollection collection.identifier this.selectKit)+ )+ as |CollectionComponent|+ }}+ <CollectionComponent+ @collection={{collection}}+ @selectKit={{this.selectKit}}+ @value={{this.value}}+ />+ {{/let}}+ {{/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}}+ {{#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}}\ No newline at end of file+ </SelectKitBody>+ {{/unless}}+ </template>+}diff --git 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.gjsindex e330158095a..ab434a1a362 100644--- 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,17 +1,25 @@import { classNames } from "@ember-decorators/component";+import icon from "discourse/helpers/d-icon";import ComboBoxSelectBoxHeaderComponent from "select-kit/components/combo-box/combo-box-header";+import { resolveComponent } from "select-kit/components/select-kit";@classNames("tag-drop-header")-export default class TagDropHeader extends ComboBoxSelectBoxHeaderComponent {}+export default class TagDropHeader extends ComboBoxSelectBoxHeaderComponent {+ <template>+ <div class="select-kit-header-wrapper">+ {{#let+ (resolveComponent this this.selectKit.options.selectedNameComponent)+ as |SelectedNameComponent|+ }}+ <SelectedNameComponent+ @tabindex={{this.tabindex}}+ @item={{this.selectedContent}}+ @selectKit={{this.selectKit}}+ @shouldDisplayClearableButton={{this.shouldDisplayClearableButton}}+ />+ {{/let}}-<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>\ No newline at end of file+ {{icon this.caretIcon class="caret-icon"}}+ </div>+ </template>+}diff --git 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.gjsindex 3f3193efd97..4ba81f06273 100644--- 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,19 +1,23 @@-import templateOnly from "@ember/component/template-only";+import getUrl from "discourse/helpers/get-url";+import htmlSafe from "discourse/helpers/html-safe";+import { i18n } from "discourse-i18n";-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>+const ChatNotificationsListEmptyState = <template>+ <div class="empty-state">+ <span class="empty-state-title">+ {{i18n "user_menu.no_chat_notifications_title"}}+ </span>+ <div class="empty-state-body">+ <p>+ {{htmlSafe+ (i18n+ "user_menu.no_chat_notifications_body"+ preferencesUrl=(getUrl "/my/preferences/notifications")+ )+ }}+ </p>+ </div></div>-</div>\ No newline at end of file+</template>;++export default ChatNotificationsListEmptyState;