discourse/app/assets/javascripts/admin/addon/routes/admin-route-map.js
Martin Brennan 19af83d39e
FEATURE: Themeable site settings (#32233)
This commit introduces the concept of themeable site settings,
which is a new tool for theme authors that lives alongside theme
modifiers and theme settings. Here is a quick summary:

* Theme settings - These are custom settings used to control UI and functionality within your theme or component and provide configuration options. These cannot change core Discourse functionality.
* Theme modifiers - Allows a theme or a component to modify selected server-side functionality of core Discourse as an alternative to building a plugin.
* Themeable site settings (new) - Allows a theme (not components) to override a small subset of core site settings, which generally control parts of the UI and other minor functionality. This allows themes to have a greater control over the full site experience.

Themeable site settings will be shown for all themes, whether the theme
changes
the value or not, and have a similar UI to custom theme settings.

We are also introducing a new page at
`/admin/config/theme-site-settings` that
allows admins to see all possible themeable site settings, and which
themes
are changing the value from the default.

### Configuration

Theme authors can configure initial values themeable site settings using
a section in the `about.json` file like so:

```json
"theme_site_settings": {
  "search_experience": "search_field"
}
```

These values will not change when the theme updates, because we cannot
know if admins have manually changed them.

### Limitations

Themeable site settings are only really intended to control elements of
the UI, and when retrieving their value we require a theme ID, so these
limitations apply:

- Themeable site settings cannot be used in Sidekiq jobs
- Themeable site settings cannot be used in markdown rules
- Themeable site settings will be cached separately to client site
settings using theme ID as a key
- Themeable site settings will override keys on the `siteSettings`
service on the client using the application preloader
- `SiteSetting.client_settings_json` will not include themeable site
settings, instead you can call `SiteSetting.theme_site_settings_json`
with a theme ID

### Initial settings

There are only two site settings that will be themeable to begin with:

* `enable_welcome_banner`
* `search_experience`

And our new Horizon theme will take advantage of both. Over time, more
settings that control elements of the UI will be exposed this way.
2025-07-16 11:00:21 +10:00

432 lines
12 KiB
JavaScript
Vendored

export default function () {
this.route("admin", { resetNamespace: true }, function () {
this.route("dashboard", { path: "/" }, function () {
this.route("general", { path: "/" });
this.route("admin.dashboardModeration", {
path: "/dashboard/moderation",
resetNamespace: true,
});
this.route("admin.dashboardSecurity", {
path: "/dashboard/security",
resetNamespace: true,
});
this.route("admin.dashboardReports", {
path: "/dashboard/reports",
resetNamespace: true,
});
});
this.route(
"adminSiteSettings",
{ path: "/site_settings", resetNamespace: true },
function () {
this.route("adminSiteSettingsCategory", {
path: "category/:category_id",
resetNamespace: true,
});
}
);
this.route(
"adminEmailLogs",
{ path: "/email-logs", resetNamespace: true },
function () {
this.route("sent", { path: "/" });
this.route("skipped");
this.route("bounced");
this.route("received");
this.route("rejected");
}
);
this.route(
"adminEmail",
{ path: "/email", resetNamespace: true },
function () {
this.route("settings", { path: "/" });
this.route("serverSettings", { path: "/server-settings" });
this.route("previewDigest", { path: "/preview-digest" });
this.route("advancedTest", { path: "/advanced-test" });
this.route(
"adminEmailTemplates",
{ path: "/templates", resetNamespace: true },
function () {
this.route("edit", { path: "/:id" });
}
);
}
);
this.route(
"adminCustomize",
{ path: "/customize", resetNamespace: true },
function () {
this.route("colors", function () {
this.route("show", { path: "/:scheme_id" });
});
this.route(
"adminCustomizeThemes",
{ path: "/:type", resetNamespace: true },
function () {
this.route("show", { path: "/:theme_id" }, function () {
this.route("schema", { path: "schema/:setting_name" });
this.route("colors");
});
this.route("edit", { path: "/:theme_id/:target/:field_name/edit" });
}
);
this.route(
"adminSiteText",
{ path: "/site_texts", resetNamespace: true },
function () {
this.route("edit", { path: "/:id" });
}
);
this.route(
"adminEmbedding",
{
path: "/embedding",
resetNamespace: true,
},
function () {
this.route("index", { path: "/" });
this.route("settings");
this.route("postsAndTopics", { path: "/posts_and_topics" });
this.route("crawlers");
this.route("new");
this.route("edit", { path: "/:id" });
}
);
this.route("adminCustomizeRobotsTxt", {
path: "/robots",
resetNamespace: true,
});
this.route(
"adminCustomizeEmailStyle",
{ path: "/email_style", resetNamespace: true },
function () {
this.route("edit", { path: "/:field_name" });
}
);
this.route(
"adminCustomizeFormTemplates",
{ path: "/form-templates", resetNamespace: true },
function () {
this.route("new");
this.route("edit", { path: "/:id" });
}
);
this.route(
"adminWatchedWords",
{ path: "/watched_words", resetNamespace: true },
function () {
this.route("action", { path: "/action/:action_id" });
}
);
}
);
this.route("adminApi", { path: "/api", resetNamespace: true }, function () {
this.route(
"adminApiKeys",
{ path: "/keys", resetNamespace: true },
function () {
this.route("settings");
this.route("show", { path: "/:api_key_id" });
this.route("new");
}
);
this.route(
"adminWebHooks",
{ path: "/web_hooks", resetNamespace: true },
function () {
this.route("new");
this.route("show", { path: "/:web_hook_id" });
this.route("edit", { path: "/:web_hook_id/edit" });
}
);
});
this.route(
"admin.backups",
{ path: "/backups", resetNamespace: true },
function () {
this.route("logs");
this.route("settings");
}
);
this.route(
"adminReports",
{ path: "/reports", resetNamespace: true },
function () {
this.route("index", { path: "/" });
this.route("show", { path: ":type" });
this.route("dashboardSettings", { path: "dashboard-settings" });
}
);
this.route(
"adminLogs",
{ path: "/logs", resetNamespace: true },
function () {
this.route("staffActionLogs", { path: "/staff_action_logs" });
this.route("screenedEmails", { path: "/screened_emails" });
this.route("screenedIpAddresses", { path: "/screened_ip_addresses" });
this.route("screenedUrls", { path: "/screened_urls" });
this.route(
"adminSearchLogs",
{ path: "/search_logs", resetNamespace: true },
function () {
this.route("index", { path: "/" });
this.route("term");
}
);
}
);
this.route(
"adminUsers",
{ path: "/users", resetNamespace: true },
function () {
this.route("settings");
this.route(
"adminUser",
{ path: "/:user_id/:username", resetNamespace: true },
function () {
this.route("badges");
this.route("tl3Requirements", { path: "/tl3_requirements" });
}
);
this.route(
"adminUsersList",
{ path: "/list", resetNamespace: true },
function () {
this.route("show", { path: "/:filter" });
}
);
}
);
this.route(
"adminBadges",
{ path: "/badges", resetNamespace: true },
function () {
this.route("settings");
this.route("award", { path: "/award/:badge_id" });
this.route("show", { path: "/:badge_id" });
}
);
this.route(
"adminGroups",
{ path: "/groups", resetNamespace: true },
function () {
this.route("settings");
}
);
this.route(
"adminConfig",
{ path: "/config", resetNamespace: true },
function () {
this.route("flags", function () {
this.route("index", { path: "/" });
this.route("new");
this.route("edit", { path: "/:flag_id" });
this.route("settings");
});
this.route("about");
this.route(
"loginAndAuthentication",
{ path: "/login-and-authentication" },
function () {
this.route("settings", {
path: "/",
});
}
);
this.route("content", function () {
this.route("categoriesAndTags", { path: "/" });
this.route("settings");
this.route("sharing");
this.route("postsAndTopics", { path: "/posts-and-topics" });
this.route("statsAndThresholds", { path: "/stats-and-thresholds" });
});
this.route("localization", function () {
this.route("settings", {
path: "/",
});
});
this.route("notifications", function () {
this.route("settings", {
path: "/",
});
});
this.route("search", function () {
this.route("settings", {
path: "/",
});
});
this.route("legal", function () {
this.route("settings", {
path: "/",
});
});
this.route("experimental", function () {
this.route("settings", {
path: "/",
});
});
this.route("other", function () {
this.route("settings", {
path: "/",
});
});
this.route("files", function () {
this.route("settings", {
path: "/",
});
});
this.route("interface", function () {
this.route("settings", {
path: "/",
});
});
this.route(
"groupPermissions",
{ path: "/group-permissions" },
function () {
this.route("settings", {
path: "/",
});
}
);
this.route("userDefaults", { path: "user-defaults" }, function () {
this.route("settings", {
path: "/",
});
});
this.route("siteAdmin", { path: "/site-admin" }, function () {
this.route("settings", {
path: "/",
});
});
this.route("trustLevels", { path: "/trust-levels" }, function () {
this.route("settings", {
path: "/",
});
});
this.route("customize", function () {
this.route("themes");
this.route("components");
});
this.route(
"adminAnalytics",
{ path: "/analytics-and-seo", resetNamespace: true },
function () {
this.route("settings", {
path: "/",
});
}
);
this.route(
"adminPermalinks",
{ path: "/permalinks", resetNamespace: true },
function () {
this.route("new");
this.route("index", { path: "/" });
this.route("settings");
this.route("edit", { path: "/:permalink_id" });
}
);
this.route(
"adminUserFields",
{ path: "/user-fields", resetNamespace: true },
function () {
this.route("new");
this.route("edit", { path: "/:id/edit" });
this.route("index", { path: "/" });
}
);
this.route(
"adminEmojis",
{ path: "/emoji", resetNamespace: true },
function () {
this.route("new");
this.route("index", { path: "/" });
this.route("settings");
}
);
this.route("developer", function () {
this.route("settings", { path: "/" });
});
this.route("logo");
this.route("fonts");
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: "/" });
});
this.route("security", function () {
this.route("settings", { path: "/" });
});
this.route("spam", function () {
this.route("settings", { path: "/" });
});
this.route("theme-site-settings");
this.route(
"colorPalettes",
{
path: "/colors",
},
function () {
this.route("show", {
path: "/:palette_id",
});
}
);
}
);
this.route("schema", { path: "schema/:setting_name" });
this.route(
"adminPlugins",
{ path: "/plugins", resetNamespace: true },
function () {
this.route("index", { path: "/" });
this.route("show", { path: "/:plugin_id" }, function () {
this.route("settings");
});
}
);
this.route("admin.whatsNew", {
path: "/whats-new",
resetNamespace: true,
});
this.route(
"adminSection",
{ path: "/section", resetNamespace: true },
function () {
this.route("account");
}
);
this.route(
"adminSearch",
{ path: "/search", resetNamespace: true },
function () {
this.route("index", { path: "/" });
}
);
});
}