UX: Admin setting page consistency - Files and Other (#30572) (#30614)

Followup c2282439b3

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.
This commit is contained in:
Martin Brennan 2025-01-07 16:39:00 +10:00 committed by GitHub
parent b6c1e881be
commit 8185770d63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 136 additions and 26 deletions

View File

@ -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,15 +16,22 @@ 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;
try {
const result = await ajax("/admin/config/site_settings.json", {
data: {
filter_area: this.args.area,
@ -40,6 +48,12 @@ export default class AdminAreaSettings extends Component {
),
},
];
} 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 {
<div
class="content-body admin-config-area__settings admin-detail pull-left"
>
{{#if this.settings}}
{{#if this.showSettings}}
<AdminFilteredSiteSettings
@initialFilter={{this.filter}}
@onFilterChanged={{this.adminSettingsFilterChangedCallback}}
@settings={{this.settings}}
/>
{{else}}
<ConditionalLoadingSpinner @condition={{this.loading}}>
<AdminConfigAreaEmptyList
@emptyLabelTranslated={{i18n "admin.settings.not_found"}}
/>
</ConditionalLoadingSpinner>
{{/if}}
</div>
</template>

View File

@ -0,0 +1,3 @@
import AdminAreaSettingsBaseController from "admin/controllers/admin-area-settings-base";
export default class AdminConfigFilesSettingsController extends AdminAreaSettingsBaseController {}

View File

@ -0,0 +1,3 @@
import AdminAreaSettingsBaseController from "admin/controllers/admin-area-settings-base";
export default class AdminConfigOtherSettingsController extends AdminAreaSettingsBaseController {}

View File

@ -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");
}
}

View File

@ -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");
}
}

View File

@ -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" },

View File

@ -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(<template>
<DPageHeader
@titleLabel={{i18n "admin.config.files.title"}}
@descriptionLabel={{i18n "admin.config.files.header_description"}}
>
<:breadcrumbs>
<DBreadcrumbsItem @path="/admin" @label={{i18n "admin_title"}} />
<DBreadcrumbsItem
@path="/admin/config/files"
@label={{i18n "admin.config.files.title"}}
/>
</:breadcrumbs>
</DPageHeader>
<div class="admin-config-page__main-area">
<AdminAreaSettings
@categories="files"
@path="/admin/config/files"
@filter={{@controller.filter}}
@adminSettingsFilterChangedCallback={{@controller.adminSettingsFilterChangedCallback}}
/>
</div>
</template>);

View File

@ -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(<template>
<DPageHeader
@titleLabel={{i18n "admin.config.other.title"}}
@descriptionLabel={{i18n "admin.config.other.header_description"}}
>
<:breadcrumbs>
<DBreadcrumbsItem @path="/admin" @label={{i18n "admin_title"}} />
<DBreadcrumbsItem
@path="/admin/config/other"
@label={{i18n "admin.config.other.title"}}
/>
</:breadcrumbs>
</DPageHeader>
<div class="admin-config-page__main-area">
<AdminAreaSettings
@categories="uncategorized"
@path="/admin/config/other"
@filter={{@controller.filter}}
@adminSettingsFilterChangedCallback={{@controller.adminSettingsFilterChangedCallback}}
/>
</div>
</template>);

View File

@ -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",
},

View File

@ -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"

View File

@ -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"