From c2282439b32d879a73217eec62449f042914d7d0 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Thu, 2 Jan 2025 09:13:37 +1000 Subject: [PATCH] UX: Move first settings admin route to config page (#30510) For consistency, we are updating all sidebar links that point to an /admin/customize/site_settings URL to their own config pages, in preparation for more focused config pages in future. This will mitigate the issue we have now, which is that every sidebar link you click showing a different UI to admins. This commit moves admin/config/login-and-authentication to establish the pattern. --- ...onfig-login-and-authentication-settings.js | 3 +++ .../admin/addon/routes/admin-config-about.js | 9 ++++++-- .../admin-config-login-and-authentication.js | 8 +++++++ .../admin/addon/routes/admin-route-map.js | 5 ++++ ...nfig-login-and-authentication-settings.hbs | 23 +++++++++++++++++++ .../app/lib/sidebar/admin-nav-map.js | 7 ++---- .../acceptance/admin-sidebar-section-test.js | 7 ++++++ config/locales/client.en.yml | 5 ++++ config/routes.rb | 3 +++ 9 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 app/assets/javascripts/admin/addon/controllers/admin-config-login-and-authentication-settings.js create mode 100644 app/assets/javascripts/admin/addon/routes/admin-config-login-and-authentication.js create mode 100644 app/assets/javascripts/admin/addon/templates/config-login-and-authentication-settings.hbs diff --git a/app/assets/javascripts/admin/addon/controllers/admin-config-login-and-authentication-settings.js b/app/assets/javascripts/admin/addon/controllers/admin-config-login-and-authentication-settings.js new file mode 100644 index 00000000000..12fc98c388e --- /dev/null +++ b/app/assets/javascripts/admin/addon/controllers/admin-config-login-and-authentication-settings.js @@ -0,0 +1,3 @@ +import AdminAreaSettingsBaseController from "admin/controllers/admin-area-settings-base"; + +export default class AdminConfigLoginAndAuthenticationSettingsController extends AdminAreaSettingsBaseController {} diff --git a/app/assets/javascripts/admin/addon/routes/admin-config-about.js b/app/assets/javascripts/admin/addon/routes/admin-config-about.js index 82ce7d5c955..0edc9da96db 100644 --- a/app/assets/javascripts/admin/addon/routes/admin-config-about.js +++ b/app/assets/javascripts/admin/addon/routes/admin-config-about.js @@ -1,7 +1,12 @@ -import Route from "@ember/routing/route"; import { ajax } from "discourse/lib/ajax"; +import DiscourseRoute from "discourse/routes/discourse"; +import { i18n } from "discourse-i18n"; + +export default class AdminConfigAboutRoute extends DiscourseRoute { + titleToken() { + return i18n("admin.community.sidebar_link.about_your_site"); + } -export default class AdminConfigAboutRoute extends Route { model() { return ajax("/admin/config/site_settings.json", { data: { diff --git a/app/assets/javascripts/admin/addon/routes/admin-config-login-and-authentication.js b/app/assets/javascripts/admin/addon/routes/admin-config-login-and-authentication.js new file mode 100644 index 00000000000..bb18d420331 --- /dev/null +++ b/app/assets/javascripts/admin/addon/routes/admin-config-login-and-authentication.js @@ -0,0 +1,8 @@ +import DiscourseRoute from "discourse/routes/discourse"; +import { i18n } from "discourse-i18n"; + +export default class AdminConfigLoginAndAuthenticationRoute extends DiscourseRoute { + titleToken() { + return i18n("admin.community.sidebar_link.login_and_authentication"); + } +} 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 3ba8d71e02d..5e5be006f7c 100644 --- a/app/assets/javascripts/admin/addon/routes/admin-route-map.js +++ b/app/assets/javascripts/admin/addon/routes/admin-route-map.js @@ -206,6 +206,11 @@ export default function () { }); this.route("about"); + this.route("loginAndAuthentication", { path: "/" }, function () { + this.route("settings", { + path: "/login-and-authentication", + }); + }); this.route("lookAndFeel", { path: "/look-and-feel" }, function () { this.route("themes"); }); diff --git a/app/assets/javascripts/admin/addon/templates/config-login-and-authentication-settings.hbs b/app/assets/javascripts/admin/addon/templates/config-login-and-authentication-settings.hbs new file mode 100644 index 00000000000..24adeec9b47 --- /dev/null +++ b/app/assets/javascripts/admin/addon/templates/config-login-and-authentication-settings.hbs @@ -0,0 +1,23 @@ + + <: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 8d496ba209f..72289eba9cd 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 @@ -42,9 +42,7 @@ export const ADMIN_NAV_MAP = [ }, { name: "admin_login_and_authentication", - route: "adminSiteSettingsCategory", - routeModels: ["login"], - query: { filter: "" }, + route: "adminConfig.loginAndAuthentication.settings", label: "admin.community.sidebar_link.login_and_authentication", icon: "unlock", }, @@ -301,8 +299,7 @@ export const ADMIN_NAV_MAP = [ { name: "admin_experimental", route: "adminSiteSettingsCategory", - routeModels: ["all_results"], - query: { filter: "experimental" }, + routeModels: ["experimental"], label: "admin.advanced.sidebar_link.experimental", icon: "discourse-sparkles", }, diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js index 30ede349342..f130e91b340 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js @@ -3,6 +3,7 @@ import { test } from "qunit"; import { AUTO_GROUPS } from "discourse/lib/constants"; import { withPluginApi } from "discourse/lib/plugin-api"; import PreloadStore from "discourse/lib/preload-store"; +import pretender, { response } from "discourse/tests/helpers/create-pretender"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; @@ -24,6 +25,12 @@ acceptance("Admin Sidebar - Sections", function (needs) { }, }, ]); + + pretender.get("/admin/config/site_settings.json", () => + response({ + site_settings: [], + }) + ); }); test("default sections are loaded", async function (assert) { diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index f5517257e16..90fb65c76d8 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -5133,6 +5133,11 @@ en: sidebar_link: all: "All reports" + config: + login_and_authentication: + title: "Login and authentication" + header_description: "Configure how users log in and authenticate, secrets and keys, OAuth2 providers, and more." + new_features: title: "What's new?" check_for_updates: "Check for updates" diff --git a/config/routes.rb b/config/routes.rb index 834a94f1df8..c9aaf7a691b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -391,6 +391,9 @@ Discourse::Application.routes.draw do end namespace :config, constraints: StaffConstraint.new do resources :site_settings, only: %i[index] + resources :login_and_authentication, only: %i[index] + + get "login-and-authentication" => "site_settings#index" resources :flags, only: %i[index new create update destroy] do put "toggle"