A platform for community discussion. Free, open, simple.
DEV: Remove unused classic components (#43390)
Jarek Radosza84bcba9cf02
diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 7b7f105440a..590de9486e8 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -339,7 +339,6 @@ en:zh_CN:name: Chinese Simplifiedshare:- topic_html: 'Topic: <span class="topic-title">%{topicTitle}</span>'post: "post #%{postNumber} by @%{username}"close: "close"twitter: "Share on X"@@ -575,9 +574,6 @@ en:max_of_count:one: "max of %{count}"other: "max of %{count}"- character_count:- one: "%{count} character"- other: "%{count} characters"period_chooser:aria_label: "Filter by period"diff --git a/docs/developer-guides/docs/03-code-internals/02-ui-kit.md b/docs/developer-guides/docs/03-code-internals/02-ui-kit.mdindex 43442fc8c9d..29575bd92c6 100644--- a/docs/developer-guides/docs/03-code-internals/02-ui-kit.md+++ b/docs/developer-guides/docs/03-code-internals/02-ui-kit.md@@ -84,7 +84,7 @@ Form-level composition belongs to [FormKit](22-form-kit.md). These are the under| `DDateInput`, `DDatePicker`, `DTimeInput`, `DDateTimeInput`, `DDateTimeInputRange`, `DFutureDateInput`, `DRelativeTimePicker`, `DTimeShortcutPicker`, `DCalendarDateTimeInput` | Dates, times, and ranges. | [Date/time inputs](https://meta.discourse.org/styleguide/atoms/date-time-inputs) || `DOtp`, `DSecondFactorInput` | One-time codes. | [OTP](https://meta.discourse.org/styleguide/atoms/otp) || `DFilterInput`, `DFilterControls` | Filter a list. | |-| `DColorPicker`, `DIconGridPicker`, `DPickFilesButton` | Specialised pickers. | |+| `DIconGridPicker`, `DPickFilesButton` | Specialised pickers. | || `DCharCounter`, `DInputTip`, `DPopupInputTip` | Feedback attached to an input. | [Char counter](https://meta.discourse.org/styleguide/molecules/char-counter) || `DAccessControl`, `DAccessControlField` | Edit access control lists. | || `DEditor` | The composer's markdown editor. | |diff --git a/frontend/discourse/admin/components/flag-user.gjs b/frontend/discourse/admin/components/flag-user.gjsdeleted file mode 100644index 2c99f04e213..00000000000--- a/frontend/discourse/admin/components/flag-user.gjs+++ /dev/null@@ -1,41 +0,0 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { array } from "@ember/helper";-import { LinkTo } from "@ember/routing";-import { tagName } from "@ember-decorators/component";-import dAgeWithTooltip from "discourse/ui-kit/helpers/d-age-with-tooltip";-import dAvatar from "discourse/ui-kit/helpers/d-avatar";--@tagName("")-export default class FlagUser extends Component {- <template>- <div ...attributes>- <div class="flag-user">- <LinkTo- class="flag-user-avatar"- @models={{array this.user.id this.user.username}}- @route="adminUser"- >- {{dAvatar this.user imageSize="small"}}- </LinkTo>- <div class="flag-user-details">- <div class="flag-user-who">- <LinkTo- class="flag-user-username"- @models={{array this.user.id this.user.username}}- @route="adminUser"- >- {{this.user.username}}- </LinkTo>- <div class="flag-user-date">- {{dAgeWithTooltip this.date}}- </div>- </div>- <div class="flag-user-extra">- {{yield}}- </div>- </div>- </div>- </div>- </template>-}diff --git a/frontend/discourse/admin/components/permalink-form.gjs b/frontend/discourse/admin/components/permalink-form.gjsdeleted file mode 100644index 589ca037cdc..00000000000--- a/frontend/discourse/admin/components/permalink-form.gjs+++ /dev/null@@ -1,141 +0,0 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { fn } from "@ember/helper";-import { action, computed } from "@ember/object";-import { schedule } from "@ember/runloop";-import { service } from "@ember/service";-import { tagName } from "@ember-decorators/component";-import Permalink from "discourse/admin/models/permalink";-import { bind } from "discourse/lib/decorators";-import ComboBox from "discourse/select-kit/components/combo-box";-import DButton from "discourse/ui-kit/d-button";-import DTextField from "discourse/ui-kit/d-text-field";-import { i18n } from "discourse-i18n";--@tagName("")-export default class PermalinkForm extends Component {- @service dialog;-- formSubmitted = false;- permalinkType = "topic_id";-- action = null;- permalinkTypeValue = null;-- @computed("permalinkType")- get permalinkTypePlaceholder() {- return `admin.permalink.${this.permalinkType}`;- }-- @computed- get permalinkTypes() {- return [- { id: "topic_id", name: i18n("admin.permalink.topic_id") },- { id: "post_id", name: i18n("admin.permalink.post_id") },- { id: "category_id", name: i18n("admin.permalink.category_id") },- { id: "tag_name", name: i18n("admin.permalink.tag_name") },- { id: "external_url", name: i18n("admin.permalink.external_url") },- { id: "user_id", name: i18n("admin.permalink.user_id") },- ];- }-- @bind- focusPermalink() {- schedule("afterRender", () =>- document.querySelector(".permalink-url")?.focus()- );- }-- @action- submitFormOnEnter(event) {- if (event.key === "Enter") {- this.onSubmit();- }- }-- @action- onSubmit() {- if (!this.formSubmitted) {- this.set("formSubmitted", true);-- Permalink.create({- url: this.url,- permalink_type: this.permalinkType,- permalink_type_value: this.permalinkTypeValue,- })- .save()- .then(- (result) => {- this.setProperties({- url: "",- permalinkTypeValue: "",- formSubmitted: false,- });-- this.action(Permalink.create(result.permalink));-- this.focusPermalink();- },- (e) => {- this.set("formSubmitted", false);-- let error;- if (e?.jqXHR?.responseJSON?.errors) {- error = i18n("generic_error_with_reason", {- error: e.jqXHR.responseJSON.errors.join(". "),- });- } else {- error = i18n("generic_error");- }-- this.dialog.alert({- message: error,- didConfirm: () => this.focusPermalink(),- didCancel: () => this.focusPermalink(),- });- }- );- }- }-- <template>- <div class="permalink-form">- <div class="inline-form">- <label>{{i18n "admin.permalink.form.label"}}</label>-- <DTextField- class="permalink-url"- @autocapitalize="off"- @autocorrect="off"- @disabled={{this.formSubmitted}}- @placeholderKey="admin.permalink.url"- @value={{this.url}}- />-- <ComboBox- class="permalink-type"- @content={{this.permalinkTypes}}- @onChange={{fn (mut this.permalinkType)}}- @value={{this.permalinkType}}- />-- <DTextField- class="permalink-destination"- @autocapitalize="off"- @autocorrect="off"- @disabled={{this.formSubmitted}}- @keyDown={{this.submitFormOnEnter}}- @placeholderKey={{this.permalinkTypePlaceholder}}- @value={{this.permalinkTypeValue}}- />-- <DButton- class="permalink-add"- @action={{this.onSubmit}}- @disabled={{this.formSubmitted}}- @label="admin.permalink.form.add"- />- </div>- </div>- </template>-}diff --git a/frontend/discourse/admin/components/site-customization-change-details.gjs b/frontend/discourse/admin/components/site-customization-change-details.gjsdeleted file mode 100644index 422dd13f727..00000000000--- a/frontend/discourse/admin/components/site-customization-change-details.gjs+++ /dev/null@@ -1,68 +0,0 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { tagName } from "@ember-decorators/component";-import SiteCustomizationChangeField from "discourse/admin/components/site-customization-change-field";-import { i18n } from "discourse-i18n";--@tagName("")-export default class SiteCustomizationChangeDetails extends Component {- <template>- <div ...attributes>- <section class="field">- <b>{{i18n "admin.customize.enabled"}}</b>:- {{this.change.enabled}}- </section>-- <SiteCustomizationChangeField- @field={{this.change.stylesheet}}- @name="admin.customize.css"- />- <SiteCustomizationChangeField- @field={{this.change.mobile_stylesheet}}- @icon="mobile"- @name="admin.customize.css"- />-- <SiteCustomizationChangeField- @field={{this.change.header}}- @name="admin.customize.header"- />- <SiteCustomizationChangeField- @field={{this.change.mobile_header}}- @icon="mobile"- @name="admin.customize.header"- />-- <SiteCustomizationChangeField- @field={{this.change.top}}- @name="admin.customize.top"- />- <SiteCustomizationChangeField- @field={{this.change.mobile_top}}- @icon="mobile"- @name="admin.customize.top"- />-- <SiteCustomizationChangeField- @field={{this.change.footer}}- @name="admin.customize.footer"- />- <SiteCustomizationChangeField- @field={{this.change.mobile_footer}}- @icon="mobile"- @name="admin.customize.footer"- />-- <SiteCustomizationChangeField- @field={{this.change.head_tag}}- @icon="file-text-o"- @name="admin.customize.head_tag.text"- />- <SiteCustomizationChangeField- @field={{this.change.body_tag}}- @icon="file-text-o"- @name="admin.customize.body_tag.text"- />- </div>- </template>-}diff --git a/frontend/discourse/admin/components/site-customization-change-field.gjs b/frontend/discourse/admin/components/site-customization-change-field.gjsdeleted file mode 100644index db0945d9cba..00000000000--- a/frontend/discourse/admin/components/site-customization-change-field.gjs+++ /dev/null@@ -1,22 +0,0 @@-/* eslint-disable ember/no-classic-components */-import Component, { Textarea } from "@ember/component";-import { tagName } from "@ember-decorators/component";-import { i18n } from "discourse-i18n";--@tagName("")-export default class SiteCustomizationChangeField extends Component {- <template>- <div ...attributes>- {{#if this.field}}- <section class="field">- <b>{{i18n this.name}}</b>: ({{i18n- "character_count"- count=this.field.length- }})- <br />- <Textarea class="plain" @value={{this.field}} />- </section>- {{/if}}- </div>- </template>-}diff --git a/frontend/discourse/app/components/discourse-tag-bound.gjs b/frontend/discourse/app/components/discourse-tag-bound.gjsdeleted file mode 100644index df1da74b615..00000000000--- a/frontend/discourse/app/components/discourse-tag-bound.gjs+++ /dev/null@@ -1,32 +0,0 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { computed } from "@ember/object";-import { tagName } from "@ember-decorators/component";-import getURL from "discourse/lib/get-url";-import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";--@tagName("")-export default class DiscourseTagBound extends Component {- @computed("tagRecord.name")- get tagClass() {- return "tag-" + this.tagRecord?.name;- }-- @computed("tagRecord.slug", "tagRecord.id")- get href() {- if (this.tagRecord?.id) {- const slugForUrl = this.tagRecord?.slug || `${this.tagRecord?.id}-tag`;- return getURL(`/tag/${slugForUrl}/${this.tagRecord?.id}`);- }- // fallback for tags without id- return getURL("/tag/" + this.tagRecord.name);- }-- <template>- <a- class={{dConcatClass "discourse-tag" this.style this.tagClass}}- href={{this.href}}- ...attributes- >{{this.tagRecord.name}}</a>- </template>-}diff --git a/frontend/discourse/app/components/group-member.gjs b/frontend/discourse/app/components/group-member.gjsdeleted file mode 100644index 8062829179e..00000000000--- a/frontend/discourse/app/components/group-member.gjs+++ /dev/null@@ -1,30 +0,0 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { on } from "@ember/modifier";-import { action } from "@ember/object";-import { tagName } from "@ember-decorators/component";-import dAvatar from "discourse/ui-kit/helpers/d-avatar";-import dIcon from "discourse/ui-kit/helpers/d-icon";--@tagName("")-export default class GroupMember extends Component {- @action- remove(event) {- event?.preventDefault();- this.removeAction(this.member);- }-- <template>- <div class="item" ...attributes>- <a href={{this.member.adminPath}}>- {{dAvatar this.member imageSize="small"}}- </a>- <span>{{this.member.username}}</span>- {{#unless this.automatic}}- <a class="remove" href {{on "click" this.remove}}>- {{dIcon "xmark"}}- </a>- {{/unless}}- </div>- </template>-}diff --git a/frontend/discourse/app/components/share-panel.gjs b/frontend/discourse/app/components/share-panel.gjsdeleted file mode 100644index f89745c9e5e..00000000000--- a/frontend/discourse/app/components/share-panel.gjs+++ /dev/null@@ -1,115 +0,0 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { action, computed, set } from "@ember/object";-import { trustHTML } from "@ember/template";-import { isEmpty } from "@ember/utils";-import ShareSource from "discourse/components/share-source";-import discourseLater from "discourse/lib/later";-import Sharing from "discourse/lib/sharing";-import { escapeExpression } from "discourse/lib/utilities";-import DTextarea from "discourse/ui-kit/d-textarea";-import { i18n } from "discourse-i18n";--export default class SharePanel extends Component {- tagName = null;-- @computed("panel.model.type")- get type() {- return this.panel?.model?.type;- }-- set type(value) {- set(this, "panel.model.type", value);- }-- @computed("panel.model.topic")- get topic() {- return this.panel?.model?.topic;- }-- set topic(value) {- set(this, "panel.model.topic", value);- }-- @computed("panel.model.topic.category.read_restricted")- get privateCategory() {- return this.panel?.model?.topic?.category?.read_restricted;- }-- set privateCategory(value) {- set(this, "panel.model.topic.category.read_restricted", value);- }-- @computed("topic.{isPrivateMessage,invisible,category}")- get sources() {- const privateContext =- this.siteSettings.login_required ||- (this.topic && this.topic?.isPrivateMessage) ||- (this.topic && this.topic?.invisible) ||- this.privateCategory;- return Sharing.activeSources(this.siteSettings.share_links, privateContext);- }-- @computed("type", "topic.title")- get shareTitle() {- const topicTitle = escapeExpression(this.topic?.title);- return i18n("share.topic_html", { topicTitle });- }-- @computed("panel.model.shareUrl", "topic.shareUrl")- get shareUrl() {- let shareUrl = this.panel?.model?.shareUrl || this.topic?.shareUrl;-- if (isEmpty(shareUrl)) {- return;- }-- // Relative urls- if (shareUrl.startsWith("/")) {- const location = window.location;- shareUrl = `${location.protocol}//${location.host}${shareUrl}`;- }-- return encodeURI(shareUrl);- }-- didInsertElement() {- super.didInsertElement(...arguments);- discourseLater(() => {- if (this.element) {- const textArea = this.element.querySelector(".topic-share-url");- textArea.style.height = textArea.scrollHeight + "px";- textArea.focus();- textArea.setSelectionRange(0, this.shareUrl.length);- }- }, 200);- }-- @action- share(source) {- Sharing.shareSource(source, {- url: this.shareUrl,- title: this.topic.get("title"),- });- }-- <template>- <div class="header">- <h3 class="title">{{trustHTML this.shareTitle}}</h3>- </div>-- <div class="body">- <DTextarea- class="topic-share-url"- @aria-label={{i18n "share.url"}}- @value={{this.shareUrl}}- />-- <div class="sources">- {{#each this.sources as |source|}}- <ShareSource @action={{this.share}} @source={{source}} />- {{/each}}- </div>- </div>- </template>-}diff --git a/frontend/discourse/app/ui-kit-shims.js b/frontend/discourse/app/ui-kit-shims.jsindex 8ac57196af5..b5436a7f07c 100644--- a/frontend/discourse/app/ui-kit-shims.js+++ b/frontend/discourse/app/ui-kit-shims.js@@ -80,12 +80,6 @@ loaderShim("discourse/components/cdn-img", () =>loaderShim("discourse/components/char-counter", () =>importSync("discourse/ui-kit/d-char-counter"));-loaderShim("discourse/components/color-picker", () =>- importSync("discourse/ui-kit/d-color-picker")-);-loaderShim("discourse/components/color-picker-choice", () =>- importSync("discourse/ui-kit/d-color-picker-choice")-);loaderShim("discourse/components/conditional-in-element", () =>importSync("discourse/ui-kit/d-conditional-in-element"));diff --git a/frontend/discourse/app/ui-kit/d-color-picker-choice.js b/frontend/discourse/app/ui-kit/d-color-picker-choice.jsdeleted file mode 100644index c0394e963e9..00000000000--- a/frontend/discourse/app/ui-kit/d-color-picker-choice.js+++ /dev/null@@ -1,35 +0,0 @@-/* eslint-disable ember/no-classic-components, ember/require-tagless-components */-import Component from "@ember/component";-import { computed } from "@ember/object";-import { trustHTML } from "@ember/template";-import {- attributeBindings,- classNameBindings,- tagName,-} from "@ember-decorators/component";-import { i18n } from "discourse-i18n";--@tagName("button")-@attributeBindings("style", "title", "ariaLabel:aria-label")-@classNameBindings(":colorpicker", "isUsed:used-color:unused-color")-export default class DColorPickerChoice extends Component {- @computed("color", "usedColors")- get isUsed() {- return (this.usedColors || []).includes(this.color.toUpperCase());- }-- @computed("isUsed")- get title() {- return this.isUsed ? i18n("category.already_used") : null;- }-- @computed("color")- get style() {- return trustHTML(`background-color: #${this.color};`);- }-- click(e) {- e.preventDefault();- this.selectColor(this.color);- }-}diff --git a/frontend/discourse/app/ui-kit/d-color-picker.gjs b/frontend/discourse/app/ui-kit/d-color-picker.gjsdeleted file mode 100644index 5099de6c6f3..00000000000--- a/frontend/discourse/app/ui-kit/d-color-picker.gjs+++ /dev/null@@ -1,46 +0,0 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { action } from "@ember/object";-import { tagName } from "@ember-decorators/component";-import DColorPickerChoice from "discourse/ui-kit/d-color-picker-choice";-import dIcon from "discourse/ui-kit/helpers/d-icon";-import { i18n } from "discourse-i18n";--@tagName("")-export default class DColorPicker extends Component {- role = "group";-- @action- selectColor(color) {- this.set("value", color);- this.onSelectColor?.(color);- }-- @action- getColorLabel(color) {- const isUsed = this.usedColors?.includes(color.toUpperCase())- ? i18n("category.color_used")- : "";- return `#${color} ${isUsed}`;- }-- <template>- <div- aria-label={{this.ariaLabel}}- class="colors-container"- role={{this.role}}- ...attributes- >- {{#each this.colors as |c|}}- <DColorPickerChoice- @ariaLabel={{this.getColorLabel c}}- @color={{c}}- @selectColor={{this.selectColor}}- @usedColors={{this.usedColors}}- >- {{dIcon "check"}}- </DColorPickerChoice>- {{/each}}- </div>- </template>-}