diff --git a/app/api/settings/route.ts b/app/api/settings/route.ts index 7b230da3..d0f237e7 100644 --- a/app/api/settings/route.ts +++ b/app/api/settings/route.ts @@ -129,8 +129,24 @@ export async function POST(request: NextRequest) { const filteredSettings = { ...settings }; for (const key of Object.keys(filteredSettings)) { const restriction = policy.restrictions[key]; - if (restriction?.locked) { + if (!restriction) continue; + if (restriction.locked) { delete filteredSettings[key]; + continue; + } + const value = filteredSettings[key]; + if (restriction.allowedValues && restriction.allowedValues.length > 0) { + if (!restriction.allowedValues.includes(value)) { + delete filteredSettings[key]; + } + } + if (typeof value === 'number') { + if (restriction.min !== undefined && value < restriction.min) { + delete filteredSettings[key]; + } + if (restriction.max !== undefined && value > restriction.max) { + delete filteredSettings[key]; + } } } diff --git a/components/settings/calendar-settings.tsx b/components/settings/calendar-settings.tsx index 9d714565..9834a614 100644 --- a/components/settings/calendar-settings.tsx +++ b/components/settings/calendar-settings.tsx @@ -3,6 +3,7 @@ import { useTranslations } from 'next-intl'; import { useCalendarStore, CalendarViewMode } from '@/stores/calendar-store'; import { useSettingsStore } from '@/stores/settings-store'; +import { usePolicyStore } from '@/stores/policy-store'; import { SettingsSection, SettingItem, Select, RadioGroup, ToggleSwitch } from './settings-section'; export function CalendarSettings() { @@ -20,6 +21,7 @@ export function CalendarSettings() { showTasksOnCalendar, updateSetting, } = useSettingsStore(); + const { isFeatureEnabled } = usePolicyStore(); return ( @@ -78,6 +80,8 @@ export function CalendarSettings() { /> + {isFeatureEnabled('calendarTasksEnabled') && ( + <> )} + + )} ); diff --git a/components/settings/folder-settings.tsx b/components/settings/folder-settings.tsx index b9855902..dcb1ccbc 100644 --- a/components/settings/folder-settings.tsx +++ b/components/settings/folder-settings.tsx @@ -5,6 +5,7 @@ import { useTranslations } from 'next-intl'; import { useEmailStore } from '@/stores/email-store'; import { useAuthStore } from '@/stores/auth-store'; import { useSettingsStore } from '@/stores/settings-store'; +import { usePolicyStore } from '@/stores/policy-store'; import { toast } from '@/stores/toast-store'; import { SettingsSection, SettingItem, Select } from './settings-section'; import { @@ -100,6 +101,8 @@ export function FolderSettings() { const { client } = useAuthStore(); const { mailboxes, createMailbox, renameMailbox, deleteMailbox, setMailboxRole } = useEmailStore(); const { folderIcons, setFolderIcon } = useSettingsStore(); + const { isFeatureEnabled } = usePolicyStore(); + const folderIconsAllowed = isFeatureEnabled('folderIconsEnabled'); const [isCreating, setIsCreating] = useState(false); const [creatingParentId, setCreatingParentId] = useState(null); @@ -380,22 +383,31 @@ export function FolderSettings() { )}
- - {iconPickerId === mb.id && ( + {folderIconsAllowed ? ( + + ) : ( + + + + )} + {folderIconsAllowed && iconPickerId === mb.id && ( { diff --git a/components/settings/plugins-settings.tsx b/components/settings/plugins-settings.tsx index 6463161b..ec9541ea 100644 --- a/components/settings/plugins-settings.tsx +++ b/components/settings/plugins-settings.tsx @@ -2,6 +2,7 @@ import { useState, useRef } from 'react'; import { usePluginStore } from '@/stores/plugin-store'; +import { usePolicyStore } from '@/stores/policy-store'; import { SettingsSection, SettingItem, ToggleSwitch } from './settings-section'; import { cn } from '@/lib/utils'; import { Upload, Trash2, AlertTriangle, Puzzle } from 'lucide-react'; @@ -19,10 +20,15 @@ const STATUS_COLORS: Record = { export function PluginsSettings() { const { plugins, installPlugin, uninstallPlugin, enablePlugin, disablePlugin, updatePluginSettings } = usePluginStore(); + const { isFeatureEnabled } = usePolicyStore(); const [isUploading, setIsUploading] = useState(false); const [expandedPlugin, setExpandedPlugin] = useState(null); const fileInputRef = useRef(null); + if (!isFeatureEnabled('pluginsEnabled')) { + return null; + } + const handleUpload = async (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (!file) return;