A platform for community discussion. Free, open, simple.
UX: Use core description of popular components when there's no description (#32286)
Osama Sayegh5e8778ecf71e
diff --git a/app/assets/javascripts/admin/addon/components/admin-config-areas/components.gjs b/app/assets/javascripts/admin/addon/components/admin-config-areas/components.gjsindex 88656567092..f5bcdab892f 100644--- a/app/assets/javascripts/admin/addon/components/admin-config-areas/components.gjs+++ b/app/assets/javascripts/admin/addon/components/admin-config-areas/components.gjs@@ -18,6 +18,7 @@ import { extractErrorInfo } from "discourse/lib/ajax-error";import discourseDebounce from "discourse/lib/debounce";import { INPUT_DELAY } from "discourse/lib/environment";import getURL from "discourse/lib/get-url";+import { descriptionForRemoteUrl } from "discourse/lib/popular-themes";import { i18n } from "discourse-i18n";import AdminConfigAreaEmptyList from "admin/components/admin-config-area-empty-list";import InstallComponentModal from "admin/components/modal/install-theme";@@ -300,6 +301,14 @@ class ComponentRow extends Component {}}+ get description() {+ const remoteUrl = this.args.component.remote_theme?.remote_url;+ return (+ this.args.component.description ??+ (remoteUrl && descriptionForRemoteUrl(remoteUrl))+ );+ }+@actionasync toggleEnabled() {this.disableToggle = true;@@ -437,11 +446,11 @@ class ComponentRow extends Component {(hash [email protected]_theme.authors)}}</div>{{/if}}- {{#if @component.description}}+ {{#if this.description}}<divclass="d-admin-row__overview-about admin-config-components__description">- {{@component.description}}+ {{this.description}}{{#if @component.remote_theme.about_url}}<a href={{@component.remote_theme.about_url}}>{{i18n"admin.config_areas.themes_and_components.components.learn_more"diff --git a/app/assets/javascripts/discourse/app/lib/popular-themes.js b/app/assets/javascripts/discourse/app/lib/popular-themes.jsindex 7560a20f1c3..36f7396f6e5 100644--- a/app/assets/javascripts/discourse/app/lib/popular-themes.js+++ b/app/assets/javascripts/discourse/app/lib/popular-themes.js@@ -128,3 +128,8 @@ export const POPULAR_THEMES = [component: true,},];++export function descriptionForRemoteUrl(url) {+ url = url.replace(/\.git$/, "");+ return POPULAR_THEMES.find((obj) => obj.value === url)?.description;+}diff --git a/spec/system/admin_customize_components_config_area_spec.rb b/spec/system/admin_customize_components_config_area_spec.rbindex fa8b3bd0f9d..31b14626d6b 100644--- a/spec/system/admin_customize_components_config_area_spec.rb+++ b/spec/system/admin_customize_components_config_area_spec.rb@@ -57,7 +57,10 @@ describe "Admin Customize Themes Config Area Page", type: :system docomponent: true,enabled: false,remote_theme:- RemoteTheme.create!(remote_url: "https://github.com/discourse/tc-2", commits_behind: 4),+ RemoteTheme.create!(+ remote_url: "https://github.com/discourse/discourse-kanban-theme.git",+ commits_behind: 4,+ ),)end@@ -141,6 +144,9 @@ describe "Admin Customize Themes Config Area Page", type: :system doexpect(config_area.component(remote_component.id)).to have_description("Description of my remote component",)+ expect(config_area.component(remote_component_with_update.id)).to have_description(+ "Display and organize topics using a Kanban board interface.",+ )expect(config_area.component(remote_component.id)).to be_not_pending_updateexpect(config_area.component(remote_component_with_update.id)).to be_pending_update