From 8185770d63ee130e48c4337731e8d62462b03ba8 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Tue, 7 Jan 2025 16:39:00 +1000 Subject: [PATCH] UX: Admin setting page consistency - Files and Other (#30572) (#30614) Followup c2282439b32d879a73217eec62449f042914d7d0 Make the Files and Other config pages reached from the sidebar use our consistent site setting page rules. Also slightly improves AdminAreaSettings so we don't show "Settings not found" when still loading settings. --- .../addon/components/admin-area-settings.gjs | 56 ++++++++++++------- .../admin-config-files-settings.js | 3 + .../admin-config-other-settings.js | 3 + .../admin/addon/routes/admin-config-files.js | 8 +++ .../admin/addon/routes/admin-config-other.js | 8 +++ .../admin/addon/routes/admin-route-map.js | 10 ++++ .../addon/templates/config-files-settings.gjs | 29 ++++++++++ .../addon/templates/config-other-settings.gjs | 29 ++++++++++ .../app/lib/sidebar/admin-nav-map.js | 8 +-- config/locales/client.en.yml | 6 ++ config/routes.rb | 2 + 11 files changed, 136 insertions(+), 26 deletions(-) create mode 100644 app/assets/javascripts/admin/addon/controllers/admin-config-files-settings.js create mode 100644 app/assets/javascripts/admin/addon/controllers/admin-config-other-settings.js create mode 100644 app/assets/javascripts/admin/addon/routes/admin-config-files.js create mode 100644 app/assets/javascripts/admin/addon/routes/admin-config-other.js create mode 100644 app/assets/javascripts/admin/addon/templates/config-files-settings.gjs create mode 100644 app/assets/javascripts/admin/addon/templates/config-other-settings.gjs diff --git a/app/assets/javascripts/admin/addon/components/admin-area-settings.gjs b/app/assets/javascripts/admin/addon/components/admin-area-settings.gjs index ae186024636..65cd42794bc 100644 --- a/app/assets/javascripts/admin/addon/components/admin-area-settings.gjs +++ b/app/assets/javascripts/admin/addon/components/admin-area-settings.gjs @@ -2,6 +2,7 @@ import Component from "@glimmer/component"; import { tracked } from "@glimmer/tracking"; import { action } from "@ember/object"; import { service } from "@ember/service"; +import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner"; import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item"; import { ajax } from "discourse/lib/ajax"; import { bind } from "discourse-common/utils/decorators"; @@ -15,31 +16,44 @@ export default class AdminAreaSettings extends Component { @service router; @tracked settings = []; @tracked filter = ""; + @tracked loading = false; constructor() { super(...arguments); this.#loadSettings(); } + get showSettings() { + return !this.loading && this.settings.length > 0; + } + @bind async #loadSettings() { + this.loading = true; this.filter = this.args.filter; - const result = await ajax("/admin/config/site_settings.json", { - data: { - filter_area: this.args.area, - plugin: this.args.plugin, - categories: this.args.categories, - }, - }); - this.settings = [ - { - name: "All", - nameKey: "all_results", - siteSettings: result.site_settings.map((setting) => - SiteSetting.create(setting) - ), - }, - ]; + try { + const result = await ajax("/admin/config/site_settings.json", { + data: { + filter_area: this.args.area, + plugin: this.args.plugin, + categories: this.args.categories, + }, + }); + this.settings = [ + { + name: "All", + nameKey: "all_results", + siteSettings: result.site_settings.map((setting) => + SiteSetting.create(setting) + ), + }, + ]; + } catch (error) { + // eslint-disable-next-line no-console + console.warn(`Failed to load settings with error: ${error}`); + } finally { + this.loading = false; + } } @action @@ -53,16 +67,18 @@ export default class AdminAreaSettings extends Component {
- {{#if this.settings}} + {{#if this.showSettings}} {{else}} - + + + {{/if}}
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-config-files-settings.js b/app/assets/javascripts/admin/addon/controllers/admin-config-files-settings.js new file mode 100644 index 00000000000..16caec16269 --- /dev/null +++ b/app/assets/javascripts/admin/addon/controllers/admin-config-files-settings.js @@ -0,0 +1,3 @@ +import AdminAreaSettingsBaseController from "admin/controllers/admin-area-settings-base"; + +export default class AdminConfigFilesSettingsController extends AdminAreaSettingsBaseController {} diff --git a/app/assets/javascripts/admin/addon/controllers/admin-config-other-settings.js b/app/assets/javascripts/admin/addon/controllers/admin-config-other-settings.js new file mode 100644 index 00000000000..85b4686f3b1 --- /dev/null +++ b/app/assets/javascripts/admin/addon/controllers/admin-config-other-settings.js @@ -0,0 +1,3 @@ +import AdminAreaSettingsBaseController from "admin/controllers/admin-area-settings-base"; + +export default class AdminConfigOtherSettingsController extends AdminAreaSettingsBaseController {} diff --git a/app/assets/javascripts/admin/addon/routes/admin-config-files.js b/app/assets/javascripts/admin/addon/routes/admin-config-files.js new file mode 100644 index 00000000000..a920aa9f6ec --- /dev/null +++ b/app/assets/javascripts/admin/addon/routes/admin-config-files.js @@ -0,0 +1,8 @@ +import DiscourseRoute from "discourse/routes/discourse"; +import { i18n } from "discourse-i18n"; + +export default class AdminConfigFilesRoute extends DiscourseRoute { + titleToken() { + return i18n("admin.advanced.sidebar_link.files"); + } +} diff --git a/app/assets/javascripts/admin/addon/routes/admin-config-other.js b/app/assets/javascripts/admin/addon/routes/admin-config-other.js new file mode 100644 index 00000000000..7f16e2e3e67 --- /dev/null +++ b/app/assets/javascripts/admin/addon/routes/admin-config-other.js @@ -0,0 +1,8 @@ +import DiscourseRoute from "discourse/routes/discourse"; +import { i18n } from "discourse-i18n"; + +export default class AdminConfigOtherRoute extends DiscourseRoute { + titleToken() { + return i18n("admin.advanced.sidebar_link.other_options"); + } +} diff --git a/app/assets/javascripts/admin/addon/routes/admin-route-map.js b/app/assets/javascripts/admin/addon/routes/admin-route-map.js index 43b95204ad9..60c95bc5659 100644 --- a/app/assets/javascripts/admin/addon/routes/admin-route-map.js +++ b/app/assets/javascripts/admin/addon/routes/admin-route-map.js @@ -246,6 +246,16 @@ export default function () { path: "/", }); }); + this.route("other", function () { + this.route("settings", { + path: "/", + }); + }); + this.route("files", function () { + this.route("settings", { + path: "/", + }); + }); this.route( "groupPermissions", { path: "/group-permissions" }, diff --git a/app/assets/javascripts/admin/addon/templates/config-files-settings.gjs b/app/assets/javascripts/admin/addon/templates/config-files-settings.gjs new file mode 100644 index 00000000000..04dc8796d1c --- /dev/null +++ b/app/assets/javascripts/admin/addon/templates/config-files-settings.gjs @@ -0,0 +1,29 @@ +import RouteTemplate from "ember-route-template"; +import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item"; +import DPageHeader from "discourse/components/d-page-header"; +import { i18n } from "discourse-i18n"; +import AdminAreaSettings from "admin/components/admin-area-settings"; + +export default RouteTemplate(); diff --git a/app/assets/javascripts/admin/addon/templates/config-other-settings.gjs b/app/assets/javascripts/admin/addon/templates/config-other-settings.gjs new file mode 100644 index 00000000000..a7829954099 --- /dev/null +++ b/app/assets/javascripts/admin/addon/templates/config-other-settings.gjs @@ -0,0 +1,29 @@ +import RouteTemplate from "ember-route-template"; +import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item"; +import DPageHeader from "discourse/components/d-page-header"; +import { i18n } from "discourse-i18n"; +import AdminAreaSettings from "admin/components/admin-area-settings"; + +export default RouteTemplate(); diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js b/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js index d96b94ba8ad..1de4d62f52b 100644 --- a/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js +++ b/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js @@ -256,17 +256,13 @@ export const ADMIN_NAV_MAP = [ }, { name: "admin_files", - route: "adminSiteSettingsCategory", - routeModels: ["files"], - query: { filter: "" }, + route: "adminConfig.files.settings", label: "admin.advanced.sidebar_link.files", icon: "file", }, { name: "admin_other_options", - route: "adminSiteSettingsCategory", - routeModels: ["uncategorized"], - query: { filter: "" }, + route: "adminConfig.other.settings", label: "admin.advanced.sidebar_link.other_options", icon: "discourse-other-tab", }, diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 88b3a0993e7..96f003853ae 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -5143,6 +5143,9 @@ en: font_style: title: "Font style" header_description: "Customize the font styles used by your themes" + files: + title: "Files" + header_description: "Settings that control file size and type limits, avatar sizes and sources, file storage, image quality and compression, and more" legal: title: "Legal" header_description: "Configure legal settings, such as terms of service, privacy policy, contact details, and EU-specific considerations" @@ -5161,6 +5164,9 @@ en: onebox: title: "Onebox" header_description: "Configure how onebox previews are generated and displayed for your site" + other: + title: "Other" + header_description: "Settings which do not fit into any other category" rate_limits: title: "Rate limits" header_description: "Configure how often users can perform certain actions, such as creating topics, sending messages, and posting replies" diff --git a/config/routes.rb b/config/routes.rb index 16d9f5fc8b0..b9178f85dce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -395,6 +395,7 @@ Discourse::Application.routes.draw do get "developer" => "site_settings#index" get "fonts" => "site_settings#index" + get "files" => "site_settings#index" get "legal" => "site_settings#index" get "login-and-authentication" => "site_settings#index" get "logo" => "site_settings#index" @@ -402,6 +403,7 @@ Discourse::Application.routes.draw do get "notifications" => "site_settings#index" get "rate-limits" => "site_settings#index" get "onebox" => "site_settings#index" + get "other" => "site_settings#index" get "search" => "site_settings#index" get "security" => "site_settings#index" get "spam" => "site_settings#index"