ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
Introduce Modal component and lazy-load pages
Juan Denis25c625f011d1
diff --git a/frontend/package-lock.json b/frontend/package-lock.jsonindex 93f7894a..51157ce2 100644--- a/frontend/package-lock.json+++ b/frontend/package-lock.json@@ -8,6 +8,7 @@"name": "serverkit-frontend","version": "0.1.0","dependencies": {+ "@rollup/rollup-win32-x64-msvc": "^4.60.0","@xterm/addon-fit": "^0.10.0","@xterm/addon-web-links": "^0.11.0","@xterm/xterm": "^5.5.0",@@ -1636,15 +1637,13 @@]},"node_modules/@rollup/rollup-win32-x64-msvc": {- "version": "4.55.1",- "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.55.1.tgz",- "integrity": "sha512-SPEpaL6DX4rmcXtnhdrQYgzQ5W2uW3SCJch88lB2zImhJRhIIK44fkUrgIV/Q8yUNfw5oyZ5vkeQsZLhCb06lw==",+ "version": "4.60.0",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.60.0.tgz",+ "integrity": "sha512-PrsWNQ8BuE00O3Xsx3ALh2Df8fAj9+cvvX9AIA6o4KpATR98c9mud4XtDWVvsEuyia5U4tVSTKygawyJkjm60w==","cpu": ["x64"],- "dev": true,"license": "MIT",- "optional": true,"os": ["win32"]@@ -4906,6 +4905,20 @@"fsevents": "~2.3.2"}},+ "node_modules/rollup/node_modules/@rollup/rollup-win32-x64-msvc": {+ "version": "4.55.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.55.1.tgz",+ "integrity": "sha512-SPEpaL6DX4rmcXtnhdrQYgzQ5W2uW3SCJch88lB2zImhJRhIIK44fkUrgIV/Q8yUNfw5oyZ5vkeQsZLhCb06lw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ]+ },"node_modules/safe-array-concat": {"version": "1.1.3","resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.3.tgz",diff --git a/frontend/package.json b/frontend/package.jsonindex df4b7ad4..89713e8f 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -10,6 +10,7 @@"preview": "vite preview"},"dependencies": {+ "@rollup/rollup-win32-x64-msvc": "^4.60.0","@xterm/addon-fit": "^0.10.0","@xterm/addon-web-links": "^0.11.0","@xterm/xterm": "^5.5.0",diff --git a/frontend/src/App.jsx b/frontend/src/App.jsxindex 45fba18e..091d31e6 100644--- a/frontend/src/App.jsx+++ b/frontend/src/App.jsx@@ -1,54 +1,54 @@-import React, { useEffect } from 'react';+import React, { useEffect, Suspense, lazy } from 'react';import { BrowserRouter as Router, Routes, Route, Navigate, useLocation } from 'react-router-dom';import { AuthProvider, useAuth } from './contexts/AuthContext';import { ToastProvider } from './contexts/ToastContext';import { ThemeProvider } from './contexts/ThemeContext';import { ResourceTierProvider } from './contexts/ResourceTierContext';import { ToastContainer } from './components/Toast';+import { LoadingState } from './components/Spinner';import DashboardLayout from './layouts/DashboardLayout';import Dashboard from './pages/Dashboard';import Login from './pages/Login';import Register from './pages/Register';import Setup from './pages/Setup';-import Applications from './pages/Applications';-import ApplicationDetail from './pages/ApplicationDetail';-import Docker from './pages/Docker';-import Databases from './pages/Databases';-import Domains from './pages/Domains';-import Monitoring from './pages/Monitoring';-import Backups from './pages/Backups';-import Terminal from './pages/Terminal';-import Settings from './pages/Settings';-import FileManager from './pages/FileManager';-import FTPServer from './pages/FTPServer';-// Firewall is now part of Security page-import Git from './pages/Git';-import CronJobs from './pages/CronJobs';-import Security from './pages/Security';import Services from './pages/Services';import ServiceDetail from './pages/ServiceDetail';-import Templates from './pages/Templates';-import WorkflowBuilder from './pages/WorkflowBuilder';-import Servers from './pages/Servers';-import ServerDetail from './pages/ServerDetail';-import AgentFleet from './pages/AgentFleet';-import FleetMonitor from './pages/FleetMonitor';-import Downloads from './pages/Downloads';-import WordPress from './pages/WordPress';-import WordPressDetail from './pages/WordPressDetail';-import WordPressProjects from './pages/WordPressProjects';-import WordPressProject from './pages/WordPressProject';-import SSLCertificates from './pages/SSLCertificates';-import Email from './pages/Email';-import SSOCallback from './pages/SSOCallback';-import DatabaseMigration from './pages/DatabaseMigration';-import AgentPlugins from './pages/AgentPlugins';-import ServerTemplates from './pages/ServerTemplates';-import Workspaces from './pages/Workspaces';-import DNSZones from './pages/DNSZones';-import StatusPages from './pages/StatusPages';-import CloudProvision from './pages/CloudProvision';-import Marketplace from './pages/Marketplace';++// Lazy-loaded pages+const Applications = lazy(() => import('./pages/Applications'));+const ApplicationDetail = lazy(() => import('./pages/ApplicationDetail'));+const Docker = lazy(() => import('./pages/Docker'));+const Databases = lazy(() => import('./pages/Databases'));+const Domains = lazy(() => import('./pages/Domains'));+const Monitoring = lazy(() => import('./pages/Monitoring'));+const Backups = lazy(() => import('./pages/Backups'));+const Terminal = lazy(() => import('./pages/Terminal'));+const Settings = lazy(() => import('./pages/Settings'));+const FileManager = lazy(() => import('./pages/FileManager'));+// FTPServer — absorbed into FileManager page as tab+// Firewall is now part of Security page+const Git = lazy(() => import('./pages/Git'));+const CronJobs = lazy(() => import('./pages/CronJobs'));+const Security = lazy(() => import('./pages/Security'));+const Templates = lazy(() => import('./pages/Templates'));+const WorkflowBuilder = lazy(() => import('./pages/WorkflowBuilder'));+const Servers = lazy(() => import('./pages/Servers'));+const ServerDetail = lazy(() => import('./pages/ServerDetail'));+const Downloads = lazy(() => import('./pages/Downloads'));+const WordPress = lazy(() => import('./pages/WordPress'));+const WordPressDetail = lazy(() => import('./pages/WordPressDetail'));+const WordPressProjects = lazy(() => import('./pages/WordPressProjects'));+const WordPressProject = lazy(() => import('./pages/WordPressProject'));+// SSLCertificates — absorbed into Domains page as tab+const Email = lazy(() => import('./pages/Email'));+const SSOCallback = lazy(() => import('./pages/SSOCallback'));+const DatabaseMigration = lazy(() => import('./pages/DatabaseMigration'));+// AgentPlugins, ServerTemplates — absorbed into Servers page as tabs+const Workspaces = lazy(() => import('./pages/Workspaces'));+// DNSZones, SSLCertificates — absorbed into Domains page as tabs+// StatusPages — absorbed into Monitoring page as a tab+// CloudProvision, AgentFleet, FleetMonitor — absorbed into Servers page as tabs+const Marketplace = lazy(() => import('./pages/Marketplace'));// Page title mappingconst PAGE_TITLES = {@@ -64,13 +64,13 @@ const PAGE_TITLES = {'/workflow': 'Workflow Builder','/domains': 'Domains','/databases': 'Databases',- '/ssl': 'SSL Certificates',+ // SSL absorbed into Domains'/docker': 'Docker','/servers': 'Servers',- '/downloads': 'Downloads',+ // Downloads absorbed into Marketplace'/git': 'Git Repositories','/files': 'File Manager',- '/ftp': 'FTP Server',+ // FTP absorbed into File Manager'/monitoring': 'Monitoring','/backups': 'Backups','/cron': 'Cron Jobs',@@ -79,14 +79,9 @@ const PAGE_TITLES = {'/terminal': 'Terminal','/settings': 'Settings','/migrate': 'Database Migration',- '/fleet': 'Agent Fleet',- '/fleet-monitor': 'Fleet Monitor',- '/agent-plugins': 'Agent Plugins',- '/server-templates': 'Server Templates',+ // Fleet, Fleet Monitor, Agent Plugins, Server Templates, Cloud — absorbed into Servers'/workspaces': 'Workspaces',- '/dns': 'DNS Zones',- '/status-pages': 'Status Pages',- '/cloud': 'Cloud Provisioning',+ // DNS absorbed into Domains, Status Pages absorbed into Monitoring, Cloud absorbed into Servers'/marketplace': 'Marketplace',};@@ -121,7 +116,7 @@ function PrivateRoute({ children }) {const { isAuthenticated, loading, needsSetup, needsMigration } = useAuth();if (loading) {- return <div className="loading">Loading...</div>;+ return <LoadingState />;}// Priority: migrations > setup > auth@@ -140,7 +135,7 @@ function PublicRoute({ children }) {const { isAuthenticated, loading, needsSetup, needsMigration } = useAuth();if (loading) {- return <div className="loading">Loading...</div>;+ return <LoadingState />;}// Priority: migrations > setup > auth@@ -159,7 +154,7 @@ function SetupRoute({ children }) {const { loading, needsSetup, isAuthenticated } = useAuth();if (loading) {- return <div className="loading">Loading...</div>;+ return <LoadingState />;}// If setup is not needed, redirect appropriately@@ -172,6 +167,7 @@ function SetupRoute({ children }) {function AppRoutes() {return (+ <Suspense fallback={<LoadingState />}><Routes><Route path="/migrate" element={<DatabaseMigration />} /><Route path="/setup" element={@@ -214,30 +210,37 @@ function AppRoutes() {<Route path="templates" element={<Templates />} /><Route path="workflow" element={<WorkflowBuilder />} /><Route path="domains" element={<Domains />} />+ <Route path="domains/:tab" element={<Domains />} /><Route path="databases" element={<Databases />} /><Route path="databases/:tab" element={<Databases />} />- <Route path="ssl" element={<SSLCertificates />} />+ <Route path="ssl" element={<Navigate to="/domains/ssl" replace />} /><Route path="docker" element={<Docker />} /><Route path="docker/:tab" element={<Docker />} /><Route path="servers" element={<Servers />} />+ <Route path="servers/fleet" element={<Servers />} />+ <Route path="servers/monitor" element={<Servers />} />+ <Route path="servers/cloud" element={<Servers />} />+ <Route path="servers/plugins" element={<Servers />} />+ <Route path="servers/config" element={<Servers />} /><Route path="servers/:id" element={<ServerDetail />} /><Route path="servers/:id/:tab" element={<ServerDetail />} />- <Route path="fleet" element={<AgentFleet />} />- <Route path="fleet-monitor" element={<FleetMonitor />} />- <Route path="agent-plugins" element={<AgentPlugins />} />- <Route path="server-templates" element={<ServerTemplates />} />+ <Route path="fleet" element={<Navigate to="/servers/fleet" replace />} />+ <Route path="fleet-monitor" element={<Navigate to="/servers/monitor" replace />} />+ <Route path="agent-plugins" element={<Navigate to="/servers/plugins" replace />} />+ <Route path="server-templates" element={<Navigate to="/servers/config" replace />} />+ <Route path="cloud" element={<Navigate to="/servers/cloud" replace />} /><Route path="workspaces" element={<Workspaces />} />- <Route path="dns" element={<DNSZones />} />- <Route path="status-pages" element={<StatusPages />} />- <Route path="cloud" element={<CloudProvision />} />+ <Route path="dns" element={<Navigate to="/domains/dns" replace />} />+ <Route path="status-pages" element={<Navigate to="/monitoring/status-pages" replace />} /><Route path="marketplace" element={<Marketplace />} />- <Route path="downloads" element={<Downloads />} />+ <Route path="marketplace/:tab" element={<Marketplace />} />+ <Route path="downloads" element={<Navigate to="/marketplace/downloads" replace />} /><Route path="firewall" element={<Navigate to="/security/firewall" replace />} /><Route path="git" element={<Git />} /><Route path="git/:tab" element={<Git />} /><Route path="files" element={<FileManager />} />- <Route path="ftp" element={<FTPServer />} />- <Route path="ftp/:tab" element={<FTPServer />} />+ <Route path="files/:tab" element={<FileManager />} />+ <Route path="ftp" element={<Navigate to="/files/ftp" replace />} /><Route path="monitoring" element={<Monitoring />} /><Route path="monitoring/:tab" element={<Monitoring />} /><Route path="backups" element={<Backups />} />@@ -253,6 +256,7 @@ function AppRoutes() {<Route path="settings/:tab" element={<Settings />} /></Route></Routes>+ </Suspense>);}diff --git a/frontend/src/components/EmptyState.jsx b/frontend/src/components/EmptyState.jsxnew file mode 100644index 00000000..8edeadf8--- /dev/null+++ b/frontend/src/components/EmptyState.jsx@@ -0,0 +1,24 @@+import React from 'react';+import { Inbox } from 'lucide-react';++export default function EmptyState({+ icon: Icon = Inbox,+ title = 'No items found',+ description = '',+ action = null+}) {+ return (+ <div className="empty-state">+ <div className="empty-state__icon">+ <Icon size={48} />+ </div>+ <h3 className="empty-state__title">{title}</h3>+ {description && (+ <p className="empty-state__description">{description}</p>+ )}+ {action && (+ <div className="empty-state__action">{action}</div>+ )}+ </div>+ );+}diff --git a/frontend/src/components/EnvironmentVariables.jsx b/frontend/src/components/EnvironmentVariables.jsxindex 2c40d6a3..b90cd566 100644--- a/frontend/src/components/EnvironmentVariables.jsx+++ b/frontend/src/components/EnvironmentVariables.jsx@@ -1,6 +1,7 @@import React, { useState, useEffect, useRef } from 'react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import Modal from './Modal';const EnvironmentVariables = ({ appId }) => {const toast = useToast();@@ -429,14 +430,7 @@ const EnvironmentVariables = ({ appId }) => {)}{/* Import Modal */}- {showImportModal && (- <div className="modal-overlay" onClick={() => setShowImportModal(false)}>- <div className="modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>Import Environment Variables</h2>- <button className="modal-close" onClick={() => setShowImportModal(false)}>×</button>- </div>- <div className="modal-body">+ <Modal open={showImportModal} onClose={() => setShowImportModal(false)} title="Import Environment Variables"><p className="hint">Paste your .env file content below or upload a file.</p><div className="import-file-upload">@@ -471,7 +465,6 @@ const EnvironmentVariables = ({ appId }) => {/><span>Overwrite existing variables with same keys</span></label>- </div><div className="modal-footer"><button className="btn btn-secondary" onClick={() => setShowImportModal(false)}>Cancel@@ -480,19 +473,10 @@ const EnvironmentVariables = ({ appId }) => {{saving ? 'Importing...' : 'Import'}</button></div>- </div>- </div>- )}+ </Modal>{/* History Modal */}- {showHistoryModal && (- <div className="modal-overlay" onClick={() => setShowHistoryModal(false)}>- <div className="modal modal-lg" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>Change History</h2>- <button className="modal-close" onClick={() => setShowHistoryModal(false)}>×</button>- </div>- <div className="modal-body">+ <Modal open={showHistoryModal} onClose={() => setShowHistoryModal(false)} title="Change History" size="lg">{history.length === 0 ? (<p className="hint">No changes recorded yet.</p>) : (@@ -519,15 +503,12 @@ const EnvironmentVariables = ({ appId }) => {</tbody></table>)}- </div><div className="modal-footer"><button className="btn btn-secondary" onClick={() => setShowHistoryModal(false)}>Close</button></div>- </div>- </div>- )}+ </Modal></div>);};diff --git a/frontend/src/components/LinkAppModal.jsx b/frontend/src/components/LinkAppModal.jsxindex f6c82628..483cc235 100644--- a/frontend/src/components/LinkAppModal.jsx+++ b/frontend/src/components/LinkAppModal.jsx@@ -1,6 +1,7 @@import React, { useState, useEffect } from 'react';import { X, Link2, GitBranch, AlertCircle, Check } from 'lucide-react';import api from '../services/api';+import Modal from './Modal';const LinkAppModal = ({ app, onClose, onLinked }) => {const [apps, setApps] = useState([]);@@ -68,18 +69,7 @@ const LinkAppModal = ({ app, onClose, onLinked }) => {};return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal link-app-modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>- <Link2 size={20} />- Link Application- </h2>- <button className="modal-close" onClick={onClose}>- <X size={20} />- </button>- </div>-+ <Modal open={true} onClose={onClose} title="Link Application" className="link-app-modal">{error && (<div className="error-message"><AlertCircle size={16} />@@ -221,8 +211,7 @@ const LinkAppModal = ({ app, onClose, onLinked }) => {</div></form>)}- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/Modal.jsx b/frontend/src/components/Modal.jsxnew file mode 100644index 00000000..d663fb3b--- /dev/null+++ b/frontend/src/components/Modal.jsx@@ -0,0 +1,46 @@+import { useEffect, useRef } from 'react';++export default function Modal({ open, onClose, title, children, className = '', size = '' }) {+ const modalRef = useRef(null);++ // Close on Escape key+ useEffect(() => {+ if (!open) return;+ const handleKeyDown = (e) => {+ if (e.key === 'Escape') onClose();+ };+ document.addEventListener('keydown', handleKeyDown);+ return () => document.removeEventListener('keydown', handleKeyDown);+ }, [open, onClose]);++ // Focus trap: focus the modal when it opens+ useEffect(() => {+ if (open && modalRef.current) {+ modalRef.current.focus();+ }+ }, [open]);++ if (!open) return null;++ return (+ <div className="modal-overlay" onClick={onClose}>+ <div+ className={`modal ${size ? `modal-${size}` : ''} ${className}`.trim()}+ onClick={e => e.stopPropagation()}+ ref={modalRef}+ tabIndex={-1}+ role="dialog"+ aria-modal="true"+ aria-label={title}+ >+ <div className="modal-header">+ <h3>{title}</h3>+ <button className="modal-close" onClick={onClose} aria-label="Close">×</button>+ </div>+ <div className="modal-body">+ {children}+ </div>+ </div>+ </div>+ );+}diff --git a/frontend/src/components/QueryRunner.jsx b/frontend/src/components/QueryRunner.jsxindex d3b73f7d..4ead687c 100644--- a/frontend/src/components/QueryRunner.jsx+++ b/frontend/src/components/QueryRunner.jsx@@ -1,6 +1,7 @@import React, { useState, useEffect, useRef, useCallback } from 'react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import Modal from './Modal';const HISTORY_KEY = 'serverkit_query_history';const MAX_HISTORY = 50;@@ -247,35 +248,21 @@ const QueryRunner = ({ database, dbType, onClose }) => {const dbName = dbType === 'sqlite' ? database.name : database.name;return (- <div className="modal-overlay query-runner-overlay" onClick={onClose}>- <div className="query-runner-modal" onClick={e => e.stopPropagation()}>- <div className="query-runner-header">- <div className="query-runner-title">- <svg viewBox="0 0 24 24" width="20" height="20" stroke="currentColor" fill="none" strokeWidth="2">- <polyline points="16 18 22 12 16 6"/>- <polyline points="8 6 2 12 8 18"/>- </svg>- <span>Query Runner - {dbName}</span>- <span className={`db-type-badge ${dbType}`}>- {dbType === 'mysql' ? 'MySQL' : dbType === 'postgresql' ? 'PostgreSQL' : dbType === 'docker' ? 'Docker MySQL' : 'SQLite'}- </span>- </div>- <div className="query-runner-actions">- {isAdmin && (- <label className="readonly-toggle">- <input- type="checkbox"- checked={!readonly}- onChange={(e) => setReadonly(!e.target.checked)}- />- <span>Allow write queries</span>- </label>- )}- <button className="btn btn-secondary btn-sm" onClick={() => setShowHistory(!showHistory)}>- History- </button>- <button className="modal-close" onClick={onClose}>×</button>- </div>+ <Modal open={true} onClose={onClose} title={`Query Runner - ${dbName}`} className="query-runner-modal">+ <div className="query-runner-actions-bar">+ {isAdmin && (+ <label className="readonly-toggle">+ <input+ type="checkbox"+ checked={!readonly}+ onChange={(e) => setReadonly(!e.target.checked)}+ />+ <span>Allow write queries</span>+ </label>+ )}+ <button className="btn btn-secondary btn-sm" onClick={() => setShowHistory(!showHistory)}>+ History+ </button></div><div className="query-runner-body">@@ -465,8 +452,7 @@ const QueryRunner = ({ database, dbType, onClose }) => {</div></div>)}- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsxindex 199b7653..1b6a5757 100644--- a/frontend/src/components/Sidebar.jsx+++ b/frontend/src/components/Sidebar.jsx@@ -2,13 +2,13 @@ import React, { useState, useEffect, useRef, useMemo } from 'react';import { NavLink, useNavigate } from 'react-router-dom';import { useAuth } from '../contexts/AuthContext';import { useTheme } from '../contexts/ThemeContext';-import { Star, Settings, LogOut, Sun, Moon, Monitor, ChevronRight, ChevronUp, Layers } from 'lucide-react';+import { Star, Settings, LogOut, Sun, Moon, Monitor, ChevronRight, ChevronUp, Layers, Palette, PanelLeft, Check } from 'lucide-react';import { api } from '../services/api';import ServerKitLogo from './ServerKitLogo';-import { SIDEBAR_CATEGORIES, CATEGORY_LABELS, getVisibleItems } from './sidebarItems';+import { SIDEBAR_CATEGORIES, CATEGORY_LABELS, SIDEBAR_PRESETS, getVisibleItems } from './sidebarItems';const Sidebar = () => {- const { user, logout } = useAuth();+ const { user, logout, updateUser } = useAuth();const { theme, resolvedTheme, setTheme, whiteLabel } = useTheme();const navigate = useNavigate();const [starAnimating, setStarAnimating] = useState(false);@@ -71,6 +71,16 @@ const Sidebar = () => {}, [whiteLabel.enabled]);const conditions = { wpInstalled };+ const currentPreset = user?.sidebar_config?.preset || 'full';++ const handlePresetSwitch = async (presetKey) => {+ if (presetKey === currentPreset) return;+ const config = { preset: presetKey, hiddenItems: [] };+ try {+ await api.updateCurrentUser({ sidebar_config: config });+ await updateUser({ sidebar_config: config });+ } catch {}+ };const visibleItems = useMemo(() => getVisibleItems(user?.sidebar_config),@@ -219,13 +229,45 @@ const Sidebar = () => {</button></div></div>+ <div className="context-menu-section">+ <div className="context-menu-label">Sidebar View</div>+ <div className="view-switcher">+ {Object.entries(SIDEBAR_PRESETS).map(([key, preset]) => (+ <button+ key={key}+ className={`view-btn ${currentPreset === key ? 'active' : ''}`}+ onClick={() => handlePresetSwitch(key)}+ title={preset.description}+ >+ {preset.label}+ {currentPreset === key && <Check size={10} />}+ </button>+ ))}+ </div>+ </div><div className="context-menu-divider" />+ <button+ className="context-menu-item"+ onClick={() => { navigate('/settings/appearance'); setMenuOpen(false); }}+ >+ <Palette size={15} />+ Appearance+ <ChevronRight size={14} className="context-menu-arrow" />+ </button>+ <button+ className="context-menu-item"+ onClick={() => { navigate('/settings/sidebar'); setMenuOpen(false); }}+ >+ <PanelLeft size={15} />+ Customize Sidebar+ <ChevronRight size={14} className="context-menu-arrow" />+ </button><buttonclassName="context-menu-item"onClick={() => { navigate('/settings'); setMenuOpen(false); }}><Settings size={15} />- Settings+ All Settings<ChevronRight size={14} className="context-menu-arrow" /></button><div className="context-menu-divider" />diff --git a/frontend/src/components/StatusBadge.jsx b/frontend/src/components/StatusBadge.jsxnew file mode 100644index 00000000..75eb5930--- /dev/null+++ b/frontend/src/components/StatusBadge.jsx@@ -0,0 +1,33 @@+import React from 'react';++const STATUS_MAP = {+ online: { label: 'Online', className: 'status-badge--success' },+ running: { label: 'Running', className: 'status-badge--success' },+ healthy: { label: 'Healthy', className: 'status-badge--success' },+ active: { label: 'Active', className: 'status-badge--success' },+ connected: { label: 'Connected', className: 'status-badge--success' },+ offline: { label: 'Offline', className: 'status-badge--danger' },+ stopped: { label: 'Stopped', className: 'status-badge--danger' },+ error: { label: 'Error', className: 'status-badge--danger' },+ failed: { label: 'Failed', className: 'status-badge--danger' },+ disconnected: { label: 'Disconnected', className: 'status-badge--danger' },+ warning: { label: 'Warning', className: 'status-badge--warning' },+ degraded: { label: 'Degraded', className: 'status-badge--warning' },+ pending: { label: 'Pending', className: 'status-badge--info' },+ building: { label: 'Building', className: 'status-badge--info' },+ deploying: { label: 'Deploying', className: 'status-badge--info' },+ paused: { label: 'Paused', className: 'status-badge--muted' },+ unknown: { label: 'Unknown', className: 'status-badge--muted' },+};++export default function StatusBadge({ status, label, className = '' }) {+ const mapped = STATUS_MAP[status?.toLowerCase()] || STATUS_MAP.unknown;+ const displayLabel = label || mapped.label || status;++ return (+ <span className={`status-badge ${mapped.className} ${className}`.trim()}>+ <span className="status-badge__dot" />+ {displayLabel}+ </span>+ );+}diff --git a/frontend/src/components/security/AuditTab.jsx b/frontend/src/components/security/AuditTab.jsxindex 34c10293..ab043345 100644--- a/frontend/src/components/security/AuditTab.jsx+++ b/frontend/src/components/security/AuditTab.jsx@@ -53,7 +53,7 @@ const AuditTab = () => {<svg viewBox="0 0 24 24" width="48" height="48" stroke="currentColor" fill="none" strokeWidth="1"><path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"/></svg>- <p>Run a security audit to check your server's configuration.</p>+ <p>Run a security audit to check your server's configuration.</p></div>)}diff --git a/frontend/src/components/security/Fail2banTab.jsx b/frontend/src/components/security/Fail2banTab.jsxindex 01083600..1f0079c9 100644--- a/frontend/src/components/security/Fail2banTab.jsx+++ b/frontend/src/components/security/Fail2banTab.jsx@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';import api from '../../services/api';import ConfirmDialog from '../ConfirmDialog';import { useToast } from '../../contexts/ToastContext';+import Modal from '../Modal';const Fail2banTab = () => {const [status, setStatus] = useState(null);@@ -174,14 +175,7 @@ const Fail2banTab = () => {</>)}- {showBanModal && (- <div className="modal-overlay" onClick={() => setShowBanModal(false)}>- <div className="modal" onClick={(e) => e.stopPropagation()}>- <div className="modal-header">- <h2>Ban IP Address</h2>- <button className="btn btn-icon" onClick={() => setShowBanModal(false)}>×</button>- </div>- <div className="modal-body">+ <Modal open={showBanModal} onClose={() => setShowBanModal(false)} title="Ban IP Address"><div className="form-group"><label>IP Address</label><input@@ -199,16 +193,13 @@ const Fail2banTab = () => {))}</select></div>- </div><div className="modal-footer"><button className="btn btn-secondary" onClick={() => setShowBanModal(false)}>Cancel</button><button className="btn btn-danger" onClick={handleBan} disabled={actionLoading || !banIP.trim()}>{actionLoading ? 'Banning...' : 'Ban IP'}</button></div>- </div>- </div>- )}+ </Modal>{confirmDialog && (<ConfirmDialogdiff --git a/frontend/src/components/security/FirewallTab.jsx b/frontend/src/components/security/FirewallTab.jsxindex 64b46ef4..53a871e8 100644--- a/frontend/src/components/security/FirewallTab.jsx+++ b/frontend/src/components/security/FirewallTab.jsx@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';import api from '../../services/api';import ConfirmDialog from '../ConfirmDialog';import { useToast } from '../../contexts/ToastContext';+import Modal from '../Modal';const FirewallTab = () => {const [status, setStatus] = useState(null);@@ -432,14 +433,7 @@ const FirewallTab = () => {)}{/* Block IP Modal */}- {showBlockIPModal && (- <div className="modal-overlay" onClick={() => setShowBlockIPModal(false)}>- <div className="modal" onClick={(e) => e.stopPropagation()}>- <div className="modal-header">- <h2>Block IP Address</h2>- <button className="btn btn-icon" onClick={() => setShowBlockIPModal(false)}>×</button>- </div>- <div className="modal-body">+ <Modal open={showBlockIPModal} onClose={() => setShowBlockIPModal(false)} title="Block IP Address"><div className="form-group"><label>IP Address</label><input@@ -450,26 +444,16 @@ const FirewallTab = () => {/></div><p className="text-muted">You can block a single IP or a range using CIDR notation.</p>- </div><div className="modal-footer"><button className="btn btn-secondary" onClick={() => setShowBlockIPModal(false)}>Cancel</button><button className="btn btn-danger" onClick={handleBlockIP} disabled={actionLoading || !blockIP.trim()}>{actionLoading ? 'Blocking...' : 'Block IP'}</button></div>- </div>- </div>- )}+ </Modal>{/* Allow Port Modal */}- {showPortModal && (- <div className="modal-overlay" onClick={() => setShowPortModal(false)}>- <div className="modal" onClick={(e) => e.stopPropagation()}>- <div className="modal-header">- <h2>Allow Port</h2>- <button className="btn btn-icon" onClick={() => setShowPortModal(false)}>×</button>- </div>- <div className="modal-body">+ <Modal open={showPortModal} onClose={() => setShowPortModal(false)} title="Allow Port"><div className="form-row"><div className="form-group"><label>Port Number</label>@@ -490,26 +474,16 @@ const FirewallTab = () => {</select></div></div>- </div><div className="modal-footer"><button className="btn btn-secondary" onClick={() => setShowPortModal(false)}>Cancel</button><button className="btn btn-primary" onClick={handleAllowPort} disabled={actionLoading || !newPort.port}>{actionLoading ? 'Adding...' : 'Allow Port'}</button></div>- </div>- </div>- )}+ </Modal>{/* Install Firewall Modal */}- {showInstallModal && (- <div className="modal-overlay" onClick={() => setShowInstallModal(false)}>- <div className="modal" onClick={(e) => e.stopPropagation()}>- <div className="modal-header">- <h2>Install Firewall</h2>- <button className="btn btn-icon" onClick={() => setShowInstallModal(false)}>×</button>- </div>- <div className="modal-body">+ <Modal open={showInstallModal} onClose={() => setShowInstallModal(false)} title="Install Firewall"><div className="form-group"><label>Select Firewall</label><select value={selectedFirewall} onChange={(e) => setSelectedFirewall(e.target.value)}>@@ -524,16 +498,13 @@ const FirewallTab = () => {<p><strong>firewalld</strong> is a dynamically managed firewall with zone-based configuration for CentOS/RHEL.</p>)}</div>- </div><div className="modal-footer"><button className="btn btn-secondary" onClick={() => setShowInstallModal(false)}>Cancel</button><button className="btn btn-primary" onClick={handleInstall} disabled={actionLoading}>{actionLoading ? 'Installing...' : 'Install'}</button></div>- </div>- </div>- )}+ </Modal>{confirmDialog && (<ConfirmDialogdiff --git a/frontend/src/components/security/IPListsTab.jsx b/frontend/src/components/security/IPListsTab.jsxindex 44f35ac7..136c73b0 100644--- a/frontend/src/components/security/IPListsTab.jsx+++ b/frontend/src/components/security/IPListsTab.jsx@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';import api from '../../services/api';import ConfirmDialog from '../ConfirmDialog';import { useToast } from '../../contexts/ToastContext';+import Modal from '../Modal';const IPListsTab = () => {const [lists, setLists] = useState({ allowlist: [], blocklist: [] });@@ -111,14 +112,7 @@ const IPListsTab = () => {{renderList('Blocklist', 'blocklist', lists.blocklist, 'ip-blocked')}</div>- {showAddModal && (- <div className="modal-overlay" onClick={() => setShowAddModal(null)}>- <div className="modal" onClick={(e) => e.stopPropagation()}>- <div className="modal-header">- <h2>Add to {showAddModal}</h2>- <button className="btn btn-icon" onClick={() => setShowAddModal(null)}>×</button>- </div>- <div className="modal-body">+ <Modal open={!!showAddModal} onClose={() => setShowAddModal(null)} title={`Add to ${showAddModal || ''}`}><div className="form-group"><label>IP Address or CIDR</label><input@@ -137,16 +131,13 @@ const IPListsTab = () => {placeholder="Office IP, VPN, etc."/></div>- </div><div className="modal-footer"><button className="btn btn-secondary" onClick={() => setShowAddModal(null)}>Cancel</button><button className="btn btn-primary" onClick={handleAdd} disabled={actionLoading || !newIP.trim()}>{actionLoading ? 'Adding...' : 'Add'}</button></div>- </div>- </div>- )}+ </Modal>{confirmDialog && (<ConfirmDialogdiff --git a/frontend/src/components/security/SSHKeysTab.jsx b/frontend/src/components/security/SSHKeysTab.jsxindex 09d95f40..0a2ba7bf 100644--- a/frontend/src/components/security/SSHKeysTab.jsx+++ b/frontend/src/components/security/SSHKeysTab.jsx@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';import api from '../../services/api';import ConfirmDialog from '../ConfirmDialog';import { useToast } from '../../contexts/ToastContext';+import Modal from '../Modal';const SSHKeysTab = () => {const [keys, setKeys] = useState([]);@@ -117,14 +118,7 @@ const SSHKeysTab = () => {</div></div>- {showAddModal && (- <div className="modal-overlay" onClick={() => setShowAddModal(false)}>- <div className="modal modal-lg" onClick={(e) => e.stopPropagation()}>- <div className="modal-header">- <h2>Add SSH Public Key</h2>- <button className="btn btn-icon" onClick={() => setShowAddModal(false)}>×</button>- </div>- <div className="modal-body">+ <Modal open={showAddModal} onClose={() => setShowAddModal(false)} title="Add SSH Public Key" size="lg"><div className="form-group"><label>Public Key</label><textarea@@ -135,16 +129,13 @@ const SSHKeysTab = () => {/><p className="help-text">Paste your SSH public key (typically from ~/.ssh/id_rsa.pub or ~/.ssh/id_ed25519.pub)</p></div>- </div><div className="modal-footer"><button className="btn btn-secondary" onClick={() => setShowAddModal(false)}>Cancel</button><button className="btn btn-primary" onClick={handleAddKey} disabled={actionLoading || !newKey.trim()}>{actionLoading ? 'Adding...' : 'Add Key'}</button></div>- </div>- </div>- )}+ </Modal>{confirmDialog && (<ConfirmDialogdiff --git a/frontend/src/components/service-detail/GitConnectModal.jsx b/frontend/src/components/service-detail/GitConnectModal.jsxindex 8b6675a3..5baeab5f 100644--- a/frontend/src/components/service-detail/GitConnectModal.jsx+++ b/frontend/src/components/service-detail/GitConnectModal.jsx@@ -1,6 +1,7 @@import React, { useState, useEffect } from 'react';import api from '../../services/api';import { useToast } from '../../contexts/ToastContext';+import Modal from '../Modal';const GitConnectModal = ({ appId, deployConfig, onClose, onSaved }) => {const toast = useToast();@@ -72,13 +73,7 @@ const GitConnectModal = ({ appId, deployConfig, onClose, onSaved }) => {}return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal-content" onClick={(e) => e.stopPropagation()}>- <div className="modal-header">- <h2>{deployConfig ? 'Edit Repository' : 'Connect Repository'}</h2>- <button className="modal-close" onClick={onClose}>×</button>- </div>-+ <Modal open={true} onClose={onClose} title={deployConfig ? 'Edit Repository' : 'Connect Repository'}><form className="git-connect-modal__form" onSubmit={handleSubmit}><div className="git-connect-modal__field"><label>Repository URL</label>@@ -159,8 +154,7 @@ const GitConnectModal = ({ appId, deployConfig, onClose, onSaved }) => {</button></div></form>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/settings/AboutTab.jsx b/frontend/src/components/settings/AboutTab.jsxnew file mode 100644index 00000000..b798e838--- /dev/null+++ b/frontend/src/components/settings/AboutTab.jsx@@ -0,0 +1,199 @@+import React, { useState, useEffect } from 'react';+import api from '../../services/api';+import {+ Github, FileText, HelpCircle, MessageSquare, Bug, Check, Download, CheckCircle,+ RefreshCw, ExternalLink, Star, X+} from 'lucide-react';+import ServerKitLogo from '../ServerKitLogo';++const STAR_PROMPT_KEY = 'serverkit-star-prompt-dismissed';++const AboutTab = () => {+ const [version, setVersion] = useState('...');+ const [updateInfo, setUpdateInfo] = useState(null);+ const [checkingUpdate, setCheckingUpdate] = useState(false);+ const [showStarPrompt, setShowStarPrompt] = useState(() => {+ return localStorage.getItem(STAR_PROMPT_KEY) !== 'true';+ });++ useEffect(() => {+ const fetchVersion = async () => {+ try {+ const data = await api.getVersion();+ setVersion(data.version || '1.0.0');+ } catch (error) {+ setVersion('1.0.0');+ }+ };+ fetchVersion();+ }, []);++ const dismissStarPrompt = () => {+ setShowStarPrompt(false);+ localStorage.setItem(STAR_PROMPT_KEY, 'true');+ };++ const checkForUpdate = async () => {+ setCheckingUpdate(true);+ try {+ const data = await api.checkUpdate();+ setUpdateInfo(data);+ } catch (error) {+ setUpdateInfo({ error: 'Failed to check for updates' });+ }+ setCheckingUpdate(false);+ };++ return (+ <div className="settings-section">+ <div className="section-header">+ <h2>About ServerKit</h2>+ <p>Server management made simple</p>+ </div>++ <div className="about-card">+ <div className="about-logo">+ <ServerKitLogo width={64} height={64} />+ </div>+ <h3>ServerKit</h3>+ <p className="version">Version {version}</p>+ <p className="description">+ A modern, lightweight server management panel for managing web applications,+ databases, domains, and more. Built with Flask and React.+ </p>++ <div className="update-check">+ {!updateInfo ? (+ <button+ className="btn btn-secondary btn-sm"+ onClick={checkForUpdate}+ disabled={checkingUpdate}+ >+ {checkingUpdate ? (+ <><RefreshCw size={14} className="spinning" /> Checking...</>+ ) : (+ <><Download size={14} /> Check for Updates</>+ )}+ </button>+ ) : updateInfo.error ? (+ <div className="update-status error">+ <span>{updateInfo.error}</span>+ <button className="btn-link" onClick={checkForUpdate}>Retry</button>+ </div>+ ) : updateInfo.update_available ? (+ <div className="update-status available">+ <Download size={16} />+ <span>Update available: <strong>v{updateInfo.latest_version}</strong></span>+ <a+ href={updateInfo.release_url}+ target="_blank"+ rel="noopener noreferrer"+ className="btn btn-accent btn-sm"+ >+ View Release <ExternalLink size={12} />+ </a>+ </div>+ ) : (+ <div className="update-status current">+ <CheckCircle size={16} />+ <span>You're up to date!</span>+ </div>+ )}+ </div>+ </div>++ {showStarPrompt && (+ <div className="star-prompt-card">+ <button className="dismiss-btn" onClick={dismissStarPrompt} title="Dismiss">+ <X size={16} />+ </button>+ <div className="star-icon">+ <Star size={24} />+ </div>+ <div className="star-content">+ <h4>Enjoying ServerKit?</h4>+ <p>If you find ServerKit useful, consider starring the repository on GitHub. It helps others discover the project!</p>+ <a+ href="https://github.com/jhd3197/ServerKit"+ target="_blank"+ rel="noopener noreferrer"+ className="btn btn-accent"+ >+ <Star size={16} />+ Star on GitHub+ </a>+ </div>+ </div>+ )}++ <div className="settings-card">+ <h3>Features</h3>+ <ul className="feature-list">+ <li>+ <Check size={16} />+ Application Management (PHP, Python, Node.js, Docker)+ </li>+ <li>+ <Check size={16} />+ Domain & SSL Certificate Management+ </li>+ <li>+ <Check size={16} />+ Database Management (MySQL, PostgreSQL)+ </li>+ <li>+ <Check size={16} />+ Docker Container Management+ </li>+ <li>+ <Check size={16} />+ System Monitoring & Alerts+ </li>+ <li>+ <Check size={16} />+ Automated Backups+ </li>+ <li>+ <Check size={16} />+ Git Deployment with Webhooks+ </li>+ </ul>+ </div>++ <div className="settings-card">+ <h3>Links</h3>+ <div className="link-list">+ <a href="https://github.com/jhd3197/ServerKit" target="_blank" rel="noopener noreferrer" className="link-item">+ <Github size={18} />+ GitHub Repository+ </a>+ <a href="https://github.com/jhd3197/ServerKit#readme" target="_blank" rel="noopener noreferrer" className="link-item">+ <FileText size={18} />+ Documentation+ </a>+ <a href="https://github.com/jhd3197/ServerKit/issues" target="_blank" rel="noopener noreferrer" className="link-item">+ <HelpCircle size={18} />+ Support & Issues+ </a>+ <a href="https://github.com/jhd3197/ServerKit/discussions" target="_blank" rel="noopener noreferrer" className="link-item">+ <MessageSquare size={18} />+ Discussions+ </a>+ <a href="https://github.com/jhd3197/ServerKit/issues/new" target="_blank" rel="noopener noreferrer" className="link-item">+ <Bug size={18} />+ Report a Bug+ </a>+ </div>+ </div>++ <div className="settings-card">+ <h3>License</h3>+ <p className="license-text">+ ServerKit is open source software licensed under the MIT License.+ </p>+ </div>+ </div>+ );+};++export default AboutTab;diff --git a/frontend/src/components/settings/ApiKeyModal.jsx b/frontend/src/components/settings/ApiKeyModal.jsxindex d255f30f..ba77b203 100644--- a/frontend/src/components/settings/ApiKeyModal.jsx+++ b/frontend/src/components/settings/ApiKeyModal.jsx@@ -1,5 +1,6 @@import { useState } from 'react';import { X, Copy, Check, AlertTriangle } from 'lucide-react';+import Modal from '../Modal';const SCOPE_OPTIONS = [{ value: '*', label: 'Full Access' },@@ -71,13 +72,7 @@ const ApiKeyModal = ({ onClose, onSubmit, createdKey }) => {// Show created key viewif (createdKey) {return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal api-key-modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h3>API Key Created</h3>- <button className="modal-close" onClick={onClose}><X size={18} /></button>- </div>- <div className="modal-body">+ <Modal open={true} onClose={onClose} title="API Key Created" className="api-key-modal"><div className="api-key-modal__warning"><AlertTriangle size={16} /><span>Copy this key now. It will not be shown again.</span>@@ -89,22 +84,15 @@ const ApiKeyModal = ({ onClose, onSubmit, createdKey }) => {{copied ? 'Copied' : 'Copy'}</button></div>- </div><div className="modal-footer"><button className="btn btn-primary" onClick={onClose}>Done</button></div>- </div>- </div>+ </Modal>);}return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal api-key-modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h3>Create API Key</h3>- <button className="modal-close" onClick={onClose}><X size={18} /></button>- </div>+ <Modal open={true} onClose={onClose} title="Create API Key" className="api-key-modal"><form onSubmit={handleSubmit}><div className="modal-body"><div className="form-group">@@ -171,8 +159,7 @@ const ApiKeyModal = ({ onClose, onSubmit, createdKey }) => {</button></div></form>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/settings/AppearanceTab.jsx b/frontend/src/components/settings/AppearanceTab.jsxnew file mode 100644index 00000000..75a43ae5--- /dev/null+++ b/frontend/src/components/settings/AppearanceTab.jsx@@ -0,0 +1,311 @@+import React, { useRef } from 'react';+import { useTheme } from '../../contexts/ThemeContext';+import useDashboardLayout from '../../hooks/useDashboardLayout';+import {+ ChevronDown, ChevronUp, RotateCcw, Star, X, Layers, Image, Type, Upload+} from 'lucide-react';++const ACCENT_PRESETS = [+ { label: 'Indigo', color: '#6366f1' },+ { label: 'Ocean', color: '#0ea5e9' },+ { label: 'Forest', color: '#10b981' },+ { label: 'Sunset', color: '#f97316' },+ { label: 'Rose', color: '#f43f5e' },+ { label: 'Violet', color: '#8b5cf6' },+ { label: 'Amber', color: '#f59e0b' },+ { label: 'Cyan', color: '#06b6d4' },+];++const WHITELABEL_MODES = [+ { id: 'image_text', label: 'Logo + Text', icon: Layers, desc: 'Mini logo with brand name' },+ { id: 'image_full', label: 'Full-width Logo', icon: Image, desc: 'Banner image only' },+ { id: 'text_only', label: 'Text Only', icon: Type, desc: 'Just the brand name' },+];++const AppearanceTab = () => {+ const { theme, setTheme, accentColor, setAccentColor, whiteLabel, setWhiteLabel } = useTheme();+ const { widgets, toggleWidget, moveWidget, resetLayout } = useDashboardLayout();+ const logoInputRef = useRef(null);++ return (+ <div className="settings-section">+ <div className="section-header">+ <h2>Appearance</h2>+ <p>Customize the look and feel of your dashboard</p>+ </div>++ <div className="settings-card">+ <h3>Theme</h3>+ <p>Select your preferred color scheme</p>+ <div className="theme-options">+ <button+ className={`theme-option ${theme === 'dark' ? 'active' : ''}`}+ onClick={() => setTheme('dark')}+ >+ <div className="theme-preview dark">+ <div className="preview-sidebar"></div>+ <div className="preview-content">+ <div className="preview-card"></div>+ <div className="preview-card"></div>+ </div>+ </div>+ <span>Dark</span>+ </button>+ <button+ className={`theme-option ${theme === 'light' ? 'active' : ''}`}+ onClick={() => setTheme('light')}+ >+ <div className="theme-preview light">+ <div className="preview-sidebar"></div>+ <div className="preview-content">+ <div className="preview-card"></div>+ <div className="preview-card"></div>+ </div>+ </div>+ <span>Light</span>+ </button>+ <button+ className={`theme-option ${theme === 'system' ? 'active' : ''}`}+ onClick={() => setTheme('system')}+ >+ <div className="theme-preview system">+ <div className="preview-sidebar"></div>+ <div className="preview-content">+ <div className="preview-card"></div>+ <div className="preview-card"></div>+ </div>+ </div>+ <span>System</span>+ </button>+ </div>+ </div>++ <div className="settings-card">+ <h3>Accent Color</h3>+ <p>Choose the primary accent color used across the interface</p>+ <div className="accent-presets">+ {ACCENT_PRESETS.map(({ label, color }) => (+ <button+ key={color}+ className={`accent-preset${accentColor === color ? ' active' : ''}`}+ onClick={() => setAccentColor(color)}+ >+ <span className="accent-swatch" style={{ background: color }} />+ <span className="accent-label">{label}</span>+ </button>+ ))}+ </div>+ <div className="accent-custom">+ <label className="accent-custom-label">Custom color</label>+ <div className="accent-custom-row">+ <input+ type="color"+ className="accent-custom-input"+ value={accentColor}+ onChange={(e) => setAccentColor(e.target.value)}+ />+ <span className="accent-custom-hex">{accentColor.toUpperCase()}</span>+ </div>+ </div>+ </div>++ <div className="settings-card">+ <h3>Dashboard Widgets</h3>+ <p>Toggle visibility and reorder widgets on the dashboard</p>+ <div className="widget-list">+ {widgets.map((widget, idx) => (+ <div key={widget.id} className={`widget-item${!widget.visible ? ' widget-item--hidden' : ''}`}>+ <div className="widget-item__info">+ <label className="toggle-switch">+ <input+ type="checkbox"+ checked={widget.visible}+ onChange={() => toggleWidget(widget.id)}+ />+ <span className="toggle-slider"></span>+ </label>+ <span className="widget-item__label">{widget.label}</span>+ </div>+ <div className="widget-item__controls">+ <button+ className="widget-move-btn"+ onClick={() => moveWidget(widget.id, 'up')}+ disabled={idx === 0}+ title="Move up"+ >+ <ChevronUp size={14} />+ </button>+ <button+ className="widget-move-btn"+ onClick={() => moveWidget(widget.id, 'down')}+ disabled={idx === widgets.length - 1}+ title="Move down"+ >+ <ChevronDown size={14} />+ </button>+ </div>+ </div>+ ))}+ </div>+ <button className="btn btn-secondary btn-sm" onClick={resetLayout} style={{ marginTop: '12px' }}>+ <RotateCcw size={14} />+ Reset to defaults+ </button>+ </div>++ <div className="settings-card">+ <h3>Custom Branding</h3>+ <p>Replace the default ServerKit branding in the sidebar with your own</p>++ <div className="settings-row">+ <div className="settings-label">+ <span>Enable custom branding</span>+ <span className="settings-hint">Replaces the sidebar logo, name, and GitHub star link</span>+ </div>+ <div className="settings-control">+ <label className="toggle-switch">+ <input+ type="checkbox"+ checked={whiteLabel.enabled}+ onChange={(e) => setWhiteLabel({ enabled: e.target.checked })}+ />+ <span className="toggle-slider"></span>+ </label>+ </div>+ </div>++ {whiteLabel.enabled && (+ <>+ <div className="whitelabel-modes">+ {WHITELABEL_MODES.map(({ id, label, icon: Icon, desc }) => (+ <button+ key={id}+ className={`whitelabel-mode${whiteLabel.mode === id ? ' active' : ''}`}+ onClick={() => setWhiteLabel({ mode: id })}+ >+ <Icon size={20} />+ <span className="whitelabel-mode__label">{label}</span>+ <span className="whitelabel-mode__desc">{desc}</span>+ </button>+ ))}+ </div>++ <div className="whitelabel-fields">+ {whiteLabel.mode !== 'image_full' && (+ <div className="form-group">+ <label>Brand Name</label>+ <input+ type="text"+ value={whiteLabel.brandName}+ onChange={(e) => setWhiteLabel({ brandName: e.target.value })}+ placeholder="My Brand"+ maxLength={30}+ />+ </div>+ )}++ {whiteLabel.mode !== 'text_only' && (+ <div className="form-group">+ <label>Logo Image</label>+ <div className="whitelabel-upload" onClick={() => logoInputRef.current?.click()}>+ {whiteLabel.logoData ? (+ <div className="whitelabel-logo-preview">+ <img src={whiteLabel.logoData} alt="Logo preview" />+ <button+ className="btn btn-secondary btn-sm"+ onClick={(e) => { e.stopPropagation(); setWhiteLabel({ logoData: '' }); }}+ >+ <X size={12} /> Remove+ </button>+ </div>+ ) : (+ <div className="whitelabel-upload__placeholder">+ <Upload size={20} />+ <span>Click to upload logo</span>+ <span className="whitelabel-upload__hint">PNG, JPG, SVG — max 200KB</span>+ </div>+ )}+ <input+ ref={logoInputRef}+ type="file"+ accept="image/png,image/jpeg,image/svg+xml,image/webp"+ style={{ display: 'none' }}+ onChange={(e) => {+ const file = e.target.files?.[0];+ if (!file) return;+ if (file.size > 200 * 1024) {+ alert('Image must be under 200KB');+ return;+ }+ const reader = new FileReader();+ reader.onload = (ev) => setWhiteLabel({ logoData: ev.target.result });+ reader.readAsDataURL(file);+ e.target.value = '';+ }}+ />+ </div>+ </div>+ )}+ </div>++ <div className="whitelabel-preview">+ <span className="whitelabel-preview__label">Preview</span>+ <div className="whitelabel-preview__box">+ {whiteLabel.mode === 'image_full' ? (+ <div className="brand-custom-banner">+ {whiteLabel.logoData ? (+ <img src={whiteLabel.logoData} alt="Preview" />+ ) : (+ <Layers size={24} />+ )}+ </div>+ ) : whiteLabel.mode === 'text_only' ? (+ <span className="brand-custom-text">+ {whiteLabel.brandName || 'Brand'}+ </span>+ ) : (+ <>+ <div className="brand-custom-logo">+ {whiteLabel.logoData ? (+ <img src={whiteLabel.logoData} alt="Preview" />+ ) : (+ <Layers size={16} />+ )}+ </div>+ <span className="brand-custom-text">+ {whiteLabel.brandName || 'Brand'}+ </span>+ </>+ )}+ </div>+ </div>++ <div className="whitelabel-star-prompt">+ <div className="star-icon">+ <Star size={22} />+ </div>+ <div className="star-content">+ <h4>Support ServerKit</h4>+ <p>+ By using custom branding, the GitHub star link is hidden from the sidebar.+ If ServerKit is useful to you, please consider starring the project — it helps the community grow!+ </p>+ <a+ href="https://github.com/jhd3197/ServerKit"+ target="_blank"+ rel="noopener noreferrer"+ className="btn btn-primary btn-sm"+ >+ <Star size={14} />+ Star on GitHub+ </a>+ </div>+ </div>+ </>+ )}+ </div>+ </div>+ );+};++export default AppearanceTab;diff --git a/frontend/src/components/settings/IconReferenceTab.jsx b/frontend/src/components/settings/IconReferenceTab.jsxnew file mode 100644index 00000000..8dfcc068--- /dev/null+++ b/frontend/src/components/settings/IconReferenceTab.jsx@@ -0,0 +1,132 @@+import React, { useState } from 'react';+import {+ Github, FileText, HelpCircle, MessageSquare, Bug, Check, Download, CheckCircle,+ RefreshCw, ExternalLink, Star, X, Code, Search, Container, Globe, BarChart3,+ Database, Shield, Cloud, Video, Music, Image, Home, Server, GitBranch, Workflow,+ HardDrive, Lock, Users, Settings as SettingsIcon, Layers, ChevronDown, Copy, Tag,+ Cpu, AlertTriangle, Info, Activity, Terminal, Play, Square, Trash2, Plus, Package,+ ArrowRight, ArrowLeft, Eye, Save, Clock, Calendar, Edit3, Link, Unlink, Archive,+ Radio, Zap, MemoryStick, Monitor, Sun, Moon, ChevronRight, ChevronUp, LogOut,+ Loader, RotateCcw, FolderOpen, Layout, Palette, Camera, Newspaper, TrendingUp,+ Sparkles, ArrowUpCircle, AlertCircle, XCircle, GitCompare, GitCommit, Rocket,+ Minus, Unlock, ArrowDownLeft, ArrowUpRight+} from 'lucide-react';++const ICON_CATALOG = {+ 'General': {+ Search, X, Check, Copy, Plus, Trash2, Edit3, Save, Eye, Info,+ HelpCircle, AlertTriangle, AlertCircle, ExternalLink, Link, Unlink,+ ChevronDown, ChevronRight, ChevronUp, ArrowRight, ArrowLeft,+ ArrowUpRight, ArrowDownLeft, ArrowUpCircle+ },+ 'Status': {+ CheckCircle, XCircle, Loader, RefreshCw, RotateCcw, Activity,+ Zap, Sparkles+ },+ 'Files & Data': {+ FileText, FolderOpen, Archive, Download, Package, Database,+ HardDrive, Layers, Tag+ },+ 'Media': {+ Image, Video, Music, Camera+ },+ 'Development': {+ Code, Terminal, GitBranch, GitCommit, GitCompare, Rocket,+ Bug, Container, Workflow, Layout+ },+ 'Infrastructure': {+ Server, Globe, Cloud, Shield, Lock, Unlock, Cpu, MemoryStick,+ Radio, Monitor+ },+ 'Communication': {+ MessageSquare, Users+ },+ 'Navigation & UI': {+ Home, Star, Sun, Moon, Palette, Play, Square, Calendar, Clock,+ LogOut, SettingsIcon, Newspaper, TrendingUp, BarChart3, Minus+ },+ 'Brands': {+ Github+ }+};++const IconReferenceTab = () => {+ const [searchQuery, setSearchQuery] = useState('');+ const [copiedIcon, setCopiedIcon] = useState(null);++ function handleCopyImport(name) {+ navigator.clipboard.writeText(name);+ setCopiedIcon(name);+ setTimeout(() => setCopiedIcon(null), 1500);+ }++ const filteredCatalog = Object.entries(ICON_CATALOG).reduce((acc, [group, icons]) => {+ if (!searchQuery) {+ acc[group] = icons;+ return acc;+ }+ const filtered = Object.entries(icons).filter(([name]) =>+ name.toLowerCase().includes(searchQuery.toLowerCase())+ );+ if (filtered.length > 0) {+ acc[group] = Object.fromEntries(filtered);+ }+ return acc;+ }, {});++ const totalIcons = Object.values(ICON_CATALOG).reduce((sum, icons) => sum + Object.keys(icons).length, 0);++ return (+ <div className="settings-section">+ <h2>Icon Reference</h2>+ <p className="section-description">+ Lucide React icons available in the project ({totalIcons} icons). Click an icon name to copy it.+ </p>++ <div className="settings-card">+ <div className="form-group">+ <div className="search-input-wrapper" style={{ position: 'relative' }}>+ <Search size={16} style={{ position: 'absolute', left: 12, top: '50%', transform: 'translateY(-50%)', opacity: 0.5 }} />+ <input+ type="text"+ placeholder="Search icons..."+ value={searchQuery}+ onChange={(e) => setSearchQuery(e.target.value)}+ className="form-input"+ style={{ paddingLeft: 36 }}+ />+ </div>+ </div>+ </div>++ {Object.entries(filteredCatalog).map(([group, icons]) => (+ <div key={group} className="settings-card">+ <h3>{group}</h3>+ <div className="icon-reference-grid">+ {Object.entries(icons).map(([name, IconComp]) => (+ <button+ key={name}+ className={`icon-reference-item ${copiedIcon === name ? 'copied' : ''}`}+ onClick={() => handleCopyImport(name)}+ title={`Click to copy "${name}"`}+ >+ <IconComp size={20} />+ <span className="icon-reference-name">+ {copiedIcon === name ? 'Copied!' : name}+ </span>+ </button>+ ))}+ </div>+ </div>+ ))}++ {Object.keys(filteredCatalog).length === 0 && (+ <div className="settings-card">+ <p style={{ textAlign: 'center', opacity: 0.5 }}>No icons match "{searchQuery}"</p>+ </div>+ )}+ </div>+ );+};++export default IconReferenceTab;diff --git a/frontend/src/components/settings/InviteModal.jsx b/frontend/src/components/settings/InviteModal.jsxindex a0ee2c43..108a7050 100644--- a/frontend/src/components/settings/InviteModal.jsx+++ b/frontend/src/components/settings/InviteModal.jsx@@ -1,6 +1,7 @@import React, { useState, useEffect } from 'react';import api from '../../services/api';import PermissionEditor from './PermissionEditor';+import Modal from '../Modal';const InviteModal = ({ onClose, onCreated }) => {const [email, setEmail] = useState('');@@ -67,18 +68,7 @@ const InviteModal = ({ onClose, onCreated }) => {// Show result screen after creationif (result) {return (- <div className="modal-overlay">- <div className="modal modal-md">- <div className="modal-header">- <h3>Invitation Created</h3>- <button className="modal-close" onClick={onClose}>- <svg viewBox="0 0 24 24" width="20" height="20" stroke="currentColor" fill="none" strokeWidth="2">- <line x1="18" y1="6" x2="6" y2="18"/>- <line x1="6" y1="6" x2="18" y2="18"/>- </svg>- </button>- </div>- <div className="modal-body">+ <Modal open={true} onClose={onClose} title="Invitation Created" size="md"><p>Share this invitation link:</p><div className="invite-link-display"><code>{result.invite_url}</code>@@ -96,28 +86,15 @@ const InviteModal = ({ onClose, onCreated }) => {Email could not be sent: {result.email_error}</p>)}- </div><div className="modal-footer"><button className="btn btn-primary" onClick={onClose}>Done</button></div>- </div>- </div>+ </Modal>);}return (- <div className="modal-overlay">- <div className="modal modal-md">- <div className="modal-header">- <h3>Invite User</h3>- <button className="modal-close" onClick={onClose}>- <svg viewBox="0 0 24 24" width="20" height="20" stroke="currentColor" fill="none" strokeWidth="2">- <line x1="18" y1="6" x2="6" y2="18"/>- <line x1="6" y1="6" x2="18" y2="18"/>- </svg>- </button>- </div>-+ <Modal open={true} onClose={onClose} title="Invite User" size="md"><form onSubmit={handleSubmit}><div className="modal-body">{error && <div className="error-message">{error}</div>}@@ -195,8 +172,7 @@ const InviteModal = ({ onClose, onCreated }) => {</button></div></form>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/settings/NotificationsTab.jsx b/frontend/src/components/settings/NotificationsTab.jsxnew file mode 100644index 00000000..214f553d--- /dev/null+++ b/frontend/src/components/settings/NotificationsTab.jsx@@ -0,0 +1,689 @@+import React, { useState, useEffect } from 'react';+import { useAuth } from '../../contexts/AuthContext';+import api from '../../services/api';++const NotificationsTab = () => {+ const { isAdmin, user } = useAuth();+ const [loading, setLoading] = useState(true);+ const [saving, setSaving] = useState(false);+ const [testing, setTesting] = useState(null);+ const [message, setMessage] = useState(null);+ const [activeSection, setActiveSection] = useState('personal');+ const [config, setConfig] = useState({+ discord: { enabled: false, webhook_url: '', username: 'ServerKit', avatar_url: '', notify_on: ['critical', 'warning'] },+ slack: { enabled: false, webhook_url: '', channel: '', username: 'ServerKit', icon_emoji: ':robot_face:', notify_on: ['critical', 'warning'] },+ telegram: { enabled: false, bot_token: '', chat_id: '', notify_on: ['critical', 'warning'] },+ email: { enabled: false, smtp_host: '', smtp_port: 587, smtp_user: '', smtp_password: '', smtp_tls: true, from_email: '', from_name: 'ServerKit', to_emails: [], notify_on: ['critical', 'warning'] },+ generic_webhook: { enabled: false, url: '', headers: {}, notify_on: ['critical', 'warning'] }+ });+ const [expandedChannel, setExpandedChannel] = useState(null);+ const [userPrefs, setUserPrefs] = useState({+ enabled: true,+ channels: ['email'],+ severities: ['critical', 'warning'],+ email: '',+ discord_webhook: '',+ telegram_chat_id: '',+ categories: { system: true, security: true, backups: true, apps: true },+ quiet_hours: { enabled: false, start: '22:00', end: '08:00' }+ });++ const severityOptions = ['critical', 'warning', 'info', 'success'];++ useEffect(() => {+ loadUserPrefs();+ if (isAdmin) loadConfig();+ }, [isAdmin]);++ async function loadConfig() {+ try {+ const data = await api.getNotificationsConfig();+ setConfig(prev => ({+ discord: { ...prev.discord, ...data.discord },+ slack: { ...prev.slack, ...data.slack },+ telegram: { ...prev.telegram, ...data.telegram },+ email: { ...prev.email, ...data.email },+ generic_webhook: { ...prev.generic_webhook, ...data.generic_webhook }+ }));+ } catch (err) {+ console.error('Failed to load notification config:', err);+ } finally {+ setLoading(false);+ }+ }++ async function loadUserPrefs() {+ try {+ const data = await api.getUserNotificationPreferences();+ setUserPrefs(prev => ({ ...prev, ...data }));+ } catch (err) {+ console.error('Failed to load user notification preferences:', err);+ } finally {+ setLoading(false);+ }+ }++ async function handleSaveUserPrefs() {+ setSaving(true);+ setMessage(null);+ try {+ await api.updateUserNotificationPreferences(userPrefs);+ setMessage({ type: 'success', text: 'Your notification preferences have been saved' });+ } catch (err) {+ setMessage({ type: 'error', text: err.message });+ } finally {+ setSaving(false);+ }+ }++ async function handleTestUserNotification() {+ setTesting('user');+ setMessage(null);+ try {+ const result = await api.testUserNotification();+ setMessage({ type: result.success ? 'success' : 'error', text: result.success ? 'Test notification sent!' : (result.error || 'Test failed') });+ } catch (err) {+ setMessage({ type: 'error', text: err.message });+ } finally {+ setTesting(null);+ }+ }++ async function handleSaveChannel(channel) {+ setSaving(true);+ setMessage(null);+ try {+ await api.updateNotificationChannel(channel, config[channel]);+ setMessage({ type: 'success', text: `${channel.charAt(0).toUpperCase() + channel.slice(1).replace('_', ' ')} settings saved` });+ } catch (err) {+ setMessage({ type: 'error', text: err.message });+ } finally {+ setSaving(false);+ }+ }++ async function handleTestChannel(channel) {+ setTesting(channel);+ setMessage(null);+ try {+ const result = await api.testNotificationChannel(channel);+ setMessage({ type: result.success ? 'success' : 'error', text: result.message || result.error || 'Test completed' });+ } catch (err) {+ setMessage({ type: 'error', text: err.message });+ } finally {+ setTesting(null);+ }+ }++ function updateChannelConfig(channel, key, value) {+ setConfig(prev => ({+ ...prev,+ [channel]: { ...prev[channel], [key]: value }+ }));+ }++ function toggleSeverity(channel, severity) {+ const current = config[channel].notify_on || [];+ const updated = current.includes(severity)+ ? current.filter(s => s !== severity)+ : [...current, severity];+ updateChannelConfig(channel, 'notify_on', updated);+ }++ if (loading) {+ return <div className="loading">Loading notification settings...</div>;+ }++ const userPrefsUI = (+ <div className="user-notification-prefs">+ <div className="settings-card">+ <div className="form-group">+ <label className="toggle-switch-label">+ <span>Enable notifications for my account</span>+ <label className="toggle-switch">+ <input+ type="checkbox"+ checked={userPrefs.enabled}+ onChange={(e) => setUserPrefs({...userPrefs, enabled: e.target.checked})}+ />+ <span className="toggle-slider"></span>+ </label>+ </label>+ </div>+ </div>++ <div className="settings-card">+ <h3>Notification Channels</h3>+ <p>Choose how you want to receive notifications</p>+ <div className="channel-toggles">+ {['email', 'discord', 'slack', 'telegram'].map(ch => (+ <label key={ch} className="channel-toggle">+ <input+ type="checkbox"+ checked={userPrefs.channels?.includes(ch)}+ onChange={(e) => {+ const channels = e.target.checked+ ? [...(userPrefs.channels || []), ch]+ : (userPrefs.channels || []).filter(c => c !== ch);+ setUserPrefs({...userPrefs, channels});+ }}+ />+ <span>{ch.charAt(0).toUpperCase() + ch.slice(1)}</span>+ </label>+ ))}+ </div>+ </div>++ {userPrefs.channels?.includes('email') && (+ <div className="settings-card">+ <h3>Email Settings</h3>+ <div className="form-group">+ <label>Notification Email (optional)</label>+ <input+ type="email"+ value={userPrefs.email || ''}+ onChange={(e) => setUserPrefs({...userPrefs, email: e.target.value})}+ placeholder={user?.email || 'Uses your account email'}+ />+ <span className="form-help">Leave empty to use your account email</span>+ </div>+ </div>+ )}++ {userPrefs.channels?.includes('discord') && (+ <div className="settings-card">+ <h3>Personal Discord Webhook</h3>+ <div className="form-group">+ <label>Webhook URL</label>+ <input+ type="text"+ value={userPrefs.discord_webhook || ''}+ onChange={(e) => setUserPrefs({...userPrefs, discord_webhook: e.target.value})}+ placeholder="https://discord.com/api/webhooks/..."+ />+ <span className="form-help">Create a webhook in your personal server or DM channel</span>+ </div>+ </div>+ )}++ {userPrefs.channels?.includes('telegram') && (+ <div className="settings-card">+ <h3>Personal Telegram</h3>+ <div className="form-group">+ <label>Your Chat ID</label>+ <input+ type="text"+ value={userPrefs.telegram_chat_id || ''}+ onChange={(e) => setUserPrefs({...userPrefs, telegram_chat_id: e.target.value})}+ placeholder="Your personal chat ID"+ />+ <span className="form-help">Use @userinfobot to get your personal chat ID</span>+ </div>+ </div>+ )}++ <div className="settings-card">+ <h3>Severity Levels</h3>+ <p>Which alert types do you want to receive?</p>+ <div className="severity-toggles">+ {severityOptions.map(severity => (+ <label key={severity} className={`severity-toggle ${severity}`}>+ <input+ type="checkbox"+ checked={userPrefs.severities?.includes(severity)}+ onChange={(e) => {+ const severities = e.target.checked+ ? [...(userPrefs.severities || []), severity]+ : (userPrefs.severities || []).filter(s => s !== severity);+ setUserPrefs({...userPrefs, severities});+ }}+ />+ <span>{severity.charAt(0).toUpperCase() + severity.slice(1)}</span>+ </label>+ ))}+ </div>+ </div>++ <div className="settings-card">+ <h3>Notification Categories</h3>+ <p>What types of events should trigger notifications?</p>+ <div className="category-toggles">+ {Object.entries({+ system: 'System Alerts (CPU, Memory, Disk)',+ security: 'Security Events',+ backups: 'Backup Status',+ apps: 'Application Events'+ }).map(([key, label]) => (+ <label key={key} className="category-toggle">+ <input+ type="checkbox"+ checked={userPrefs.categories?.[key] !== false}+ onChange={(e) => setUserPrefs({+ ...userPrefs,+ categories: { ...userPrefs.categories, [key]: e.target.checked }+ })}+ />+ <span>{label}</span>+ </label>+ ))}+ </div>+ </div>++ <div className="settings-card">+ <h3>Quiet Hours</h3>+ <p>Pause non-critical notifications during these hours</p>+ <div className="form-group">+ <label className="toggle-switch-label">+ <span>Enable quiet hours</span>+ <label className="toggle-switch">+ <input+ type="checkbox"+ checked={userPrefs.quiet_hours?.enabled}+ onChange={(e) => setUserPrefs({+ ...userPrefs,+ quiet_hours: { ...userPrefs.quiet_hours, enabled: e.target.checked }+ })}+ />+ <span className="toggle-slider"></span>+ </label>+ </label>+ </div>+ {userPrefs.quiet_hours?.enabled && (+ <div className="form-row">+ <div className="form-group">+ <label>Start Time</label>+ <input+ type="time"+ value={userPrefs.quiet_hours?.start || '22:00'}+ onChange={(e) => setUserPrefs({+ ...userPrefs,+ quiet_hours: { ...userPrefs.quiet_hours, start: e.target.value }+ })}+ />+ </div>+ <div className="form-group">+ <label>End Time</label>+ <input+ type="time"+ value={userPrefs.quiet_hours?.end || '08:00'}+ onChange={(e) => setUserPrefs({+ ...userPrefs,+ quiet_hours: { ...userPrefs.quiet_hours, end: e.target.value }+ })}+ />+ </div>+ </div>+ )}+ </div>++ <div className="form-actions">+ <button+ className="btn btn-secondary"+ onClick={handleTestUserNotification}+ disabled={testing === 'user' || !userPrefs.enabled}+ >+ {testing === 'user' ? 'Sending...' : 'Send Test Notification'}+ </button>+ <button+ className="btn btn-primary"+ onClick={handleSaveUserPrefs}+ disabled={saving}+ >+ {saving ? 'Saving...' : 'Save Preferences'}+ </button>+ </div>+ </div>+ );++ const channels = [+ { id: 'discord', name: 'Discord', icon: (+ <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor">+ <path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028 14.09 14.09 0 0 0 1.226-1.994.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"/>+ </svg>+ ), description: 'Send rich notifications to Discord channels via webhooks' },+ { id: 'slack', name: 'Slack', icon: (+ <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor">+ <path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"/>+ </svg>+ ), description: 'Send notifications to Slack channels via incoming webhooks' },+ { id: 'telegram', name: 'Telegram', icon: (+ <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor">+ <path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/>+ </svg>+ ), description: 'Send notifications to Telegram chats via bot API' },+ { id: 'email', name: 'Email', icon: (+ <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">+ <path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/>+ <polyline points="22,6 12,13 2,6"/>+ </svg>+ ), description: 'Send email notifications with HTML templates via SMTP' },+ { id: 'generic_webhook', name: 'Generic Webhook', icon: (+ <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">+ <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/>+ <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>+ </svg>+ ), description: 'Send JSON payloads to any webhook endpoint' }+ ];++ return (+ <div className="settings-section">+ <div className="section-header">+ <h2>Notification Settings</h2>+ <p>Configure how you receive alerts and notifications</p>+ </div>++ {message && (+ <div className={`alert alert-${message.type === 'success' ? 'success' : 'danger'}`}>+ {message.text}+ </div>+ )}++ <div className="notification-tabs">+ <button+ className={`notification-tab ${activeSection === 'personal' ? 'active' : ''}`}+ onClick={() => setActiveSection('personal')}+ >+ <svg viewBox="0 0 24 24" width="18" height="18" stroke="currentColor" fill="none" strokeWidth="2">+ <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>+ <circle cx="12" cy="7" r="4"/>+ </svg>+ My Preferences+ </button>+ {isAdmin && (+ <button+ className={`notification-tab ${activeSection === 'admin' ? 'active' : ''}`}+ onClick={() => setActiveSection('admin')}+ >+ <svg viewBox="0 0 24 24" width="18" height="18" stroke="currentColor" fill="none" strokeWidth="2">+ <circle cx="12" cy="12" r="3"/>+ <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>+ </svg>+ System Webhooks+ </button>+ )}+ </div>++ {activeSection === 'personal' && userPrefsUI}++ {activeSection === 'admin' && isAdmin && (+ <div className="notification-channels">+ {channels.map(channel => (+ <div key={channel.id} className={`notification-channel-card ${config[channel.id]?.enabled ? 'enabled' : ''}`}>+ <div+ className="channel-header"+ onClick={() => setExpandedChannel(expandedChannel === channel.id ? null : channel.id)}+ >+ <div className="channel-icon">{channel.icon}</div>+ <div className="channel-info">+ <h3>{channel.name}</h3>+ <p>{channel.description}</p>+ </div>+ <div className="channel-status">+ <span className={`badge ${config[channel.id]?.enabled ? 'badge-success' : 'badge-secondary'}`}>+ {config[channel.id]?.enabled ? 'Enabled' : 'Disabled'}+ </span>+ <svg+ viewBox="0 0 24 24"+ width="20"+ height="20"+ className={`expand-icon ${expandedChannel === channel.id ? 'expanded' : ''}`}+ >+ <polyline points="6 9 12 15 18 9" stroke="currentColor" fill="none" strokeWidth="2"/>+ </svg>+ </div>+ </div>++ {expandedChannel === channel.id && (+ <div className="channel-config">+ <div className="form-group">+ <label className="toggle-switch-label">+ <span>Enable {channel.name}</span>+ <label className="toggle-switch">+ <input+ type="checkbox"+ checked={config[channel.id]?.enabled || false}+ onChange={(e) => updateChannelConfig(channel.id, 'enabled', e.target.checked)}+ />+ <span className="toggle-slider"></span>+ </label>+ </label>+ </div>++ {channel.id === 'discord' && (+ <>+ <div className="form-group">+ <label>Webhook URL</label>+ <input+ type="text"+ value={config.discord.webhook_url || ''}+ onChange={(e) => updateChannelConfig('discord', 'webhook_url', e.target.value)}+ placeholder="https://discord.com/api/webhooks/..."+ />+ <span className="form-help">Create a webhook in Discord: Server Settings → Integrations → Webhooks</span>+ </div>+ <div className="form-row">+ <div className="form-group">+ <label>Bot Username</label>+ <input+ type="text"+ value={config.discord.username || 'ServerKit'}+ onChange={(e) => updateChannelConfig('discord', 'username', e.target.value)}+ placeholder="ServerKit"+ />+ </div>+ <div className="form-group">+ <label>Avatar URL (optional)</label>+ <input+ type="text"+ value={config.discord.avatar_url || ''}+ onChange={(e) => updateChannelConfig('discord', 'avatar_url', e.target.value)}+ placeholder="https://example.com/avatar.png"+ />+ </div>+ </div>+ </>+ )}++ {channel.id === 'slack' && (+ <>+ <div className="form-group">+ <label>Webhook URL</label>+ <input+ type="text"+ value={config.slack.webhook_url || ''}+ onChange={(e) => updateChannelConfig('slack', 'webhook_url', e.target.value)}+ placeholder="https://hooks.slack.com/services/..."+ />+ <span className="form-help">Create an incoming webhook in Slack: Apps → Incoming Webhooks</span>+ </div>+ <div className="form-row">+ <div className="form-group">+ <label>Channel (optional)</label>+ <input+ type="text"+ value={config.slack.channel || ''}+ onChange={(e) => updateChannelConfig('slack', 'channel', e.target.value)}+ placeholder="#alerts"+ />+ </div>+ <div className="form-group">+ <label>Username</label>+ <input+ type="text"+ value={config.slack.username || 'ServerKit'}+ onChange={(e) => updateChannelConfig('slack', 'username', e.target.value)}+ placeholder="ServerKit"+ />+ </div>+ </div>+ </>+ )}++ {channel.id === 'telegram' && (+ <>+ <div className="form-group">+ <label>Bot Token</label>+ <input+ type="password"+ value={config.telegram.bot_token || ''}+ onChange={(e) => updateChannelConfig('telegram', 'bot_token', e.target.value)}+ placeholder="123456:ABC-DEF..."+ />+ <span className="form-help">Get a bot token from @BotFather on Telegram</span>+ </div>+ <div className="form-group">+ <label>Chat ID</label>+ <input+ type="text"+ value={config.telegram.chat_id || ''}+ onChange={(e) => updateChannelConfig('telegram', 'chat_id', e.target.value)}+ placeholder="-1001234567890"+ />+ <span className="form-help">Use @userinfobot or @getidsbot to find your chat ID</span>+ </div>+ </>+ )}++ {channel.id === 'email' && (+ <>+ <div className="form-row">+ <div className="form-group">+ <label>SMTP Host</label>+ <input+ type="text"+ value={config.email.smtp_host || ''}+ onChange={(e) => updateChannelConfig('email', 'smtp_host', e.target.value)}+ placeholder="smtp.example.com"+ />+ </div>+ <div className="form-group">+ <label>SMTP Port</label>+ <input+ type="number"+ value={config.email.smtp_port || 587}+ onChange={(e) => updateChannelConfig('email', 'smtp_port', parseInt(e.target.value))}+ placeholder="587"+ />+ </div>+ </div>+ <div className="form-row">+ <div className="form-group">+ <label>SMTP Username</label>+ <input+ type="text"+ value={config.email.smtp_user || ''}+ onChange={(e) => updateChannelConfig('email', 'smtp_user', e.target.value)}+ placeholder="[email protected]"+ />+ </div>+ <div className="form-group">+ <label>SMTP Password</label>+ <input+ type="password"+ value={config.email.smtp_password || ''}+ onChange={(e) => updateChannelConfig('email', 'smtp_password', e.target.value)}+ placeholder="••••••••"+ />+ </div>+ </div>+ <div className="form-row">+ <div className="form-group">+ <label>From Email</label>+ <input+ type="email"+ value={config.email.from_email || ''}+ onChange={(e) => updateChannelConfig('email', 'from_email', e.target.value)}+ placeholder="[email protected]"+ />+ </div>+ <div className="form-group">+ <label>From Name</label>+ <input+ type="text"+ value={config.email.from_name || 'ServerKit'}+ onChange={(e) => updateChannelConfig('email', 'from_name', e.target.value)}+ placeholder="ServerKit"+ />+ </div>+ </div>+ <div className="form-group">+ <label>Recipient Emails (comma-separated)</label>+ <input+ type="text"+ value={(config.email.to_emails || []).join(', ')}+ onChange={(e) => updateChannelConfig('email', 'to_emails', e.target.value.split(',').map(s => s.trim()).filter(Boolean))}+ placeholder="[email protected], [email protected]"+ />+ </div>+ <div className="form-group">+ <label className="toggle-switch-label">+ <span>Use TLS</span>+ <label className="toggle-switch">+ <input+ type="checkbox"+ checked={config.email.smtp_tls !== false}+ onChange={(e) => updateChannelConfig('email', 'smtp_tls', e.target.checked)}+ />+ <span className="toggle-slider"></span>+ </label>+ </label>+ </div>+ </>+ )}++ {channel.id === 'generic_webhook' && (+ <div className="form-group">+ <label>Webhook URL</label>+ <input+ type="text"+ value={config.generic_webhook.url || ''}+ onChange={(e) => updateChannelConfig('generic_webhook', 'url', e.target.value)}+ placeholder="https://your-endpoint.com/webhook"+ />+ <span className="form-help">Receives JSON payload with alert data</span>+ </div>+ )}++ <div className="form-group">+ <label>Alert Severities</label>+ <div className="severity-toggles">+ {severityOptions.map(severity => (+ <label key={severity} className={`severity-toggle ${severity}`}>+ <input+ type="checkbox"+ checked={config[channel.id]?.notify_on?.includes(severity) || false}+ onChange={() => toggleSeverity(channel.id, severity)}+ />+ <span>{severity.charAt(0).toUpperCase() + severity.slice(1)}</span>+ </label>+ ))}+ </div>+ </div>++ <div className="channel-actions">+ <button+ className="btn btn-secondary"+ onClick={() => handleTestChannel(channel.id)}+ disabled={testing === channel.id || !config[channel.id]?.enabled}+ >+ {testing === channel.id ? 'Testing...' : 'Send Test'}+ </button>+ <button+ className="btn btn-primary"+ onClick={() => handleSaveChannel(channel.id)}+ disabled={saving}+ >+ {saving ? 'Saving...' : 'Save'}+ </button>+ </div>+ </div>+ )}+ </div>+ ))}+ </div>+ )}+ </div>+ );+};++export default NotificationsTab;diff --git a/frontend/src/components/settings/ProfileTab.jsx b/frontend/src/components/settings/ProfileTab.jsxindex 3b3c0ea3..3256a7b4 100644--- a/frontend/src/components/settings/ProfileTab.jsx+++ b/frontend/src/components/settings/ProfileTab.jsx@@ -1,113 +1,5 @@import React, { useState, useEffect } from 'react';import { useAuth } from '../../contexts/AuthContext';-import api from '../../services/api';-import SSOProviderIcon from '../SSOProviderIcon';--const LinkedAccounts = () => {- const { ssoProviders } = useAuth();- const [identities, setIdentities] = useState([]);- const [loading, setLoading] = useState(true);- const [unlinking, setUnlinking] = useState(null);- const [linkingProvider, setLinkingProvider] = useState(null);- const [error, setError] = useState('');-- useEffect(() => {- loadIdentities();- }, []);-- async function loadIdentities() {- try {- const data = await api.getSSOIdentities();- setIdentities(data.identities || []);- } catch (err) {- // SSO may not be configured; silently handle- } finally {- setLoading(false);- }- }-- async function handleUnlink(provider) {- setUnlinking(provider);- setError('');- try {- await api.unlinkSSOProvider(provider);- await loadIdentities();- } catch (err) {- setError(err.message);- } finally {- setUnlinking(null);- }- }-- async function handleLink(provider) {- setLinkingProvider(provider);- setError('');- try {- const redirectUri = `${window.location.origin}/login/callback/${provider}`;- const { auth_url } = await api.startSSOAuth(provider, redirectUri);- window.location.href = auth_url;- } catch (err) {- setError(err.message);- setLinkingProvider(null);- }- }-- // Only show if SSO is configured- if (loading || (!ssoProviders?.length && !identities.length)) {- return null;- }-- const linkedProviderIds = identities.map(i => i.provider);- const availableToLink = (ssoProviders || []).filter(p => !linkedProviderIds.includes(p.id));-- return (- <div className="settings-card">- <h3>Linked Accounts</h3>- <p className="text-secondary">Connect external identity providers to your account</p>-- {error && <div className="alert alert-danger">{error}</div>}-- {identities.length > 0 && (- <div className="linked-accounts-list">- {identities.map(identity => (- <div key={identity.id} className="linked-account">- <div className="linked-account__info">- <SSOProviderIcon provider={identity.provider} />- <div>- <span className="linked-account__provider">{identity.provider}</span>- <span className="linked-account__email">{identity.provider_email}</span>- </div>- </div>- <button- className="btn btn-sm btn-danger"- onClick={() => handleUnlink(identity.provider)}- disabled={unlinking === identity.provider}- >- {unlinking === identity.provider ? 'Unlinking...' : 'Unlink'}- </button>- </div>- ))}- </div>- )}-- {availableToLink.length > 0 && (- <div className="linked-accounts-available">- {availableToLink.map(p => (- <button- key={p.id}- className="btn btn-secondary btn-sm"- onClick={() => handleLink(p.id)}- disabled={linkingProvider === p.id}- >- <SSOProviderIcon provider={p.id} />- {linkingProvider === p.id ? 'Redirecting...' : `Link ${p.name}`}- </button>- ))}- </div>- )}- </div>- );-};const ProfileTab = () => {const { user, updateUser } = useAuth();@@ -198,8 +90,6 @@ const ProfileTab = () => {</button></div></form>-- <LinkedAccounts /></div>);};diff --git a/frontend/src/components/settings/SecuritySettingsTab.jsx b/frontend/src/components/settings/SecuritySettingsTab.jsxnew file mode 100644index 00000000..9bb3fc57--- /dev/null+++ b/frontend/src/components/settings/SecuritySettingsTab.jsx@@ -0,0 +1,597 @@+import React, { useState, useEffect } from 'react';+import { useAuth } from '../../contexts/AuthContext';+import api from '../../services/api';+import SSOProviderIcon from '../SSOProviderIcon';+import Modal from '../Modal';++const LinkedAccounts = () => {+ const { ssoProviders } = useAuth();+ const [identities, setIdentities] = useState([]);+ const [loading, setLoading] = useState(true);+ const [unlinking, setUnlinking] = useState(null);+ const [linkingProvider, setLinkingProvider] = useState(null);+ const [error, setError] = useState('');++ useEffect(() => {+ loadIdentities();+ }, []);++ async function loadIdentities() {+ try {+ const data = await api.getSSOIdentities();+ setIdentities(data.identities || []);+ } catch (err) {+ // SSO may not be configured; silently handle+ } finally {+ setLoading(false);+ }+ }++ async function handleUnlink(provider) {+ setUnlinking(provider);+ setError('');+ try {+ await api.unlinkSSOProvider(provider);+ await loadIdentities();+ } catch (err) {+ setError(err.message);+ } finally {+ setUnlinking(null);+ }+ }++ async function handleLink(provider) {+ setLinkingProvider(provider);+ setError('');+ try {+ const redirectUri = `${window.location.origin}/login/callback/${provider}`;+ const { auth_url } = await api.startSSOAuth(provider, redirectUri);+ window.location.href = auth_url;+ } catch (err) {+ setError(err.message);+ setLinkingProvider(null);+ }+ }++ if (loading || (!ssoProviders?.length && !identities.length)) {+ return null;+ }++ const linkedProviderIds = identities.map(i => i.provider);+ const availableToLink = (ssoProviders || []).filter(p => !linkedProviderIds.includes(p.id));++ return (+ <div className="settings-card">+ <h3>Linked Accounts</h3>+ <p className="text-secondary">Connect external identity providers to your account</p>++ {error && <div className="alert alert-danger">{error}</div>}++ {identities.length > 0 && (+ <div className="linked-accounts-list">+ {identities.map(identity => (+ <div key={identity.id} className="linked-account">+ <div className="linked-account__info">+ <SSOProviderIcon provider={identity.provider} />+ <div>+ <span className="linked-account__provider">{identity.provider}</span>+ <span className="linked-account__email">{identity.provider_email}</span>+ </div>+ </div>+ <button+ className="btn btn-sm btn-danger"+ onClick={() => handleUnlink(identity.provider)}+ disabled={unlinking === identity.provider}+ >+ {unlinking === identity.provider ? 'Unlinking...' : 'Unlink'}+ </button>+ </div>+ ))}+ </div>+ )}++ {availableToLink.length > 0 && (+ <div className="linked-accounts-available">+ {availableToLink.map(p => (+ <button+ key={p.id}+ className="btn btn-secondary btn-sm"+ onClick={() => handleLink(p.id)}+ disabled={linkingProvider === p.id}+ >+ <SSOProviderIcon provider={p.id} />+ {linkingProvider === p.id ? 'Redirecting...' : `Link ${p.name}`}+ </button>+ ))}+ </div>+ )}+ </div>+ );+};++const SecuritySettingsTab = () => {+ const { updateUser, user } = useAuth();+ const [formData, setFormData] = useState({+ currentPassword: '',+ newPassword: '',+ confirmPassword: ''+ });+ const [loading, setLoading] = useState(false);+ const [message, setMessage] = useState(null);++ // 2FA state+ const [twoFAStatus, setTwoFAStatus] = useState(null);+ const [twoFALoading, setTwoFALoading] = useState(true);+ const [showSetupModal, setShowSetupModal] = useState(false);+ const [showDisableModal, setShowDisableModal] = useState(false);+ const [showBackupCodesModal, setShowBackupCodesModal] = useState(false);+ const [setupData, setSetupData] = useState(null);+ const [verificationCode, setVerificationCode] = useState('');+ const [backupCodes, setBackupCodes] = useState([]);+ const [twoFAError, setTwoFAError] = useState('');++ useEffect(() => {+ load2FAStatus();+ }, []);++ async function load2FAStatus() {+ try {+ const status = await api.get2FAStatus();+ setTwoFAStatus(status);+ } catch (err) {+ console.error('Failed to load 2FA status:', err);+ } finally {+ setTwoFALoading(false);+ }+ }++ async function handleSubmit(e) {+ e.preventDefault();+ setMessage(null);++ if (formData.newPassword !== formData.confirmPassword) {+ setMessage({ type: 'error', text: 'Passwords do not match' });+ return;+ }++ if (formData.newPassword.length < 8) {+ setMessage({ type: 'error', text: 'Password must be at least 8 characters' });+ return;+ }++ setLoading(true);++ try {+ await updateUser({ password: formData.newPassword });+ setMessage({ type: 'success', text: 'Password changed successfully' });+ setFormData({ currentPassword: '', newPassword: '', confirmPassword: '' });+ } catch (err) {+ setMessage({ type: 'error', text: err.message });+ } finally {+ setLoading(false);+ }+ }++ async function handleInitiate2FA() {+ setTwoFAError('');+ setTwoFALoading(true);+ try {+ const data = await api.initiate2FASetup();+ setSetupData(data);+ setShowSetupModal(true);+ } catch (err) {+ setTwoFAError(err.message);+ } finally {+ setTwoFALoading(false);+ }+ }++ async function handleConfirm2FA() {+ if (!verificationCode || verificationCode.length !== 6) {+ setTwoFAError('Please enter a 6-digit code');+ return;+ }++ setTwoFALoading(true);+ setTwoFAError('');+ try {+ const result = await api.confirm2FASetup(verificationCode);+ setBackupCodes(result.backup_codes);+ setShowSetupModal(false);+ setShowBackupCodesModal(true);+ setVerificationCode('');+ load2FAStatus();+ } catch (err) {+ setTwoFAError(err.message || 'Invalid verification code');+ } finally {+ setTwoFALoading(false);+ }+ }++ async function handleDisable2FA() {+ if (!verificationCode) {+ setTwoFAError('Please enter a verification code');+ return;+ }++ setTwoFALoading(true);+ setTwoFAError('');+ try {+ await api.disable2FA(verificationCode);+ setShowDisableModal(false);+ setVerificationCode('');+ load2FAStatus();+ } catch (err) {+ setTwoFAError(err.message || 'Invalid verification code');+ } finally {+ setTwoFALoading(false);+ }+ }++ async function handleRegenerateBackupCodes() {+ if (!verificationCode || verificationCode.length !== 6) {+ setTwoFAError('Please enter a 6-digit code');+ return;+ }++ setTwoFALoading(true);+ setTwoFAError('');+ try {+ const result = await api.regenerateBackupCodes(verificationCode);+ setBackupCodes(result.backup_codes);+ setShowBackupCodesModal(true);+ setVerificationCode('');+ load2FAStatus();+ } catch (err) {+ setTwoFAError(err.message || 'Invalid verification code');+ } finally {+ setTwoFALoading(false);+ }+ }++ function downloadBackupCodes() {+ const content = `ServerKit Backup Codes+Generated: ${new Date().toLocaleString()}++These codes can be used to access your account if you lose your authenticator device.+Each code can only be used once.++${backupCodes.join('\n')}++Keep these codes in a safe place.`;++ const blob = new Blob([content], { type: 'text/plain' });+ const url = URL.createObjectURL(blob);+ const a = document.createElement('a');+ a.href = url;+ a.download = 'serverkit-backup-codes.txt';+ document.body.appendChild(a);+ a.click();+ document.body.removeChild(a);+ URL.revokeObjectURL(url);+ }++ function copyBackupCodes() {+ navigator.clipboard.writeText(backupCodes.join('\n'));+ }++ return (+ <div className="settings-section">+ <div className="section-header">+ <h2>Security Settings</h2>+ <p>Manage your password and security preferences</p>+ </div>++ {message && (+ <div className={`alert alert-${message.type === 'success' ? 'success' : 'danger'}`}>+ {message.text}+ </div>+ )}++ {/* Two-Factor Authentication Section */}+ <div className="settings-card two-fa-card">+ <div className="two-fa-header">+ <div className="two-fa-icon">+ <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">+ <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>+ <path d="M7 11V7a5 5 0 0 1 10 0v4"/>+ </svg>+ </div>+ <div>+ <h3>Two-Factor Authentication (2FA)</h3>+ <p>Add an extra layer of security to your account</p>+ </div>+ </div>++ {twoFALoading && !twoFAStatus ? (+ <div className="loading-sm">Loading...</div>+ ) : twoFAStatus?.enabled ? (+ <div className="two-fa-enabled">+ <div className="two-fa-status">+ <span className="badge badge-success">Enabled</span>+ <span className="two-fa-info">+ Enabled on {new Date(twoFAStatus.confirmed_at).toLocaleDateString()}+ </span>+ </div>+ <div className="two-fa-backup-info">+ <span>Backup codes remaining: <strong>{twoFAStatus.backup_codes_remaining}</strong></span>+ {twoFAStatus.backup_codes_remaining <= 3 && (+ <span className="warning-text">Consider regenerating your backup codes</span>+ )}+ </div>+ <div className="two-fa-actions">+ <button+ className="btn btn-secondary"+ onClick={() => {+ setVerificationCode('');+ setTwoFAError('');+ setShowBackupCodesModal(true);+ }}+ >+ Regenerate Backup Codes+ </button>+ <button+ className="btn btn-danger"+ onClick={() => {+ setVerificationCode('');+ setTwoFAError('');+ setShowDisableModal(true);+ }}+ >+ Disable 2FA+ </button>+ </div>+ </div>+ ) : (+ <div className="two-fa-disabled">+ <p className="two-fa-description">+ Two-factor authentication adds an additional layer of security to your account+ by requiring a code from your authenticator app in addition to your password.+ </p>+ <button+ className="btn btn-primary"+ onClick={handleInitiate2FA}+ disabled={twoFALoading}+ >+ Enable Two-Factor Authentication+ </button>+ </div>+ )}+ </div>++ <form onSubmit={handleSubmit} className="settings-form">+ <h3>Change Password</h3>++ <div className="form-group">+ <label>Current Password</label>+ <input+ type="password"+ value={formData.currentPassword}+ onChange={(e) => setFormData({ ...formData, currentPassword: e.target.value })}+ placeholder="Enter current password"+ />+ </div>++ <div className="form-group">+ <label>New Password</label>+ <input+ type="password"+ value={formData.newPassword}+ onChange={(e) => setFormData({ ...formData, newPassword: e.target.value })}+ placeholder="Enter new password"+ required+ />+ <span className="form-help">Minimum 8 characters</span>+ </div>++ <div className="form-group">+ <label>Confirm New Password</label>+ <input+ type="password"+ value={formData.confirmPassword}+ onChange={(e) => setFormData({ ...formData, confirmPassword: e.target.value })}+ placeholder="Confirm new password"+ required+ />+ </div>++ <div className="form-actions">+ <button type="submit" className="btn btn-primary" disabled={loading}>+ {loading ? 'Changing...' : 'Change Password'}+ </button>+ </div>+ </form>++ <div className="settings-card">+ <h3>Sessions</h3>+ <p>Manage your active sessions</p>+ <div className="session-item current">+ <div className="session-info">+ <svg viewBox="0 0 24 24" width="20" height="20">+ <rect x="2" y="3" width="20" height="14" rx="2" ry="2"/>+ <line x1="8" y1="21" x2="16" y2="21"/>+ <line x1="12" y1="17" x2="12" y2="21"/>+ </svg>+ <div>+ <span className="session-device">Current Session</span>+ <span className="session-details">This device - Active now</span>+ </div>+ </div>+ <span className="badge badge-success">Current</span>+ </div>+ </div>++ {/* Linked Accounts */}+ <LinkedAccounts />++ {/* 2FA Setup Modal */}+ {showSetupModal && setupData && (+ <Modal open={true} onClose={() => setShowSetupModal(false)} title="Set Up Two-Factor Authentication" size="md">+ <div className="setup-steps">+ <div className="setup-step">+ <span className="step-number">1</span>+ <div className="step-content">+ <h4>Scan the QR Code</h4>+ <p>Use your authenticator app (Google Authenticator, Authy, 1Password, etc.) to scan this QR code.</p>+ {setupData.qr_code ? (+ <div className="qr-code-container">+ <img src={setupData.qr_code} alt="2FA QR Code" className="qr-code" />+ </div>+ ) : (+ <div className="qr-fallback">+ <p>QR code unavailable. Enter this secret manually:</p>+ <code className="secret-key">{setupData.secret}</code>+ </div>+ )}+ <details className="manual-entry">+ <summary>Can't scan? Enter manually</summary>+ <p>Account: {user?.email ?? ''}</p>+ <p>Secret: <code>{setupData.secret}</code></p>+ </details>+ </div>+ </div>++ <div className="setup-step">+ <span className="step-number">2</span>+ <div className="step-content">+ <h4>Enter Verification Code</h4>+ <p>Enter the 6-digit code from your authenticator app to verify setup.</p>+ <input+ type="text"+ value={verificationCode}+ onChange={(e) => setVerificationCode(e.target.value.replace(/\D/g, '').slice(0, 6))}+ placeholder="000000"+ className="verification-input"+ autoFocus+ />+ {twoFAError && <p className="error-text">{twoFAError}</p>}+ </div>+ </div>+ </div>+ <div className="modal-footer">+ <button className="btn btn-secondary" onClick={() => setShowSetupModal(false)}>+ Cancel+ </button>+ <button+ className="btn btn-primary"+ onClick={handleConfirm2FA}+ disabled={twoFALoading || verificationCode.length !== 6}+ >+ {twoFALoading ? 'Verifying...' : 'Enable 2FA'}+ </button>+ </div>+ </Modal>+ )}++ {/* Disable 2FA Modal */}+ {showDisableModal && (+ <Modal open={true} onClose={() => setShowDisableModal(false)} title="Disable Two-Factor Authentication">+ <div className="warning-box">+ <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">+ <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>+ <line x1="12" y1="9" x2="12" y2="13"/>+ <line x1="12" y1="17" x2="12.01" y2="17"/>+ </svg>+ <p>Disabling 2FA will make your account less secure. You will only need your password to log in.</p>+ </div>+ <div className="form-group">+ <label>Enter a verification code or backup code to disable 2FA:</label>+ <input+ type="text"+ value={verificationCode}+ onChange={(e) => setVerificationCode(e.target.value)}+ placeholder="Code from authenticator or backup code"+ autoFocus+ />+ {twoFAError && <p className="error-text">{twoFAError}</p>}+ </div>+ <div className="modal-footer">+ <button className="btn btn-secondary" onClick={() => setShowDisableModal(false)}>+ Cancel+ </button>+ <button+ className="btn btn-danger"+ onClick={handleDisable2FA}+ disabled={twoFALoading || !verificationCode}+ >+ {twoFALoading ? 'Disabling...' : 'Disable 2FA'}+ </button>+ </div>+ </Modal>+ )}++ {/* Backup Codes Modal */}+ {showBackupCodesModal && (+ <Modal open={true} onClose={() => setShowBackupCodesModal(false)} title={backupCodes.length > 0 ? 'Your Backup Codes' : 'Regenerate Backup Codes'} size="md">+ {backupCodes.length > 0 ? (+ <>+ <div className="warning-box">+ <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">+ <circle cx="12" cy="12" r="10"/>+ <line x1="12" y1="8" x2="12" y2="12"/>+ <line x1="12" y1="16" x2="12.01" y2="16"/>+ </svg>+ <p>Save these backup codes in a secure location. They will not be shown again. Each code can only be used once.</p>+ </div>+ <div className="backup-codes-grid">+ {backupCodes.map((code, index) => (+ <code key={index} className="backup-code">{code}</code>+ ))}+ </div>+ <div className="backup-codes-actions">+ <button className="btn btn-secondary" onClick={downloadBackupCodes}>+ <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"/>+ </svg>+ Download+ </button>+ <button className="btn btn-secondary" onClick={copyBackupCodes}>+ <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">+ <rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>+ </svg>+ Copy+ </button>+ </div>+ </>+ ) : (+ <>+ <p>Enter a code from your authenticator app to generate new backup codes. This will invalidate all existing backup codes.</p>+ <div className="form-group">+ <label>Verification Code</label>+ <input+ type="text"+ value={verificationCode}+ onChange={(e) => setVerificationCode(e.target.value.replace(/\D/g, '').slice(0, 6))}+ placeholder="000000"+ autoFocus+ />+ {twoFAError && <p className="error-text">{twoFAError}</p>}+ </div>+ </>+ )}+ <div className="modal-footer">+ <button className="btn btn-secondary" onClick={() => {+ setShowBackupCodesModal(false);+ setBackupCodes([]);+ setVerificationCode('');+ }}>+ {backupCodes.length > 0 ? 'Done' : 'Cancel'}+ </button>+ {backupCodes.length === 0 && (+ <button+ className="btn btn-primary"+ onClick={handleRegenerateBackupCodes}+ disabled={twoFALoading || verificationCode.length !== 6}+ >+ {twoFALoading ? 'Generating...' : 'Generate New Codes'}+ </button>+ )}+ </div>+ </Modal>+ )}+ </div>+ );+};++export default SecuritySettingsTab;diff --git a/frontend/src/components/settings/SiteSettingsTab.jsx b/frontend/src/components/settings/SiteSettingsTab.jsxnew file mode 100644index 00000000..b04ae896--- /dev/null+++ b/frontend/src/components/settings/SiteSettingsTab.jsx@@ -0,0 +1,112 @@+import React, { useState, useEffect } from 'react';+import api from '../../services/api';++const SiteSettingsTab = ({ onDevModeChange }) => {+ const [settings, setSettings] = useState({+ registration_enabled: false,+ dev_mode: false+ });+ const [loading, setLoading] = useState(true);+ const [saving, setSaving] = useState(false);+ const [message, setMessage] = useState(null);++ useEffect(() => {+ loadSettings();+ }, []);++ async function loadSettings() {+ try {+ const data = await api.getSystemSettings();+ setSettings({+ registration_enabled: data.registration_enabled || false,+ dev_mode: data.dev_mode || false+ });+ } catch (err) {+ console.error('Failed to load settings:', err);+ } finally {+ setLoading(false);+ }+ }++ async function handleToggleSetting(key, label) {+ setSaving(true);+ setMessage(null);++ try {+ const newValue = !settings[key];+ await api.updateSystemSetting(key, newValue);+ setSettings({ ...settings, [key]: newValue });+ setMessage({ type: 'success', text: `${label} ${newValue ? 'enabled' : 'disabled'}` });+ if (key === 'dev_mode' && onDevModeChange) {+ onDevModeChange(newValue);+ }+ } catch (err) {+ setMessage({ type: 'error', text: err.message || 'Failed to update setting' });+ } finally {+ setSaving(false);+ }+ }++ if (loading) {+ return <div className="settings-section"><p>Loading...</p></div>;+ }++ return (+ <div className="settings-section">+ <h2>Site Settings</h2>+ <p className="section-description">Configure global site settings</p>++ {message && (+ <div className={`message ${message.type}`}>{message.text}</div>+ )}++ <div className="settings-card">+ <h3>User Registration</h3>+ <p>Allow new users to create accounts on the login page.</p>++ <div className="form-group">+ <label className="toggle-switch-label">+ <span>Enable public registration</span>+ <label className="toggle-switch">+ <input+ type="checkbox"+ checked={settings.registration_enabled}+ onChange={() => handleToggleSetting('registration_enabled', 'User registration')}+ disabled={saving}+ />+ <span className="toggle-slider"></span>+ </label>+ </label>+ <span className="form-help">+ When disabled, only administrators can create new user accounts.+ </span>+ </div>+ </div>++ <div className="settings-card">+ <h3>Developer Mode</h3>+ <p>Enable developer tools and diagnostics.</p>++ <div className="form-group">+ <label className="toggle-switch-label">+ <span>Enable developer mode</span>+ <label className="toggle-switch">+ <input+ type="checkbox"+ checked={settings.dev_mode}+ onChange={() => handleToggleSetting('dev_mode', 'Developer mode')}+ disabled={saving}+ />+ <span className="toggle-slider"></span>+ </label>+ </label>+ <span className="form-help">+ Enables the Developer tab with icon reference and diagnostic tools.+ </span>+ </div>+ </div>+ </div>+ );+};++export default SiteSettingsTab;diff --git a/frontend/src/components/settings/SystemTab.jsx b/frontend/src/components/settings/SystemTab.jsxnew file mode 100644index 00000000..e4c935a8--- /dev/null+++ b/frontend/src/components/settings/SystemTab.jsx@@ -0,0 +1,263 @@+import React, { useState, useEffect } from 'react';+import { useAuth } from '../../contexts/AuthContext';+import api from '../../services/api';++function formatBytes(bytes) {+ if (!bytes) return '-';+ const units = ['B', 'KB', 'MB', 'GB', 'TB'];+ let i = 0;+ while (bytes >= 1024 && i < units.length - 1) {+ bytes /= 1024;+ i++;+ }+ return `${bytes.toFixed(1)} ${units[i]}`;+}++function formatUptime(seconds) {+ if (!seconds) return '-';+ const days = Math.floor(seconds / 86400);+ const hours = Math.floor((seconds % 86400) / 3600);+ const minutes = Math.floor((seconds % 3600) / 60);++ const parts = [];+ if (days > 0) parts.push(`${days}d`);+ if (hours > 0) parts.push(`${hours}h`);+ if (minutes > 0) parts.push(`${minutes}m`);++ return parts.join(' ') || '< 1m';+}++const SystemTab = () => {+ const { isAdmin } = useAuth();+ const [metrics, setMetrics] = useState(null);+ const [loading, setLoading] = useState(true);+ const [timezones, setTimezones] = useState([]);+ const [selectedTimezone, setSelectedTimezone] = useState('');+ const [savingTimezone, setSavingTimezone] = useState(false);+ const [timezoneMessage, setTimezoneMessage] = useState(null);++ useEffect(() => {+ if (isAdmin) {+ loadMetrics();+ loadTimezones();+ }+ }, [isAdmin]);++ async function loadMetrics() {+ try {+ const data = await api.getSystemMetrics();+ setMetrics(data);+ if (data?.time?.timezone_id) {+ setSelectedTimezone(data.time.timezone_id);+ }+ } catch (err) {+ console.error('Failed to load metrics:', err);+ } finally {+ setLoading(false);+ }+ }++ async function loadTimezones() {+ try {+ const data = await api.getTimezones();+ setTimezones(data.timezones || []);+ } catch (err) {+ console.error('Failed to load timezones:', err);+ }+ }++ async function handleTimezoneChange() {+ if (!selectedTimezone) return;++ setSavingTimezone(true);+ setTimezoneMessage(null);++ try {+ const result = await api.setTimezone(selectedTimezone);+ setTimezoneMessage({ type: 'success', text: result.message || 'Timezone updated' });+ // Refresh metrics to show new time+ loadMetrics();+ } catch (err) {+ setTimezoneMessage({ type: 'error', text: err.message || 'Failed to set timezone' });+ } finally {+ setSavingTimezone(false);+ setTimeout(() => setTimezoneMessage(null), 5000);+ }+ }++ if (!isAdmin) {+ return (+ <div className="settings-section">+ <div className="section-header">+ <h2>System Information</h2>+ <p>View system details and server information</p>+ </div>+ <div className="alert alert-warning">+ Admin access required to view system information.+ </div>+ </div>+ );+ }++ if (loading) {+ return <div className="loading">Loading system information...</div>;+ }++ return (+ <div className="settings-section">+ <div className="section-header">+ <h2>System Information</h2>+ <p>View system details and server information</p>+ </div>++ <div className="system-info-grid">+ <div className="settings-card">+ <h3>CPU</h3>+ <div className="info-list">+ <div className="info-item">+ <span className="info-label">Usage</span>+ <span className="info-value">{metrics?.cpu?.percent?.toFixed(1) || 0}%</span>+ </div>+ <div className="info-item">+ <span className="info-label">Cores</span>+ <span className="info-value">{metrics?.cpu?.count || '-'}</span>+ </div>+ <div className="info-item">+ <span className="info-label">Load Average</span>+ <span className="info-value">+ {metrics?.cpu?.load_avg ? metrics.cpu.load_avg.map(l => l.toFixed(2)).join(', ') : '-'}+ </span>+ </div>+ </div>+ </div>++ <div className="settings-card">+ <h3>Memory</h3>+ <div className="info-list">+ <div className="info-item">+ <span className="info-label">Usage</span>+ <span className="info-value">{metrics?.memory?.percent?.toFixed(1) || 0}%</span>+ </div>+ <div className="info-item">+ <span className="info-label">Used</span>+ <span className="info-value">{formatBytes(metrics?.memory?.used)}</span>+ </div>+ <div className="info-item">+ <span className="info-label">Total</span>+ <span className="info-value">{formatBytes(metrics?.memory?.total)}</span>+ </div>+ </div>+ </div>++ <div className="settings-card">+ <h3>Disk</h3>+ <div className="info-list">+ <div className="info-item">+ <span className="info-label">Usage</span>+ <span className="info-value">{metrics?.disk?.percent?.toFixed(1) || 0}%</span>+ </div>+ <div className="info-item">+ <span className="info-label">Used</span>+ <span className="info-value">{formatBytes(metrics?.disk?.used)}</span>+ </div>+ <div className="info-item">+ <span className="info-label">Total</span>+ <span className="info-value">{formatBytes(metrics?.disk?.total)}</span>+ </div>+ </div>+ </div>++ <div className="settings-card">+ <h3>Network</h3>+ <div className="info-list">+ <div className="info-item">+ <span className="info-label">Bytes Sent</span>+ <span className="info-value">{formatBytes(metrics?.network?.bytes_sent)}</span>+ </div>+ <div className="info-item">+ <span className="info-label">Bytes Received</span>+ <span className="info-value">{formatBytes(metrics?.network?.bytes_recv)}</span>+ </div>+ </div>+ </div>+ </div>++ {metrics?.system && (+ <div className="settings-card">+ <h3>System Details</h3>+ <div className="info-list">+ <div className="info-item">+ <span className="info-label">Hostname</span>+ <span className="info-value">{metrics.system.hostname || '-'}</span>+ </div>+ <div className="info-item">+ <span className="info-label">Platform</span>+ <span className="info-value">{metrics.system.platform || '-'}</span>+ </div>+ <div className="info-item">+ <span className="info-label">OS Version</span>+ <span className="info-value">{metrics.system.version || '-'}</span>+ </div>+ <div className="info-item">+ <span className="info-label">Uptime</span>+ <span className="info-value">{formatUptime(metrics.system.uptime)}</span>+ </div>+ </div>+ </div>+ )}++ {/* Server Time & Timezone */}+ <div className="settings-card">+ <h3>Server Time & Timezone</h3>+ {metrics?.time && (+ <div className="info-list" style={{ marginBottom: '1rem' }}>+ <div className="info-item">+ <span className="info-label">Current Time</span>+ <span className="info-value">{metrics.time.current_time_formatted}</span>+ </div>+ <div className="info-item">+ <span className="info-label">UTC Offset</span>+ <span className="info-value">{metrics.time.utc_offset}</span>+ </div>+ <div className="info-item">+ <span className="info-label">Current Timezone</span>+ <span className="info-value">{metrics.time.timezone_id || metrics.time.timezone_name}</span>+ </div>+ </div>+ )}+ <div className="form-group">+ <label>Change Timezone</label>+ <div className="timezone-selector">+ <select+ value={selectedTimezone}+ onChange={(e) => setSelectedTimezone(e.target.value)}+ className="form-control"+ >+ <option value="">Select timezone...</option>+ {timezones.map((tz) => (+ <option key={tz} value={tz}>{tz}</option>+ ))}+ </select>+ <button+ className="btn btn-primary"+ onClick={handleTimezoneChange}+ disabled={savingTimezone || !selectedTimezone || selectedTimezone === metrics?.time?.timezone_id}+ >+ {savingTimezone ? 'Saving...' : 'Apply'}+ </button>+ </div>+ {timezoneMessage && (+ <div className={`timezone-message ${timezoneMessage.type}`}>+ {timezoneMessage.text}+ </div>+ )}+ <span className="form-help">+ Changing timezone requires server restart to take full effect+ </span>+ </div>+ </div>+ </div>+ );+};++export default SystemTab;diff --git a/frontend/src/components/settings/UserModal.jsx b/frontend/src/components/settings/UserModal.jsxindex d8c68d27..cec19333 100644--- a/frontend/src/components/settings/UserModal.jsx+++ b/frontend/src/components/settings/UserModal.jsx@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';import { useAuth } from '../../contexts/AuthContext';import api from '../../services/api';import PermissionEditor from './PermissionEditor';+import Modal from '../Modal';const UserModal = ({ user, onSave, onClose }) => {const [formData, setFormData] = useState({@@ -113,18 +114,7 @@ const UserModal = ({ user, onSave, onClose }) => {}return (- <div className="modal-overlay">- <div className="modal modal-md">- <div className="modal-header">- <h3>{isEditing ? 'Edit User' : 'Add New User'}</h3>- <button className="modal-close" onClick={onClose}>- <svg viewBox="0 0 24 24" width="20" height="20" stroke="currentColor" fill="none" strokeWidth="2">- <line x1="18" y1="6" x2="6" y2="18"/>- <line x1="6" y1="6" x2="18" y2="18"/>- </svg>- </button>- </div>-+ <Modal open={true} onClose={onClose} title={isEditing ? 'Edit User' : 'Add New User'} size="md"><form onSubmit={handleSubmit}><div className="modal-body">{error && <div className="error-message">{error}</div>}@@ -274,8 +264,7 @@ const UserModal = ({ user, onSave, onClose }) => {</button></div></form>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/settings/UsersTab.jsx b/frontend/src/components/settings/UsersTab.jsxindex 5a699833..dce4a06f 100644--- a/frontend/src/components/settings/UsersTab.jsx+++ b/frontend/src/components/settings/UsersTab.jsx@@ -3,6 +3,7 @@ import api from '../../services/api';import { useAuth } from '../../contexts/AuthContext';import UserModal from './UserModal';import InvitationsTab from './InvitationsTab';+import Modal from '../Modal';const UsersTab = () => {const [users, setUsers] = useState([]);@@ -227,21 +228,9 @@ const UsersTab = () => {)}{deleteConfirm && (- <div className="modal-overlay">- <div className="modal modal-sm">- <div className="modal-header">- <h3>Delete User</h3>- <button className="modal-close" onClick={() => setDeleteConfirm(null)}>- <svg viewBox="0 0 24 24" width="20" height="20" stroke="currentColor" fill="none" strokeWidth="2">- <line x1="18" y1="6" x2="6" y2="18"/>- <line x1="6" y1="6" x2="18" y2="18"/>- </svg>- </button>- </div>- <div className="modal-body">+ <Modal open={true} onClose={() => setDeleteConfirm(null)} title="Delete User" size="sm"><p>Are you sure you want to delete <strong>{deleteConfirm.username}</strong>?</p><p className="text-muted">This action cannot be undone.</p>- </div><div className="modal-footer"><button className="btn btn-ghost" onClick={() => setDeleteConfirm(null)}>Cancel@@ -250,8 +239,7 @@ const UsersTab = () => {Delete User</button></div>- </div>- </div>+ </Modal>)}<InvitationsTab />diff --git a/frontend/src/components/settings/WebhookSubscriptionModal.jsx b/frontend/src/components/settings/WebhookSubscriptionModal.jsxindex 2e95f95e..ddc1458c 100644--- a/frontend/src/components/settings/WebhookSubscriptionModal.jsx+++ b/frontend/src/components/settings/WebhookSubscriptionModal.jsx@@ -1,6 +1,7 @@import { useState, useEffect } from 'react';import { X } from 'lucide-react';import api from '../../services/api';+import Modal from '../Modal';const WebhookSubscriptionModal = ({ subscription, onClose, onSubmit }) => {const [name, setName] = useState('');@@ -70,12 +71,7 @@ const WebhookSubscriptionModal = ({ subscription, onClose, onSubmit }) => {}, {});return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal webhook-modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h3>{subscription ? 'Edit Subscription' : 'Create Webhook Subscription'}</h3>- <button className="modal-close" onClick={onClose}><X size={18} /></button>- </div>+ <Modal open={true} onClose={onClose} title={subscription ? 'Edit Subscription' : 'Create Webhook Subscription'} className="webhook-modal"><form onSubmit={handleSubmit}><div className="modal-body"><div className="form-group">@@ -173,8 +169,7 @@ const WebhookSubscriptionModal = ({ subscription, onClose, onSubmit }) => {</button></div></form>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/sidebarItems.js b/frontend/src/components/sidebarItems.jsindex 97fb4f6e..b3334176 100644--- a/frontend/src/components/sidebarItems.js+++ b/frontend/src/components/sidebarItems.js@@ -28,41 +28,6 @@ export const SIDEBAR_ITEMS = [category: 'infrastructure',icon: '<rect x="2" y="2" width="20" height="8" rx="2" ry="2"/><rect x="2" y="14" width="20" height="8" rx="2" ry="2"/><line x1="6" y1="6" x2="6.01" y2="6"/><line x1="6" y1="18" x2="6.01" y2="18"/>'},- {- id: 'fleet',- label: 'Agent Fleet',- route: '/fleet',- category: 'infrastructure',- icon: '<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>'- },- {- id: 'fleet-monitor',- label: 'Fleet Monitor',- route: '/fleet-monitor',- category: 'infrastructure',- icon: '<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>'- },- {- id: 'agent-plugins',- label: 'Agent Plugins',- route: '/agent-plugins',- category: 'infrastructure',- icon: '<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/>'- },- {- id: 'cloud',- label: 'Cloud Servers',- route: '/cloud',- category: 'infrastructure',- icon: '<path d="M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z"/>'- },- {- id: 'server-templates',- label: 'Server Templates',- route: '/server-templates',- category: 'infrastructure',- icon: '<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/>'- },{id: 'domains',label: 'Domains & Sites',@@ -93,13 +58,6 @@ export const SIDEBAR_ITEMS = [}]},- {- id: 'templates',- label: 'Templates',- route: '/templates',- category: 'infrastructure',- icon: '<rect x="3" y="3" width="7" height="9"/><rect x="14" y="3" width="7" height="5"/><rect x="14" y="12" width="7" height="9"/><rect x="3" y="16" width="7" height="5"/>'- },{id: 'workflow',label: 'Workflow Builder',@@ -114,20 +72,6 @@ export const SIDEBAR_ITEMS = [category: 'infrastructure',icon: '<ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"/><path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"/>'},- {- id: 'dns',- label: 'DNS Zones',- route: '/dns',- category: 'infrastructure',- icon: '<path d="M12 2L2 7l10 5 10-5-10-5z"/><path d="M2 17l10 5 10-5"/><path d="M2 12l10 5 10-5"/>'- },- {- id: 'ssl',- label: 'SSL Certificates',- route: '/ssl',- category: 'infrastructure',- icon: '<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>'- },{id: 'docker',label: 'Docker',@@ -149,13 +93,6 @@ export const SIDEBAR_ITEMS = [category: 'operations',icon: '<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>'},- {- id: 'ftp',- label: 'FTP Server',- route: '/ftp',- category: 'operations',- icon: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/>'- },{id: 'monitoring',label: 'Monitoring',@@ -191,13 +128,6 @@ export const SIDEBAR_ITEMS = [category: 'operations',icon: '<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/>'},- {- id: 'status-pages',- label: 'Status Pages',- route: '/status-pages',- category: 'operations',- icon: '<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/>'- },{id: 'workspaces',label: 'Workspaces',@@ -218,13 +148,6 @@ export const SIDEBAR_ITEMS = [route: '/marketplace',category: 'system',icon: '<circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/>'- },- {- id: 'downloads',- label: 'Downloads',- route: '/downloads',- category: 'system',- icon: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>'}];@@ -238,22 +161,22 @@ export const SIDEBAR_PRESETS = {web: {label: 'Web Hosting',description: 'Domains, SSL, databases, and web essentials',- hiddenItems: ['docker', 'git', 'email', 'workflow']+ hiddenItems: ['docker', 'git', 'workflow', 'email', 'workspaces', 'marketplace']},email: {label: 'Email Admin',description: 'Email server, security, DNS, and monitoring',- hiddenItems: ['docker', 'git', 'wordpress', 'templates', 'workflow', 'ftp']+ hiddenItems: ['services', 'wordpress', 'workflow', 'databases', 'docker', 'git', 'cron', 'workspaces', 'marketplace']},devops: {label: 'Docker / DevOps',description: 'Docker, Git, monitoring, and CI/CD tools',- hiddenItems: ['wordpress', 'templates', 'email', 'ftp', 'ssl']+ hiddenItems: ['wordpress', 'email', 'marketplace']},minimal: {label: 'Minimal',description: 'Just the essentials — dashboard, servers, terminal',- hiddenItems: ['wordpress', 'templates', 'workflow', 'ftp', 'email', 'git', 'docker', 'ssl', 'cron', 'downloads']+ hiddenItems: ['wordpress', 'workflow', 'databases', 'docker', 'git', 'email', 'cron', 'workspaces', 'marketplace']}};diff --git a/frontend/src/components/wordpress/AutoSyncScheduleModal.jsx b/frontend/src/components/wordpress/AutoSyncScheduleModal.jsxindex e9355eff..d084d8bd 100644--- a/frontend/src/components/wordpress/AutoSyncScheduleModal.jsx+++ b/frontend/src/components/wordpress/AutoSyncScheduleModal.jsx@@ -1,6 +1,7 @@import React, { useState, useEffect } from 'react';import { Clock, RefreshCw } from 'lucide-react';import Spinner from '../Spinner';+import Modal from '../Modal';const SCHEDULE_PRESETS = [{ label: 'Daily at 3 AM', value: '0 3 * * *' },@@ -83,16 +84,7 @@ const AutoSyncScheduleModal = ({ environment, prodId, onClose, api }) => {const envName = environment?.name || 'Environment';return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal auto-sync-modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>- <Clock size={18} />- Auto-Sync Schedule- </h2>- <button className="modal-close" onClick={onClose}>×</button>- </div>-+ <Modal open={true} onClose={onClose} title="Auto-Sync Schedule" className="auto-sync-modal">{loading ? (<div className="auto-sync-loading"><Spinner size="sm" />@@ -183,8 +175,7 @@ const AutoSyncScheduleModal = ({ environment, prodId, onClose, api }) => {{saving ? <><Spinner size="sm" /> Saving...</> : 'Save Schedule'}</button></div>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/wordpress/BasicAuthModal.jsx b/frontend/src/components/wordpress/BasicAuthModal.jsxindex cdd04dde..4fa47c98 100644--- a/frontend/src/components/wordpress/BasicAuthModal.jsx+++ b/frontend/src/components/wordpress/BasicAuthModal.jsx@@ -1,6 +1,7 @@import React, { useState, useEffect } from 'react';import { Shield, Copy, Check, AlertTriangle } from 'lucide-react';import Spinner from '../Spinner';+import Modal from '../Modal';const BasicAuthModal = ({ environment, prodId, onClose, api }) => {const [loading, setLoading] = useState(true);@@ -64,16 +65,7 @@ const BasicAuthModal = ({ environment, prodId, onClose, api }) => {const envName = environment?.name || 'Environment';return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal basic-auth-modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>- <Shield size={18} />- Basic Auth- </h2>- <button className="modal-close" onClick={onClose}>×</button>- </div>-+ <Modal open={true} onClose={onClose} title="Basic Auth" className="basic-auth-modal"><div className="basic-auth-body"><div className="basic-auth-env-name">{envName}</div>@@ -155,8 +147,7 @@ const BasicAuthModal = ({ environment, prodId, onClose, api }) => {Close</button></div>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/wordpress/CommitList.jsx b/frontend/src/components/wordpress/CommitList.jsxindex ad8c47ba..350ef7c3 100644--- a/frontend/src/components/wordpress/CommitList.jsx+++ b/frontend/src/components/wordpress/CommitList.jsx@@ -1,5 +1,6 @@import React, { useState } from 'react';import { GitCommit, Rocket, Copy, CheckCircle } from 'lucide-react';+import Modal from '../Modal';const CommitList = ({ commits, currentCommit, onDeploy, onCreateDev, loading = false }) => {const [actionLoading, setActionLoading] = useState({});@@ -141,14 +142,7 @@ const CreateDevModal = ({ commit, onClose, onCreate, loading }) => {}return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>Create Dev Environment</h2>- <button className="modal-close" onClick={onClose}>×</button>- </div>-- <div className="modal-body">+ <Modal open={true} onClose={onClose} title="Create Dev Environment"><p className="hint">Create a development environment with code from commit{' '}<code>{commit.sha.substring(0, 7)}</code>@@ -188,9 +182,7 @@ const CreateDevModal = ({ commit, onClose, onCreate, loading }) => {</button></div></form>- </div>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/wordpress/CompareView.jsx b/frontend/src/components/wordpress/CompareView.jsxindex f0c40f6c..59b3da8d 100644--- a/frontend/src/components/wordpress/CompareView.jsx+++ b/frontend/src/components/wordpress/CompareView.jsx@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';import { GitCompare, Check, X, Minus, RefreshCw } from 'lucide-react';import wordpressApi from '../../services/wordpress';import Spinner from '../Spinner';+import Modal from '../Modal';const CompareView = ({ projectId, envA, envB, onClose }) => {const [comparison, setComparison] = useState(null);@@ -31,16 +32,7 @@ const CompareView = ({ projectId, envA, envB, onClose }) => {const envBType = envB?.environment_type || 'development';return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal modal-xl" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>- <GitCompare size={18} style={{ marginRight: 8, verticalAlign: -3 }} />- Compare Environments- </h2>- <button className="modal-close" onClick={onClose}>×</button>- </div>-+ <Modal open={true} onClose={onClose} title="Compare Environments" size="xl"><div className="compare-header"><div className={`compare-env-pill ${envAType}`}><span className="compare-env-type">{envAType}</span>@@ -142,8 +134,7 @@ const CompareView = ({ projectId, envA, envB, onClose }) => {<div className="modal-actions"><button className="btn btn-secondary" onClick={onClose}>Close</button></div>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/wordpress/CreateSiteModal.jsx b/frontend/src/components/wordpress/CreateSiteModal.jsxindex b645d255..eb17ec76 100644--- a/frontend/src/components/wordpress/CreateSiteModal.jsx+++ b/frontend/src/components/wordpress/CreateSiteModal.jsx@@ -1,5 +1,6 @@import React, { useState } from 'react';import { X } from 'lucide-react';+import Modal from '../Modal';const CreateSiteModal = ({ onClose, onCreate }) => {const [formData, setFormData] = useState({@@ -57,15 +58,7 @@ const CreateSiteModal = ({ onClose, onCreate }) => {}return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>Create WordPress Site</h2>- <button className="modal-close" onClick={onClose}>- <X size={20} />- </button>- </div>-+ <Modal open={true} onClose={onClose} title="Create WordPress Site">{error && <div className="error-message">{error}</div>}<form onSubmit={handleSubmit}>@@ -151,8 +144,7 @@ const CreateSiteModal = ({ onClose, onCreate }) => {</button></div></form>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/wordpress/PromoteModal.jsx b/frontend/src/components/wordpress/PromoteModal.jsxindex d7032316..f0b58f6d 100644--- a/frontend/src/components/wordpress/PromoteModal.jsx+++ b/frontend/src/components/wordpress/PromoteModal.jsx@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';import { ArrowRight, Shield } from 'lucide-react';import wordpressApi from '../../services/wordpress';import Spinner from '../Spinner';+import Modal from '../Modal';const PromoteModal = ({ sourceEnv, targetEnv, onClose, onPromote }) => {const [promotionType, setPromotionType] = useState('code');@@ -63,13 +64,7 @@ const PromoteModal = ({ sourceEnv, targetEnv, onClose, onPromote }) => {const targetType = targetEnv.environment_type || 'staging';return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal modal-lg" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>Promote Environment</h2>- <button className="modal-close" onClick={onClose}>×</button>- </div>-+ <Modal open={true} onClose={onClose} title="Promote Environment" size="lg"><form onSubmit={handleSubmit}><div className="promote-direction"><div className={`promote-env-pill ${sourceType}`}>@@ -240,8 +235,7 @@ const PromoteModal = ({ sourceEnv, targetEnv, onClose, onPromote }) => {</button></div></form>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/wordpress/ResourceLimitsModal.jsx b/frontend/src/components/wordpress/ResourceLimitsModal.jsxindex f2bec00a..c5eed852 100644--- a/frontend/src/components/wordpress/ResourceLimitsModal.jsx+++ b/frontend/src/components/wordpress/ResourceLimitsModal.jsx@@ -1,6 +1,7 @@import React, { useState } from 'react';import { Cpu, HardDrive, AlertTriangle } from 'lucide-react';import Spinner from '../Spinner';+import Modal from '../Modal';const PRESETS = {low: { memory: '256M', cpus: '0.25', db_memory: '256M', db_cpus: '0.25' },@@ -41,16 +42,7 @@ const ResourceLimitsModal = ({ environment, currentLimits, onClose, onApply }) =const envName = environment?.name || 'Environment';return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal resource-limits-modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>- <Cpu size={18} />- Resource Limits- </h2>- <button className="modal-close" onClick={onClose}>×</button>- </div>-+ <Modal open={true} onClose={onClose} title="Resource Limits" className="resource-limits-modal"><form onSubmit={handleSubmit}><div className="resource-limits-env-name">{envName}</div>@@ -140,8 +132,7 @@ const ResourceLimitsModal = ({ environment, currentLimits, onClose, onApply }) =</button></div></form>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/wordpress/SanitizationProfileForm.jsx b/frontend/src/components/wordpress/SanitizationProfileForm.jsxindex f47ddca2..92f8731c 100644--- a/frontend/src/components/wordpress/SanitizationProfileForm.jsx+++ b/frontend/src/components/wordpress/SanitizationProfileForm.jsx@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';import { Shield, Plus, Trash2, Star, Edit3, Save } from 'lucide-react';import wordpressApi from '../../services/wordpress';import Spinner from '../Spinner';+import Modal from '../Modal';const SanitizationProfileForm = ({ onClose, onProfilesChange }) => {const [profiles, setProfiles] = useState([]);@@ -71,16 +72,7 @@ const SanitizationProfileForm = ({ onClose, onProfilesChange }) => {}return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal modal-lg" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>- <Shield size={18} style={{ marginRight: 8, verticalAlign: -3 }} />- Sanitization Profiles- </h2>- <button className="modal-close" onClick={onClose}>×</button>- </div>-+ <Modal open={true} onClose={onClose} title="Sanitization Profiles" size="lg"><div className="sanitization-profiles-body">{loading ? (<div className="sanitization-loading">@@ -124,8 +116,7 @@ const SanitizationProfileForm = ({ onClose, onProfilesChange }) => {<div className="modal-actions"><button className="btn btn-secondary" onClick={onClose}>Close</button></div>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/wordpress/SyncModal.jsx b/frontend/src/components/wordpress/SyncModal.jsxindex a4f9b6aa..4e40f054 100644--- a/frontend/src/components/wordpress/SyncModal.jsx+++ b/frontend/src/components/wordpress/SyncModal.jsx@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';import { ArrowDownLeft, Shield } from 'lucide-react';import wordpressApi from '../../services/wordpress';import Spinner from '../Spinner';+import Modal from '../Modal';const SyncModal = ({ environment, productionName, onClose, onSync }) => {const [syncType, setSyncType] = useState('database');@@ -64,13 +65,7 @@ const SyncModal = ({ environment, productionName, onClose, onSync }) => {const envType = environment.environment_type || 'development';return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>Sync from Production</h2>- <button className="modal-close" onClick={onClose}>×</button>- </div>-+ <Modal open={true} onClose={onClose} title="Sync from Production"><form onSubmit={handleSubmit}><div className="sync-direction"><div className="promote-env-pill production">@@ -211,8 +206,7 @@ const SyncModal = ({ environment, productionName, onClose, onSync }) => {</button></div></form>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/wordpress/WpCliTerminal.jsx b/frontend/src/components/wordpress/WpCliTerminal.jsxindex d2dfdcca..d52df74f 100644--- a/frontend/src/components/wordpress/WpCliTerminal.jsx+++ b/frontend/src/components/wordpress/WpCliTerminal.jsx@@ -1,6 +1,7 @@import React, { useState, useRef, useEffect } from 'react';import { Terminal, Play, Clock, X } from 'lucide-react';import Spinner from '../Spinner';+import Modal from '../Modal';const QUICK_COMMANDS = [{ label: 'Plugin List', command: 'wp plugin list --format=table' },@@ -91,16 +92,7 @@ const WpCliTerminal = ({ environment, prodId, onClose, api }) => {const envName = environment?.name || 'Environment';return (- <div className="modal-overlay" onClick={onClose}>- <div className="modal wpcli-terminal-modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>- <Terminal size={18} />- WP-CLI - {envName}- </h2>- <button className="modal-close" onClick={onClose}>×</button>- </div>-+ <Modal open={true} onClose={onClose} title={`WP-CLI - ${envName}`} className="wpcli-terminal-modal"><div className="wpcli-quick-actions">{QUICK_COMMANDS.map(qc => (<button@@ -189,8 +181,7 @@ const WpCliTerminal = ({ environment, prodId, onClose, api }) => {<Play size={12} /></button></div>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/workflow/DeploymentProgressModal.jsx b/frontend/src/components/workflow/DeploymentProgressModal.jsxindex 2b1df43c..bef290fa 100644--- a/frontend/src/components/workflow/DeploymentProgressModal.jsx+++ b/frontend/src/components/workflow/DeploymentProgressModal.jsx@@ -1,5 +1,6 @@import React from 'react';import { X, Loader, CheckCircle, XCircle, Server, Database, Globe, Box, ExternalLink } from 'lucide-react';+import Modal from '../Modal';const nodeTypeConfig = {dockerApp: { icon: Server, label: 'Docker App', color: '#2496ed' },@@ -21,17 +22,7 @@ const DeploymentProgressModal = ({ isDeploying, results, nodes, onClose }) => {const isComplete = !isDeploying && results;return (- <div className="deployment-modal-overlay" onClick={onClose}>- <div className="deployment-modal" onClick={(e) => e.stopPropagation()}>- <div className="deployment-modal-header">- <h2>- {isDeploying ? 'Deploying...' : hasErrors ? 'Deployment Completed with Errors' : 'Deployment Complete'}- </h2>- <button className="modal-close-btn" onClick={onClose}>- <X size={20} />- </button>- </div>-+ <Modal open={true} onClose={onClose} title={isDeploying ? 'Deploying...' : hasErrors ? 'Deployment Completed with Errors' : 'Deployment Complete'} className="deployment-modal"><div className="deployment-modal-content">{isDeploying && !results && (<div className="deployment-loading">@@ -129,8 +120,7 @@ const DeploymentProgressModal = ({ isDeploying, results, nodes, onClose }) => {</button>)}</div>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/workflow/WorkflowExecutionHistory.jsx b/frontend/src/components/workflow/WorkflowExecutionHistory.jsxindex 1b03c1d1..b9af163d 100644--- a/frontend/src/components/workflow/WorkflowExecutionHistory.jsx+++ b/frontend/src/components/workflow/WorkflowExecutionHistory.jsx@@ -1,6 +1,7 @@import React, { useState, useEffect, useCallback } from 'react';import { X, Clock, CheckCircle, XCircle, Loader2, List, FileText, RefreshCw, Activity } from 'lucide-react';import api from '../../services/api';+import Modal from '../Modal';const WorkflowExecutionHistory = ({ workflowId, onClose }) => {const [executions, setExecutions] = useState([]);@@ -53,27 +54,7 @@ const WorkflowExecutionHistory = ({ workflowId, onClose }) => {};return (- <div className="modal-overlay">- <div className="modal-content max-w-4xl w-full h-[80vh] flex flex-col p-0 overflow-hidden">- <div className="modal-header p-4 border-b border-gray-700 flex justify-between items-center bg-gray-800/50">- <div className="flex items-center gap-2">- <Activity size={20} className="text-blue-400" />- <h2 className="text-lg font-semibold">Execution History</h2>- </div>- <div className="flex items-center gap-4">- <button- onClick={fetchExecutions}- className="p-1.5 hover:bg-gray-700 rounded transition-colors text-gray-400 hover:text-white"- title="Refresh"- >- <RefreshCw size={18} />- </button>- <button onClick={onClose} className="p-1 hover:bg-gray-700 rounded transition-colors">- <X size={20} />- </button>- </div>- </div>-+ <Modal open={true} onClose={onClose} title="Execution History" size="lg"><div className="flex-1 flex overflow-hidden">{/* Executions List */}<div className="w-1/3 border-r border-gray-700 overflow-y-auto bg-gray-900/30">@@ -166,8 +147,7 @@ const WorkflowExecutionHistory = ({ workflowId, onClose }) => {)}</div></div>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/components/workflow/WorkflowListModal.jsx b/frontend/src/components/workflow/WorkflowListModal.jsxindex 7a4e69f1..4f4d4d87 100644--- a/frontend/src/components/workflow/WorkflowListModal.jsx+++ b/frontend/src/components/workflow/WorkflowListModal.jsx@@ -1,6 +1,7 @@import React, { useState, useEffect } from 'react';import { X, Trash2, Clock, Layers, GitBranch, Loader } from 'lucide-react';import api from '../../services/api';+import Modal from '../Modal';const WorkflowListModal = ({ onLoad, onClose }) => {const [workflows, setWorkflows] = useState([]);@@ -65,15 +66,7 @@ const WorkflowListModal = ({ onLoad, onClose }) => {};return (- <div className="workflow-modal-overlay" onClick={onClose}>- <div className="workflow-modal" onClick={(e) => e.stopPropagation()}>- <div className="workflow-modal-header">- <h2>Load Workflow</h2>- <button className="modal-close-btn" onClick={onClose}>- <X size={20} />- </button>- </div>-+ <Modal open={true} onClose={onClose} title="Load Workflow" className="workflow-modal"><div className="workflow-modal-content">{loading ? (<div className="workflow-list-loading">@@ -138,8 +131,7 @@ const WorkflowListModal = ({ onLoad, onClose }) => {</div>)}</div>- </div>- </div>+ </Modal>);};diff --git a/frontend/src/pages/ApplicationDetail.jsx b/frontend/src/pages/ApplicationDetail.jsxindex 05a34f03..67474597 100644--- a/frontend/src/pages/ApplicationDetail.jsx+++ b/frontend/src/pages/ApplicationDetail.jsx@@ -4,6 +4,8 @@ import { GitBranch } from 'lucide-react';import api from '../services/api';import useTabParam from '../hooks/useTabParam';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';import EnvironmentVariables from '../components/EnvironmentVariables';import PrivateURLSection from '../components/PrivateURLSection';import LinkedAppsSection from '../components/LinkedAppsSection';@@ -83,7 +85,7 @@ const ApplicationDetail = () => {</svg>);default:- return <span style={{ fontSize: '20px', fontWeight: 'bold' }}>{type.charAt(0).toUpperCase()}</span>;+ return <span className="text-xl font-bold">{type.charAt(0).toUpperCase()}</span>;}}@@ -270,6 +272,7 @@ const ApplicationDetail = () => {// Overview Tab with new grid layoutconst OverviewTab = ({ app, onUpdate }) => {const navigate = useNavigate();+ const { confirm: confirmOverview, confirmState: confirmOverviewState, handleConfirm: handleOverviewConfirm, handleCancel: handleOverviewCancel } = useConfirm();const [status, setStatus] = useState(null);const [appStatus, setAppStatus] = useState(null);const [linkedApps, setLinkedApps] = useState([]);@@ -332,7 +335,8 @@ const OverviewTab = ({ app, onUpdate }) => {}async function handleUnlink() {- if (!window.confirm('Are you sure you want to unlink these apps? Database credentials will remain unchanged.')) {+ const confirmed = await confirmOverview({ title: 'Unlink Apps', message: 'Are you sure you want to unlink these apps? Database credentials will remain unchanged.', variant: 'warning' });+ if (!confirmed) {return;}setLinkLoading(true);@@ -533,6 +537,16 @@ const OverviewTab = ({ app, onUpdate }) => {onLinked={handleLinked}/>)}+ <ConfirmDialog+ isOpen={confirmOverviewState.isOpen}+ title={confirmOverviewState.title}+ message={confirmOverviewState.message}+ confirmText={confirmOverviewState.confirmText}+ cancelText={confirmOverviewState.cancelText}+ variant={confirmOverviewState.variant}+ onConfirm={handleOverviewConfirm}+ onCancel={handleOverviewCancel}+ /></div>);};@@ -847,6 +861,7 @@ const CommandsTab = ({ appId, appType }) => {const BuildTab = ({ appId, appPath }) => {const toast = useToast();+ const { confirm: confirmBuild, confirmState: confirmBuildState, handleConfirm: handleBuildConfirm, handleCancel: handleBuildCancel } = useConfirm();const [buildConfig, setBuildConfig] = useState(null);const [detection, setDetection] = useState(null);const [deployments, setDeployments] = useState([]);@@ -965,10 +980,11 @@ const BuildTab = ({ appId, appPath }) => {}async function handleRollback(version = null) {- if (!confirm(version+ const rollbackMsg = version? `Rollback to version ${version}? This will replace the current deployment.`- : 'Rollback to previous deployment?'- )) return;+ : 'Rollback to previous deployment?';+ const confirmed = await confirmBuild({ title: 'Rollback', message: rollbackMsg, variant: 'warning' });+ if (!confirmed) return;setDeploying(true);setError(null);@@ -1182,6 +1198,16 @@ const BuildTab = ({ appId, appPath }) => {</div></div>)}+ <ConfirmDialog+ isOpen={confirmBuildState.isOpen}+ title={confirmBuildState.title}+ message={confirmBuildState.message}+ confirmText={confirmBuildState.confirmText}+ cancelText={confirmBuildState.cancelText}+ variant={confirmBuildState.variant}+ onConfirm={handleBuildConfirm}+ onCancel={handleBuildCancel}+ /></div>);};@@ -1254,6 +1280,7 @@ const LogsTab = ({ app }) => {const SettingsTab = ({ app, onUpdate }) => {const navigate = useNavigate();+ const { confirm: confirmAppSettings, confirmState: confirmAppSettingsState, handleConfirm: handleAppSettingsConfirm, handleCancel: handleAppSettingsCancel } = useConfirm();const [deleting, setDeleting] = useState(false);const [environmentType, setEnvironmentType] = useState(app.environment_type || 'standalone');const [savingEnvironment, setSavingEnvironment] = useState(false);@@ -1267,8 +1294,10 @@ const SettingsTab = ({ app, onUpdate }) => {};async function handleDelete() {- if (!confirm(`Delete ${app.name}? This action cannot be undone.`)) return;- if (!confirm('Are you sure? Type "delete" to confirm.')) return;+ const firstConfirm = await confirmAppSettings({ title: 'Delete Application', message: `Delete ${app.name}? This action cannot be undone.` });+ if (!firstConfirm) return;+ const secondConfirm = await confirmAppSettings({ title: 'Confirm Deletion', message: 'Are you sure? This will permanently delete the application and all its data.' });+ if (!secondConfirm) return;setDeleting(true);try {@@ -1297,7 +1326,8 @@ const SettingsTab = ({ app, onUpdate }) => {}async function handleUnlink() {- if (!confirm(`Unlink ${app.name} from its linked application? Both apps will become standalone.`)) return;+ const confirmed = await confirmAppSettings({ title: 'Unlink Application', message: `Unlink ${app.name} from its linked application? Both apps will become standalone.`, variant: 'warning' });+ if (!confirmed) return;setUnlinking(true);try {@@ -1379,12 +1409,23 @@ const SettingsTab = ({ app, onUpdate }) => {{deleting ? 'Deleting...' : 'Delete Application'}</button></div>+ <ConfirmDialog+ isOpen={confirmAppSettingsState.isOpen}+ title={confirmAppSettingsState.title}+ message={confirmAppSettingsState.message}+ confirmText={confirmAppSettingsState.confirmText}+ cancelText={confirmAppSettingsState.cancelText}+ variant={confirmAppSettingsState.variant}+ onConfirm={handleAppSettingsConfirm}+ onCancel={handleAppSettingsCancel}+ /></div>);};const DeployTab = ({ appId, appPath }) => {const toast = useToast();+ const { confirm: confirmDeploy, confirmState: confirmDeployState, handleConfirm: handleDeployConfirm, handleCancel: handleDeployCancel } = useConfirm();const [config, setConfig] = useState(null);const [gitStatus, setGitStatus] = useState(null);const [history, setHistory] = useState([]);@@ -1459,7 +1500,8 @@ const DeployTab = ({ appId, appPath }) => {}async function handleRemoveDeployment() {- if (!confirm('Remove deployment configuration? This will not delete the repository files.')) return;+ const confirmed = await confirmDeploy({ title: 'Remove Deployment', message: 'Remove deployment configuration? This will not delete the repository files.', variant: 'warning' });+ if (!confirmed) return;try {await api.removeDeployment(appId);setConfig(null);@@ -1686,6 +1728,16 @@ const DeployTab = ({ appId, appPath }) => {</div></div>)}+ <ConfirmDialog+ isOpen={confirmDeployState.isOpen}+ title={confirmDeployState.title}+ message={confirmDeployState.message}+ confirmText={confirmDeployState.confirmText}+ cancelText={confirmDeployState.cancelText}+ variant={confirmDeployState.variant}+ onConfirm={handleDeployConfirm}+ onCancel={handleDeployCancel}+ /></div>);};diff --git a/frontend/src/pages/Applications.jsx b/frontend/src/pages/Applications.jsxindex 0e96feae..7a3f3a8d 100644--- a/frontend/src/pages/Applications.jsx+++ b/frontend/src/pages/Applications.jsx@@ -3,10 +3,13 @@ import { useNavigate } from 'react-router-dom';import { Plus, X, Container, Globe, Package, FileText, RefreshCw, Square, Play, Settings, Trash2, AlertTriangle } from 'lucide-react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';const Applications = () => {const navigate = useNavigate();const toast = useToast();+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();const [apps, setApps] = useState([]);const [appStats, setAppStats] = useState({});const [loading, setLoading] = useState(true);@@ -98,7 +101,8 @@ const Applications = () => {await api.restartApp(appId);toast.success('Application restarted');} else if (action === 'delete') {- if (!confirm('Delete this application? This action cannot be undone.')) return;+ const deleteConfirmed = await confirm({ title: 'Delete Application', message: 'Delete this application? This action cannot be undone.' });+ if (!deleteConfirmed) return;await api.deleteApp(appId);toast.success('Application deleted');}@@ -218,7 +222,7 @@ const Applications = () => {<th>Status</th><th>Domain</th><th>Resources</th>- <th style={{ textAlign: 'right' }}>Actions</th>+ <th className="text-right">Actions</th></tr></thead><tbody>@@ -236,7 +240,7 @@ const Applications = () => {</td><td><span className="docker-image-tag" style={{ borderLeft: `3px solid ${getStackColor(app.app_type)}` }}>- {app.app_type === 'docker' && <Container size={12} style={{ marginRight: 4 }} />}+ {app.app_type === 'docker' && <Container size={12} className="mr-1" />}{app.app_type.toUpperCase()}</span></td>@@ -254,13 +258,13 @@ const Applications = () => {{app.domains && app.domains.length > 0 ? (app.domains.map((d, i) => (<span key={i}>- <Globe size={12} style={{ marginRight: 4, verticalAlign: 'middle' }} />+ <Globe size={12} className="mr-1 align-middle" />{d.name}{i < app.domains.length - 1 && <br />}</span>))) : (- <span style={{ color: 'var(--text-tertiary)' }}>-</span>+ <span className="text-gray-400">-</span>)}</span></td>@@ -324,6 +328,16 @@ const Applications = () => {onClose={() => setSelectedApp(null)}/>)}+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ /></div>);};@@ -446,12 +460,11 @@ const AppLogsModal = ({ app, onClose }) => {</div><div className="modal-body">{app.app_type !== 'docker' && (- <div style={{ marginBottom: '1rem' }}>+ <div className="mb-4"><selectvalue={logType}onChange={(e) => setLogType(e.target.value)}- className="docker-search"- style={{ width: 'auto' }}+ className="docker-search w-auto"><option value="access">Access Logs</option><option value="error">Error Logs</option>diff --git a/frontend/src/pages/Backups.jsx b/frontend/src/pages/Backups.jsxindex b8f09559..b93b03f1 100644--- a/frontend/src/pages/Backups.jsx+++ b/frontend/src/pages/Backups.jsx@@ -3,11 +3,14 @@ import useTabParam from '../hooks/useTabParam';import { Upload, Download, Check, AlertTriangle, Clock, Database, Package, FolderArchive, HardDrive, Cloud, CloudOff, RefreshCw, Trash2, Plus, Settings, CheckCircle, XCircle, Server, FileArchive } from 'lucide-react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';const VALID_TABS = ['backups', 'schedules', 'storage', 'settings'];const Backups = () => {const toast = useToast();+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();const [backups, setBackups] = useState([]);const [stats, setStats] = useState(null);const [schedules, setSchedules] = useState([]);@@ -146,7 +149,8 @@ const Backups = () => {};const handleDeleteBackup = async (backupPath) => {- if (!window.confirm('Are you sure you want to delete this backup?')) return;+ const confirmed = await confirm({ title: 'Delete Backup', message: 'Are you sure you want to delete this backup?' });+ if (!confirmed) return;try {await api.deleteBackup(backupPath);toast.success('Backup deleted');@@ -171,7 +175,8 @@ const Backups = () => {const handleRestore = async () => {if (!selectedBackup) return;- if (!window.confirm('Are you sure you want to restore this backup? This may overwrite existing data.')) return;+ const restoreConfirmed = await confirm({ title: 'Restore Backup', message: 'Are you sure you want to restore this backup? This may overwrite existing data.', variant: 'warning' });+ if (!restoreConfirmed) return;try {if (selectedBackup.type === 'application') {@@ -222,7 +227,8 @@ const Backups = () => {};const handleRemoveSchedule = async (scheduleId) => {- if (!window.confirm('Are you sure you want to remove this schedule?')) return;+ const confirmed = await confirm({ title: 'Remove Schedule', message: 'Are you sure you want to remove this schedule?' });+ if (!confirmed) return;try {await api.removeBackupSchedule(scheduleId);toast.success('Schedule removed');@@ -271,7 +277,8 @@ const Backups = () => {};const handleCleanup = async () => {- if (!window.confirm(`This will delete backups older than ${configForm.retention_days} days. Continue?`)) return;+ const confirmed = await confirm({ title: 'Cleanup Backups', message: `This will delete backups older than ${configForm.retention_days} days. Continue?`, variant: 'warning' });+ if (!confirmed) return;try {const result = await api.cleanupBackups(configForm.retention_days);toast.success(result.message);@@ -1161,6 +1168,16 @@ const Backups = () => {</div></div>)}+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ /></div>);};diff --git a/frontend/src/pages/CronJobs.jsx b/frontend/src/pages/CronJobs.jsxindex 037b9f11..9cf2f375 100644--- a/frontend/src/pages/CronJobs.jsx+++ b/frontend/src/pages/CronJobs.jsx@@ -1,9 +1,12 @@import React, { useState, useEffect } from 'react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';const CronJobs = () => {const toast = useToast();+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();const [status, setStatus] = useState(null);const [jobs, setJobs] = useState([]);const [presets, setPresets] = useState({});@@ -105,7 +108,8 @@ const CronJobs = () => {};const handleDeleteJob = async (jobId) => {- if (!window.confirm('Are you sure you want to delete this cron job?')) return;+ const confirmed = await confirm({ title: 'Delete Cron Job', message: 'Are you sure you want to delete this cron job?' });+ if (!confirmed) return;try {await api.deleteCronJob(jobId);toast.success('Cron job deleted');@@ -521,6 +525,16 @@ const CronJobs = () => {</div></div>)}+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ /></div>);};diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsxindex 7124167f..38341812 100644--- a/frontend/src/pages/Dashboard.jsx+++ b/frontend/src/pages/Dashboard.jsx@@ -303,7 +303,7 @@ const Dashboard = () => {<span><RotateCcw size={14} /></span></button>- <h3 className="spec-panel-title" style={{ marginTop: '1.5rem' }}>Hardware Specs</h3>+ <h3 className="spec-panel-title mt-6">Hardware Specs</h3><div className="spec-row"><span className="spec-label">Processor</span><span className="spec-data">{systemInfo?.cpu?.model || 'N/A'}</span>@@ -339,13 +339,13 @@ const Dashboard = () => {<tbody>{apps.length === 0 ? (<tr>- <td colSpan="5" style={{ textAlign: 'center', color: 'var(--text-tertiary)' }}>+ <td colSpan="5" className="text-center text-gray-400">No applications found</td></tr>) : (apps.slice(0, 6).map(app => (- <tr key={app.id} onClick={() => navigate(`/apps/${app.id}`)} style={{ cursor: 'pointer' }}>+ <tr key={app.id} onClick={() => navigate(`/apps/${app.id}`)} className="cursor-pointer"><td>{app.id}</td><td><div className="app-name-cell">diff --git a/frontend/src/pages/Databases.jsx b/frontend/src/pages/Databases.jsxindex 7b089d64..b8d2ac69 100644--- a/frontend/src/pages/Databases.jsx+++ b/frontend/src/pages/Databases.jsx@@ -3,6 +3,8 @@ import { useParams } from 'react-router-dom';import useTabParam from '../hooks/useTabParam';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';import QueryRunner from '../components/QueryRunner';const VALID_TABS = ['mysql', 'postgresql', 'docker', 'backups', 'sqlite'];@@ -104,6 +106,7 @@ const Databases = () => {const MySQLTab = ({ status }) => {const toast = useToast();+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();const [databases, setDatabases] = useState([]);const [users, setUsers] = useState([]);const [loading, setLoading] = useState(true);@@ -138,7 +141,8 @@ const MySQLTab = ({ status }) => {}async function handleDropDatabase(name) {- if (!confirm(`Drop database "${name}"? This cannot be undone!`)) return;+ const confirmed = await confirm({ title: 'Drop Database', message: `Drop database "${name}"? This cannot be undone!` });+ if (!confirmed) return;try {await api.dropMySQLDatabase(name);@@ -163,7 +167,8 @@ const MySQLTab = ({ status }) => {}async function handleDropUser(username, host) {- if (!confirm(`Drop user "${username}"@"${host}"?`)) return;+ const confirmed = await confirm({ title: 'Drop User', message: `Drop user "${username}"@"${host}"?` });+ if (!confirmed) return;try {await api.dropMySQLUser(username, host);@@ -349,12 +354,23 @@ const MySQLTab = ({ status }) => {onClose={() => setQueryDb(null)}/>)}+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ /></div>);};const PostgreSQLTab = ({ status }) => {const toast = useToast();+ const { confirm: confirmPg, confirmState: confirmPgState, handleConfirm: handlePgConfirm, handleCancel: handlePgCancel } = useConfirm();const [databases, setDatabases] = useState([]);const [users, setUsers] = useState([]);const [loading, setLoading] = useState(true);@@ -389,7 +405,8 @@ const PostgreSQLTab = ({ status }) => {}async function handleDropDatabase(name) {- if (!confirm(`Drop database "${name}"? This cannot be undone!`)) return;+ const confirmed = await confirmPg({ title: 'Drop Database', message: `Drop database "${name}"? This cannot be undone!` });+ if (!confirmed) return;try {await api.dropPostgreSQLDatabase(name);@@ -414,7 +431,8 @@ const PostgreSQLTab = ({ status }) => {}async function handleDropUser(username) {- if (!confirm(`Drop user "${username}"?`)) return;+ const confirmed = await confirmPg({ title: 'Drop User', message: `Drop user "${username}"?` });+ if (!confirmed) return;try {await api.dropPostgreSQLUser(username);@@ -600,11 +618,22 @@ const PostgreSQLTab = ({ status }) => {onClose={() => setQueryDb(null)}/>)}+ <ConfirmDialog+ isOpen={confirmPgState.isOpen}+ title={confirmPgState.title}+ message={confirmPgState.message}+ confirmText={confirmPgState.confirmText}+ cancelText={confirmPgState.cancelText}+ variant={confirmPgState.variant}+ onConfirm={handlePgConfirm}+ onCancel={handlePgCancel}+ /></div>);};const BackupsTab = () => {+ const { confirm: confirmBackup, confirmState: confirmBackupState, handleConfirm: handleBackupConfirm, handleCancel: handleBackupCancel } = useConfirm();const [backups, setBackups] = useState([]);const [loading, setLoading] = useState(true);const [filter, setFilter] = useState('all');@@ -627,7 +656,8 @@ const BackupsTab = () => {}async function handleDelete(filename) {- if (!confirm('Delete this backup?')) return;+ const confirmed = await confirmBackup({ title: 'Delete Backup', message: 'Delete this backup?' });+ if (!confirmed) return;try {await api.deleteDatabaseBackup(filename);@@ -707,6 +737,16 @@ const BackupsTab = () => {))}</div>)}+ <ConfirmDialog+ isOpen={confirmBackupState.isOpen}+ title={confirmBackupState.title}+ message={confirmBackupState.message}+ confirmText={confirmBackupState.confirmText}+ cancelText={confirmBackupState.cancelText}+ variant={confirmBackupState.variant}+ onConfirm={handleBackupConfirm}+ onCancel={handleBackupCancel}+ /></div>);};diff --git a/frontend/src/pages/Docker.jsx b/frontend/src/pages/Docker.jsxindex 3b7c3533..cd7c601a 100644--- a/frontend/src/pages/Docker.jsx+++ b/frontend/src/pages/Docker.jsx@@ -2,6 +2,8 @@ import React, { useState, useEffect, useCallback, createContext, useContext } frimport useTabParam from '../hooks/useTabParam';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';// Server context for Docker operationsconst ServerContext = createContext({ serverId: 'local', serverName: 'Local' });@@ -354,9 +356,11 @@ const CreateVolumeButton = () => {const PruneButton = ({ onPruned }) => {const toast = useToast();const [loading, setLoading] = useState(false);+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();async function handlePrune() {- if (!confirm('Remove unused Docker resources? This will remove:\n- Stopped containers\n- Unused images\n- Unused networks')) return;+ const confirmed = await confirm({ title: 'Docker Cleanup', message: 'Remove unused Docker resources? This will remove stopped containers, unused images, and unused networks.' });+ if (!confirmed) return;setLoading(true);try {@@ -371,9 +375,21 @@ const PruneButton = ({ onPruned }) => {}return (- <button className="btn btn-secondary btn-sm" onClick={handlePrune} disabled={loading}>- {loading ? 'Cleaning...' : 'Prune Unused'}- </button>+ <>+ <button className="btn btn-secondary btn-sm" onClick={handlePrune} disabled={loading}>+ {loading ? 'Cleaning...' : 'Prune Unused'}+ </button>+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ />+ </>);};@@ -455,6 +471,7 @@ const TrashIcon = () => (const ContainersTab = ({ onStatsChange }) => {const toast = useToast();const { serverId, isRemote } = useServer();+ const { confirm: confirmContainer, confirmState: confirmContainerState, handleConfirm: handleContainerConfirm, handleCancel: handleContainerCancel } = useConfirm();const [containers, setContainers] = useState([]);const [containerStats, setContainerStats] = useState({});const [loading, setLoading] = useState(true);@@ -534,7 +551,8 @@ const ContainersTab = ({ onStatsChange }) => {}toast.success('Container restarted');} else if (action === 'remove') {- if (!confirm('Remove this container?')) return;+ const removeConfirmed = await confirmContainer({ title: 'Remove Container', message: 'Remove this container?' });+ if (!removeConfirmed) return;if (isRemote) {await api.removeRemoteContainer(serverId, containerId, true);} else {@@ -617,7 +635,7 @@ const ContainersTab = ({ onStatsChange }) => {<th>Status</th><th>Bindings</th><th>Resources</th>- <th style={{ textAlign: 'right' }}>Actions</th>+ <th className="text-right">Actions</th></tr></thead><tbody>@@ -711,6 +729,16 @@ const ContainersTab = ({ onStatsChange }) => {onClose={() => setExecContainer(null)}/>)}+ <ConfirmDialog+ isOpen={confirmContainerState.isOpen}+ title={confirmContainerState.title}+ message={confirmContainerState.message}+ confirmText={confirmContainerState.confirmText}+ cancelText={confirmContainerState.cancelText}+ variant={confirmContainerState.variant}+ onConfirm={handleContainerConfirm}+ onCancel={handleContainerCancel}+ /></div>);};@@ -719,6 +747,7 @@ const ContainersTab = ({ onStatsChange }) => {const ImagesTab = ({ onStatsChange }) => {const toast = useToast();const { serverId, isRemote } = useServer();+ const { confirm: confirmImage, confirmState: confirmImageState, handleConfirm: handleImageConfirm, handleCancel: handleImageCancel } = useConfirm();const [images, setImages] = useState([]);const [loading, setLoading] = useState(true);const [searchTerm, setSearchTerm] = useState('');@@ -746,7 +775,8 @@ const ImagesTab = ({ onStatsChange }) => {}async function handleRemove(imageId) {- if (!confirm('Remove this image?')) return;+ const confirmed = await confirmImage({ title: 'Remove Image', message: 'Remove this image?' });+ if (!confirmed) return;try {if (isRemote) {@@ -802,7 +832,7 @@ const ImagesTab = ({ onStatsChange }) => {<th>Image ID</th><th>Size</th><th>Created</th>- <th style={{ textAlign: 'right' }}>Actions</th>+ <th className="text-right">Actions</th></tr></thead><tbody>@@ -829,6 +859,16 @@ const ImagesTab = ({ onStatsChange }) => {</tbody></table>)}+ <ConfirmDialog+ isOpen={confirmImageState.isOpen}+ title={confirmImageState.title}+ message={confirmImageState.message}+ confirmText={confirmImageState.confirmText}+ cancelText={confirmImageState.cancelText}+ variant={confirmImageState.variant}+ onConfirm={handleImageConfirm}+ onCancel={handleImageCancel}+ /></div>);};@@ -837,6 +877,7 @@ const ImagesTab = ({ onStatsChange }) => {const NetworksTab = ({ onStatsChange }) => {const toast = useToast();const { serverId, isRemote } = useServer();+ const { confirm: confirmNetwork, confirmState: confirmNetworkState, handleConfirm: handleNetworkConfirm, handleCancel: handleNetworkCancel } = useConfirm();const [networks, setNetworks] = useState([]);const [loading, setLoading] = useState(true);@@ -863,7 +904,8 @@ const NetworksTab = ({ onStatsChange }) => {}async function handleRemove(networkId) {- if (!confirm('Remove this network?')) return;+ const confirmed = await confirmNetwork({ title: 'Remove Network', message: 'Remove this network?' });+ if (!confirmed) return;try {await api.removeNetwork(networkId);@@ -897,7 +939,7 @@ const NetworksTab = ({ onStatsChange }) => {<th>Network ID</th><th>Driver</th><th>Scope</th>- <th style={{ textAlign: 'right' }}>Actions</th>+ <th className="text-right">Actions</th></tr></thead><tbody>@@ -923,6 +965,16 @@ const NetworksTab = ({ onStatsChange }) => {</tbody></table>)}+ <ConfirmDialog+ isOpen={confirmNetworkState.isOpen}+ title={confirmNetworkState.title}+ message={confirmNetworkState.message}+ confirmText={confirmNetworkState.confirmText}+ cancelText={confirmNetworkState.cancelText}+ variant={confirmNetworkState.variant}+ onConfirm={handleNetworkConfirm}+ onCancel={handleNetworkCancel}+ /></div>);};@@ -931,6 +983,7 @@ const NetworksTab = ({ onStatsChange }) => {const VolumesTab = ({ onStatsChange }) => {const toast = useToast();const { serverId, isRemote } = useServer();+ const { confirm: confirmVolume, confirmState: confirmVolumeState, handleConfirm: handleVolumeConfirm, handleCancel: handleVolumeCancel } = useConfirm();const [volumes, setVolumes] = useState([]);const [loading, setLoading] = useState(true);@@ -957,7 +1010,8 @@ const VolumesTab = ({ onStatsChange }) => {}async function handleRemove(volumeName) {- if (!confirm('Remove this volume? All data will be lost.')) return;+ const confirmed = await confirmVolume({ title: 'Remove Volume', message: 'Remove this volume? All data will be lost.' });+ if (!confirmed) return;try {await api.removeVolume(volumeName, true);@@ -988,7 +1042,7 @@ const VolumesTab = ({ onStatsChange }) => {<th>Name</th><th>Driver</th><th>Mountpoint</th>- <th style={{ textAlign: 'right' }}>Actions</th>+ <th className="text-right">Actions</th></tr></thead><tbody>@@ -999,7 +1053,7 @@ const VolumesTab = ({ onStatsChange }) => {</td><td>{volume.driver}</td><td>- <span className="docker-container-id" style={{ maxWidth: '300px', display: 'inline-block', overflow: 'hidden', textOverflow: 'ellipsis' }}>+ <span className="docker-container-id truncate inline-block" style={{ maxWidth: '300px' }}>{volume.mountpoint || '-'}</span></td>@@ -1013,6 +1067,16 @@ const VolumesTab = ({ onStatsChange }) => {</tbody></table>)}+ <ConfirmDialog+ isOpen={confirmVolumeState.isOpen}+ title={confirmVolumeState.title}+ message={confirmVolumeState.message}+ confirmText={confirmVolumeState.confirmText}+ cancelText={confirmVolumeState.cancelText}+ variant={confirmVolumeState.variant}+ onConfirm={handleVolumeConfirm}+ onCancel={handleVolumeCancel}+ /></div>);};@@ -1021,6 +1085,7 @@ const VolumesTab = ({ onStatsChange }) => {const ComposeTab = ({ onStatsChange }) => {const toast = useToast();const { serverId, isRemote } = useServer();+ const { confirm: confirmCompose, confirmState: confirmComposeState, handleConfirm: handleComposeConfirm, handleCancel: handleComposeCancel } = useConfirm();const [projects, setProjects] = useState([]);const [loading, setLoading] = useState(true);const [selectedProject, setSelectedProject] = useState(null);@@ -1068,7 +1133,8 @@ const ComposeTab = ({ onStatsChange }) => {}toast.success('Project started');} else if (action === 'down') {- if (!confirm('Stop this compose project? Containers will be removed.')) {+ const downConfirmed = await confirmCompose({ title: 'Stop Compose Project', message: 'Stop this compose project? Containers will be removed.' });+ if (!downConfirmed) {setActionLoading(prev => ({ ...prev, [project.Name || project.name]: false }));return;}@@ -1146,7 +1212,7 @@ const ComposeTab = ({ onStatsChange }) => {<th>Project</th><th>Status</th><th>Config File</th>- <th style={{ textAlign: 'right' }}>Actions</th>+ <th className="text-right">Actions</th></tr></thead><tbody>@@ -1171,7 +1237,7 @@ const ComposeTab = ({ onStatsChange }) => {<div className="docker-status-detail">{status}</div></td><td>- <span className="docker-container-id" style={{ maxWidth: '300px', display: 'inline-block', overflow: 'hidden', textOverflow: 'ellipsis' }}>+ <span className="docker-container-id truncate inline-block" style={{ maxWidth: '300px' }}>{configFiles}</span></td>@@ -1232,6 +1298,16 @@ const ComposeTab = ({ onStatsChange }) => {onClose={() => setLogsProject(null)}/>)}+ <ConfirmDialog+ isOpen={confirmComposeState.isOpen}+ title={confirmComposeState.title}+ message={confirmComposeState.message}+ confirmText={confirmComposeState.confirmText}+ cancelText={confirmComposeState.cancelText}+ variant={confirmComposeState.variant}+ onConfirm={handleComposeConfirm}+ onCancel={handleComposeCancel}+ /></div>);};@@ -1309,12 +1385,12 @@ const ComposeLogsModal = ({ project, onClose }) => {<button className="modal-close" onClick={onClose}>×</button></div><div className="modal-body">- <div className="logs-controls" style={{ marginBottom: '10px', display: 'flex', gap: '10px', alignItems: 'center', flexWrap: 'wrap' }}>+ <div className="logs-controls flex flex-wrap items-center gap-2 mb-2"><label>Service:</label><selectvalue={selectedService}onChange={(e) => setSelectedService(e.target.value)}- style={{ padding: '4px 8px' }}+ className="py-2 px-2"><option value="">All Services</option>{services.map(service => (@@ -1322,7 +1398,7 @@ const ComposeLogsModal = ({ project, onClose }) => {))}</select><label>Lines:</label>- <select value={tail} onChange={(e) => setTail(Number(e.target.value))} style={{ padding: '4px 8px' }}>+ <select value={tail} onChange={(e) => setTail(Number(e.target.value))} className="py-2 px-2"><option value={50}>50</option><option value={100}>100</option><option value={200}>200</option>@@ -1505,9 +1581,9 @@ const ContainerLogsModal = ({ container, onClose }) => {<button className="modal-close" onClick={onClose}>×</button></div><div className="modal-body">- <div className="logs-controls" style={{ marginBottom: '10px', display: 'flex', gap: '10px', alignItems: 'center' }}>+ <div className="logs-controls flex items-center gap-2 mb-2"><label>Lines:</label>- <select value={tail} onChange={(e) => setTail(Number(e.target.value))} style={{ padding: '4px 8px' }}>+ <select value={tail} onChange={(e) => setTail(Number(e.target.value))} className="py-2 px-2"><option value={50}>50</option><option value={100}>100</option><option value={200}>200</option>diff --git a/frontend/src/pages/Domains.jsx b/frontend/src/pages/Domains.jsxindex f8fe0c17..922a9ee6 100644--- a/frontend/src/pages/Domains.jsx+++ b/frontend/src/pages/Domains.jsx@@ -1,4 +1,4 @@-import React, { useState, useEffect } from 'react';+import React, { useState, useEffect, lazy, Suspense } from 'react';import {Globe, Plus, Shield, ShieldCheck, ShieldOff, RefreshCw,Trash2, ExternalLink, CheckCircle, XCircle, AlertTriangle,@@ -6,9 +6,21 @@ import {} from 'lucide-react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';+import useTabParam from '../hooks/useTabParam';+import { LoadingState } from '../components/Spinner';++const DNSZones = lazy(() => import('./DNSZones'));+const SSLCertificates = lazy(() => import('./SSLCertificates'));++const VALID_TABS = ['domains', 'dns', 'ssl'];+const TAB_LABELS = { domains: 'Domains', dns: 'DNS Zones', ssl: 'SSL Certificates' };const Domains = () => {+ const [activeTab, setActiveTab] = useTabParam('/domains', VALID_TABS);const toast = useToast();+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();const [domains, setDomains] = useState([]);const [apps, setApps] = useState([]);const [sslStatus, setSslStatus] = useState(null);@@ -74,7 +86,8 @@ const Domains = () => {}async function handleDeleteDomain(domain) {- if (!confirm(`Are you sure you want to delete ${domain.name}?`)) return;+ const confirmed = await confirm({ title: 'Delete Domain', message: `Are you sure you want to delete ${domain.name}?` });+ if (!confirmed) return;try {await api.deleteDomain(domain.id);@@ -103,7 +116,8 @@ const Domains = () => {}async function handleDisableSsl(domain) {- if (!confirm(`Disable SSL for ${domain.name}?`)) return;+ const confirmed = await confirm({ title: 'Disable SSL', message: `Disable SSL for ${domain.name}?`, variant: 'warning' });+ if (!confirmed) return;try {await api.disableSsl(domain.id);@@ -143,7 +157,7 @@ const Domains = () => {return app ? app.name : 'Unknown';}- if (loading) {+ if (loading && activeTab === 'domains') {return <div className="loading">Loading domains...</div>;}@@ -151,25 +165,48 @@ const Domains = () => {<div><header className="top-bar"><div>- <h1>Domains & SSL</h1>- <p className="subtitle">Manage your domains and SSL certificates</p>- </div>- <div className="top-bar-actions">- <button className="btn btn-secondary" onClick={loadData}>- <RefreshCw size={16} />- Refresh- </button>- <button className="btn btn-primary" onClick={() => setShowAddModal(true)}>- <Plus size={16} />- Add Domain- </button>+ <h1>Domains & Sites</h1>+ <p className="subtitle">Manage your domains, DNS zones, and SSL certificates</p></div>+ {activeTab === 'domains' && (+ <div className="top-bar-actions">+ <button className="btn btn-secondary" onClick={loadData}>+ <RefreshCw size={16} />+ Refresh+ </button>+ <button className="btn btn-primary" onClick={() => setShowAddModal(true)}>+ <Plus size={16} />+ Add Domain+ </button>+ </div>+ )}</header>+ <div className="tabs-nav tabs-nav-scrollable">+ {VALID_TABS.map(tab => (+ <button+ key={tab}+ className={`tab-btn ${activeTab === tab ? 'active' : ''}`}+ onClick={() => setActiveTab(tab)}+ >+ {TAB_LABELS[tab]}+ </button>+ ))}+ </div>++ {activeTab !== 'domains' && (+ <Suspense fallback={<LoadingState />}>+ {activeTab === 'dns' && <DNSZones />}+ {activeTab === 'ssl' && <SSLCertificates />}+ </Suspense>+ )}++ {activeTab === 'domains' && <>+{error && (<div className="error-banner">{error}- <button onClick={() => setError('')} style={{ float: 'right', background: 'none', border: 'none', cursor: 'pointer' }}>×</button>+ <button className="btn-dismiss" onClick={() => setError('')}>×</button></div>)}@@ -298,7 +335,7 @@ const Domains = () => {{/* SSL Certificates */}{sslStatus && sslStatus.certificates && sslStatus.certificates.length > 0 && (<>- <h2 className="section-title" style={{ marginTop: '40px' }}>SSL Certificates</h2>+ <h2 className="section-title mt-10">SSL Certificates</h2><div className="cert-list">{sslStatus.certificates.map((cert, index) => (<div key={index} className="cert-item">@@ -435,6 +472,17 @@ const Domains = () => {</div></div>)}+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ />+ </>}</div>);};diff --git a/frontend/src/pages/Email.jsx b/frontend/src/pages/Email.jsxindex d7fb8754..3759db82 100644--- a/frontend/src/pages/Email.jsx+++ b/frontend/src/pages/Email.jsx@@ -494,7 +494,7 @@ function Email() {<h2>Email Server Not Installed</h2><p>Install Postfix, Dovecot, OpenDKIM, and SpamAssassin to enable email hosting.</p><div className="install-form">- <div className="form-group" style={{ width: '100%' }}>+ <div className="form-group w-full"><label>Hostname (e.g. mail.example.com)</label><input type="text" value={installHostname} onChange={e => setInstallHostname(e.target.value)} placeholder="mail.example.com" /></div>@@ -926,7 +926,7 @@ function Email() {))}</div></div>- <div className="email-logs" style={{ marginTop: '2rem' }}>+ <div className="email-logs mt-8"><div className="section-header"><h2>Mail Logs</h2><div className="log-controls">diff --git a/frontend/src/pages/FileManager.jsx b/frontend/src/pages/FileManager.jsxindex ddcc68c7..9c7ec653 100644--- a/frontend/src/pages/FileManager.jsx+++ b/frontend/src/pages/FileManager.jsx@@ -1,8 +1,11 @@-import { useState, useEffect, useRef } from 'react';+import { useState, useEffect, useRef, lazy, Suspense } from 'react';import { api } from '../services/api';import { useToast } from '../contexts/ToastContext';-import Spinner from '../components/Spinner';+import Spinner, { LoadingState } from '../components/Spinner';import ConfirmDialog from '../components/ConfirmDialog';+import useTabParam from '../hooks/useTabParam';++const FTPServer = lazy(() => import('./FTPServer'));import {Folder, File, FileCode, FileText, FileImage, FileVideo, FileAudio,FileArchive, Database, Terminal, Upload, FolderPlus, FilePlus,@@ -16,7 +19,11 @@ import { PieChart as RechartsPie, Pie, Cell, ResponsiveContainer, Tooltip, Legenconst SIDEBAR_VISIBLE_KEY = 'serverkit-fm-sidebar';const DISK_COLLAPSED_KEY = 'serverkit-fm-disk-collapsed';+const FILE_TABS = ['files', 'ftp'];+const FILE_TAB_LABELS = { files: 'File Manager', ftp: 'FTP Server' };+function FileManager() {+ const [activeTab, setActiveTab] = useTabParam('/files', FILE_TABS);const [currentPath, setCurrentPath] = useState('/home');const [entries, setEntries] = useState([]);const [parentPath, setParentPath] = useState(null);@@ -326,6 +333,29 @@ function FileManager() {const displayedEntries = searchResults || entries;+ if (activeTab === 'ftp') {+ return (+ <div className="file-manager">+ <div className="page-header">+ <div className="page-header-content">+ <h1>File Manager</h1>+ <p className="page-description">Browse, edit, and manage your server files</p>+ </div>+ </div>+ <div className="tabs-nav">+ {FILE_TABS.map(tab => (+ <button key={tab} className={`tab-btn ${activeTab === tab ? 'active' : ''}`} onClick={() => setActiveTab(tab)}>+ {FILE_TAB_LABELS[tab]}+ </button>+ ))}+ </div>+ <Suspense fallback={<LoadingState />}>+ <FTPServer />+ </Suspense>+ </div>+ );+ }+return (<div className={`file-manager ${sidebarVisible ? 'sidebar-open' : ''}`}><div className="page-header">@@ -349,12 +379,20 @@ function FileManager() {<inputtype="file"ref={fileInputRef}- style={{ display: 'none' }}+ className="hidden"onChange={handleUpload}/></div></div>+ <div className="tabs-nav">+ {FILE_TABS.map(tab => (+ <button key={tab} className={`tab-btn ${activeTab === tab ? 'active' : ''}`} onClick={() => setActiveTab(tab)}>+ {FILE_TAB_LABELS[tab]}+ </button>+ ))}+ </div>+{uploadProgress !== null && (<div className="upload-progress"><div className="progress-bar">diff --git a/frontend/src/pages/SSLCertificates.jsx b/frontend/src/pages/SSLCertificates.jsxindex d422289c..ceb9e04a 100644--- a/frontend/src/pages/SSLCertificates.jsx+++ b/frontend/src/pages/SSLCertificates.jsx@@ -6,9 +6,12 @@ import {} from 'lucide-react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';const SSLCertificates = () => {const toast = useToast();+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();const [status, setStatus] = useState(null);const [loading, setLoading] = useState(true);const [actionLoading, setActionLoading] = useState(false);@@ -102,7 +105,8 @@ const SSLCertificates = () => {}async function handleRevokeCertificate(domain) {- if (!confirm(`Revoke and delete the certificate for ${domain}? This cannot be undone.`)) return;+ const confirmed = await confirm({ title: 'Revoke Certificate', message: `Revoke and delete the certificate for ${domain}? This cannot be undone.` });+ if (!confirmed) return;try {setActionLoading(true);@@ -178,7 +182,7 @@ const SSLCertificates = () => {{[1, 2].map(i => (<div key={i} className="ssl-cert-item"><div className="skeleton-box" style={{ width: 40, height: 40, borderRadius: 10 }} />- <div style={{ flex: 1 }}>+ <div className="flex-1"><div className="skeleton-box" style={{ width: 200, height: 14, marginBottom: 8 }} /><div className="skeleton-box" style={{ width: 300, height: 12 }} /></div>@@ -247,10 +251,9 @@ const SSLCertificates = () => {</div>{!certbotInstalled && (<button- className="btn btn-primary btn-sm"+ className="btn btn-primary btn-sm ml-auto"onClick={handleInstallCertbot}disabled={actionLoading}- style={{ marginLeft: 'auto' }}><Download size={14} />Install@@ -460,6 +463,16 @@ const SSLCertificates = () => {</div></div>)}+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ /></div>);};diff --git a/frontend/src/pages/ServerDetail.jsx b/frontend/src/pages/ServerDetail.jsxindex 60ecffb8..2ef1843a 100644--- a/frontend/src/pages/ServerDetail.jsx+++ b/frontend/src/pages/ServerDetail.jsx@@ -3,10 +3,13 @@ import { useParams, Link, useNavigate } from 'react-router-dom';import api from '../services/api';import { useToast } from '../contexts/ToastContext';import MetricsGraph from '../components/MetricsGraph';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';const ServerDetail = () => {const { id, tab } = useParams();const navigate = useNavigate();+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();const [server, setServer] = useState(null);const [metrics, setMetrics] = useState(null);const [systemInfo, setSystemInfo] = useState(null);@@ -68,7 +71,8 @@ const ServerDetail = () => {}, [server, loadMetrics, loadSystemInfo]);async function handleDeleteServer() {- if (!confirm('Are you sure you want to remove this server? This action cannot be undone.')) return;+ const confirmed = await confirm({ title: 'Remove Server', message: 'Are you sure you want to remove this server? This action cannot be undone.' });+ if (!confirmed) return;try {await api.deleteServer(id);@@ -94,7 +98,8 @@ const ServerDetail = () => {}async function handleRegenerateToken() {- if (!confirm('Generate a new registration token? The old token will be invalidated.')) return;+ const tokenConfirmed = await confirm({ title: 'Regenerate Token', message: 'Generate a new registration token? The old token will be invalidated.', variant: 'warning' });+ if (!tokenConfirmed) return;try {const result = await api.generateRegistrationToken(id);@@ -235,6 +240,16 @@ const ServerDetail = () => {onClose={() => setShowTokenModal(false)}/>)}+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ /></div>);};@@ -397,6 +412,7 @@ const DockerTab = ({ serverId, serverStatus }) => {const [loading, setLoading] = useState(true);const [subTab, setSubTab] = useState('containers');const toast = useToast();+ const { confirm: confirmDocker, confirmState: confirmDockerState, handleConfirm: handleDockerConfirm, handleCancel: handleDockerCancel } = useConfirm();useEffect(() => {if (serverStatus === 'online') {@@ -436,7 +452,8 @@ const DockerTab = ({ serverId, serverStatus }) => {result = await api.restartRemoteContainer(serverId, containerId);toast.success('Container restarted');} else if (action === 'remove') {- if (!confirm('Remove this container?')) return;+ const removeConfirmed = await confirmDocker({ title: 'Remove Container', message: 'Remove this container?' });+ if (!removeConfirmed) return;result = await api.removeRemoteContainer(serverId, containerId, true);toast.success('Container removed');}@@ -584,6 +601,16 @@ const DockerTab = ({ serverId, serverStatus }) => {)}</div>)}+ <ConfirmDialog+ isOpen={confirmDockerState.isOpen}+ title={confirmDockerState.title}+ message={confirmDockerState.message}+ confirmText={confirmDockerState.confirmText}+ cancelText={confirmDockerState.cancelText}+ variant={confirmDockerState.variant}+ onConfirm={handleDockerConfirm}+ onCancel={handleDockerCancel}+ /></div>);};@@ -714,6 +741,7 @@ Install-ServerKitAgent -Server "${window.location.origin}" -Token "${token}"` :};const SettingsTab = ({ server, onUpdate, onRegenerateToken, onDelete }) => {+ const { confirm: confirmSettings, confirmState: confirmSettingsState, handleConfirm: handleSettingsConfirm, handleCancel: handleSettingsCancel } = useConfirm();const [formData, setFormData] = useState({name: server.name || '',description: server.description || '',@@ -784,7 +812,8 @@ const SettingsTab = ({ server, onUpdate, onRegenerateToken, onDelete }) => {}async function handleRotateKey() {- if (!confirm('Rotate API credentials? The agent must be online to receive new credentials.')) return;+ const confirmed = await confirmSettings({ title: 'Rotate Credentials', message: 'Rotate API credentials? The agent must be online to receive new credentials.', variant: 'warning' });+ if (!confirmed) return;setRotatingKey(true);try {const result = await api.rotateAPIKey(server.id);@@ -1055,6 +1084,16 @@ const SettingsTab = ({ server, onUpdate, onRegenerateToken, onDelete }) => {<TrashIcon /> Remove Server</button></div>+ <ConfirmDialog+ isOpen={confirmSettingsState.isOpen}+ title={confirmSettingsState.title}+ message={confirmSettingsState.message}+ confirmText={confirmSettingsState.confirmText}+ cancelText={confirmSettingsState.cancelText}+ variant={confirmSettingsState.variant}+ onConfirm={handleSettingsConfirm}+ onCancel={handleSettingsCancel}+ /></div>);};diff --git a/frontend/src/pages/Servers.jsx b/frontend/src/pages/Servers.jsxindex 685baee5..77ca4e40 100644--- a/frontend/src/pages/Servers.jsx+++ b/frontend/src/pages/Servers.jsx@@ -1,9 +1,34 @@-import React, { useState, useEffect } from 'react';-import { Link } from 'react-router-dom';+import React, { useState, useEffect, lazy, Suspense } from 'react';+import { Link, useLocation, useNavigate } from 'react-router-dom';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';+import { LoadingState } from '../components/Spinner';++const AgentFleet = lazy(() => import('./AgentFleet'));+const FleetMonitor = lazy(() => import('./FleetMonitor'));+const CloudProvision = lazy(() => import('./CloudProvision'));+const AgentPlugins = lazy(() => import('./AgentPlugins'));+const ServerTemplates = lazy(() => import('./ServerTemplates'));++const SERVER_TABS = ['overview', 'fleet', 'monitor', 'cloud', 'plugins', 'config'];+const TAB_LABELS = {+ overview: 'Servers',+ fleet: 'Fleet',+ monitor: 'Monitor',+ cloud: 'Cloud',+ plugins: 'Plugins',+ config: 'Config'+};const Servers = () => {+ const location = useLocation();+ const navigate = useNavigate();+ const segment = location.pathname.split('/')[2];+ const activeTab = SERVER_TABS.includes(segment) ? segment : 'overview';+ const setActiveTab = (tab) => navigate(tab === 'overview' ? '/servers' : `/servers/${tab}`, { replace: true });+const [servers, setServers] = useState([]);const [groups, setGroups] = useState([]);const [loading, setLoading] = useState(true);@@ -64,7 +89,7 @@ const Servers = () => {connecting: servers.filter(s => s.status === 'connecting').length};- if (loading) {+ if (loading && activeTab === 'overview') {return <div className="loading">Loading servers...</div>;}@@ -75,18 +100,43 @@ const Servers = () => {<h1>Servers</h1><p className="page-description">Manage your connected servers and agents</p></div>- <div className="page-header-actions">- <button className="btn btn-secondary" onClick={() => setShowGroupModal(true)}>- <FolderIcon />- Manage Groups- </button>- <button className="btn btn-primary" onClick={() => setShowAddModal(true)}>- <PlusIcon />- Add Server+ {activeTab === 'overview' && (+ <div className="page-header-actions">+ <button className="btn btn-secondary" onClick={() => setShowGroupModal(true)}>+ <FolderIcon />+ Manage Groups+ </button>+ <button className="btn btn-primary" onClick={() => setShowAddModal(true)}>+ <PlusIcon />+ Add Server+ </button>+ </div>+ )}+ </div>++ <div className="tabs-nav tabs-nav-scrollable">+ {SERVER_TABS.map(tab => (+ <button+ key={tab}+ className={`tab-btn ${activeTab === tab ? 'active' : ''}`}+ onClick={() => setActiveTab(tab)}+ >+ {TAB_LABELS[tab]}</button>- </div>+ ))}</div>+ {activeTab !== 'overview' && (+ <Suspense fallback={<LoadingState />}>+ {activeTab === 'fleet' && <AgentFleet />}+ {activeTab === 'monitor' && <FleetMonitor />}+ {activeTab === 'cloud' && <CloudProvision />}+ {activeTab === 'plugins' && <AgentPlugins />}+ {activeTab === 'config' && <ServerTemplates />}+ </Suspense>+ )}++ {activeTab === 'overview' && <><div className="servers-stats"><div className="stat-card"><div className="stat-icon total">@@ -192,6 +242,7 @@ const Servers = () => {onUpdated={loadData}/>)}+ </>}</div>);};@@ -530,6 +581,7 @@ const ManageGroupsModal = ({ groups, onClose, onUpdated }) => {const [editingGroup, setEditingGroup] = useState(null);const [loading, setLoading] = useState(false);const toast = useToast();+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();async function handleCreateGroup(e) {e.preventDefault();@@ -564,7 +616,8 @@ const ManageGroupsModal = ({ groups, onClose, onUpdated }) => {}async function handleDeleteGroup(groupId) {- if (!confirm('Delete this group? Servers in this group will become ungrouped.')) return;+ const confirmed = await confirm({ title: 'Delete Group', message: 'Delete this group? Servers in this group will become ungrouped.' });+ if (!confirmed) return;try {await api.deleteServerGroup(groupId);@@ -649,6 +702,16 @@ const ManageGroupsModal = ({ groups, onClose, onUpdated }) => {<button className="btn btn-primary" onClick={onClose}>Done</button></div></div>+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ /></div>);};diff --git a/frontend/src/pages/ServiceDetail.jsx b/frontend/src/pages/ServiceDetail.jsxindex 24794741..3ec73f30 100644--- a/frontend/src/pages/ServiceDetail.jsx+++ b/frontend/src/pages/ServiceDetail.jsx@@ -1,6 +1,8 @@import React, { useState, useEffect, useRef } from 'react';import { useParams, useNavigate, Link } from 'react-router-dom';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';import { useService } from '../hooks/useService';import { getTabsForType } from '../utils/serviceTypes';import EnvironmentVariables from '../components/EnvironmentVariables';@@ -30,6 +32,7 @@ const ServiceDetail = () => {const { id } = useParams();const navigate = useNavigate();const toast = useToast();+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();const { service, deployConfig, loading, error, reload, performAction, deleteService } = useService(id);const [activeTab, setActiveTab] = useState('events');const [showDeployMenu, setShowDeployMenu] = useState(false);@@ -75,8 +78,10 @@ const ServiceDetail = () => {}async function handleDelete() {- if (!confirm(`Delete ${service.name}? This action cannot be undone.`)) return;- if (!confirm('Are you sure? This will permanently remove the service and all its data.')) return;+ const firstConfirm = await confirm({ title: 'Delete Service', message: `Delete ${service.name}? This action cannot be undone.` });+ if (!firstConfirm) return;+ const secondConfirm = await confirm({ title: 'Confirm Deletion', message: 'Are you sure? This will permanently remove the service and all its data.' });+ if (!secondConfirm) return;setActionLoading('delete');try {@@ -154,7 +159,7 @@ const ServiceDetail = () => {onClick={() => setShowDeployMenu(!showDeployMenu)}>Deploy- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" style={{ marginLeft: 4 }}>+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" className="ml-1"><polyline points="6 9 12 15 18 9"/></svg></button>@@ -334,6 +339,16 @@ const ServiceDetail = () => {}}/>)}+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ /></div>);};@@ -356,7 +371,7 @@ function ServiceIcon({ type }) {</svg>);default:- return <span style={{ fontSize: '16px', fontWeight: 'bold' }}>{type?.charAt(0).toUpperCase()}</span>;+ return <span className="text-lg font-bold">{type?.charAt(0).toUpperCase()}</span>;}}diff --git a/frontend/src/pages/Services.jsx b/frontend/src/pages/Services.jsxindex f4d42571..17999f9b 100644--- a/frontend/src/pages/Services.jsx+++ b/frontend/src/pages/Services.jsx@@ -263,7 +263,7 @@ function ServiceTypeIcon({ type }) {</svg>);case 'php':- return <span style={{ fontSize: '12px', fontWeight: 700 }}>PHP</span>;+ return <span className="text-xs font-bold">PHP</span>;case 'static':return (<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">@@ -278,7 +278,7 @@ function ServiceTypeIcon({ type }) {</svg>);default:- return <span style={{ fontSize: '12px', fontWeight: 700 }}>{type?.charAt(0).toUpperCase()}</span>;+ return <span className="text-xs font-bold">{type?.charAt(0).toUpperCase()}</span>;}}diff --git a/frontend/src/pages/Settings.jsx b/frontend/src/pages/Settings.jsxindex 97642cbd..de4d8edb 100644--- a/frontend/src/pages/Settings.jsx+++ b/frontend/src/pages/Settings.jsx@@ -1,30 +1,23 @@-import React, { useState, useEffect, useRef } from 'react';+import React, { useState, useEffect } from 'react';import useTabParam from '../hooks/useTabParam';import { useAuth } from '../contexts/AuthContext';-import { useTheme } from '../contexts/ThemeContext';-import useDashboardLayout from '../hooks/useDashboardLayout';import api from '../services/api';+import ProfileTab from '../components/settings/ProfileTab';+import SecuritySettingsTab from '../components/settings/SecuritySettingsTab';+import AppearanceTab from '../components/settings/AppearanceTab';+import SidebarSettings from '../components/settings/SidebarSettings';+import NotificationsTab from '../components/settings/NotificationsTab';+import SystemTab from '../components/settings/SystemTab';import UsersTab from '../components/settings/UsersTab';import AuditLogTab from '../components/settings/AuditLogTab';import ActivityTab from '../components/settings/ActivityTab';+import SiteSettingsTab from '../components/settings/SiteSettingsTab';import SSOConfigTab from '../components/settings/SSOConfigTab';-import MigrationHistoryTab from '../components/settings/MigrationHistoryTab';import ApiSettingsTab from '../components/settings/ApiSettingsTab';-import SidebarSettings from '../components/settings/SidebarSettings';-import SSOProviderIcon from '../components/SSOProviderIcon';-import {- Github, FileText, HelpCircle, MessageSquare, Bug, Check, Download, CheckCircle,- RefreshCw, ExternalLink, Star, X, Code, Search, Container, Globe, BarChart3,- Database, Shield, Cloud, Video, Music, Image, Home, Server, GitBranch, Workflow,- HardDrive, Lock, Users, Settings as SettingsIcon, Layers, ChevronDown, Copy, Tag,- Cpu, AlertTriangle, Info, Activity, Terminal, Play, Square, Trash2, Plus, Package,- ArrowRight, ArrowLeft, Eye, Save, Clock, Calendar, Edit3, Link, Unlink, Archive,- Radio, Zap, MemoryStick, Monitor, Sun, Moon, ChevronRight, ChevronUp, LogOut,- Loader, RotateCcw, FolderOpen, Layout, Palette, Camera, Newspaper, TrendingUp,- Sparkles, ArrowUpCircle, AlertCircle, XCircle, GitCompare, GitCommit, Rocket,- Minus, Unlock, ArrowDownLeft, ArrowUpRight, Upload, Type-} from 'lucide-react';-import ServerKitLogo from '../components/ServerKitLogo';+import MigrationHistoryTab from '../components/settings/MigrationHistoryTab';+import IconReferenceTab from '../components/settings/IconReferenceTab';+import AboutTab from '../components/settings/AboutTab';+import { Activity, Code, Database } from 'lucide-react';const VALID_TABS = ['profile', 'security', 'appearance', 'sidebar', 'notifications', 'system', 'users', 'audit', 'activity', 'site', 'sso', 'api', 'migrations', 'developer', 'about'];@@ -52,6 +45,7 @@ const Settings = () => {<div className="settings-layout"><nav className="settings-nav">+ <div className="settings-nav-divider">Account</div><buttonclassName={`settings-nav-item ${activeTab === 'profile' ? 'active' : ''}`}onClick={() => setActiveTab('profile')}@@ -72,6 +66,17 @@ const Settings = () => {</svg>Security</button>+ <button+ className={`settings-nav-item ${activeTab === 'notifications' ? 'active' : ''}`}+ onClick={() => setActiveTab('notifications')}+ >+ <svg viewBox="0 0 24 24" width="18" height="18">+ <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/>+ <path d="M13.73 21a2 2 0 0 1-3.46 0"/>+ </svg>+ Notifications+ </button>+ <div className="settings-nav-divider">Preferences</div><buttonclassName={`settings-nav-item ${activeTab === 'appearance' ? 'active' : ''}`}onClick={() => setActiveTab('appearance')}@@ -99,27 +104,6 @@ const Settings = () => {</svg>Sidebar</button>- <button- className={`settings-nav-item ${activeTab === 'notifications' ? 'active' : ''}`}- onClick={() => setActiveTab('notifications')}- >- <svg viewBox="0 0 24 24" width="18" height="18">- <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/>- <path d="M13.73 21a2 2 0 0 1-3.46 0"/>- </svg>- Notifications- </button>- <button- className={`settings-nav-item ${activeTab === 'system' ? 'active' : ''}`}- onClick={() => setActiveTab('system')}- >- <svg viewBox="0 0 24 24" width="18" height="18">- <rect x="2" y="3" width="20" height="14" rx="2" ry="2"/>- <line x1="8" y1="21" x2="16" y2="21"/>- <line x1="12" y1="17" x2="12" y2="21"/>- </svg>- System Info- </button>{isAdmin && (<><div className="settings-nav-divider">Admin</div>@@ -190,6 +174,17 @@ const Settings = () => {<Database size={18} />Migrations</button>+ <button+ className={`settings-nav-item ${activeTab === 'system' ? 'active' : ''}`}+ onClick={() => setActiveTab('system')}+ >+ <svg viewBox="0 0 24 24" width="18" height="18">+ <rect x="2" y="3" width="20" height="14" rx="2" ry="2"/>+ <line x1="8" y1="21" x2="16" y2="21"/>+ <line x1="12" y1="17" x2="12" y2="21"/>+ </svg>+ System Info+ </button></>)}{devMode && isAdmin && (@@ -204,6 +199,7 @@ const Settings = () => {</button></>)}+ <div className="settings-nav-spacer" /><buttonclassName={`settings-nav-item ${activeTab === 'about' ? 'active' : ''}`}onClick={() => setActiveTab('about')}@@ -218,2394 +214,25 @@ const Settings = () => {</nav><div className="settings-content">- {activeTab === 'profile' && <ProfileSettings />}- {activeTab === 'security' && <SecuritySettings />}- {activeTab === 'appearance' && <AppearanceSettings />}+ {activeTab === 'profile' && <ProfileTab />}+ {activeTab === 'security' && <SecuritySettingsTab />}+ {activeTab === 'appearance' && <AppearanceTab />}{activeTab === 'sidebar' && <SidebarSettings />}- {activeTab === 'notifications' && <NotificationSettings />}- {activeTab === 'system' && <SystemInfo />}+ {activeTab === 'notifications' && <NotificationsTab />}{activeTab === 'users' && isAdmin && <UsersTab />}{activeTab === 'audit' && isAdmin && <AuditLogTab />}{activeTab === 'activity' && isAdmin && <ActivityTab />}- {activeTab === 'site' && isAdmin && <SiteSettings onDevModeChange={setDevMode} />}+ {activeTab === 'site' && isAdmin && <SiteSettingsTab onDevModeChange={setDevMode} />}{activeTab === 'sso' && isAdmin && <SSOConfigTab />}{activeTab === 'api' && isAdmin && <ApiSettingsTab />}{activeTab === 'migrations' && isAdmin && <MigrationHistoryTab />}- {activeTab === 'developer' && devMode && isAdmin && <IconReference />}- {activeTab === 'about' && <AboutSection />}+ {activeTab === 'system' && isAdmin && <SystemTab />}+ {activeTab === 'developer' && devMode && isAdmin && <IconReferenceTab />}+ {activeTab === 'about' && <AboutTab />}</div></div></div>);};-const ProfileSettings = () => {- const { user, updateUser } = useAuth();- const [formData, setFormData] = useState({- username: '',- email: ''- });- const [loading, setLoading] = useState(false);- const [message, setMessage] = useState(null);-- useEffect(() => {- if (user) {- setFormData({- username: user.username || '',- email: user.email || ''- });- }- }, [user]);-- async function handleSubmit(e) {- e.preventDefault();- setLoading(true);- setMessage(null);-- try {- await updateUser(formData);- setMessage({ type: 'success', text: 'Profile updated successfully' });- } catch (err) {- setMessage({ type: 'error', text: err.message });- } finally {- setLoading(false);- }- }-- return (- <div className="settings-section">- <div className="section-header">- <h2>Profile Settings</h2>- <p>Update your personal information</p>- </div>-- {message && (- <div className={`alert alert-${message.type === 'success' ? 'success' : 'danger'}`}>- {message.text}- </div>- )}-- <form onSubmit={handleSubmit} className="settings-form">- <div className="form-group">- <label>Username</label>- <input- type="text"- value={formData.username}- onChange={(e) => setFormData({ ...formData, username: e.target.value })}- required- />- </div>-- <div className="form-group">- <label>Email Address</label>- <input- type="email"- value={formData.email}- onChange={(e) => setFormData({ ...formData, email: e.target.value })}- required- />- </div>-- <div className="form-group">- <label>Role</label>- <input type="text" value={user?.role || 'user'} disabled className="input-disabled" />- <span className="form-help">Contact an administrator to change your role</span>- </div>-- <div className="form-group">- <label>Member Since</label>- <input- type="text"- value={user?.created_at ? new Date(user.created_at).toLocaleDateString() : '-'}- disabled- className="input-disabled"- />- </div>-- <div className="form-actions">- <button type="submit" className="btn btn-primary" disabled={loading}>- {loading ? 'Saving...' : 'Save Changes'}- </button>- </div>- </form>- </div>- );-};--const LinkedAccounts = () => {- const { ssoProviders } = useAuth();- const [identities, setIdentities] = useState([]);- const [loading, setLoading] = useState(true);- const [unlinking, setUnlinking] = useState(null);- const [linkingProvider, setLinkingProvider] = useState(null);- const [error, setError] = useState('');-- useEffect(() => {- loadIdentities();- }, []);-- async function loadIdentities() {- try {- const data = await api.getSSOIdentities();- setIdentities(data.identities || []);- } catch (err) {- // SSO may not be configured; silently handle- } finally {- setLoading(false);- }- }-- async function handleUnlink(provider) {- setUnlinking(provider);- setError('');- try {- await api.unlinkSSOProvider(provider);- await loadIdentities();- } catch (err) {- setError(err.message);- } finally {- setUnlinking(null);- }- }-- async function handleLink(provider) {- setLinkingProvider(provider);- setError('');- try {- const redirectUri = `${window.location.origin}/login/callback/${provider}`;- const { auth_url } = await api.startSSOAuth(provider, redirectUri);- window.location.href = auth_url;- } catch (err) {- setError(err.message);- setLinkingProvider(null);- }- }-- // Only show if SSO is configured- if (loading || (!ssoProviders?.length && !identities.length)) {- return null;- }-- const linkedProviderIds = identities.map(i => i.provider);- const availableToLink = (ssoProviders || []).filter(p => !linkedProviderIds.includes(p.id));-- return (- <div className="settings-card">- <h3>Linked Accounts</h3>- <p className="text-secondary">Connect external identity providers to your account</p>-- {error && <div className="alert alert-danger">{error}</div>}-- {identities.length > 0 && (- <div className="linked-accounts-list">- {identities.map(identity => (- <div key={identity.id} className="linked-account">- <div className="linked-account__info">- <SSOProviderIcon provider={identity.provider} />- <div>- <span className="linked-account__provider">{identity.provider}</span>- <span className="linked-account__email">{identity.provider_email}</span>- </div>- </div>- <button- className="btn btn-sm btn-danger"- onClick={() => handleUnlink(identity.provider)}- disabled={unlinking === identity.provider}- >- {unlinking === identity.provider ? 'Unlinking...' : 'Unlink'}- </button>- </div>- ))}- </div>- )}-- {availableToLink.length > 0 && (- <div className="linked-accounts-available">- {availableToLink.map(p => (- <button- key={p.id}- className="btn btn-secondary btn-sm"- onClick={() => handleLink(p.id)}- disabled={linkingProvider === p.id}- >- <SSOProviderIcon provider={p.id} />- {linkingProvider === p.id ? 'Redirecting...' : `Link ${p.name}`}- </button>- ))}- </div>- )}- </div>- );-};--const SecuritySettings = () => {- const { updateUser, user } = useAuth();- const [formData, setFormData] = useState({- currentPassword: '',- newPassword: '',- confirmPassword: ''- });- const [loading, setLoading] = useState(false);- const [message, setMessage] = useState(null);-- // 2FA state- const [twoFAStatus, setTwoFAStatus] = useState(null);- const [twoFALoading, setTwoFALoading] = useState(true);- const [showSetupModal, setShowSetupModal] = useState(false);- const [showDisableModal, setShowDisableModal] = useState(false);- const [showBackupCodesModal, setShowBackupCodesModal] = useState(false);- const [setupData, setSetupData] = useState(null);- const [verificationCode, setVerificationCode] = useState('');- const [backupCodes, setBackupCodes] = useState([]);- const [twoFAError, setTwoFAError] = useState('');-- useEffect(() => {- load2FAStatus();- }, []);-- async function load2FAStatus() {- try {- const status = await api.get2FAStatus();- setTwoFAStatus(status);- } catch (err) {- console.error('Failed to load 2FA status:', err);- } finally {- setTwoFALoading(false);- }- }-- async function handleSubmit(e) {- e.preventDefault();- setMessage(null);-- if (formData.newPassword !== formData.confirmPassword) {- setMessage({ type: 'error', text: 'Passwords do not match' });- return;- }-- if (formData.newPassword.length < 8) {- setMessage({ type: 'error', text: 'Password must be at least 8 characters' });- return;- }-- setLoading(true);-- try {- await updateUser({ password: formData.newPassword });- setMessage({ type: 'success', text: 'Password changed successfully' });- setFormData({ currentPassword: '', newPassword: '', confirmPassword: '' });- } catch (err) {- setMessage({ type: 'error', text: err.message });- } finally {- setLoading(false);- }- }-- async function handleInitiate2FA() {- setTwoFAError('');- setTwoFALoading(true);- try {- const data = await api.initiate2FASetup();- setSetupData(data);- setShowSetupModal(true);- } catch (err) {- setTwoFAError(err.message);- } finally {- setTwoFALoading(false);- }- }-- async function handleConfirm2FA() {- if (!verificationCode || verificationCode.length !== 6) {- setTwoFAError('Please enter a 6-digit code');- return;- }-- setTwoFALoading(true);- setTwoFAError('');- try {- const result = await api.confirm2FASetup(verificationCode);- setBackupCodes(result.backup_codes);- setShowSetupModal(false);- setShowBackupCodesModal(true);- setVerificationCode('');- load2FAStatus();- } catch (err) {- setTwoFAError(err.message || 'Invalid verification code');- } finally {- setTwoFALoading(false);- }- }-- async function handleDisable2FA() {- if (!verificationCode) {- setTwoFAError('Please enter a verification code');- return;- }-- setTwoFALoading(true);- setTwoFAError('');- try {- await api.disable2FA(verificationCode);- setShowDisableModal(false);- setVerificationCode('');- load2FAStatus();- } catch (err) {- setTwoFAError(err.message || 'Invalid verification code');- } finally {- setTwoFALoading(false);- }- }-- async function handleRegenerateBackupCodes() {- if (!verificationCode || verificationCode.length !== 6) {- setTwoFAError('Please enter a 6-digit code');- return;- }-- setTwoFALoading(true);- setTwoFAError('');- try {- const result = await api.regenerateBackupCodes(verificationCode);- setBackupCodes(result.backup_codes);- setShowBackupCodesModal(true);- setVerificationCode('');- load2FAStatus();- } catch (err) {- setTwoFAError(err.message || 'Invalid verification code');- } finally {- setTwoFALoading(false);- }- }-- function downloadBackupCodes() {- const content = `ServerKit Backup Codes-Generated: ${new Date().toLocaleString()}--These codes can be used to access your account if you lose your authenticator device.-Each code can only be used once.--${backupCodes.join('\n')}--Keep these codes in a safe place.`;-- const blob = new Blob([content], { type: 'text/plain' });- const url = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = url;- a.download = 'serverkit-backup-codes.txt';- document.body.appendChild(a);- a.click();- document.body.removeChild(a);- URL.revokeObjectURL(url);- }-- function copyBackupCodes() {- navigator.clipboard.writeText(backupCodes.join('\n'));- }-- return (- <div className="settings-section">- <div className="section-header">- <h2>Security Settings</h2>- <p>Manage your password and security preferences</p>- </div>-- {message && (- <div className={`alert alert-${message.type === 'success' ? 'success' : 'danger'}`}>- {message.text}- </div>- )}-- {/* Two-Factor Authentication Section */}- <div className="settings-card two-fa-card">- <div className="two-fa-header">- <div className="two-fa-icon">- <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">- <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>- <path d="M7 11V7a5 5 0 0 1 10 0v4"/>- </svg>- </div>- <div>- <h3>Two-Factor Authentication (2FA)</h3>- <p>Add an extra layer of security to your account</p>- </div>- </div>-- {twoFALoading && !twoFAStatus ? (- <div className="loading-sm">Loading...</div>- ) : twoFAStatus?.enabled ? (- <div className="two-fa-enabled">- <div className="two-fa-status">- <span className="badge badge-success">Enabled</span>- <span className="two-fa-info">- Enabled on {new Date(twoFAStatus.confirmed_at).toLocaleDateString()}- </span>- </div>- <div className="two-fa-backup-info">- <span>Backup codes remaining: <strong>{twoFAStatus.backup_codes_remaining}</strong></span>- {twoFAStatus.backup_codes_remaining <= 3 && (- <span className="warning-text">Consider regenerating your backup codes</span>- )}- </div>- <div className="two-fa-actions">- <button- className="btn btn-secondary"- onClick={() => {- setVerificationCode('');- setTwoFAError('');- setShowBackupCodesModal(true);- }}- >- Regenerate Backup Codes- </button>- <button- className="btn btn-danger"- onClick={() => {- setVerificationCode('');- setTwoFAError('');- setShowDisableModal(true);- }}- >- Disable 2FA- </button>- </div>- </div>- ) : (- <div className="two-fa-disabled">- <p className="two-fa-description">- Two-factor authentication adds an additional layer of security to your account- by requiring a code from your authenticator app in addition to your password.- </p>- <button- className="btn btn-primary"- onClick={handleInitiate2FA}- disabled={twoFALoading}- >- Enable Two-Factor Authentication- </button>- </div>- )}- </div>-- <form onSubmit={handleSubmit} className="settings-form">- <h3>Change Password</h3>-- <div className="form-group">- <label>Current Password</label>- <input- type="password"- value={formData.currentPassword}- onChange={(e) => setFormData({ ...formData, currentPassword: e.target.value })}- placeholder="Enter current password"- />- </div>-- <div className="form-group">- <label>New Password</label>- <input- type="password"- value={formData.newPassword}- onChange={(e) => setFormData({ ...formData, newPassword: e.target.value })}- placeholder="Enter new password"- required- />- <span className="form-help">Minimum 8 characters</span>- </div>-- <div className="form-group">- <label>Confirm New Password</label>- <input- type="password"- value={formData.confirmPassword}- onChange={(e) => setFormData({ ...formData, confirmPassword: e.target.value })}- placeholder="Confirm new password"- required- />- </div>-- <div className="form-actions">- <button type="submit" className="btn btn-primary" disabled={loading}>- {loading ? 'Changing...' : 'Change Password'}- </button>- </div>- </form>-- <div className="settings-card">- <h3>Sessions</h3>- <p>Manage your active sessions</p>- <div className="session-item current">- <div className="session-info">- <svg viewBox="0 0 24 24" width="20" height="20">- <rect x="2" y="3" width="20" height="14" rx="2" ry="2"/>- <line x1="8" y1="21" x2="16" y2="21"/>- <line x1="12" y1="17" x2="12" y2="21"/>- </svg>- <div>- <span className="session-device">Current Session</span>- <span className="session-details">This device - Active now</span>- </div>- </div>- <span className="badge badge-success">Current</span>- </div>- </div>-- {/* Linked Accounts */}- <LinkedAccounts />-- {/* 2FA Setup Modal */}- {showSetupModal && setupData && (- <div className="modal-overlay" onClick={() => setShowSetupModal(false)}>- <div className="modal modal-md" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>Set Up Two-Factor Authentication</h2>- <button className="modal-close" onClick={() => setShowSetupModal(false)}>×</button>- </div>- <div className="modal-body">- <div className="setup-steps">- <div className="setup-step">- <span className="step-number">1</span>- <div className="step-content">- <h4>Scan the QR Code</h4>- <p>Use your authenticator app (Google Authenticator, Authy, 1Password, etc.) to scan this QR code.</p>- {setupData.qr_code ? (- <div className="qr-code-container">- <img src={setupData.qr_code} alt="2FA QR Code" className="qr-code" />- </div>- ) : (- <div className="qr-fallback">- <p>QR code unavailable. Enter this secret manually:</p>- <code className="secret-key">{setupData.secret}</code>- </div>- )}- <details className="manual-entry">- <summary>Can't scan? Enter manually</summary>- <p>Account: {user?.email}</p>- <p>Secret: <code>{setupData.secret}</code></p>- </details>- </div>- </div>-- <div className="setup-step">- <span className="step-number">2</span>- <div className="step-content">- <h4>Enter Verification Code</h4>- <p>Enter the 6-digit code from your authenticator app to verify setup.</p>- <input- type="text"- value={verificationCode}- onChange={(e) => setVerificationCode(e.target.value.replace(/\D/g, '').slice(0, 6))}- placeholder="000000"- className="verification-input"- autoFocus- />- {twoFAError && <p className="error-text">{twoFAError}</p>}- </div>- </div>- </div>- </div>- <div className="modal-footer">- <button className="btn btn-secondary" onClick={() => setShowSetupModal(false)}>- Cancel- </button>- <button- className="btn btn-primary"- onClick={handleConfirm2FA}- disabled={twoFALoading || verificationCode.length !== 6}- >- {twoFALoading ? 'Verifying...' : 'Enable 2FA'}- </button>- </div>- </div>- </div>- )}-- {/* Disable 2FA Modal */}- {showDisableModal && (- <div className="modal-overlay" onClick={() => setShowDisableModal(false)}>- <div className="modal" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>Disable Two-Factor Authentication</h2>- <button className="modal-close" onClick={() => setShowDisableModal(false)}>×</button>- </div>- <div className="modal-body">- <div className="warning-box">- <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>- <line x1="12" y1="9" x2="12" y2="13"/>- <line x1="12" y1="17" x2="12.01" y2="17"/>- </svg>- <p>Disabling 2FA will make your account less secure. You will only need your password to log in.</p>- </div>- <div className="form-group">- <label>Enter a verification code or backup code to disable 2FA:</label>- <input- type="text"- value={verificationCode}- onChange={(e) => setVerificationCode(e.target.value)}- placeholder="Code from authenticator or backup code"- autoFocus- />- {twoFAError && <p className="error-text">{twoFAError}</p>}- </div>- </div>- <div className="modal-footer">- <button className="btn btn-secondary" onClick={() => setShowDisableModal(false)}>- Cancel- </button>- <button- className="btn btn-danger"- onClick={handleDisable2FA}- disabled={twoFALoading || !verificationCode}- >- {twoFALoading ? 'Disabling...' : 'Disable 2FA'}- </button>- </div>- </div>- </div>- )}-- {/* Backup Codes Modal */}- {showBackupCodesModal && (- <div className="modal-overlay" onClick={() => setShowBackupCodesModal(false)}>- <div className="modal modal-md" onClick={e => e.stopPropagation()}>- <div className="modal-header">- <h2>{backupCodes.length > 0 ? 'Your Backup Codes' : 'Regenerate Backup Codes'}</h2>- <button className="modal-close" onClick={() => setShowBackupCodesModal(false)}>×</button>- </div>- <div className="modal-body">- {backupCodes.length > 0 ? (- <>- <div className="warning-box">- <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">- <circle cx="12" cy="12" r="10"/>- <line x1="12" y1="8" x2="12" y2="12"/>- <line x1="12" y1="16" x2="12.01" y2="16"/>- </svg>- <p>Save these backup codes in a secure location. They will not be shown again. Each code can only be used once.</p>- </div>- <div className="backup-codes-grid">- {backupCodes.map((code, index) => (- <code key={index} className="backup-code">{code}</code>- ))}- </div>- <div className="backup-codes-actions">- <button className="btn btn-secondary" onClick={downloadBackupCodes}>- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"/>- </svg>- Download- </button>- <button className="btn btn-secondary" onClick={copyBackupCodes}>- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">- <rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>- <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>- </svg>- Copy- </button>- </div>- </>- ) : (- <>- <p>Enter a code from your authenticator app to generate new backup codes. This will invalidate all existing backup codes.</p>- <div className="form-group">- <label>Verification Code</label>- <input- type="text"- value={verificationCode}- onChange={(e) => setVerificationCode(e.target.value.replace(/\D/g, '').slice(0, 6))}- placeholder="000000"- autoFocus- />- {twoFAError && <p className="error-text">{twoFAError}</p>}- </div>- </>- )}- </div>- <div className="modal-footer">- <button className="btn btn-secondary" onClick={() => {- setShowBackupCodesModal(false);- setBackupCodes([]);- setVerificationCode('');- }}>- {backupCodes.length > 0 ? 'Done' : 'Cancel'}- </button>- {backupCodes.length === 0 && (- <button- className="btn btn-primary"- onClick={handleRegenerateBackupCodes}- disabled={twoFALoading || verificationCode.length !== 6}- >- {twoFALoading ? 'Generating...' : 'Generate New Codes'}- </button>- )}- </div>- </div>- </div>- )}- </div>- );-};--const ACCENT_PRESETS = [- { label: 'Indigo', color: '#6366f1' },- { label: 'Ocean', color: '#0ea5e9' },- { label: 'Forest', color: '#10b981' },- { label: 'Sunset', color: '#f97316' },- { label: 'Rose', color: '#f43f5e' },- { label: 'Violet', color: '#8b5cf6' },- { label: 'Amber', color: '#f59e0b' },- { label: 'Cyan', color: '#06b6d4' },-];--const WHITELABEL_MODES = [- { id: 'image_text', label: 'Logo + Text', icon: Layers, desc: 'Mini logo with brand name' },- { id: 'image_full', label: 'Full-width Logo', icon: Image, desc: 'Banner image only' },- { id: 'text_only', label: 'Text Only', icon: Type, desc: 'Just the brand name' },-];--const AppearanceSettings = () => {- const { theme, setTheme, accentColor, setAccentColor, whiteLabel, setWhiteLabel } = useTheme();- const { widgets, toggleWidget, moveWidget, resetLayout } = useDashboardLayout();- const logoInputRef = useRef(null);-- return (- <div className="settings-section">- <div className="section-header">- <h2>Appearance</h2>- <p>Customize the look and feel of your dashboard</p>- </div>-- <div className="settings-card">- <h3>Theme</h3>- <p>Select your preferred color scheme</p>- <div className="theme-options">- <button- className={`theme-option ${theme === 'dark' ? 'active' : ''}`}- onClick={() => setTheme('dark')}- >- <div className="theme-preview dark">- <div className="preview-sidebar"></div>- <div className="preview-content">- <div className="preview-card"></div>- <div className="preview-card"></div>- </div>- </div>- <span>Dark</span>- </button>- <button- className={`theme-option ${theme === 'light' ? 'active' : ''}`}- onClick={() => setTheme('light')}- >- <div className="theme-preview light">- <div className="preview-sidebar"></div>- <div className="preview-content">- <div className="preview-card"></div>- <div className="preview-card"></div>- </div>- </div>- <span>Light</span>- </button>- <button- className={`theme-option ${theme === 'system' ? 'active' : ''}`}- onClick={() => setTheme('system')}- >- <div className="theme-preview system">- <div className="preview-sidebar"></div>- <div className="preview-content">- <div className="preview-card"></div>- <div className="preview-card"></div>- </div>- </div>- <span>System</span>- </button>- </div>- </div>-- <div className="settings-card">- <h3>Accent Color</h3>- <p>Choose the primary accent color used across the interface</p>- <div className="accent-presets">- {ACCENT_PRESETS.map(({ label, color }) => (- <button- key={color}- className={`accent-preset${accentColor === color ? ' active' : ''}`}- onClick={() => setAccentColor(color)}- >- <span className="accent-swatch" style={{ background: color }} />- <span className="accent-label">{label}</span>- </button>- ))}- </div>- <div className="accent-custom">- <label className="accent-custom-label">Custom color</label>- <div className="accent-custom-row">- <input- type="color"- className="accent-custom-input"- value={accentColor}- onChange={(e) => setAccentColor(e.target.value)}- />- <span className="accent-custom-hex">{accentColor.toUpperCase()}</span>- </div>- </div>- </div>-- <div className="settings-card">- <h3>Dashboard Widgets</h3>- <p>Toggle visibility and reorder widgets on the dashboard</p>- <div className="widget-list">- {widgets.map((widget, idx) => (- <div key={widget.id} className={`widget-item${!widget.visible ? ' widget-item--hidden' : ''}`}>- <div className="widget-item__info">- <label className="toggle-switch">- <input- type="checkbox"- checked={widget.visible}- onChange={() => toggleWidget(widget.id)}- />- <span className="toggle-slider"></span>- </label>- <span className="widget-item__label">{widget.label}</span>- </div>- <div className="widget-item__controls">- <button- className="widget-move-btn"- onClick={() => moveWidget(widget.id, 'up')}- disabled={idx === 0}- title="Move up"- >- <ChevronUp size={14} />- </button>- <button- className="widget-move-btn"- onClick={() => moveWidget(widget.id, 'down')}- disabled={idx === widgets.length - 1}- title="Move down"- >- <ChevronDown size={14} />- </button>- </div>- </div>- ))}- </div>- <button className="btn btn-secondary btn-sm" onClick={resetLayout} style={{ marginTop: '12px' }}>- <RotateCcw size={14} />- Reset to defaults- </button>- </div>-- <div className="settings-card">- <h3>Custom Branding</h3>- <p>Replace the default ServerKit branding in the sidebar with your own</p>-- <div className="settings-row">- <div className="settings-label">- <span>Enable custom branding</span>- <span className="settings-hint">Replaces the sidebar logo, name, and GitHub star link</span>- </div>- <div className="settings-control">- <label className="toggle-switch">- <input- type="checkbox"- checked={whiteLabel.enabled}- onChange={(e) => setWhiteLabel({ enabled: e.target.checked })}- />- <span className="toggle-slider"></span>- </label>- </div>- </div>-- {whiteLabel.enabled && (- <>- <div className="whitelabel-modes">- {WHITELABEL_MODES.map(({ id, label, icon: Icon, desc }) => (- <button- key={id}- className={`whitelabel-mode${whiteLabel.mode === id ? ' active' : ''}`}- onClick={() => setWhiteLabel({ mode: id })}- >- <Icon size={20} />- <span className="whitelabel-mode__label">{label}</span>- <span className="whitelabel-mode__desc">{desc}</span>- </button>- ))}- </div>-- <div className="whitelabel-fields">- {whiteLabel.mode !== 'image_full' && (- <div className="form-group">- <label>Brand Name</label>- <input- type="text"- value={whiteLabel.brandName}- onChange={(e) => setWhiteLabel({ brandName: e.target.value })}- placeholder="My Brand"- maxLength={30}- />- </div>- )}-- {whiteLabel.mode !== 'text_only' && (- <div className="form-group">- <label>Logo Image</label>- <div className="whitelabel-upload" onClick={() => logoInputRef.current?.click()}>- {whiteLabel.logoData ? (- <div className="whitelabel-logo-preview">- <img src={whiteLabel.logoData} alt="Logo preview" />- <button- className="btn btn-secondary btn-sm"- onClick={(e) => { e.stopPropagation(); setWhiteLabel({ logoData: '' }); }}- >- <X size={12} /> Remove- </button>- </div>- ) : (- <div className="whitelabel-upload__placeholder">- <Upload size={20} />- <span>Click to upload logo</span>- <span className="whitelabel-upload__hint">PNG, JPG, SVG — max 200KB</span>- </div>- )}- <input- ref={logoInputRef}- type="file"- accept="image/png,image/jpeg,image/svg+xml,image/webp"- style={{ display: 'none' }}- onChange={(e) => {- const file = e.target.files?.[0];- if (!file) return;- if (file.size > 200 * 1024) {- alert('Image must be under 200KB');- return;- }- const reader = new FileReader();- reader.onload = (ev) => setWhiteLabel({ logoData: ev.target.result });- reader.readAsDataURL(file);- e.target.value = '';- }}- />- </div>- </div>- )}- </div>-- <div className="whitelabel-preview">- <span className="whitelabel-preview__label">Preview</span>- <div className="whitelabel-preview__box">- {whiteLabel.mode === 'image_full' ? (- <div className="brand-custom-banner">- {whiteLabel.logoData ? (- <img src={whiteLabel.logoData} alt="Preview" />- ) : (- <Layers size={24} />- )}- </div>- ) : whiteLabel.mode === 'text_only' ? (- <span className="brand-custom-text">- {whiteLabel.brandName || 'Brand'}- </span>- ) : (- <>- <div className="brand-custom-logo">- {whiteLabel.logoData ? (- <img src={whiteLabel.logoData} alt="Preview" />- ) : (- <Layers size={16} />- )}- </div>- <span className="brand-custom-text">- {whiteLabel.brandName || 'Brand'}- </span>- </>- )}- </div>- </div>-- <div className="whitelabel-star-prompt">- <div className="star-icon">- <Star size={22} />- </div>- <div className="star-content">- <h4>Support ServerKit</h4>- <p>- By using custom branding, the GitHub star link is hidden from the sidebar.- If ServerKit is useful to you, please consider starring the project — it helps the community grow!- </p>- <a- href="https://github.com/jhd3197/ServerKit"- target="_blank"- rel="noopener noreferrer"- className="btn btn-primary btn-sm"- >- <Star size={14} />- Star on GitHub- </a>- </div>- </div>- </>- )}- </div>- </div>- );-};--const NotificationSettings = () => {- const { isAdmin, user } = useAuth();- const [loading, setLoading] = useState(true);- const [saving, setSaving] = useState(false);- const [testing, setTesting] = useState(null);- const [message, setMessage] = useState(null);- const [activeSection, setActiveSection] = useState('personal');- const [config, setConfig] = useState({- discord: { enabled: false, webhook_url: '', username: 'ServerKit', avatar_url: '', notify_on: ['critical', 'warning'] },- slack: { enabled: false, webhook_url: '', channel: '', username: 'ServerKit', icon_emoji: ':robot_face:', notify_on: ['critical', 'warning'] },- telegram: { enabled: false, bot_token: '', chat_id: '', notify_on: ['critical', 'warning'] },- email: { enabled: false, smtp_host: '', smtp_port: 587, smtp_user: '', smtp_password: '', smtp_tls: true, from_email: '', from_name: 'ServerKit', to_emails: [], notify_on: ['critical', 'warning'] },- generic_webhook: { enabled: false, url: '', headers: {}, notify_on: ['critical', 'warning'] }- });- const [expandedChannel, setExpandedChannel] = useState(null);- const [userPrefs, setUserPrefs] = useState({- enabled: true,- channels: ['email'],- severities: ['critical', 'warning'],- email: '',- discord_webhook: '',- telegram_chat_id: '',- categories: { system: true, security: true, backups: true, apps: true },- quiet_hours: { enabled: false, start: '22:00', end: '08:00' }- });-- const severityOptions = ['critical', 'warning', 'info', 'success'];-- useEffect(() => {- loadUserPrefs();- if (isAdmin) loadConfig();- }, [isAdmin]);-- async function loadConfig() {- try {- const data = await api.getNotificationsConfig();- setConfig(prev => ({- discord: { ...prev.discord, ...data.discord },- slack: { ...prev.slack, ...data.slack },- telegram: { ...prev.telegram, ...data.telegram },- email: { ...prev.email, ...data.email },- generic_webhook: { ...prev.generic_webhook, ...data.generic_webhook }- }));- } catch (err) {- console.error('Failed to load notification config:', err);- } finally {- setLoading(false);- }- }-- async function loadUserPrefs() {- try {- const data = await api.getUserNotificationPreferences();- setUserPrefs(prev => ({ ...prev, ...data }));- } catch (err) {- console.error('Failed to load user notification preferences:', err);- } finally {- setLoading(false);- }- }-- async function handleSaveUserPrefs() {- setSaving(true);- setMessage(null);- try {- await api.updateUserNotificationPreferences(userPrefs);- setMessage({ type: 'success', text: 'Your notification preferences have been saved' });- } catch (err) {- setMessage({ type: 'error', text: err.message });- } finally {- setSaving(false);- }- }-- async function handleTestUserNotification() {- setTesting('user');- setMessage(null);- try {- const result = await api.testUserNotification();- setMessage({ type: result.success ? 'success' : 'error', text: result.success ? 'Test notification sent!' : (result.error || 'Test failed') });- } catch (err) {- setMessage({ type: 'error', text: err.message });- } finally {- setTesting(null);- }- }-- async function handleSaveChannel(channel) {- setSaving(true);- setMessage(null);- try {- await api.updateNotificationChannel(channel, config[channel]);- setMessage({ type: 'success', text: `${channel.charAt(0).toUpperCase() + channel.slice(1).replace('_', ' ')} settings saved` });- } catch (err) {- setMessage({ type: 'error', text: err.message });- } finally {- setSaving(false);- }- }-- async function handleTestChannel(channel) {- setTesting(channel);- setMessage(null);- try {- const result = await api.testNotificationChannel(channel);- setMessage({ type: result.success ? 'success' : 'error', text: result.message || result.error || 'Test completed' });- } catch (err) {- setMessage({ type: 'error', text: err.message });- } finally {- setTesting(null);- }- }-- function updateChannelConfig(channel, key, value) {- setConfig(prev => ({- ...prev,- [channel]: { ...prev[channel], [key]: value }- }));- }-- function toggleSeverity(channel, severity) {- const current = config[channel].notify_on || [];- const updated = current.includes(severity)- ? current.filter(s => s !== severity)- : [...current, severity];- updateChannelConfig(channel, 'notify_on', updated);- }-- if (loading) {- return <div className="loading">Loading notification settings...</div>;- }-- const userPrefsUI = (- <div className="user-notification-prefs">- <div className="settings-card">- <div className="form-group">- <label className="toggle-switch-label">- <span>Enable notifications for my account</span>- <label className="toggle-switch">- <input- type="checkbox"- checked={userPrefs.enabled}- onChange={(e) => setUserPrefs({...userPrefs, enabled: e.target.checked})}- />- <span className="toggle-slider"></span>- </label>- </label>- </div>- </div>-- <div className="settings-card">- <h3>Notification Channels</h3>- <p>Choose how you want to receive notifications</p>- <div className="channel-toggles">- {['email', 'discord', 'slack', 'telegram'].map(ch => (- <label key={ch} className="channel-toggle">- <input- type="checkbox"- checked={userPrefs.channels?.includes(ch)}- onChange={(e) => {- const channels = e.target.checked- ? [...(userPrefs.channels || []), ch]- : (userPrefs.channels || []).filter(c => c !== ch);- setUserPrefs({...userPrefs, channels});- }}- />- <span>{ch.charAt(0).toUpperCase() + ch.slice(1)}</span>- </label>- ))}- </div>- </div>-- {userPrefs.channels?.includes('email') && (- <div className="settings-card">- <h3>Email Settings</h3>- <div className="form-group">- <label>Notification Email (optional)</label>- <input- type="email"- value={userPrefs.email || ''}- onChange={(e) => setUserPrefs({...userPrefs, email: e.target.value})}- placeholder={user?.email || 'Uses your account email'}- />- <span className="form-help">Leave empty to use your account email</span>- </div>- </div>- )}-- {userPrefs.channels?.includes('discord') && (- <div className="settings-card">- <h3>Personal Discord Webhook</h3>- <div className="form-group">- <label>Webhook URL</label>- <input- type="text"- value={userPrefs.discord_webhook || ''}- onChange={(e) => setUserPrefs({...userPrefs, discord_webhook: e.target.value})}- placeholder="https://discord.com/api/webhooks/..."- />- <span className="form-help">Create a webhook in your personal server or DM channel</span>- </div>- </div>- )}-- {userPrefs.channels?.includes('telegram') && (- <div className="settings-card">- <h3>Personal Telegram</h3>- <div className="form-group">- <label>Your Chat ID</label>- <input- type="text"- value={userPrefs.telegram_chat_id || ''}- onChange={(e) => setUserPrefs({...userPrefs, telegram_chat_id: e.target.value})}- placeholder="Your personal chat ID"- />- <span className="form-help">Use @userinfobot to get your personal chat ID</span>- </div>- </div>- )}-- <div className="settings-card">- <h3>Severity Levels</h3>- <p>Which alert types do you want to receive?</p>- <div className="severity-toggles">- {severityOptions.map(severity => (- <label key={severity} className={`severity-toggle ${severity}`}>- <input- type="checkbox"- checked={userPrefs.severities?.includes(severity)}- onChange={(e) => {- const severities = e.target.checked- ? [...(userPrefs.severities || []), severity]- : (userPrefs.severities || []).filter(s => s !== severity);- setUserPrefs({...userPrefs, severities});- }}- />- <span>{severity.charAt(0).toUpperCase() + severity.slice(1)}</span>- </label>- ))}- </div>- </div>-- <div className="settings-card">- <h3>Notification Categories</h3>- <p>What types of events should trigger notifications?</p>- <div className="category-toggles">- {Object.entries({- system: 'System Alerts (CPU, Memory, Disk)',- security: 'Security Events',- backups: 'Backup Status',- apps: 'Application Events'- }).map(([key, label]) => (- <label key={key} className="category-toggle">- <input- type="checkbox"- checked={userPrefs.categories?.[key] !== false}- onChange={(e) => setUserPrefs({- ...userPrefs,- categories: { ...userPrefs.categories, [key]: e.target.checked }- })}- />- <span>{label}</span>- </label>- ))}- </div>- </div>-- <div className="settings-card">- <h3>Quiet Hours</h3>- <p>Pause non-critical notifications during these hours</p>- <div className="form-group">- <label className="toggle-switch-label">- <span>Enable quiet hours</span>- <label className="toggle-switch">- <input- type="checkbox"- checked={userPrefs.quiet_hours?.enabled}- onChange={(e) => setUserPrefs({- ...userPrefs,- quiet_hours: { ...userPrefs.quiet_hours, enabled: e.target.checked }- })}- />- <span className="toggle-slider"></span>- </label>- </label>- </div>- {userPrefs.quiet_hours?.enabled && (- <div className="form-row">- <div className="form-group">- <label>Start Time</label>- <input- type="time"- value={userPrefs.quiet_hours?.start || '22:00'}- onChange={(e) => setUserPrefs({- ...userPrefs,- quiet_hours: { ...userPrefs.quiet_hours, start: e.target.value }- })}- />- </div>- <div className="form-group">- <label>End Time</label>- <input- type="time"- value={userPrefs.quiet_hours?.end || '08:00'}- onChange={(e) => setUserPrefs({- ...userPrefs,- quiet_hours: { ...userPrefs.quiet_hours, end: e.target.value }- })}- />- </div>- </div>- )}- </div>-- <div className="form-actions">- <button- className="btn btn-secondary"- onClick={handleTestUserNotification}- disabled={testing === 'user' || !userPrefs.enabled}- >- {testing === 'user' ? 'Sending...' : 'Send Test Notification'}- </button>- <button- className="btn btn-primary"- onClick={handleSaveUserPrefs}- disabled={saving}- >- {saving ? 'Saving...' : 'Save Preferences'}- </button>- </div>- </div>- );-- const channels = [- { id: 'discord', name: 'Discord', icon: (- <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor">- <path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028 14.09 14.09 0 0 0 1.226-1.994.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"/>- </svg>- ), description: 'Send rich notifications to Discord channels via webhooks' },- { id: 'slack', name: 'Slack', icon: (- <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor">- <path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"/>- </svg>- ), description: 'Send notifications to Slack channels via incoming webhooks' },- { id: 'telegram', name: 'Telegram', icon: (- <svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor">- <path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/>- </svg>- ), description: 'Send notifications to Telegram chats via bot API' },- { id: 'email', name: 'Email', icon: (- <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/>- <polyline points="22,6 12,13 2,6"/>- </svg>- ), description: 'Send email notifications with HTML templates via SMTP' },- { id: 'generic_webhook', name: 'Generic Webhook', icon: (- <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/>- <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>- </svg>- ), description: 'Send JSON payloads to any webhook endpoint' }- ];-- return (- <div className="settings-section">- <div className="section-header">- <h2>Notification Settings</h2>- <p>Configure how you receive alerts and notifications</p>- </div>-- {message && (- <div className={`alert alert-${message.type === 'success' ? 'success' : 'danger'}`}>- {message.text}- </div>- )}-- <div className="notification-tabs">- <button- className={`notification-tab ${activeSection === 'personal' ? 'active' : ''}`}- onClick={() => setActiveSection('personal')}- >- <svg viewBox="0 0 24 24" width="18" height="18" stroke="currentColor" fill="none" strokeWidth="2">- <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>- <circle cx="12" cy="7" r="4"/>- </svg>- My Preferences- </button>- {isAdmin && (- <button- className={`notification-tab ${activeSection === 'admin' ? 'active' : ''}`}- onClick={() => setActiveSection('admin')}- >- <svg viewBox="0 0 24 24" width="18" height="18" stroke="currentColor" fill="none" strokeWidth="2">- <circle cx="12" cy="12" r="3"/>- <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>- </svg>- System Webhooks- </button>- )}- </div>-- {activeSection === 'personal' && userPrefsUI}-- {activeSection === 'admin' && isAdmin && (- <div className="notification-channels">- {channels.map(channel => (- <div key={channel.id} className={`notification-channel-card ${config[channel.id]?.enabled ? 'enabled' : ''}`}>- <div- className="channel-header"- onClick={() => setExpandedChannel(expandedChannel === channel.id ? null : channel.id)}- >- <div className="channel-icon">{channel.icon}</div>- <div className="channel-info">- <h3>{channel.name}</h3>- <p>{channel.description}</p>- </div>- <div className="channel-status">- <span className={`badge ${config[channel.id]?.enabled ? 'badge-success' : 'badge-secondary'}`}>- {config[channel.id]?.enabled ? 'Enabled' : 'Disabled'}- </span>- <svg- viewBox="0 0 24 24"- width="20"- height="20"- className={`expand-icon ${expandedChannel === channel.id ? 'expanded' : ''}`}- >- <polyline points="6 9 12 15 18 9" stroke="currentColor" fill="none" strokeWidth="2"/>- </svg>- </div>- </div>-- {expandedChannel === channel.id && (- <div className="channel-config">- <div className="form-group">- <label className="toggle-switch-label">- <span>Enable {channel.name}</span>- <label className="toggle-switch">- <input- type="checkbox"- checked={config[channel.id]?.enabled || false}- onChange={(e) => updateChannelConfig(channel.id, 'enabled', e.target.checked)}- />- <span className="toggle-slider"></span>- </label>- </label>- </div>-- {channel.id === 'discord' && (- <>- <div className="form-group">- <label>Webhook URL</label>- <input- type="text"- value={config.discord.webhook_url || ''}- onChange={(e) => updateChannelConfig('discord', 'webhook_url', e.target.value)}- placeholder="https://discord.com/api/webhooks/..."- />- <span className="form-help">Create a webhook in Discord: Server Settings → Integrations → Webhooks</span>- </div>- <div className="form-row">- <div className="form-group">- <label>Bot Username</label>- <input- type="text"- value={config.discord.username || 'ServerKit'}- onChange={(e) => updateChannelConfig('discord', 'username', e.target.value)}- placeholder="ServerKit"- />- </div>- <div className="form-group">- <label>Avatar URL (optional)</label>- <input- type="text"- value={config.discord.avatar_url || ''}- onChange={(e) => updateChannelConfig('discord', 'avatar_url', e.target.value)}- placeholder="https://example.com/avatar.png"- />- </div>- </div>- </>- )}-- {channel.id === 'slack' && (- <>- <div className="form-group">- <label>Webhook URL</label>- <input- type="text"- value={config.slack.webhook_url || ''}- onChange={(e) => updateChannelConfig('slack', 'webhook_url', e.target.value)}- placeholder="https://hooks.slack.com/services/..."- />- <span className="form-help">Create an incoming webhook in Slack: Apps → Incoming Webhooks</span>- </div>- <div className="form-row">- <div className="form-group">- <label>Channel (optional)</label>- <input- type="text"- value={config.slack.channel || ''}- onChange={(e) => updateChannelConfig('slack', 'channel', e.target.value)}- placeholder="#alerts"- />- </div>- <div className="form-group">- <label>Username</label>- <input- type="text"- value={config.slack.username || 'ServerKit'}- onChange={(e) => updateChannelConfig('slack', 'username', e.target.value)}- placeholder="ServerKit"- />- </div>- </div>- </>- )}-- {channel.id === 'telegram' && (- <>- <div className="form-group">- <label>Bot Token</label>- <input- type="password"- value={config.telegram.bot_token || ''}- onChange={(e) => updateChannelConfig('telegram', 'bot_token', e.target.value)}- placeholder="123456:ABC-DEF..."- />- <span className="form-help">Get a bot token from @BotFather on Telegram</span>- </div>- <div className="form-group">- <label>Chat ID</label>- <input- type="text"- value={config.telegram.chat_id || ''}- onChange={(e) => updateChannelConfig('telegram', 'chat_id', e.target.value)}- placeholder="-1001234567890"- />- <span className="form-help">Use @userinfobot or @getidsbot to find your chat ID</span>- </div>- </>- )}-- {channel.id === 'email' && (- <>- <div className="form-row">- <div className="form-group">- <label>SMTP Host</label>- <input- type="text"- value={config.email.smtp_host || ''}- onChange={(e) => updateChannelConfig('email', 'smtp_host', e.target.value)}- placeholder="smtp.example.com"- />- </div>- <div className="form-group">- <label>SMTP Port</label>- <input- type="number"- value={config.email.smtp_port || 587}- onChange={(e) => updateChannelConfig('email', 'smtp_port', parseInt(e.target.value))}- placeholder="587"- />- </div>- </div>- <div className="form-row">- <div className="form-group">- <label>SMTP Username</label>- <input- type="text"- value={config.email.smtp_user || ''}- onChange={(e) => updateChannelConfig('email', 'smtp_user', e.target.value)}- placeholder="[email protected]"- />- </div>- <div className="form-group">- <label>SMTP Password</label>- <input- type="password"- value={config.email.smtp_password || ''}- onChange={(e) => updateChannelConfig('email', 'smtp_password', e.target.value)}- placeholder="••••••••"- />- </div>- </div>- <div className="form-row">- <div className="form-group">- <label>From Email</label>- <input- type="email"- value={config.email.from_email || ''}- onChange={(e) => updateChannelConfig('email', 'from_email', e.target.value)}- placeholder="[email protected]"- />- </div>- <div className="form-group">- <label>From Name</label>- <input- type="text"- value={config.email.from_name || 'ServerKit'}- onChange={(e) => updateChannelConfig('email', 'from_name', e.target.value)}- placeholder="ServerKit"- />- </div>- </div>- <div className="form-group">- <label>Recipient Emails (comma-separated)</label>- <input- type="text"- value={(config.email.to_emails || []).join(', ')}- onChange={(e) => updateChannelConfig('email', 'to_emails', e.target.value.split(',').map(s => s.trim()).filter(Boolean))}- placeholder="[email protected], [email protected]"- />- </div>- <div className="form-group">- <label className="toggle-switch-label">- <span>Use TLS</span>- <label className="toggle-switch">- <input- type="checkbox"- checked={config.email.smtp_tls !== false}- onChange={(e) => updateChannelConfig('email', 'smtp_tls', e.target.checked)}- />- <span className="toggle-slider"></span>- </label>- </label>- </div>- </>- )}-- {channel.id === 'generic_webhook' && (- <div className="form-group">- <label>Webhook URL</label>- <input- type="text"- value={config.generic_webhook.url || ''}- onChange={(e) => updateChannelConfig('generic_webhook', 'url', e.target.value)}- placeholder="https://your-endpoint.com/webhook"- />- <span className="form-help">Receives JSON payload with alert data</span>- </div>- )}-- <div className="form-group">- <label>Alert Severities</label>- <div className="severity-toggles">- {severityOptions.map(severity => (- <label key={severity} className={`severity-toggle ${severity}`}>- <input- type="checkbox"- checked={config[channel.id]?.notify_on?.includes(severity) || false}- onChange={() => toggleSeverity(channel.id, severity)}- />- <span>{severity.charAt(0).toUpperCase() + severity.slice(1)}</span>- </label>- ))}- </div>- </div>-- <div className="channel-actions">- <button- className="btn btn-secondary"- onClick={() => handleTestChannel(channel.id)}- disabled={testing === channel.id || !config[channel.id]?.enabled}- >- {testing === channel.id ? 'Testing...' : 'Send Test'}- </button>- <button- className="btn btn-primary"- onClick={() => handleSaveChannel(channel.id)}- disabled={saving}- >- {saving ? 'Saving...' : 'Save'}- </button>- </div>- </div>- )}- </div>- ))}- </div>- )}- </div>- );-};--const SystemInfo = () => {- const { isAdmin } = useAuth();- const [metrics, setMetrics] = useState(null);- const [loading, setLoading] = useState(true);- const [timezones, setTimezones] = useState([]);- const [selectedTimezone, setSelectedTimezone] = useState('');- const [savingTimezone, setSavingTimezone] = useState(false);- const [timezoneMessage, setTimezoneMessage] = useState(null);-- useEffect(() => {- if (isAdmin) {- loadMetrics();- loadTimezones();- }- }, [isAdmin]);-- async function loadMetrics() {- try {- const data = await api.getSystemMetrics();- setMetrics(data);- if (data?.time?.timezone_id) {- setSelectedTimezone(data.time.timezone_id);- }- } catch (err) {- console.error('Failed to load metrics:', err);- } finally {- setLoading(false);- }- }-- async function loadTimezones() {- try {- const data = await api.getTimezones();- setTimezones(data.timezones || []);- } catch (err) {- console.error('Failed to load timezones:', err);- }- }-- async function handleTimezoneChange() {- if (!selectedTimezone) return;-- setSavingTimezone(true);- setTimezoneMessage(null);-- try {- const result = await api.setTimezone(selectedTimezone);- setTimezoneMessage({ type: 'success', text: result.message || 'Timezone updated' });- // Refresh metrics to show new time- loadMetrics();- } catch (err) {- setTimezoneMessage({ type: 'error', text: err.message || 'Failed to set timezone' });- } finally {- setSavingTimezone(false);- setTimeout(() => setTimezoneMessage(null), 5000);- }- }-- if (!isAdmin) {- return (- <div className="settings-section">- <div className="section-header">- <h2>System Information</h2>- <p>View system details and server information</p>- </div>- <div className="alert alert-warning">- Admin access required to view system information.- </div>- </div>- );- }-- if (loading) {- return <div className="loading">Loading system information...</div>;- }-- return (- <div className="settings-section">- <div className="section-header">- <h2>System Information</h2>- <p>View system details and server information</p>- </div>-- <div className="system-info-grid">- <div className="settings-card">- <h3>CPU</h3>- <div className="info-list">- <div className="info-item">- <span className="info-label">Usage</span>- <span className="info-value">{metrics?.cpu?.percent?.toFixed(1) || 0}%</span>- </div>- <div className="info-item">- <span className="info-label">Cores</span>- <span className="info-value">{metrics?.cpu?.count || '-'}</span>- </div>- <div className="info-item">- <span className="info-label">Load Average</span>- <span className="info-value">- {metrics?.cpu?.load_avg ? metrics.cpu.load_avg.map(l => l.toFixed(2)).join(', ') : '-'}- </span>- </div>- </div>- </div>-- <div className="settings-card">- <h3>Memory</h3>- <div className="info-list">- <div className="info-item">- <span className="info-label">Usage</span>- <span className="info-value">{metrics?.memory?.percent?.toFixed(1) || 0}%</span>- </div>- <div className="info-item">- <span className="info-label">Used</span>- <span className="info-value">{formatBytes(metrics?.memory?.used)}</span>- </div>- <div className="info-item">- <span className="info-label">Total</span>- <span className="info-value">{formatBytes(metrics?.memory?.total)}</span>- </div>- </div>- </div>-- <div className="settings-card">- <h3>Disk</h3>- <div className="info-list">- <div className="info-item">- <span className="info-label">Usage</span>- <span className="info-value">{metrics?.disk?.percent?.toFixed(1) || 0}%</span>- </div>- <div className="info-item">- <span className="info-label">Used</span>- <span className="info-value">{formatBytes(metrics?.disk?.used)}</span>- </div>- <div className="info-item">- <span className="info-label">Total</span>- <span className="info-value">{formatBytes(metrics?.disk?.total)}</span>- </div>- </div>- </div>-- <div className="settings-card">- <h3>Network</h3>- <div className="info-list">- <div className="info-item">- <span className="info-label">Bytes Sent</span>- <span className="info-value">{formatBytes(metrics?.network?.bytes_sent)}</span>- </div>- <div className="info-item">- <span className="info-label">Bytes Received</span>- <span className="info-value">{formatBytes(metrics?.network?.bytes_recv)}</span>- </div>- </div>- </div>- </div>-- {metrics?.system && (- <div className="settings-card">- <h3>System Details</h3>- <div className="info-list">- <div className="info-item">- <span className="info-label">Hostname</span>- <span className="info-value">{metrics.system.hostname || '-'}</span>- </div>- <div className="info-item">- <span className="info-label">Platform</span>- <span className="info-value">{metrics.system.platform || '-'}</span>- </div>- <div className="info-item">- <span className="info-label">OS Version</span>- <span className="info-value">{metrics.system.version || '-'}</span>- </div>- <div className="info-item">- <span className="info-label">Uptime</span>- <span className="info-value">{formatUptime(metrics.system.uptime)}</span>- </div>- </div>- </div>- )}-- {/* Server Time & Timezone */}- <div className="settings-card">- <h3>Server Time & Timezone</h3>- {metrics?.time && (- <div className="info-list" style={{ marginBottom: '1rem' }}>- <div className="info-item">- <span className="info-label">Current Time</span>- <span className="info-value">{metrics.time.current_time_formatted}</span>- </div>- <div className="info-item">- <span className="info-label">UTC Offset</span>- <span className="info-value">{metrics.time.utc_offset}</span>- </div>- <div className="info-item">- <span className="info-label">Current Timezone</span>- <span className="info-value">{metrics.time.timezone_id || metrics.time.timezone_name}</span>- </div>- </div>- )}- <div className="form-group">- <label>Change Timezone</label>- <div className="timezone-selector">- <select- value={selectedTimezone}- onChange={(e) => setSelectedTimezone(e.target.value)}- className="form-control"- >- <option value="">Select timezone...</option>- {timezones.map((tz) => (- <option key={tz} value={tz}>{tz}</option>- ))}- </select>- <button- className="btn btn-primary"- onClick={handleTimezoneChange}- disabled={savingTimezone || !selectedTimezone || selectedTimezone === metrics?.time?.timezone_id}- >- {savingTimezone ? 'Saving...' : 'Apply'}- </button>- </div>- {timezoneMessage && (- <div className={`timezone-message ${timezoneMessage.type}`}>- {timezoneMessage.text}- </div>- )}- <span className="form-help">- Changing timezone requires server restart to take full effect- </span>- </div>- </div>- </div>- );-};--const STAR_PROMPT_KEY = 'serverkit-star-prompt-dismissed';--const AboutSection = () => {- const [version, setVersion] = useState('...');- const [updateInfo, setUpdateInfo] = useState(null);- const [checkingUpdate, setCheckingUpdate] = useState(false);- const [showStarPrompt, setShowStarPrompt] = useState(() => {- return localStorage.getItem(STAR_PROMPT_KEY) !== 'true';- });-- useEffect(() => {- const fetchVersion = async () => {- try {- const data = await api.getVersion();- setVersion(data.version || '1.0.0');- } catch (error) {- setVersion('1.0.0');- }- };- fetchVersion();- }, []);-- const dismissStarPrompt = () => {- setShowStarPrompt(false);- localStorage.setItem(STAR_PROMPT_KEY, 'true');- };-- const checkForUpdate = async () => {- setCheckingUpdate(true);- try {- const data = await api.checkUpdate();- setUpdateInfo(data);- } catch (error) {- setUpdateInfo({ error: 'Failed to check for updates' });- }- setCheckingUpdate(false);- };-- return (- <div className="settings-section">- <div className="section-header">- <h2>About ServerKit</h2>- <p>Server management made simple</p>- </div>-- <div className="about-card">- <div className="about-logo">- <ServerKitLogo width={64} height={64} />- </div>- <h3>ServerKit</h3>- <p className="version">Version {version}</p>- <p className="description">- A modern, lightweight server management panel for managing web applications,- databases, domains, and more. Built with Flask and React.- </p>-- <div className="update-check">- {!updateInfo ? (- <button- className="btn btn-secondary btn-sm"- onClick={checkForUpdate}- disabled={checkingUpdate}- >- {checkingUpdate ? (- <><RefreshCw size={14} className="spinning" /> Checking...</>- ) : (- <><Download size={14} /> Check for Updates</>- )}- </button>- ) : updateInfo.error ? (- <div className="update-status error">- <span>{updateInfo.error}</span>- <button className="btn-link" onClick={checkForUpdate}>Retry</button>- </div>- ) : updateInfo.update_available ? (- <div className="update-status available">- <Download size={16} />- <span>Update available: <strong>v{updateInfo.latest_version}</strong></span>- <a- href={updateInfo.release_url}- target="_blank"- rel="noopener noreferrer"- className="btn btn-accent btn-sm"- >- View Release <ExternalLink size={12} />- </a>- </div>- ) : (- <div className="update-status current">- <CheckCircle size={16} />- <span>You're up to date!</span>- </div>- )}- </div>- </div>-- {showStarPrompt && (- <div className="star-prompt-card">- <button className="dismiss-btn" onClick={dismissStarPrompt} title="Dismiss">- <X size={16} />- </button>- <div className="star-icon">- <Star size={24} />- </div>- <div className="star-content">- <h4>Enjoying ServerKit?</h4>- <p>If you find ServerKit useful, consider starring the repository on GitHub. It helps others discover the project!</p>- <a- href="https://github.com/jhd3197/ServerKit"- target="_blank"- rel="noopener noreferrer"- className="btn btn-accent"- >- <Star size={16} />- Star on GitHub- </a>- </div>- </div>- )}-- <div className="settings-card">- <h3>Features</h3>- <ul className="feature-list">- <li>- <Check size={16} />- Application Management (PHP, Python, Node.js, Docker)- </li>- <li>- <Check size={16} />- Domain & SSL Certificate Management- </li>- <li>- <Check size={16} />- Database Management (MySQL, PostgreSQL)- </li>- <li>- <Check size={16} />- Docker Container Management- </li>- <li>- <Check size={16} />- System Monitoring & Alerts- </li>- <li>- <Check size={16} />- Automated Backups- </li>- <li>- <Check size={16} />- Git Deployment with Webhooks- </li>- </ul>- </div>-- <div className="settings-card">- <h3>Links</h3>- <div className="link-list">- <a href="https://github.com/jhd3197/ServerKit" target="_blank" rel="noopener noreferrer" className="link-item">- <Github size={18} />- GitHub Repository- </a>- <a href="https://github.com/jhd3197/ServerKit#readme" target="_blank" rel="noopener noreferrer" className="link-item">- <FileText size={18} />- Documentation- </a>- <a href="https://github.com/jhd3197/ServerKit/issues" target="_blank" rel="noopener noreferrer" className="link-item">- <HelpCircle size={18} />- Support & Issues- </a>- <a href="https://github.com/jhd3197/ServerKit/discussions" target="_blank" rel="noopener noreferrer" className="link-item">- <MessageSquare size={18} />- Discussions- </a>- <a href="https://github.com/jhd3197/ServerKit/issues/new" target="_blank" rel="noopener noreferrer" className="link-item">- <Bug size={18} />- Report a Bug- </a>- </div>- </div>-- <div className="settings-card">- <h3>License</h3>- <p className="license-text">- ServerKit is open source software licensed under the MIT License.- </p>- </div>- </div>- );-};--const SiteSettings = ({ onDevModeChange }) => {- const [settings, setSettings] = useState({- registration_enabled: false,- dev_mode: false- });- const [loading, setLoading] = useState(true);- const [saving, setSaving] = useState(false);- const [message, setMessage] = useState(null);-- useEffect(() => {- loadSettings();- }, []);-- async function loadSettings() {- try {- const data = await api.getSystemSettings();- setSettings({- registration_enabled: data.registration_enabled || false,- dev_mode: data.dev_mode || false- });- } catch (err) {- console.error('Failed to load settings:', err);- } finally {- setLoading(false);- }- }-- async function handleToggleSetting(key, label) {- setSaving(true);- setMessage(null);-- try {- const newValue = !settings[key];- await api.updateSystemSetting(key, newValue);- setSettings({ ...settings, [key]: newValue });- setMessage({ type: 'success', text: `${label} ${newValue ? 'enabled' : 'disabled'}` });- if (key === 'dev_mode' && onDevModeChange) {- onDevModeChange(newValue);- }- } catch (err) {- setMessage({ type: 'error', text: err.message || 'Failed to update setting' });- } finally {- setSaving(false);- }- }-- if (loading) {- return <div className="settings-section"><p>Loading...</p></div>;- }-- return (- <div className="settings-section">- <h2>Site Settings</h2>- <p className="section-description">Configure global site settings</p>-- {message && (- <div className={`message ${message.type}`}>{message.text}</div>- )}-- <div className="settings-card">- <h3>User Registration</h3>- <p>Allow new users to create accounts on the login page.</p>-- <div className="form-group">- <label className="toggle-switch-label">- <span>Enable public registration</span>- <label className="toggle-switch">- <input- type="checkbox"- checked={settings.registration_enabled}- onChange={() => handleToggleSetting('registration_enabled', 'User registration')}- disabled={saving}- />- <span className="toggle-slider"></span>- </label>- </label>- <span className="form-help">- When disabled, only administrators can create new user accounts.- </span>- </div>- </div>-- <div className="settings-card">- <h3>Developer Mode</h3>- <p>Enable developer tools and diagnostics.</p>-- <div className="form-group">- <label className="toggle-switch-label">- <span>Enable developer mode</span>- <label className="toggle-switch">- <input- type="checkbox"- checked={settings.dev_mode}- onChange={() => handleToggleSetting('dev_mode', 'Developer mode')}- disabled={saving}- />- <span className="toggle-slider"></span>- </label>- </label>- <span className="form-help">- Enables the Developer tab with icon reference and diagnostic tools.- </span>- </div>- </div>- </div>- );-};--const ICON_CATALOG = {- 'General': {- Search, X, Check, Copy, Plus, Trash2, Edit3, Save, Eye, Info,- HelpCircle, AlertTriangle, AlertCircle, ExternalLink, Link, Unlink,- ChevronDown, ChevronRight, ChevronUp, ArrowRight, ArrowLeft,- ArrowUpRight, ArrowDownLeft, ArrowUpCircle- },- 'Status': {- CheckCircle, XCircle, Loader, RefreshCw, RotateCcw, Activity,- Zap, Sparkles- },- 'Files & Data': {- FileText, FolderOpen, Archive, Download, Package, Database,- HardDrive, Layers, Tag- },- 'Media': {- Image, Video, Music, Camera- },- 'Development': {- Code, Terminal, GitBranch, GitCommit, GitCompare, Rocket,- Bug, Container, Workflow, Layout- },- 'Infrastructure': {- Server, Globe, Cloud, Shield, Lock, Unlock, Cpu, MemoryStick,- Radio, Monitor- },- 'Communication': {- MessageSquare, Users- },- 'Navigation & UI': {- Home, Star, Sun, Moon, Palette, Play, Square, Calendar, Clock,- LogOut, SettingsIcon, Newspaper, TrendingUp, BarChart3, Minus- },- 'Brands': {- Github- }-};--const IconReference = () => {- const [searchQuery, setSearchQuery] = useState('');- const [copiedIcon, setCopiedIcon] = useState(null);-- function handleCopyImport(name) {- navigator.clipboard.writeText(name);- setCopiedIcon(name);- setTimeout(() => setCopiedIcon(null), 1500);- }-- const filteredCatalog = Object.entries(ICON_CATALOG).reduce((acc, [group, icons]) => {- if (!searchQuery) {- acc[group] = icons;- return acc;- }- const filtered = Object.entries(icons).filter(([name]) =>- name.toLowerCase().includes(searchQuery.toLowerCase())- );- if (filtered.length > 0) {- acc[group] = Object.fromEntries(filtered);- }- return acc;- }, {});-- const totalIcons = Object.values(ICON_CATALOG).reduce((sum, icons) => sum + Object.keys(icons).length, 0);-- return (- <div className="settings-section">- <h2>Icon Reference</h2>- <p className="section-description">- Lucide React icons available in the project ({totalIcons} icons). Click an icon name to copy it.- </p>-- <div className="settings-card">- <div className="form-group">- <div className="search-input-wrapper" style={{ position: 'relative' }}>- <Search size={16} style={{ position: 'absolute', left: 12, top: '50%', transform: 'translateY(-50%)', opacity: 0.5 }} />- <input- type="text"- placeholder="Search icons..."- value={searchQuery}- onChange={(e) => setSearchQuery(e.target.value)}- className="form-input"- style={{ paddingLeft: 36 }}- />- </div>- </div>- </div>-- {Object.entries(filteredCatalog).map(([group, icons]) => (- <div key={group} className="settings-card">- <h3>{group}</h3>- <div className="icon-reference-grid">- {Object.entries(icons).map(([name, IconComp]) => (- <button- key={name}- className={`icon-reference-item ${copiedIcon === name ? 'copied' : ''}`}- onClick={() => handleCopyImport(name)}- title={`Click to copy "${name}"`}- >- <IconComp size={20} />- <span className="icon-reference-name">- {copiedIcon === name ? 'Copied!' : name}- </span>- </button>- ))}- </div>- </div>- ))}-- {Object.keys(filteredCatalog).length === 0 && (- <div className="settings-card">- <p style={{ textAlign: 'center', opacity: 0.5 }}>No icons match "{searchQuery}"</p>- </div>- )}- </div>- );-};--// Helper functions-function formatBytes(bytes) {- if (!bytes) return '-';- const units = ['B', 'KB', 'MB', 'GB', 'TB'];- let i = 0;- while (bytes >= 1024 && i < units.length - 1) {- bytes /= 1024;- i++;- }- return `${bytes.toFixed(1)} ${units[i]}`;-}--function formatUptime(seconds) {- if (!seconds) return '-';- const days = Math.floor(seconds / 86400);- const hours = Math.floor((seconds % 86400) / 3600);- const minutes = Math.floor((seconds % 3600) / 60);-- const parts = [];- if (days > 0) parts.push(`${days}d`);- if (hours > 0) parts.push(`${hours}h`);- if (minutes > 0) parts.push(`${minutes}m`);-- return parts.join(' ') || '< 1m';-}-export default Settings;diff --git a/frontend/src/pages/Setup.jsx b/frontend/src/pages/Setup.jsxindex 8a324953..d96f3969 100644--- a/frontend/src/pages/Setup.jsx+++ b/frontend/src/pages/Setup.jsx@@ -125,9 +125,8 @@ const Setup = () => {{currentStep > 2 && (<button- className="btn-wizard-prev"+ className="btn-wizard-prev mb-4"onClick={handleBack}- style={{ marginBottom: 16 }}><ArrowLeft size={16} />Backdiff --git a/frontend/src/pages/Terminal.jsx b/frontend/src/pages/Terminal.jsxindex 29fc3b88..68a6a095 100644--- a/frontend/src/pages/Terminal.jsx+++ b/frontend/src/pages/Terminal.jsx@@ -2,6 +2,8 @@ import React, { useState, useEffect, useRef } from 'react';import useTabParam from '../hooks/useTabParam';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { ConfirmDialog } from '../components/ConfirmDialog';const VALID_TABS = ['logs', 'journal', 'processes', 'services'];@@ -76,6 +78,7 @@ const Terminal = () => {};const LogFilesTab = () => {+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();const [logFiles, setLogFiles] = useState([]);const [selectedLog, setSelectedLog] = useState(null);const [logContent, setLogContent] = useState('');@@ -141,7 +144,8 @@ const LogFilesTab = () => {async function handleClearLog() {if (!selectedLog) return;- if (!confirm(`Clear ${selectedLog}? This cannot be undone.`)) return;+ const confirmed = await confirm({ title: 'Clear Log', message: `Clear ${selectedLog}? This cannot be undone.` });+ if (!confirmed) return;try {await api.clearLog(selectedLog);@@ -310,6 +314,16 @@ const LogFilesTab = () => {</div></div></div>+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ /></div>);};@@ -460,6 +474,7 @@ const JournalTab = () => {const ProcessesTab = () => {const toast = useToast();+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();const [processes, setProcesses] = useState([]);const [loading, setLoading] = useState(true);const [sortBy, setSortBy] = useState('cpu');@@ -486,7 +501,8 @@ const ProcessesTab = () => {const confirmMsg = force? `Force kill process ${pid}? This may cause data loss.`: `Kill process ${pid}?`;- if (!confirm(confirmMsg)) return;+ const confirmed = await confirm({ title: force ? 'Force Kill Process' : 'Kill Process', message: confirmMsg, variant: force ? 'danger' : 'warning' });+ if (!confirmed) return;try {await api.killProcess(pid, force);@@ -688,6 +704,16 @@ const ProcessesTab = () => {</div></div>)}+ <ConfirmDialog+ isOpen={confirmState.isOpen}+ title={confirmState.title}+ message={confirmState.message}+ confirmText={confirmState.confirmText}+ cancelText={confirmState.cancelText}+ variant={confirmState.variant}+ onConfirm={handleConfirm}+ onCancel={handleCancel}+ /></div>);};diff --git a/frontend/src/pages/WordPressDetail.jsx b/frontend/src/pages/WordPressDetail.jsxindex 194f1199..6b7feb85 100644--- a/frontend/src/pages/WordPressDetail.jsx+++ b/frontend/src/pages/WordPressDetail.jsx@@ -24,7 +24,7 @@ const DetailPageSkeleton = () => (<div className="skeleton" style={{ width: 300, height: 16 }} /></div></div>- <div className="app-detail-tabs" style={{ display: 'flex', gap: 8 }}>+ <div className="app-detail-tabs flex gap-2">{[1, 2, 3, 4, 5, 6, 7].map(i => (<div key={i} className="skeleton" style={{ width: 80, height: 32, borderRadius: 4 }} />))}@@ -894,7 +894,7 @@ const DatabaseTab = ({ siteId, site }) => {</div>{/* Snapshots */}- <div className="section-header" style={{ marginTop: 24 }}>+ <div className="section-header mt-6"><h3>Database Snapshots</h3><button className="btn btn-primary" onClick={() => setShowCreateModal(true)}><Plus size={14} /> Create Snapshotdiff --git a/frontend/src/pages/WordPressProject.jsx b/frontend/src/pages/WordPressProject.jsxindex e96e8b68..37c22a19 100644--- a/frontend/src/pages/WordPressProject.jsx+++ b/frontend/src/pages/WordPressProject.jsx@@ -793,7 +793,7 @@ const CreatePipelineEnvModal = ({ onClose, onCreate, productionDomain, existingT{formData.type === 'multidev' && (<div className="form-group"><label>- <GitBranch size={14} style={{ marginRight: 4, verticalAlign: -2 }} />+ <GitBranch size={14} className="mr-1" style={{ verticalAlign: -2 }} />Git Branch *</label>@@ -898,9 +898,8 @@ const CreatePipelineEnvModal = ({ onClose, onCreate, productionDomain, existingT{branches.length > 0 && (<buttontype="button"- className="btn btn-ghost btn-sm"+ className="btn btn-ghost btn-sm mt-1"onClick={() => { setUseCustomBranch(false); setFormData(prev => ({ ...prev, branch: '' })); }}- style={{ marginTop: 4 }}>Back to branch list</button>diff --git a/frontend/src/pages/Workspaces.jsx b/frontend/src/pages/Workspaces.jsxindex 58138490..4e40be71 100644--- a/frontend/src/pages/Workspaces.jsx+++ b/frontend/src/pages/Workspaces.jsx@@ -204,7 +204,7 @@ const Workspaces = () => {<div key={m.id} className="member-row"><div><strong>{m.username || m.email}</strong>- <span className="badge badge--outline" style={{ marginLeft: 8 }}>{m.role}</span>+ <span className="badge badge--outline ml-2">{m.role}</span></div>{m.role !== 'owner' && (<button className="btn btn--sm btn--danger" onClick={() => handleRemoveMember(m.id)}>Remove</button>diff --git a/frontend/src/styles/base/_utilities.scss b/frontend/src/styles/base/_utilities.scssindex c80b0e79..d86d1825 100644--- a/frontend/src/styles/base/_utilities.scss+++ b/frontend/src/styles/base/_utilities.scss@@ -11,9 +11,17 @@.flex-wrap { flex-wrap: wrap; }.flex-col { flex-direction: column; }.items-center { align-items: center; }+.items-start { align-items: flex-start; }+.items-end { align-items: flex-end; }+.self-start { align-self: flex-start; }+.self-end { align-self: flex-end; }+.self-center { align-self: center; }.justify-between { justify-content: space-between; }.justify-end { justify-content: flex-end; }.justify-center { justify-content: center; }+.flex-1 { flex: 1; }+.flex-shrink-0 { flex-shrink: 0; }+.flex-grow { flex-grow: 1; }// --------------------------------------------// GRID@@ -65,6 +73,7 @@.mt-4 { margin-top: 1rem; }.mt-6 { margin-top: 1.5rem; }.mt-8 { margin-top: 2rem; }+.mt-10 { margin-top: 2.5rem; }.mb-1 { margin-bottom: 0.25rem; }.mb-2 { margin-bottom: 0.5rem; }@@ -77,6 +86,7 @@.ml-2 { margin-left: 0.5rem; }.ml-3 { margin-left: 0.75rem; }.ml-4 { margin-left: 1rem; }+.ml-auto { margin-left: auto; }.mr-1 { margin-right: 0.25rem; }.mr-2 { margin-right: 0.5rem; }@@ -101,7 +111,13 @@// SIZING// --------------------------------------------.w-full { width: 100%; }+.w-auto { width: auto; }.w-\[1px\] { width: 1px; }+.min-w-0 { min-width: 0; }+.max-w-sm { max-width: 24rem; }+.max-w-md { max-width: 28rem; }+.max-w-lg { max-width: 32rem; }+.max-w-xl { max-width: 36rem; }.h-6 { height: 1.5rem; }.h-full { height: 100%; }@@ -112,27 +128,28 @@.text-sm { font-size: 0.875rem; }.text-lg { font-size: 1.125rem; }.text-xl { font-size: 1.25rem; }-.text-gray-300 { color: #d1d5db; }-.text-gray-400 { color: #9ca3af; }-.text-gray-500 { color: #6b7280; }-.text-gray-600 { color: #4b5563; }-.text-blue-600 { color: #2563eb; }-.text-green-600 { color: #16a34a; }-.text-red-600 { color: #dc2626; }-.text-green-400 { color: #4ade80; }+.text-gray-300 { color: $text-tertiary; }+.text-gray-400 { color: $text-tertiary; }+.text-gray-500 { color: $text-secondary; }+.text-gray-600 { color: $text-secondary; }+.text-blue-600 { color: $accent-primary; }+.text-green-600 { color: $success; }+.text-red-600 { color: $danger; }+.text-green-400 { color: $success; }.font-medium { font-weight: 500; }.font-semibold { font-weight: 600; }.font-bold { font-weight: 700; }.text-center { text-align: center; }+.text-right { text-align: right; }// --------------------------------------------// BACKGROUNDS// ---------------------------------------------.bg-gray-700 { background-color: #374151; }-.bg-gray-100 { background-color: #f3f4f6; }-.bg-blue-100 { background-color: #dbeafe; }-.bg-green-100 { background-color: #dcfce7; }-.bg-red-100 { background-color: #fee2e2; }+.bg-gray-700 { background-color: $bg-hover; }+.bg-gray-100 { background-color: $bg-elevated; }+.bg-blue-100 { background-color: fade($accent-primary-raw, 10%); }+.bg-green-100 { background-color: fade($success, 10%); }+.bg-red-100 { background-color: fade($danger, 10%); }.bg-body { background-color: $bg-body; }// --------------------------------------------@@ -147,8 +164,16 @@// MISC// --------------------------------------------.block { display: block; }+.inline-flex { display: inline-flex; }.hidden { display: none; }+.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.whitespace-nowrap { white-space: nowrap; }+.overflow-hidden { overflow: hidden; }.overflow-y-auto { overflow-y: auto; }+.cursor-pointer { cursor: pointer; }+.inline-block { display: inline-block; }+.btn-dismiss { float: right; background: none; border: none; cursor: pointer; color: inherit; }+.align-middle { vertical-align: middle; }.max-h-24 { max-height: 6rem; }.animate-spin { animation: spin 1s linear infinite; }.animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }diff --git a/frontend/src/styles/components/_empty-state.scss b/frontend/src/styles/components/_empty-state.scssnew file mode 100644index 00000000..0f34186a--- /dev/null+++ b/frontend/src/styles/components/_empty-state.scss@@ -0,0 +1,33 @@+.empty-state {+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ padding: $spacing-xl * 2;+ text-align: center;+ min-height: 200px;++ &__icon {+ color: $text-tertiary;+ margin-bottom: $spacing-md;+ opacity: 0.5;+ }++ &__title {+ font-size: $font-size-lg;+ font-weight: $font-weight-semibold;+ color: $text-secondary;+ margin: 0 0 $spacing-sm;+ }++ &__description {+ font-size: $font-size-sm + 1;+ color: $text-tertiary;+ max-width: 400px;+ margin: 0 0 $spacing-md;+ }++ &__action {+ margin-top: $spacing-sm;+ }+}diff --git a/frontend/src/styles/components/_forms.scss b/frontend/src/styles/components/_forms.scssindex a0f796cc..e8957f6e 100644--- a/frontend/src/styles/components/_forms.scss+++ b/frontend/src/styles/components/_forms.scss@@ -107,6 +107,21 @@}}+// Standalone form elements (used outside .form-group)+.form-input {+ @include input-base();+}++.form-select {+ @include input-base();+ cursor: pointer;+ appearance: none;+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");+ background-repeat: no-repeat;+ background-position: right $space-4 center;+ padding-right: $space-10;+}+// Code editor textarea.code-editor {width: 100%;diff --git a/frontend/src/styles/components/_status-badge.scss b/frontend/src/styles/components/_status-badge.scssnew file mode 100644index 00000000..31a4e728--- /dev/null+++ b/frontend/src/styles/components/_status-badge.scss@@ -0,0 +1,47 @@+.status-badge {+ display: inline-flex;+ align-items: center;+ gap: $spacing-xs;+ padding: 2px $spacing-sm;+ border-radius: $radius-full;+ font-size: $font-size-xs + 1;+ font-weight: $font-weight-medium;+ line-height: 1.4;++ &__dot {+ width: 6px;+ height: 6px;+ border-radius: 50%;+ flex-shrink: 0;+ }++ &--success {+ background: rgba($success, 0.15);+ color: $success;+ .status-badge__dot { background: $success; }+ }++ &--danger {+ background: rgba($danger, 0.15);+ color: $danger;+ .status-badge__dot { background: $danger; }+ }++ &--warning {+ background: rgba($warning, 0.15);+ color: $warning;+ .status-badge__dot { background: $warning; }+ }++ &--info {+ background: rgba($accent-primary-raw, 0.15);+ color: $accent-primary;+ .status-badge__dot { background: $accent-primary; }+ }++ &--muted {+ background: $bg-hover;+ color: $text-tertiary;+ .status-badge__dot { background: $text-tertiary; }+ }+}diff --git a/frontend/src/styles/components/_users.scss b/frontend/src/styles/components/_users.scssindex 5e7337c6..fd8cfe99 100644--- a/frontend/src/styles/components/_users.scss+++ b/frontend/src/styles/components/_users.scss@@ -446,6 +446,15 @@color: $text-tertiary;text-transform: uppercase;letter-spacing: 0.1em;++ &:first-child {+ margin-top: 0;+ }+}++.settings-nav-spacer {+ flex: 1;+ min-height: $space-4;}// --------------------------------------------diff --git a/frontend/src/styles/layout/_main-content.scss b/frontend/src/styles/layout/_main-content.scssindex 4f91d2a5..b1655f8b 100644--- a/frontend/src/styles/layout/_main-content.scss+++ b/frontend/src/styles/layout/_main-content.scss@@ -111,9 +111,14 @@color: $text-secondary;}-// Loading state+// Loading state (full-page spinner).loading {@include flex-center();- min-height: 100vh;+ min-height: 60vh;color: $text-secondary;}++// Route-level loading (within dashboard)+.loading-state {+ min-height: 40vh;+}diff --git a/frontend/src/styles/layout/_sidebar.scss b/frontend/src/styles/layout/_sidebar.scssindex 980bd5bf..471933bc 100644--- a/frontend/src/styles/layout/_sidebar.scss+++ b/frontend/src/styles/layout/_sidebar.scss@@ -595,6 +595,39 @@}}+.view-switcher {+ display: flex;+ flex-wrap: wrap;+ gap: 4px;+}++.view-btn {+ display: inline-flex;+ align-items: center;+ gap: 4px;+ padding: 4px 8px;+ border: 1px solid $border-subtle;+ background: transparent;+ color: $text-tertiary;+ font-size: 0.65rem;+ font-weight: $font-weight-medium;+ border-radius: $radius-sm;+ cursor: pointer;+ transition: all 0.15s ease;++ &:hover {+ border-color: $border-active;+ color: $text-primary;+ background: rgba(255, 255, 255, 0.03);+ }++ &.active {+ border-color: $accent-primary;+ color: $accent-primary;+ background: $accent-glow;+ }+}+.context-menu-divider {height: 1px;background: $border-subtle;diff --git a/frontend/src/styles/main.scss b/frontend/src/styles/main.scssindex 36f118cf..716b8740 100644--- a/frontend/src/styles/main.scss+++ b/frontend/src/styles/main.scss@@ -53,6 +53,8 @@@import 'components/_users';@import 'components/_linked-apps';@import 'components/_api-settings';+@import 'components/_empty-state';+@import 'components/_status-badge';// --------------------------------------------// 5. PAGE-SPECIFIC STYLESdiff --git a/frontend/src/styles/pages/_settings.scss b/frontend/src/styles/pages/_settings.scssindex fd675e33..874b4847 100644--- a/frontend/src/styles/pages/_settings.scss+++ b/frontend/src/styles/pages/_settings.scss@@ -511,6 +511,38 @@}}+// Div-based toggle (used in SidebarSettings)+// Mirrors the input-based .toggle-switch above but driven by .on class+.toggle-switch:not(:has(input)) {+ width: 44px;+ height: 24px;+ background: $border-active;+ border-radius: 24px;+ cursor: pointer;+ transition: background $transition-fast;+ flex-shrink: 0;++ &.on {+ background: $accent-primary;++ .toggle-knob {+ transform: translateX(20px);+ }+ }++ .toggle-knob {+ position: absolute;+ height: 18px;+ width: 18px;+ left: 3px;+ top: 3px;+ background: white;+ border-radius: 50%;+ transition: transform $transition-fast;+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);+ }+}+// Toggle Label (checkbox + text inline).toggle-label {display: flex !important;diff --git a/frontend/vite.config.js b/frontend/vite.config.jsindex 75040fcf..f5ca9ad8 100644--- a/frontend/vite.config.js+++ b/frontend/vite.config.js@@ -18,7 +18,7 @@ export default defineConfig({// Silence Dart Sass deprecation warnings for @import and slash-div// These are expected during migration from LESS and will be addressed// when moving to @use/@forward module system- silenceDeprecations: ['import', 'slash-div', 'legacy-js-api', 'global-builtin'],+ silenceDeprecations: ['import', 'slash-div', 'legacy-js-api', 'global-builtin', 'color-functions', 'strict-unary'],},},},