From 46e4290a2a34e52c53b5d1c87794dc7436fd5ae5 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 7 Jan 2025 16:05:54 +1100 Subject: [PATCH] UX: Admin setting page consistency - User API (#30610) Create a basic config page that only contains user API-related settings, to replace the "user_api" category view linked to from "User API" in the admin sidebar. --- .../admin-config-user-api-settings.js | 3 ++ .../addon/routes/admin-config-user-api.js | 8 +++++ .../admin/addon/routes/admin-route-map.js | 3 ++ .../templates/config-user-api-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-user-api-settings.js create mode 100644 app/assets/javascripts/admin/addon/routes/admin-config-user-api.js create mode 100644 app/assets/javascripts/admin/addon/templates/config-user-api-settings.gjs diff --git a/app/assets/javascripts/admin/addon/controllers/admin-config-user-api-settings.js b/app/assets/javascripts/admin/addon/controllers/admin-config-user-api-settings.js new file mode 100644 index 00000000000..af7214951bc --- /dev/null +++ b/app/assets/javascripts/admin/addon/controllers/admin-config-user-api-settings.js @@ -0,0 +1,3 @@ +import AdminAreaSettingsBaseController from "admin/controllers/admin-area-settings-base"; + +export default class AdminConfigUserApiSettingsController extends AdminAreaSettingsBaseController {} diff --git a/app/assets/javascripts/admin/addon/routes/admin-config-user-api.js b/app/assets/javascripts/admin/addon/routes/admin-config-user-api.js new file mode 100644 index 00000000000..7cc34d7bf3d --- /dev/null +++ b/app/assets/javascripts/admin/addon/routes/admin-config-user-api.js @@ -0,0 +1,8 @@ +import DiscourseRoute from "discourse/routes/discourse"; +import { i18n } from "discourse-i18n"; + +export default class AdminConfigUserApiRoute extends DiscourseRoute { + titleToken() { + return i18n("admin.advanced.sidebar_link.user_api"); + } +} 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 43d663d0995..6f12e2a45f2 100644 --- a/app/assets/javascripts/admin/addon/routes/admin-route-map.js +++ b/app/assets/javascripts/admin/addon/routes/admin-route-map.js @@ -312,6 +312,9 @@ export default function () { this.route("spam", function () { this.route("settings", { path: "/" }); }); + this.route("user-api", function () { + this.route("settings", { path: "/" }); + }); } ); diff --git a/app/assets/javascripts/admin/addon/templates/config-user-api-settings.gjs b/app/assets/javascripts/admin/addon/templates/config-user-api-settings.gjs new file mode 100644 index 00000000000..043156d32b7 --- /dev/null +++ b/app/assets/javascripts/admin/addon/templates/config-user-api-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 21df96593d0..96338596893 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 @@ -244,9 +244,7 @@ export const ADMIN_NAV_MAP = [ }, { name: "admin_user_api", - route: "adminSiteSettingsCategory", - routeModels: ["user_api"], - query: { filter: "" }, + route: "adminConfig.user-api.settings", label: "admin.advanced.sidebar_link.user_api", icon: "shuffle", }, diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index daacff08d52..dbefa3aace5 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -5173,6 +5173,9 @@ en: trust_levels: title: "Trust levels" header_description: "Trust level settings allow you to fine-tune the requirements and notifications for your community’s progression system, which automatically promotes users to higher trust levels as they demonstrate consistent, positive engagement with your forum" + user_api: + title: "User API" + header_description: "Configure which user groups can access the API, as well as which scopes are allowed" group_permissions: title: "Group permissions" header_description: "All group-based app permissions are managed here, which control access to various features within Discourse" diff --git a/config/routes.rb b/config/routes.rb index 8cdac809cb5..e8a79672cda 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -404,6 +404,7 @@ Discourse::Application.routes.draw do get "search" => "site_settings#index" get "security" => "site_settings#index" get "spam" => "site_settings#index" + get "user-api" => "site_settings#index" get "experimental" => "site_settings#index" get "trust-levels" => "site_settings#index" get "group-permissions" => "site_settings#index"