diff --git a/components/settings/plugins-settings.tsx b/components/settings/plugins-settings.tsx index be9f2607..4cfc8c35 100644 --- a/components/settings/plugins-settings.tsx +++ b/components/settings/plugins-settings.tsx @@ -1,12 +1,11 @@ 'use client'; -import { useState, useRef, useEffect } from 'react'; +import { useState, useEffect } from 'react'; import { usePluginStore } from '@/stores/plugin-store'; import { usePolicyStore } from '@/stores/policy-store'; -import { SettingsSection, SettingItem, ToggleSwitch } from './settings-section'; +import { SettingsSection, ToggleSwitch } from './settings-section'; import { cn } from '@/lib/utils'; -import { Upload, Trash2, AlertTriangle, Puzzle, Lock, Server } from 'lucide-react'; -import { Button } from '@/components/ui/button'; +import { AlertTriangle, Puzzle, Lock, Server } from 'lucide-react'; import { toast } from '@/stores/toast-store'; import type { InstalledPlugin, PluginStatus, SettingFieldSchema } from '@/lib/plugin-types'; @@ -19,11 +18,9 @@ const STATUS_COLORS: Record = { }; export function PluginsSettings() { - const { plugins, installPlugin, uninstallPlugin, enablePlugin, disablePlugin, updatePluginSettings, initializePlugins, initialized } = usePluginStore(); + const { plugins, enablePlugin, disablePlugin, updatePluginSettings, initializePlugins, initialized } = usePluginStore(); const { isFeatureEnabled, isPluginForceEnabled, isPluginApproved, fetchPolicy, loaded } = usePolicyStore(); - const [isUploading, setIsUploading] = useState(false); const [expandedPlugin, setExpandedPlugin] = useState(null); - const fileInputRef = useRef(null); useEffect(() => { if (!loaded) { @@ -48,36 +45,6 @@ export function PluginsSettings() { return null; } - const pluginUploadsEnabled = isFeatureEnabled('pluginsUploadEnabled'); - - const handleUpload = async (e: React.ChangeEvent) => { - if (!pluginUploadsEnabled) { - toast.info('Plugin uploads are disabled by your administrator'); - return; - } - - const file = e.target.files?.[0]; - if (!file) return; - - setIsUploading(true); - try { - const result = await installPlugin(file); - if (result.success) { - toast.success('Plugin installed'); - if (result.warnings?.length) { - toast.warning('Plugin warnings', { message: result.warnings.join('\n') }); - } - } else { - toast.error('Plugin installation failed', { message: result.error }); - } - } catch (err) { - toast.error('Plugin installation failed', { message: err instanceof Error ? err.message : 'Unknown error' }); - } finally { - setIsUploading(false); - if (fileInputRef.current) fileInputRef.current.value = ''; - } - }; - const handleToggle = async (plugin: InstalledPlugin) => { if (!initialized) return; @@ -103,27 +70,14 @@ export function PluginsSettings() { } }; - const handleUninstall = (plugin: InstalledPlugin) => { - if (!initialized) return; - - const isForceEnabled = plugin.forceEnabled || isPluginForceEnabled(plugin.id); - if (isForceEnabled) { - toast.info(`Plugin "${plugin.name}" is forced by admin and cannot be uninstalled`); - return; - } - - uninstallPlugin(plugin.id); - toast.success(`Plugin "${plugin.name}" removed`); - }; - return ( - + {/* Plugin List */} {plugins.length === 0 ? (
-

No plugins installed

-

Upload a plugin .zip file to get started

+

No plugins available

+

Your administrator has not deployed any plugins

) : (
@@ -142,7 +96,6 @@ export function PluginsSettings() { controlsDisabled={!initialized} onToggleExpand={() => setExpandedPlugin(expandedPlugin === plugin.id ? null : plugin.id)} onToggle={() => handleToggle(plugin)} - onUninstall={() => handleUninstall(plugin)} onUpdateSettings={(settings) => updatePluginSettings(plugin.id, settings)} /> ); @@ -153,33 +106,6 @@ export function PluginsSettings() { {!initialized && plugins.length > 0 && (

Syncing plugin policy and managed state...

)} - - {/* Upload */} - {pluginUploadsEnabled ? ( - - - - - ) : ( - - Disabled by administrator policy - - )} ); } @@ -195,11 +121,10 @@ interface PluginCardProps { controlsDisabled: boolean; onToggleExpand: () => void; onToggle: () => void; - onUninstall: () => void; onUpdateSettings: (settings: Record) => void; } -function PluginCard({ plugin, isExpanded, isForceEnabled, isManaged, needsApproval, controlsDisabled, onToggleExpand, onToggle, onUninstall, onUpdateSettings }: PluginCardProps) { +function PluginCard({ plugin, isExpanded, isForceEnabled, isManaged, needsApproval, controlsDisabled, onToggleExpand, onToggle, onUpdateSettings }: PluginCardProps) { return (
{isForceEnabled && ( -

This plugin is forced by an administrator and cannot be disabled or uninstalled.

+

This plugin is forced by an administrator and cannot be disabled.

)} {needsApproval && ( @@ -297,14 +222,6 @@ function PluginCard({ plugin, isExpanded, isForceEnabled, isManaged, needsApprov ))}
)} - - {/* Uninstall */} -
- -
)} diff --git a/components/settings/themes-settings.tsx b/components/settings/themes-settings.tsx index 096f57d5..d941131e 100644 --- a/components/settings/themes-settings.tsx +++ b/components/settings/themes-settings.tsx @@ -1,21 +1,16 @@ 'use client'; -import { useState, useRef, useEffect } from 'react'; +import { useEffect } from 'react'; import { useThemeStore } from '@/stores/theme-store'; -import { SettingsSection, SettingItem } from './settings-section'; +import { SettingsSection } from './settings-section'; import { cn } from '@/lib/utils'; -import { Upload, Trash2, Check, Palette, Lock } from 'lucide-react'; -import { Button } from '@/components/ui/button'; +import { Check, Palette, Lock } from 'lucide-react'; import { toast } from '@/stores/toast-store'; -import type { InstalledTheme } from '@/lib/plugin-types'; import { usePolicyStore } from '@/stores/policy-store'; export function ThemesSettings() { - const { installedThemes, activeThemeId, installTheme, uninstallTheme, activateTheme } = useThemeStore(); - const [isUploading, setIsUploading] = useState(false); - const fileInputRef = useRef(null); - const { isFeatureEnabled, isThemeDisabled, getThemePolicy, getForcedThemeId, isThemeForceEnabled } = usePolicyStore(); - const canUpload = isFeatureEnabled('userThemesEnabled'); + const { installedThemes, activeThemeId, activateTheme } = useThemeStore(); + const { isThemeDisabled, getThemePolicy, getForcedThemeId, isThemeForceEnabled } = usePolicyStore(); const themePolicy = getThemePolicy(); const forcedThemeId = getForcedThemeId(installedThemes.map((theme) => theme.id)); @@ -40,30 +35,6 @@ export function ThemesSettings() { } }, [activeThemeId, activateTheme, forcedThemeId, installedThemes, isThemeDisabled]); - const handleUpload = async (e: React.ChangeEvent) => { - const file = e.target.files?.[0]; - if (!file) return; - - setIsUploading(true); - try { - const result = await installTheme(file); - if (result.success) { - toast.success('Theme installed'); - if (result.warnings?.length) { - toast.warning('Theme warnings', { message: result.warnings.join('\n') }); - } - } else { - toast.error('Theme installation failed', { message: result.error }); - } - } catch (err) { - toast.error('Theme installation failed', { message: err instanceof Error ? err.message : 'Unknown error' }); - } finally { - setIsUploading(false); - // Reset file input - if (fileInputRef.current) fileInputRef.current.value = ''; - } - }; - const handleActivate = (id: string | null) => { if (forcedThemeId && id !== forcedThemeId) { const forcedTheme = installedThemes.find((theme) => theme.id === forcedThemeId); @@ -75,19 +46,8 @@ export function ThemesSettings() { toast.success(id ? 'Theme activated' : 'Default theme restored'); }; - const handleUninstall = (theme: InstalledTheme) => { - if (theme.builtIn) return; - if (theme.id === forcedThemeId || theme.forceEnabled || isThemeForceEnabled(theme.id)) { - toast.info(`Theme "${theme.name}" is forced by admin and cannot be removed`); - return; - } - - uninstallTheme(theme.id); - toast.success('Theme removed'); - }; - return ( - + {forcedThemeId && (
@@ -124,34 +84,10 @@ export function ThemesSettings() { disabled={Boolean(forcedThemeId) && !isForceEnabled} variants={theme.variants} onActivate={() => handleActivate(theme.id)} - onRemove={!theme.builtIn && !isForceEnabled ? () => handleUninstall(theme) : undefined} /> ); })}
- - {/* Upload */} - {canUpload && ( - - - - - )}
); } @@ -169,10 +105,9 @@ interface ThemeCardProps { disabled?: boolean; variants?: ('light' | 'dark')[]; onActivate: () => void; - onRemove?: () => void; } -function ThemeCard({ name, author, preview, isActive, isDefault, isForceEnabled, disabled, variants, onActivate, onRemove }: ThemeCardProps) { +function ThemeCard({ name, author, preview, isActive, isDefault, isForceEnabled, disabled, variants, onActivate }: ThemeCardProps) { return (
- - {/* Remove button */} - {onRemove && !isActive && ( - - )}
); }