feat(automations): gate menu and route behind enable_automation
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -202,7 +202,7 @@ import SettingValueField from './SettingValueField.vue'
|
|||||||
import SettingCard from './SettingCard.vue'
|
import SettingCard from './SettingCard.vue'
|
||||||
import { refreshAppModeMenu } from '@/router'
|
import { refreshAppModeMenu } from '@/router'
|
||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import { applyBannerEnabledFromRows, applyTrackingSystemsEnabledFromRows, applyConditionalOrderEnabledFromRows, applyProductFundsEnabledFromRows, applyPriceTriggerEnabledFromRows, applyAppNotificationEnabledFromRows, applyPriceProviderFromRows, applyPriceChannelAccessFromRows, applySupportChatMenuEnabledFromRows, applyGroupSmsFromRows, applyCustomerSpecialPricingFromRows, setBannerEnabledFromSettings, setConditionalOrderEnabledFromSettings, setProductFundsEnabledFromSettings, setPriceTriggerEnabledFromSettings, setAppNotificationEnabledFromSettings, setPriceProviderFromSettings, setPriceChannelAccessFromSettings, setStoreModeFromSettings, setTrackingSystemsEnabledFromSettings, setGroupSmsEnabledFromSettings, setCustomerSpecialPricingEnabledFromSettings } from '@/utils/config'
|
import { applyBannerEnabledFromRows, applyTrackingSystemsEnabledFromRows, applyConditionalOrderEnabledFromRows, applyAutomationEnabledFromRows, applyProductFundsEnabledFromRows, applyPriceTriggerEnabledFromRows, applyAppNotificationEnabledFromRows, applyPriceProviderFromRows, applyPriceChannelAccessFromRows, applySupportChatMenuEnabledFromRows, applyGroupSmsFromRows, applyCustomerSpecialPricingFromRows, setBannerEnabledFromSettings, setConditionalOrderEnabledFromSettings, setAutomationEnabledFromSettings, setProductFundsEnabledFromSettings, setPriceTriggerEnabledFromSettings, setAppNotificationEnabledFromSettings, setPriceProviderFromSettings, setPriceChannelAccessFromSettings, setStoreModeFromSettings, setTrackingSystemsEnabledFromSettings, setGroupSmsEnabledFromSettings, setCustomerSpecialPricingEnabledFromSettings } from '@/utils/config'
|
||||||
import {
|
import {
|
||||||
EDITABLE_SETTING_GROUPS,
|
EDITABLE_SETTING_GROUPS,
|
||||||
SYSTEM_SETTING_GROUPS,
|
SYSTEM_SETTING_GROUPS,
|
||||||
@@ -490,6 +490,7 @@ async function initConfig() {
|
|||||||
applyBannerEnabledFromRows(baseData.value)
|
applyBannerEnabledFromRows(baseData.value)
|
||||||
applyTrackingSystemsEnabledFromRows(baseData.value)
|
applyTrackingSystemsEnabledFromRows(baseData.value)
|
||||||
applyConditionalOrderEnabledFromRows(baseData.value)
|
applyConditionalOrderEnabledFromRows(baseData.value)
|
||||||
|
applyAutomationEnabledFromRows(baseData.value)
|
||||||
applyProductFundsEnabledFromRows(baseData.value)
|
applyProductFundsEnabledFromRows(baseData.value)
|
||||||
applyPriceTriggerEnabledFromRows(baseData.value)
|
applyPriceTriggerEnabledFromRows(baseData.value)
|
||||||
applyAppNotificationEnabledFromRows(baseData.value)
|
applyAppNotificationEnabledFromRows(baseData.value)
|
||||||
@@ -561,6 +562,10 @@ function syncMenuFlagsFromSetting(key: string | undefined, value: string) {
|
|||||||
setConditionalOrderEnabledFromSettings(isSwitchOn(value))
|
setConditionalOrderEnabledFromSettings(isSwitchOn(value))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (key === 'enable_automation') {
|
||||||
|
setAutomationEnabledFromSettings(isSwitchOn(value))
|
||||||
|
return
|
||||||
|
}
|
||||||
if (key === 'enable_product_funds') {
|
if (key === 'enable_product_funds') {
|
||||||
setProductFundsEnabledFromSettings(isSwitchOn(value))
|
setProductFundsEnabledFromSettings(isSwitchOn(value))
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ export const SYSTEM_SETTING_GROUPS: SettingGroupDef[] = [
|
|||||||
title: 'دسترسی مشتری به قابلیتها',
|
title: 'دسترسی مشتری به قابلیتها',
|
||||||
icon: 'vuesax-linear:people',
|
icon: 'vuesax-linear:people',
|
||||||
match: (k) =>
|
match: (k) =>
|
||||||
/^(enable_conditional_order|enable_product_funds|has_page_price_trigger|has_page_notification|has_page_gift_card|enable_customer_level_profit|banner_enabled|jibit_enabled|customer_direct_sms|has_page_earn_money|group_sms|customer_special_pricing|tracking_systems_enabled|permision__enabled|show_to_users_chat)$/.test(
|
/^(enable_automation|enable_conditional_order|enable_product_funds|has_page_price_trigger|has_page_notification|has_page_gift_card|enable_customer_level_profit|banner_enabled|jibit_enabled|customer_direct_sms|has_page_earn_money|group_sms|customer_special_pricing|tracking_systems_enabled|permision__enabled|show_to_users_chat)$/.test(
|
||||||
k
|
k
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ export function isCodeManagedSettingKey(key?: string | null): boolean {
|
|||||||
export const SUPERADMIN_OWNED_SETTING_KEYS = new Set([
|
export const SUPERADMIN_OWNED_SETTING_KEYS = new Set([
|
||||||
'customer_direct_sms',
|
'customer_direct_sms',
|
||||||
'customer_special_pricing',
|
'customer_special_pricing',
|
||||||
|
'enable_automation',
|
||||||
'enable_conditional_order',
|
'enable_conditional_order',
|
||||||
'enable_customer_level_profit',
|
'enable_customer_level_profit',
|
||||||
'enable_product_funds',
|
'enable_product_funds',
|
||||||
@@ -310,6 +311,7 @@ const KEY_TYPE_FALLBACK: Record<string, SettingFieldType> = {
|
|||||||
sell_fee: 'price',
|
sell_fee: 'price',
|
||||||
fee_free: 'number',
|
fee_free: 'number',
|
||||||
fee_conditional_order: 'price',
|
fee_conditional_order: 'price',
|
||||||
|
enable_automation: 'switch',
|
||||||
enable_conditional_order: 'switch',
|
enable_conditional_order: 'switch',
|
||||||
enable_product_funds: 'switch',
|
enable_product_funds: 'switch',
|
||||||
has_page_price_trigger: 'switch',
|
has_page_price_trigger: 'switch',
|
||||||
@@ -704,6 +706,8 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
|||||||
'تعداد اولین سفارشهای هر کاربر که از کارمزد معاف میشوند. صفر یعنی غیرفعال.',
|
'تعداد اولین سفارشهای هر کاربر که از کارمزد معاف میشوند. صفر یعنی غیرفعال.',
|
||||||
fee_conditional_order:
|
fee_conditional_order:
|
||||||
'مبلغ ریالی که با هر بار ثبت تریگر سفارش شرطی از کیف پول ریالی مشتری کم میشود. صفر = رایگان.',
|
'مبلغ ریالی که با هر بار ثبت تریگر سفارش شرطی از کیف پول ریالی مشتری کم میشود. صفر = رایگان.',
|
||||||
|
enable_automation:
|
||||||
|
'روشن: منوی اتوماسیون در پنل ادمین و اجرای موتور فعال است. خاموش: منو مخفی است و API/کران اجرا نمیشود. فقط از سوپرادمین قابل تغییر است.',
|
||||||
enable_conditional_order:
|
enable_conditional_order:
|
||||||
'روشن: قابلیت سفارش شرطی سراسری فعال است. خاموش: منو و ارزیابی اجرا نمیشود. فقط از صفحه دیپلوی قابل تغییر است.',
|
'روشن: قابلیت سفارش شرطی سراسری فعال است. خاموش: منو و ارزیابی اجرا نمیشود. فقط از صفحه دیپلوی قابل تغییر است.',
|
||||||
enable_product_funds:
|
enable_product_funds:
|
||||||
@@ -1016,6 +1020,7 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
|
|||||||
require_zero_main_gold_before_other_buy: 'الزام صفر بودن کیف اصلی قبل از خرید محصول دیگر',
|
require_zero_main_gold_before_other_buy: 'الزام صفر بودن کیف اصلی قبل از خرید محصول دیگر',
|
||||||
fee_free: 'معافیت کارمزد سفارش اول',
|
fee_free: 'معافیت کارمزد سفارش اول',
|
||||||
fee_conditional_order: 'کارمزد سفارش شرطی',
|
fee_conditional_order: 'کارمزد سفارش شرطی',
|
||||||
|
enable_automation: 'اتوماسیون',
|
||||||
enable_conditional_order: 'سفارش شرطی',
|
enable_conditional_order: 'سفارش شرطی',
|
||||||
enable_product_funds: 'قلک محصول',
|
enable_product_funds: 'قلک محصول',
|
||||||
has_page_gift_card: 'کارت هدیه',
|
has_page_gift_card: 'کارت هدیه',
|
||||||
@@ -1140,6 +1145,7 @@ export const SETTING_LOCKED_KEYS = new Set([
|
|||||||
'group_sms',
|
'group_sms',
|
||||||
'customer_special_pricing',
|
'customer_special_pricing',
|
||||||
'customer_direct_sms',
|
'customer_direct_sms',
|
||||||
|
'enable_automation',
|
||||||
'enable_conditional_order',
|
'enable_conditional_order',
|
||||||
'enable_product_funds',
|
'enable_product_funds',
|
||||||
'has_page_price_trigger',
|
'has_page_price_trigger',
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import { useRouterStore } from '@core/stores/router'
|
|||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import { isDeployAdmin } from '@/utils/deployAdmin'
|
import { isDeployAdmin } from '@/utils/deployAdmin'
|
||||||
import { hasSmsPanelAccess, isSmsBillingEnabled } from '@/utils/smsPanelAccess'
|
import { hasSmsPanelAccess, isSmsBillingEnabled } from '@/utils/smsPanelAccess'
|
||||||
import { bannerEnabledSetting, trackingSystemsEnabledSetting, appNotificationEnabledSetting } from '@/utils/config'
|
import { bannerEnabledSetting, trackingSystemsEnabledSetting, appNotificationEnabledSetting, automationEnabledSetting } from '@/utils/config'
|
||||||
import { get } from 'lodash'
|
import { get } from 'lodash'
|
||||||
import type { RouteRecordRaw } from 'vue-router'
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
|
|
||||||
@@ -40,6 +40,7 @@ const menu = computed(() => {
|
|||||||
.filter((child) => !child.meta?.hideMenu)
|
.filter((child) => !child.meta?.hideMenu)
|
||||||
.filter((child) => child.name !== 'banners' || bannerEnabledSetting.value)
|
.filter((child) => child.name !== 'banners' || bannerEnabledSetting.value)
|
||||||
.filter((child) => child.name !== 'appNotifications' || appNotificationEnabledSetting.value)
|
.filter((child) => child.name !== 'appNotifications' || appNotificationEnabledSetting.value)
|
||||||
|
.filter((child) => child.name !== 'automations' || automationEnabledSetting.value)
|
||||||
.filter((child) => child.name !== 'captureSitesMain' || trackingSystemsEnabledSetting.value)
|
.filter((child) => child.name !== 'captureSitesMain' || trackingSystemsEnabledSetting.value)
|
||||||
.filter(
|
.filter(
|
||||||
(child) =>
|
(child) =>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { RouteRecordRaw } from 'vue-router'
|
|||||||
import { hasSmsPanelAccess } from '@/utils/smsPanelAccess'
|
import { hasSmsPanelAccess } from '@/utils/smsPanelAccess'
|
||||||
import { isDeployAdmin } from '@/utils/deployAdmin'
|
import { isDeployAdmin } from '@/utils/deployAdmin'
|
||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import { bannerEnabledSetting, trackingSystemsEnabledSetting, appNotificationEnabledSetting } from '@/utils/config'
|
import { bannerEnabledSetting, trackingSystemsEnabledSetting, appNotificationEnabledSetting, automationEnabledSetting } from '@/utils/config'
|
||||||
|
|
||||||
const Setting: RouteRecordRaw = {
|
const Setting: RouteRecordRaw = {
|
||||||
name: 'settings',
|
name: 'settings',
|
||||||
@@ -142,6 +142,11 @@ const Setting: RouteRecordRaw = {
|
|||||||
icon: 'vuesax-linear:flash',
|
icon: 'vuesax-linear:flash',
|
||||||
title: 'اتوماسیون',
|
title: 'اتوماسیون',
|
||||||
order: 4.7
|
order: 4.7
|
||||||
|
},
|
||||||
|
beforeEnter() {
|
||||||
|
if (!automationEnabledSetting.value) {
|
||||||
|
return { name: 'configuration' }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ export const customerDirectSmsEnabledSetting = ref(false)
|
|||||||
/** reactive — منو و UI سفارش شرطی (ادمین + کنترلهای مشتری) */
|
/** reactive — منو و UI سفارش شرطی (ادمین + کنترلهای مشتری) */
|
||||||
export const conditionalOrderEnabledSetting = ref(false)
|
export const conditionalOrderEnabledSetting = ref(false)
|
||||||
|
|
||||||
|
/** reactive — منوی اتوماسیون در تنظیمات ادمین */
|
||||||
|
export const automationEnabledSetting = ref(false)
|
||||||
|
|
||||||
/** reactive — قلک per-product در اپ مشتری */
|
/** reactive — قلک per-product در اپ مشتری */
|
||||||
export const productFundsEnabledSetting = ref(false)
|
export const productFundsEnabledSetting = ref(false)
|
||||||
|
|
||||||
@@ -167,6 +170,10 @@ export function setConditionalOrderEnabledFromSettings(value: boolean): void {
|
|||||||
conditionalOrderEnabledSetting.value = value
|
conditionalOrderEnabledSetting.value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setAutomationEnabledFromSettings(value: boolean): void {
|
||||||
|
automationEnabledSetting.value = value
|
||||||
|
}
|
||||||
|
|
||||||
export function setProductFundsEnabledFromSettings(value: boolean): void {
|
export function setProductFundsEnabledFromSettings(value: boolean): void {
|
||||||
productFundsEnabledSetting.value = value
|
productFundsEnabledSetting.value = value
|
||||||
}
|
}
|
||||||
@@ -283,6 +290,13 @@ export function applyConditionalOrderEnabledFromRows(
|
|||||||
if (row) setConditionalOrderEnabledFromSettings(isSwitchOn(row.value))
|
if (row) setConditionalOrderEnabledFromSettings(isSwitchOn(row.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function applyAutomationEnabledFromRows(
|
||||||
|
rows: Array<{ key?: string; value?: string | null }>
|
||||||
|
) {
|
||||||
|
const row = rows.find((item) => item.key === 'enable_automation')
|
||||||
|
if (row) setAutomationEnabledFromSettings(isSwitchOn(row.value))
|
||||||
|
}
|
||||||
|
|
||||||
export function applyProductFundsEnabledFromRows(
|
export function applyProductFundsEnabledFromRows(
|
||||||
rows: Array<{ key?: string; value?: string | null }>
|
rows: Array<{ key?: string; value?: string | null }>
|
||||||
) {
|
) {
|
||||||
@@ -346,6 +360,7 @@ async function bootstrapSettingsFromApi(): Promise<void> {
|
|||||||
applyGroupSmsFromRows(list)
|
applyGroupSmsFromRows(list)
|
||||||
applyCustomerSpecialPricingFromRows(list)
|
applyCustomerSpecialPricingFromRows(list)
|
||||||
applyConditionalOrderEnabledFromRows(list)
|
applyConditionalOrderEnabledFromRows(list)
|
||||||
|
applyAutomationEnabledFromRows(list)
|
||||||
applyProductFundsEnabledFromRows(list)
|
applyProductFundsEnabledFromRows(list)
|
||||||
applyCustomerLevelProfitEnabledFromRows(list)
|
applyCustomerLevelProfitEnabledFromRows(list)
|
||||||
applyPriceTriggerEnabledFromRows(list)
|
applyPriceTriggerEnabledFromRows(list)
|
||||||
|
|||||||
Reference in New Issue
Block a user