From ec3b6d57c26e817e702bc5a78b5fd5d5486f2bf0 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 7 Jan 2025 16:21:53 +1100 Subject: [PATCH] UX: Admin setting page consistency - Onebox (#30611) Create a basic config page that only contains Onebox-related settings, to replace the "onebox" category view linked to from "Onebox" in the admin sidebar. --- .../admin-config-onebox-settings.js | 3 ++ .../admin/addon/routes/admin-config-onebox.js | 8 +++++ .../admin/addon/routes/admin-route-map.js | 3 ++ .../templates/config-onebox-settings.gjs | 29 +++++++++++++++++++ .../app/lib/sidebar/admin-nav-map.js | 4 +-- config/locales/client.en.yml | 3 ++ config/routes.rb | 1 + 7 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/admin/addon/controllers/admin-config-onebox-settings.js create mode 100644 app/assets/javascripts/admin/addon/routes/admin-config-onebox.js create mode 100644 app/assets/javascripts/admin/addon/templates/config-onebox-settings.gjs diff --git a/app/assets/javascripts/admin/addon/controllers/admin-config-onebox-settings.js b/app/assets/javascripts/admin/addon/controllers/admin-config-onebox-settings.js new file mode 100644 index 00000000000..4e3ae842fca --- /dev/null +++ b/app/assets/javascripts/admin/addon/controllers/admin-config-onebox-settings.js @@ -0,0 +1,3 @@ +import AdminAreaSettingsBaseController from "admin/controllers/admin-area-settings-base"; + +export default class AdminConfigOneboxSettingsController extends AdminAreaSettingsBaseController {} diff --git a/app/assets/javascripts/admin/addon/routes/admin-config-onebox.js b/app/assets/javascripts/admin/addon/routes/admin-config-onebox.js new file mode 100644 index 00000000000..1a9e653a687 --- /dev/null +++ b/app/assets/javascripts/admin/addon/routes/admin-config-onebox.js @@ -0,0 +1,8 @@ +import DiscourseRoute from "discourse/routes/discourse"; +import { i18n } from "discourse-i18n"; + +export default class AdminConfigOneboxRoute extends DiscourseRoute { + titleToken() { + return i18n("admin.advanced.sidebar_link.onebox"); + } +} 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 6f12e2a45f2..43b95204ad9 100644 --- a/app/assets/javascripts/admin/addon/routes/admin-route-map.js +++ b/app/assets/javascripts/admin/addon/routes/admin-route-map.js @@ -303,6 +303,9 @@ export default function () { this.route("navigation", function () { this.route("settings", { path: "/" }); }); + this.route("onebox", function () { + this.route("settings", { path: "/" }); + }); this.route("rate-limits", function () { this.route("settings", { path: "/" }); }); diff --git a/app/assets/javascripts/admin/addon/templates/config-onebox-settings.gjs b/app/assets/javascripts/admin/addon/templates/config-onebox-settings.gjs new file mode 100644 index 00000000000..ea51f5ef5d1 --- /dev/null +++ b/app/assets/javascripts/admin/addon/templates/config-onebox-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 96338596893..d96b94ba8ad 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 @@ -250,9 +250,7 @@ export const ADMIN_NAV_MAP = [ }, { name: "admin_onebox", - route: "adminSiteSettingsCategory", - routeModels: ["onebox"], - query: { filter: "" }, + route: "adminConfig.onebox.settings", label: "admin.advanced.sidebar_link.onebox", icon: "far-square", }, diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index dbefa3aace5..88b3a0993e7 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -5158,6 +5158,9 @@ en: notifications: title: "Notifications" header_description: "Configure how notifications are managed and delivered for users, including email preferences, push notifications, mention limits, and notification consolidation" + onebox: + title: "Onebox" + header_description: "Configure how onebox previews are generated and displayed for your site" 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 e8a79672cda..16d9f5fc8b0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -401,6 +401,7 @@ Discourse::Application.routes.draw do get "navigation" => "site_settings#index" get "notifications" => "site_settings#index" get "rate-limits" => "site_settings#index" + get "onebox" => "site_settings#index" get "search" => "site_settings#index" get "security" => "site_settings#index" get "spam" => "site_settings#index"