From 83f5834aff06b935ab3aa0a0af37b729491ab240 Mon Sep 17 00:00:00 2001 From: adonis Date: Mon, 24 Aug 2026 16:15:52 +0330 Subject: [PATCH] feat(settings): add enable_automation SuperAdmin switch (default off) Co-authored-by: Cursor --- prisma/setting-templates-from-deploy.json | 9 ++++++++ scripts/sync-superadmin-setting-template.mjs | 23 +++++++++++++++++++ .../deploy-setting-catalog-keys.ts | 4 ++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/prisma/setting-templates-from-deploy.json b/prisma/setting-templates-from-deploy.json index 292d0cc..946cc07 100644 --- a/prisma/setting-templates-from-deploy.json +++ b/prisma/setting-templates-from-deploy.json @@ -17,6 +17,15 @@ "description": "", "type": "switch" }, + { + "key": "enable_automation", + "value": "false", + "title_fa": "اتوماسیون", + "can_edit": 0, + "is_active": 1, + "description": "روشن: منوی اتوماسیون در پنل ادمین و اجرای موتور فعال است. خاموش: منو مخفی است و API/کران اجرا نمی‌شود. فقط از سوپرادمین قابل تغییر است.", + "type": "switch" + }, { "key": "enable_conditional_order", "value": "", diff --git a/scripts/sync-superadmin-setting-template.mjs b/scripts/sync-superadmin-setting-template.mjs index 34866c5..4e474d3 100644 --- a/scripts/sync-superadmin-setting-template.mjs +++ b/scripts/sync-superadmin-setting-template.mjs @@ -211,6 +211,7 @@ for (const key of EXTRA_EDITABLE) { const SUPERADMIN_OWNED_KEYS = new Set([ 'customer_direct_sms', 'customer_special_pricing', + 'enable_automation', 'enable_conditional_order', 'enable_customer_level_profit', 'enable_product_funds', @@ -224,6 +225,28 @@ const SUPERADMIN_OWNED_KEYS = new Set([ 'show_to_users_chat', ]); +/** متادیتای کلیدهای SA که INSERTشان در SQL کامنت شده — برای قالب سوپرادمین */ +const SUPERADMIN_OWNED_META = { + enable_automation: { + value: 'false', + title_fa: 'اتوماسیون', + description: + 'روشن: منوی اتوماسیون در پنل ادمین و اجرای موتور فعال است. خاموش: منو مخفی است و API/کران اجرا نمی‌شود. فقط از سوپرادمین قابل تغییر است.', + type: 'switch', + }, +}; + +for (const [key, meta] of Object.entries(SUPERADMIN_OWNED_META)) { + const row = ensureRow(key); + if (!row) continue; + row.can_edit = 0; + row.is_active = 1; + if (meta.value !== undefined) row.value = meta.value; + if (meta.title_fa) row.title_fa = meta.title_fa; + if (meta.description) row.description = meta.description; + if (meta.type) row.type = meta.type; +} + const systemRows = [...rows.values()] .filter((r) => r.can_edit === 0 && SUPERADMIN_OWNED_KEYS.has(r.key)) .sort((a, b) => a.key.localeCompare(b.key)); diff --git a/src/program-settings/deploy-setting-catalog-keys.ts b/src/program-settings/deploy-setting-catalog-keys.ts index 0367b0f..01b2118 100644 --- a/src/program-settings/deploy-setting-catalog-keys.ts +++ b/src/program-settings/deploy-setting-catalog-keys.ts @@ -5,6 +5,7 @@ export const DEPLOY_SETTING_CATALOG_KEYS = new Set([ "customer_direct_sms", "customer_special_pricing", + "enable_automation", "enable_conditional_order", "enable_customer_level_profit", "enable_product_funds", @@ -20,8 +21,7 @@ export const DEPLOY_SETTING_CATALOG_KEYS = new Set([ /** * کلیدهایی که سوپرادمین مالکشان نیست (مالک: دیتابیس هر نصب). - * در هر بوت از قالب حذف می‌شوند؛ از ردیف هر پروژه فقط با دکمهٔ - * «حذف تنظیمات غیر دسترسی» در صفحهٔ تنظیمات همان پروژه. + * در هر بوت از قالب حذف می‌شوند؛ از ردیف هر پروژه فقط با دکمهٔ صفحهٔ تنظیمات همان پروژه. */ export const DEPLOY_SETTING_EDITABLE_KEYS = new Set([ "about_software",