feat: expose webapp title in admin settings
This commit is contained in:
@@ -11,6 +11,7 @@ from bot.app.web.webapp.cache_helpers import (
|
||||
|
||||
WEBAPP_APPEARANCE_SETTING_KEYS = frozenset(
|
||||
{
|
||||
"WEBAPP_TITLE",
|
||||
"WEBAPP_LOGO_URL",
|
||||
"WEBAPP_LOGO_USE_EMOJI",
|
||||
"WEBAPP_LOGO_EMOJI",
|
||||
|
||||
@@ -34,6 +34,13 @@ class SettingField:
|
||||
|
||||
SETTINGS_MANIFEST: List[SettingField] = [
|
||||
# ─── General ────────────────────────────────────────────────────
|
||||
SettingField(
|
||||
"WEBAPP_TITLE",
|
||||
"string",
|
||||
"general",
|
||||
"Web App title",
|
||||
placeholder="My subscription",
|
||||
),
|
||||
SettingField(
|
||||
"DEFAULT_LANGUAGE",
|
||||
"string",
|
||||
@@ -117,9 +124,6 @@ SETTINGS_MANIFEST: List[SettingField] = [
|
||||
subsection="Remnawave",
|
||||
),
|
||||
# ─── Web app appearance ────────────────────────────────────────
|
||||
SettingField(
|
||||
"WEBAPP_TITLE", "string", "appearance", "Название Web App", placeholder="Моя подписка"
|
||||
),
|
||||
SettingField(
|
||||
"SUBSCRIPTION_MINI_APP_URL",
|
||||
"url",
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
const settingsStore = getContext("settingsStore");
|
||||
const themesStore = getContext("themesStore");
|
||||
const APPEARANCE_SETTING_KEYS = new Set([
|
||||
"WEBAPP_TITLE",
|
||||
"SUBSCRIPTION_MINI_APP_URL",
|
||||
"WEBAPP_PRIMARY_COLOR",
|
||||
"WEBAPP_LOGO_URL",
|
||||
|
||||
@@ -444,6 +444,9 @@ export async function mockApi(path, options = {}, context = {}) {
|
||||
try {
|
||||
const body = options?.body ? JSON.parse(String(options.body)) : {};
|
||||
const updates = body.updates || {};
|
||||
if (Object.prototype.hasOwnProperty.call(updates, "WEBAPP_TITLE")) {
|
||||
DEV_MOCK.config.title = updates.WEBAPP_TITLE || "";
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(updates, "WEBAPP_LOGO_URL")) {
|
||||
DEV_MOCK.config.logoUrl = updates.WEBAPP_LOGO_URL || "";
|
||||
}
|
||||
@@ -473,6 +476,22 @@ export async function mockApi(path, options = {}, context = {}) {
|
||||
return {
|
||||
ok: true,
|
||||
sections: [
|
||||
{
|
||||
id: "general",
|
||||
order: 1,
|
||||
fields: [
|
||||
{
|
||||
key: "WEBAPP_TITLE",
|
||||
type: "string",
|
||||
section: "general",
|
||||
label: "Web App title",
|
||||
value: DEV_MOCK.config.title || "",
|
||||
i18n_label_key: "admin_settings_field_webapp_title_label",
|
||||
i18n_placeholder_key: "admin_settings_field_webapp_title_placeholder",
|
||||
placeholder: "My subscription",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "appearance",
|
||||
order: 2,
|
||||
|
||||
+1
-1
@@ -1424,7 +1424,7 @@
|
||||
"admin_settings_field_user_squad_uuids_description": "Comma-separated UUIDs for the legacy mode without a JSON tariff catalog.",
|
||||
"admin_settings_field_user_external_squad_uuid_label": "Default External Squad",
|
||||
"admin_settings_field_user_external_squad_uuid_description": "Optional External Squad UUID for new users.",
|
||||
"admin_settings_field_webapp_title_label": "WebApp Title",
|
||||
"admin_settings_field_webapp_title_label": "Web App title",
|
||||
"admin_settings_field_subscription_mini_app_url_label": "Public Mini App URL",
|
||||
"admin_settings_field_subscription_mini_app_url_description": "For example, https://app.example.com/.",
|
||||
"admin_settings_field_webapp_primary_color_label": "WebApp Primary Color",
|
||||
|
||||
@@ -99,6 +99,16 @@ def _locale(language: str) -> dict[str, str]:
|
||||
return json.loads((REPO_ROOT / "locales" / f"{language}.json").read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def test_webapp_title_is_first_general_admin_setting():
|
||||
items = _manifest_items()
|
||||
manifest = {item["key"]: item for item in items}
|
||||
field = manifest["WEBAPP_TITLE"]
|
||||
|
||||
assert field["section"] == "general"
|
||||
assert field["section_order"] == 1
|
||||
assert [item["key"] for item in items if item["section"] == "general"][0] == "WEBAPP_TITLE"
|
||||
|
||||
|
||||
def test_support_settings_manifest_uses_admin_i18n_keys():
|
||||
manifest = _manifest_by_key()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user