From 01ceeae2d6372f406dac47fd30328a55fe61429b Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 6 Jan 2025 15:05:40 +1100 Subject: [PATCH] UX: Admin setting page consistency - Fonts (#30564) Create a basic config page that only contains font-related settings, to replace the setting filtered view linked to from "Font style" in the admin sidebar. --- .../admin-config-fonts-settings.js | 3 +++ .../admin/addon/routes/admin-config-fonts.js | 8 +++++++ .../admin/addon/routes/admin-route-map.js | 3 +++ .../addon/templates/config-fonts-settings.hbs | 21 +++++++++++++++++++ .../app/lib/sidebar/admin-nav-map.js | 4 +--- app/models/site_setting.rb | 2 +- config/locales/client.en.yml | 3 +++ config/routes.rb | 1 + config/site_settings.yml | 3 +++ 9 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 app/assets/javascripts/admin/addon/controllers/admin-config-fonts-settings.js create mode 100644 app/assets/javascripts/admin/addon/routes/admin-config-fonts.js create mode 100644 app/assets/javascripts/admin/addon/templates/config-fonts-settings.hbs diff --git a/app/assets/javascripts/admin/addon/controllers/admin-config-fonts-settings.js b/app/assets/javascripts/admin/addon/controllers/admin-config-fonts-settings.js new file mode 100644 index 00000000000..1c517c5c1f0 --- /dev/null +++ b/app/assets/javascripts/admin/addon/controllers/admin-config-fonts-settings.js @@ -0,0 +1,3 @@ +import AdminAreaSettingsBaseController from "admin/controllers/admin-area-settings-base"; + +export default class AdminConfigFontsController extends AdminAreaSettingsBaseController {} diff --git a/app/assets/javascripts/admin/addon/routes/admin-config-fonts.js b/app/assets/javascripts/admin/addon/routes/admin-config-fonts.js new file mode 100644 index 00000000000..c5e53323e7e --- /dev/null +++ b/app/assets/javascripts/admin/addon/routes/admin-config-fonts.js @@ -0,0 +1,8 @@ +import DiscourseRoute from "discourse/routes/discourse"; +import { i18n } from "discourse-i18n"; + +export default class AdminConfigFontsRoute extends DiscourseRoute { + titleToken() { + return i18n("admin.appearance.sidebar_link.font_style"); + } +} 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 92f2e4f3bf4..e9136b0f770 100644 --- a/app/assets/javascripts/admin/addon/routes/admin-route-map.js +++ b/app/assets/javascripts/admin/addon/routes/admin-route-map.js @@ -262,6 +262,9 @@ export default function () { this.route("settings"); } ); + this.route("fonts", function () { + this.route("settings", { path: "/" }); + }); } ); diff --git a/app/assets/javascripts/admin/addon/templates/config-fonts-settings.hbs b/app/assets/javascripts/admin/addon/templates/config-fonts-settings.hbs new file mode 100644 index 00000000000..2f1f01a89f9 --- /dev/null +++ b/app/assets/javascripts/admin/addon/templates/config-fonts-settings.hbs @@ -0,0 +1,21 @@ + + <:breadcrumbs> + + + + + +
+ +
\ No newline at end of file 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 4bde262ab47..525536006da 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 @@ -102,9 +102,7 @@ export const ADMIN_NAV_MAP = [ links: [ { name: "admin_font_style", - route: "adminSiteSettingsCategory", - routeModels: ["all_results"], - query: { filter: "font" }, + route: "adminConfig.fonts.settings", label: "admin.appearance.sidebar_link.font_style", icon: "italic", }, diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index 6208cde44e8..1a40faeefef 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class SiteSetting < ActiveRecord::Base - VALID_AREAS = %w[about embedding emojis flags notifications permalinks] + VALID_AREAS = %w[about embedding emojis flags fonts notifications permalinks] extend GlobalPath extend SiteSettingExtension diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 2c0a61c349f..eb35275381a 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -5134,6 +5134,9 @@ en: all: "All reports" config: + font_style: + title: "Font style" + header_description: "Customize the font styles used by your themes." login_and_authentication: title: "Login and authentication" header_description: "Configure how users log in and authenticate, secrets and keys, OAuth2 providers, and more." diff --git a/config/routes.rb b/config/routes.rb index 00c02d78a28..08e82408258 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -393,6 +393,7 @@ Discourse::Application.routes.draw do namespace :config, constraints: StaffConstraint.new do resources :site_settings, only: %i[index] + get "fonts" => "site_settings#index" get "login-and-authentication" => "site_settings#index" get "notifications" => "site_settings#index" diff --git a/config/site_settings.yml b/config/site_settings.yml index 8dbad54a119..4c3170d1815 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -406,10 +406,12 @@ basic: default: "arial" enum: "BaseFontSetting" refresh: true + area: "fonts" heading_font: default: "arial" enum: "BaseFontSetting" refresh: true + area: "fonts" enable_sitemap: default: true sitemap_page_size: @@ -3144,6 +3146,7 @@ user_preferences: - normal - larger - largest + area: "fonts" default_title_count_mode: type: enum