Skip to content

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.

cleanup: remove orphaned components and unused shadcn primitives

Juan Denisb96626f96f2d
diff --git a/frontend/src/components/QueryRunner.jsx b/frontend/src/components/QueryRunner.jsx
deleted file mode 100644
index 9490f507..00000000
--- a/frontend/src/components/QueryRunner.jsx
+++ /dev/null
@@ -1,459 +0,0 @@
-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;
-
-const QueryRunner = ({ database, dbType, onClose }) => {
- const toast = useToast();
- const textareaRef = useRef(null);
-
- const [query, setQuery] = useState('');
- const [results, setResults] = useState(null);
- const [loading, setLoading] = useState(false);
- const [error, setError] = useState('');
- const [readonly, setReadonly] = useState(true);
- const [tables, setTables] = useState([]);
- const [selectedTable, setSelectedTable] = useState(null);
- const [tableStructure, setTableStructure] = useState(null);
- const [history, setHistory] = useState([]);
- const [showHistory, setShowHistory] = useState(false);
- const [sortConfig, setSortConfig] = useState({ column: null, direction: 'asc' });
- const [isAdmin, setIsAdmin] = useState(false);
-
- useEffect(() => {
- loadTables();
- loadHistory();
- checkAdminStatus();
-
- // Focus textarea on mount
- if (textareaRef.current) {
- textareaRef.current.focus();
- }
- }, []);
-
- async function checkAdminStatus() {
- try {
- const user = await api.getCurrentUser();
- setIsAdmin(user.role === 'admin');
- } catch (err) {
- console.error('Failed to check admin status:', err);
- }
- }
-
- async function loadTables() {
- try {
- let data;
- if (dbType === 'mysql') {
- data = await api.getMySQLTables(database.name);
- } else if (dbType === 'postgresql') {
- data = await api.getPostgreSQLTables(database.name);
- } else if (dbType === 'sqlite') {
- data = await api.getSQLiteTables(database.path);
- } else if (dbType === 'docker') {
- data = await api.getDockerDatabaseTables(database.container, database.name, database.password);
- }
- setTables(data?.tables || []);
- } catch (err) {
- console.error('Failed to load tables:', err);
- }
- }
-
- function loadHistory() {
- try {
- const stored = localStorage.getItem(HISTORY_KEY);
- if (stored) {
- const allHistory = JSON.parse(stored);
- const dbKey = dbType === 'sqlite' ? database.path : database.name;
- setHistory(allHistory[dbKey] || []);
- }
- } catch (err) {
- console.error('Failed to load query history:', err);
- }
- }
-
- function saveToHistory(sql) {
- try {
- const stored = localStorage.getItem(HISTORY_KEY);
- const allHistory = stored ? JSON.parse(stored) : {};
- const dbKey = dbType === 'sqlite' ? database.path : database.name;
-
- const dbHistory = allHistory[dbKey] || [];
- // Remove duplicate if exists
- const filtered = dbHistory.filter(h => h.query !== sql);
- // Add to front
- filtered.unshift({
- query: sql,
- timestamp: new Date().toISOString()
- });
- // Limit size
- allHistory[dbKey] = filtered.slice(0, MAX_HISTORY);
-
- localStorage.setItem(HISTORY_KEY, JSON.stringify(allHistory));
- setHistory(allHistory[dbKey]);
- } catch (err) {
- console.error('Failed to save query history:', err);
- }
- }
-
- async function executeQuery() {
- if (!query.trim()) {
- setError('Please enter a query');
- return;
- }
-
- setLoading(true);
- setError('');
- setResults(null);
-
- try {
- let result;
- if (dbType === 'mysql') {
- result = await api.executeMySQLQuery(database.name, query, readonly);
- } else if (dbType === 'postgresql') {
- result = await api.executePostgreSQLQuery(database.name, query, readonly);
- } else if (dbType === 'sqlite') {
- result = await api.executeSQLiteQuery(database.path, query, readonly);
- } else if (dbType === 'docker') {
- result = await api.executeDockerQuery(database.container, database.name, query, database.password, readonly);
- }
-
- if (result.success) {
- setResults(result);
- saveToHistory(query);
- toast.success(`Query executed in ${result.execution_time}s (${result.row_count} rows)`);
- } else {
- setError(result.error || 'Query execution failed');
- }
- } catch (err) {
- setError(err.message || 'Failed to execute query');
- } finally {
- setLoading(false);
- }
- }
-
- async function loadTableStructure(table) {
- setSelectedTable(table);
- try {
- let result;
- if (dbType === 'mysql') {
- result = await api.getMySQLTableStructure(database.name, table.name);
- } else if (dbType === 'postgresql') {
- result = await api.getPostgreSQLTableStructure(database.name, table.name);
- } else if (dbType === 'sqlite') {
- result = await api.getSQLiteTableStructure(database.path, table.name);
- }
- if (result.success) {
- setTableStructure(result.columns);
- }
- } catch (err) {
- console.error('Failed to load table structure:', err);
- }
- }
-
- function insertTableName(tableName) {
- const textarea = textareaRef.current;
- if (!textarea) return;
-
- const start = textarea.selectionStart;
- const end = textarea.selectionEnd;
- const newQuery = query.substring(0, start) + tableName + query.substring(end);
- setQuery(newQuery);
-
- // Restore focus and position cursor after table name
- setTimeout(() => {
- textarea.focus();
- textarea.setSelectionRange(start + tableName.length, start + tableName.length);
- }, 0);
- }
-
- function insertSelectAll(tableName) {
- setQuery(`SELECT * FROM ${tableName} LIMIT 100;`);
- if (textareaRef.current) {
- textareaRef.current.focus();
- }
- }
-
- function handleKeyDown(e) {
- // Ctrl+Enter or Cmd+Enter to execute
- if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
- e.preventDefault();
- executeQuery();
- }
- }
-
- function handleSort(columnIndex) {
- setSortConfig(prev => ({
- column: columnIndex,
- direction: prev.column === columnIndex && prev.direction === 'asc' ? 'desc' : 'asc'
- }));
- }
-
- function getSortedRows() {
- if (!results?.rows || sortConfig.column === null) {
- return results?.rows || [];
- }
-
- return [...results.rows].sort((a, b) => {
- const aVal = a[sortConfig.column];
- const bVal = b[sortConfig.column];
-
- // Handle nulls
- if (aVal === null && bVal === null) return 0;
- if (aVal === null) return 1;
- if (bVal === null) return -1;
-
- // Try numeric comparison
- const aNum = Number(aVal);
- const bNum = Number(bVal);
- if (!isNaN(aNum) && !isNaN(bNum)) {
- return sortConfig.direction === 'asc' ? aNum - bNum : bNum - aNum;
- }
-
- // String comparison
- const comparison = String(aVal).localeCompare(String(bVal));
- return sortConfig.direction === 'asc' ? comparison : -comparison;
- });
- }
-
- function exportToCSV() {
- if (!results?.columns || !results?.rows) return;
-
- const escape = (val) => {
- if (val === null) return '';
- const str = String(val);
- if (str.includes(',') || str.includes('"') || str.includes('\n')) {
- return `"${str.replace(/"/g, '""')}"`;
- }
- return str;
- };
-
- const header = results.columns.map(escape).join(',');
- const rows = results.rows.map(row => row.map(escape).join(','));
- const csv = [header, ...rows].join('\n');
-
- const blob = new Blob([csv], { type: 'text/csv' });
- const url = URL.createObjectURL(blob);
- const a = document.createElement('a');
- a.href = url;
- a.download = `query_results_${new Date().toISOString().slice(0, 10)}.csv`;
- a.click();
- URL.revokeObjectURL(url);
-
- toast.success('Results exported to CSV');
- }
-
- const dbName = dbType === 'sqlite' ? database.name : database.name;
-
- return (
- <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">
- <div className="query-runner-sidebar">
- <div className="sidebar-section">
- <h4>Tables ({tables.length})</h4>
- <div className="tables-list">
- {tables.map(table => (
- <div
- key={table.name}
- className={`table-item ${selectedTable?.name === table.name ? 'selected' : ''}`}
- onClick={() => loadTableStructure(table)}
- >
- <span className="table-name" title={table.name}>{table.name}</span>
- <span className="table-rows">{table.rows}</span>
- </div>
- ))}
- {tables.length === 0 && (
- <p className="hint">No tables found</p>
- )}
- </div>
- </div>
-
- {selectedTable && tableStructure && (
- <div className="sidebar-section">
- <h4>
- {selectedTable.name}
- <button
- className="btn-icon"
- title="SELECT * FROM table"
- onClick={() => insertSelectAll(selectedTable.name)}
- >
- <svg viewBox="0 0 24 24" width="14" height="14" stroke="currentColor" fill="none" strokeWidth="2">
- <polyline points="9 11 12 14 22 4"/>
- <path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"/>
- </svg>
- </button>
- </h4>
- <div className="columns-list">
- {tableStructure.map(col => (
- <div
- key={col.name}
- className="column-item"
- onClick={() => insertTableName(col.name)}
- title={`${col.type}${col.nullable ? '' : ' NOT NULL'}${col.key === 'PRI' || col.primary_key ? ' PRIMARY KEY' : ''}`}
- >
- <span className="column-name">{col.name}</span>
- <span className="column-type">{col.type}</span>
- </div>
- ))}
- </div>
- </div>
- )}
- </div>
-
- <div className="query-runner-main">
- <div className="query-editor">
- <textarea
- ref={textareaRef}
- value={query}
- onChange={(e) => setQuery(e.target.value)}
- onKeyDown={handleKeyDown}
- placeholder="Enter your SQL query here... (Ctrl+Enter to execute)"
- spellCheck={false}
- />
- <div className="query-actions">
- <div className="query-hints">
- {readonly && (
- <span className="hint">
- <svg viewBox="0 0 24 24" width="14" height="14" 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>
- Readonly mode - only SELECT, SHOW, DESCRIBE allowed
- </span>
- )}
- </div>
- <button
- className="btn btn-primary"
- onClick={executeQuery}
- disabled={loading || !query.trim()}
- >
- {loading ? 'Executing...' : 'Execute (Ctrl+Enter)'}
- </button>
- </div>
- </div>
-
- {error && (
- <div className="alert alert-danger">
- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">
- <circle cx="12" cy="12" r="10"/>
- <line x1="15" y1="9" x2="9" y2="15"/>
- <line x1="9" y1="9" x2="15" y2="15"/>
- </svg>
- {error}
- </div>
- )}
-
- {results && (
- <div className="query-results">
- <div className="results-header">
- <span className="results-info">
- {results.row_count} row{results.row_count !== 1 ? 's' : ''}
- {results.truncated && ` (truncated from ${results.total_rows})`}
- {' - '}{results.execution_time}s
- </span>
- <button
- className="btn btn-secondary btn-sm"
- onClick={exportToCSV}
- disabled={!results.rows?.length}
- >
- Export CSV
- </button>
- </div>
-
- {results.columns?.length > 0 ? (
- <div className="results-table-container">
- <table className="results-table">
- <thead>
- <tr>
- {results.columns.map((col, idx) => (
- <th
- key={idx}
- onClick={() => handleSort(idx)}
- className={sortConfig.column === idx ? `sorted-${sortConfig.direction}` : ''}
- >
- {col}
- {sortConfig.column === idx && (
- <span className="sort-indicator">
- {sortConfig.direction === 'asc' ? ' ▲' : ' ▼'}
- </span>
- )}
- </th>
- ))}
- </tr>
- </thead>
- <tbody>
- {getSortedRows().map((row, rowIdx) => (
- <tr key={rowIdx}>
- {row.map((cell, cellIdx) => (
- <td key={cellIdx} className={cell === null ? 'null-value' : ''}>
- {cell === null ? 'NULL' : String(cell)}
- </td>
- ))}
- </tr>
- ))}
- </tbody>
- </table>
- </div>
- ) : (
- <p className="hint">Query executed successfully. No results to display.</p>
- )}
- </div>
- )}
- </div>
- </div>
-
- {showHistory && (
- <div className="query-history-panel">
- <div className="history-header">
- <h4>Query History</h4>
- <button className="modal-close" onClick={() => setShowHistory(false)}>&times;</button>
- </div>
- <div className="history-list">
- {history.length === 0 ? (
- <p className="hint">No query history</p>
- ) : (
- history.map((item, idx) => (
- <div
- key={idx}
- className="history-item"
- onClick={() => {
- setQuery(item.query);
- setShowHistory(false);
- if (textareaRef.current) {
- textareaRef.current.focus();
- }
- }}
- >
- <code>{item.query}</code>
- <span className="history-time">
- {new Date(item.timestamp).toLocaleString()}
- </span>
- </div>
- ))
- )}
- </div>
- </div>
- )}
- </Modal>
- );
-};
-
-export default QueryRunner;
diff --git a/frontend/src/components/Toast.jsx b/frontend/src/components/Toast.jsx
deleted file mode 100644
index 011d864a..00000000
--- a/frontend/src/components/Toast.jsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import React from 'react';
-import { CheckCircle, XCircle, AlertTriangle, Info, X } from 'lucide-react';
-import { useToast } from '../contexts/ToastContext';
-
-const iconMap = {
- success: CheckCircle,
- error: XCircle,
- warning: AlertTriangle,
- info: Info
-};
-
-function ToastItem({ toast, onDismiss }) {
- const Icon = iconMap[toast.type] || Info;
-
- return (
- <div className={`toast toast-${toast.type}`}>
- <div className="toast-icon">
- <Icon size={18} />
- </div>
- <div className="toast-message">{toast.message}</div>
- <button className="toast-dismiss" onClick={() => onDismiss(toast.id)}>
- <X size={14} />
- </button>
- </div>
- );
-}
-
-export function ToastContainer() {
- const { toasts, removeToast } = useToast();
-
- if (toasts.length === 0) return null;
-
- return (
- <div className="toast-container">
- {toasts.map((toast) => (
- <ToastItem key={toast.id} toast={toast} onDismiss={removeToast} />
- ))}
- </div>
- );
-}
-
-export default ToastContainer;
diff --git a/frontend/src/components/UptimeGraph.jsx b/frontend/src/components/UptimeGraph.jsx
deleted file mode 100644
index 37b72b33..00000000
--- a/frontend/src/components/UptimeGraph.jsx
+++ /dev/null
@@ -1,226 +0,0 @@
-import React, { useState, useEffect } from 'react';
-import { Server, Activity, Clock, CheckCircle, AlertTriangle, XCircle } from 'lucide-react';
-import api from '../services/api';
-
-const UptimeGraph = ({ compact = false }) => {
- const [uptime, setUptime] = useState(null);
- const [graphData, setGraphData] = useState(null);
- const [stats, setStats] = useState(null);
- const [period, setPeriod] = useState('24h');
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
-
- useEffect(() => {
- loadData();
- }, [period]);
-
- const loadData = async () => {
- try {
- setLoading(true);
- const [uptimeRes, graphRes, statsRes] = await Promise.all([
- api.getCurrentUptime(),
- api.getUptimeGraph(period),
- api.getUptimeStats()
- ]);
-
- setUptime(uptimeRes);
- setGraphData(graphRes);
- setStats(statsRes);
- setError(null);
- } catch (err) {
- setError(err.message);
- } finally {
- setLoading(false);
- }
- };
-
- const getStatusColor = (status) => {
- switch (status) {
- case 'up': return 'var(--success)';
- case 'degraded': return 'var(--warning)';
- case 'down': return 'var(--danger)';
- default: return 'var(--border-subtle)';
- }
- };
-
- const getStatusIcon = (status) => {
- switch (status) {
- case 'up': return <CheckCircle size={16} />;
- case 'degraded': return <AlertTriangle size={16} />;
- case 'down': return <XCircle size={16} />;
- default: return <Activity size={16} />;
- }
- };
-
- const formatSegmentTime = (isoString) => {
- const date = new Date(isoString);
- if (period === '24h') {
- return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
- } else if (period === '7d') {
- return date.toLocaleDateString([], { weekday: 'short', hour: '2-digit' });
- } else {
- return date.toLocaleDateString([], { month: 'short', day: 'numeric' });
- }
- };
-
- const getUptimeClass = (percentage) => {
- if (percentage >= 99.9) return 'excellent';
- if (percentage >= 99) return 'good';
- if (percentage >= 95) return 'fair';
- return 'poor';
- };
-
- if (loading && !uptime) {
- return (
- <div className="uptime-card loading">
- <div className="loading-spinner" />
- </div>
- );
- }
-
- if (error) {
- return (
- <div className="uptime-card error">
- <AlertTriangle size={24} />
- <span>Failed to load uptime data</span>
- </div>
- );
- }
-
- const uptimeFormatted = uptime?.uptime_formatted || { days: 0, hours: 0, minutes: 0, seconds: 0 };
- const uptimePercent = graphData?.uptime_percentage || 100;
-
- if (compact) {
- return (
- <div className="uptime-compact">
- <div className="uptime-compact-status">
- <Server size={20} style={{ color: 'var(--success)' }} />
- <span className="uptime-compact-label">Uptime</span>
- <span className={`uptime-compact-percent ${getUptimeClass(uptimePercent)}`}>
- {uptimePercent}%
- </span>
- </div>
- <div className="uptime-compact-time">
- <span className="value">{uptimeFormatted.days}</span>
- <span className="unit">d</span>
- <span className="value">{String(uptimeFormatted.hours).padStart(2, '0')}</span>
- <span className="unit">h</span>
- <span className="value">{String(uptimeFormatted.minutes).padStart(2, '0')}</span>
- <span className="unit">m</span>
- </div>
- </div>
- );
- }
-
- return (
- <div className="uptime-card">
- <div className="uptime-header">
- <div className="uptime-title">
- <Server size={24} className="uptime-icon" />
- <div>
- <h3>Server Uptime</h3>
- <span className="uptime-status online">
- <span className="status-dot" />
- Operational
- </span>
- </div>
- </div>
- <div className="uptime-percentage">
- <span className={`percentage-value ${getUptimeClass(uptimePercent)}`}>
- {uptimePercent}%
- </span>
- <span className="percentage-label">uptime</span>
- </div>
- </div>
-
- <div className="uptime-counter">
- <div className="uptime-counter-item">
- <span className="counter-value">{uptimeFormatted.days}</span>
- <span className="counter-label">Days</span>
- </div>
- <span className="counter-separator">:</span>
- <div className="uptime-counter-item">
- <span className="counter-value">{String(uptimeFormatted.hours).padStart(2, '0')}</span>
- <span className="counter-label">Hours</span>
- </div>
- <span className="counter-separator">:</span>
- <div className="uptime-counter-item">
- <span className="counter-value">{String(uptimeFormatted.minutes).padStart(2, '0')}</span>
- <span className="counter-label">Minutes</span>
- </div>
- <span className="counter-separator">:</span>
- <div className="uptime-counter-item">
- <span className="counter-value">{String(uptimeFormatted.seconds).padStart(2, '0')}</span>
- <span className="counter-label">Seconds</span>
- </div>
- </div>
-
- <div className="uptime-graph-section">
- <div className="uptime-graph-header">
- <span className="graph-title">Uptime History</span>
- <div className="period-selector">
- {['24h', '7d', '30d', '90d'].map(p => (
- <button
- key={p}
- className={`period-btn ${period === p ? 'active' : ''}`}
- onClick={() => setPeriod(p)}
- >
- {p}
- </button>
- ))}
- </div>
- </div>
-
- <div className="uptime-graph">
- {graphData?.segments?.map((segment, index) => (
- <div
- key={index}
- className={`graph-bar ${segment.status}`}
- style={{ backgroundColor: getStatusColor(segment.status) }}
- title={`${formatSegmentTime(segment.start)}: ${segment.status}`}
- />
- ))}
- </div>
-
- <div className="uptime-graph-labels">
- <span>{period === '24h' ? '24 hours ago' : period === '7d' ? '7 days ago' : period === '30d' ? '30 days ago' : '90 days ago'}</span>
- <span>Now</span>
- </div>
- </div>
-
- <div className="uptime-legend">
- <div className="legend-item">
- <span className="legend-dot up" />
- <span>Operational</span>
- </div>
- <div className="legend-item">
- <span className="legend-dot degraded" />
- <span>Degraded</span>
- </div>
- <div className="legend-item">
- <span className="legend-dot down" />
- <span>Down</span>
- </div>
- <div className="legend-item">
- <span className="legend-dot no-data" />
- <span>No Data</span>
- </div>
- </div>
-
- {stats?.periods && (
- <div className="uptime-stats-grid">
- {Object.entries(stats.periods).map(([periodKey, periodStats]) => (
- <div key={periodKey} className="uptime-stat">
- <span className="stat-period">{periodKey}</span>
- <span className={`stat-value ${getUptimeClass(periodStats.uptime_percentage)}`}>
- {periodStats.uptime_percentage}%
- </span>
- </div>
- ))}
- </div>
- )}
- </div>
- );
-};
-
-export default UptimeGraph;
diff --git a/frontend/src/components/settings/AuditLogTab.jsx b/frontend/src/components/settings/AuditLogTab.jsx
deleted file mode 100644
index 1115ba78..00000000
--- a/frontend/src/components/settings/AuditLogTab.jsx
+++ /dev/null
@@ -1,258 +0,0 @@
-import React, { useState, useEffect } from 'react';
-import api from '../../services/api';
-import { Button } from '@/components/ui/button';
-import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from '@/components/ui/select';
-
-const AuditLogTab = () => {
- const [logs, setLogs] = useState([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState('');
- const [pagination, setPagination] = useState({
- page: 1,
- perPage: 50,
- total: 0,
- pages: 1
- });
- const [filters, setFilters] = useState({
- action: '',
- user_id: ''
- });
- const [actions, setActions] = useState([]);
-
- useEffect(() => {
- loadLogs();
- loadActions();
- }, [pagination.page, filters]);
-
- async function loadLogs() {
- try {
- setLoading(true);
- const params = {
- page: pagination.page,
- per_page: pagination.perPage
- };
- if (filters.action) params.action = filters.action;
- if (filters.user_id) params.user_id = filters.user_id;
-
- const data = await api.getAuditLogs(params);
- setLogs(data.logs);
- setPagination(prev => ({
- ...prev,
- total: data.pagination.total,
- pages: data.pagination.pages
- }));
- setError('');
- } catch (err) {
- setError(err.message || 'Failed to load audit logs');
- } finally {
- setLoading(false);
- }
- }
-
- async function loadActions() {
- try {
- const data = await api.getAuditLogActions();
- setActions(data.actions);
- } catch (err) {
- console.error('Failed to load action types:', err);
- }
- }
-
- function handlePageChange(newPage) {
- setPagination(prev => ({ ...prev, page: newPage }));
- }
-
- function formatDate(dateString) {
- if (!dateString) return '';
- return new Date(dateString).toLocaleString('en-US', {
- year: 'numeric',
- month: 'short',
- day: 'numeric',
- hour: '2-digit',
- minute: '2-digit',
- second: '2-digit'
- });
- }
-
- function getActionIcon(action) {
- if (action.includes('login')) {
- return (
- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">
- <path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/>
- <polyline points="10 17 15 12 10 7"/>
- <line x1="15" y1="12" x2="3" y2="12"/>
- </svg>
- );
- }
- if (action.includes('user')) {
- return (
- <svg viewBox="0 0 24 24" width="16" height="16" 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>
- );
- }
- if (action.includes('app') || action.includes('deploy')) {
- return (
- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">
- <rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
- <line x1="3" y1="9" x2="21" y2="9"/>
- <line x1="9" y1="21" x2="9" y2="9"/>
- </svg>
- );
- }
- if (action.includes('setting')) {
- return (
- <svg viewBox="0 0 24 24" width="16" height="16" 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>
- );
- }
- return (
- <svg viewBox="0 0 24 24" width="16" height="16" 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>
- );
- }
-
- function getActionClass(action) {
- if (action.includes('failed') || action.includes('delete')) return 'action-danger';
- if (action.includes('create') || action.includes('enable')) return 'action-success';
- if (action.includes('update') || action.includes('disable')) return 'action-warning';
- return 'action-info';
- }
-
- function formatActionName(action) {
- return action.replace(/\./g, ' ').replace(/_/g, ' ');
- }
-
- function renderDetails(details) {
- if (!details || Object.keys(details).length === 0) return null;
-
- return (
- <div className="log-details">
- {Object.entries(details).map(([key, value]) => (
- <span key={key} className="detail-item">
- <span className="detail-key">{key}:</span>
- <span className="detail-value">
- {typeof value === 'object' ? JSON.stringify(value) : String(value)}
- </span>
- </span>
- ))}
- </div>
- );
- }
-
- return (
- <div className="audit-log-tab">
- <div className="tab-header">
- <div className="tab-header-content">
- <h3>Audit Log</h3>
- <p>Track user actions and system events</p>
- </div>
- </div>
-
- <div className="filters-bar">
- <div className="filter-group">
- <label>Action Type</label>
- <Select
- value={filters.action || '__all__'}
- onValueChange={(val) => {
- const value = val === '__all__' ? '' : val;
- setFilters(prev => ({ ...prev, action: value }));
- setPagination(prev => ({ ...prev, page: 1 }));
- }}
- >
- <SelectTrigger>
- <SelectValue placeholder="All Actions" />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="__all__">All Actions</SelectItem>
- {actions.map(action => (
- <SelectItem key={action} value={action}>{formatActionName(action)}</SelectItem>
- ))}
- </SelectContent>
- </Select>
- </div>
- <Button variant="ghost" onClick={() => {
- setFilters({ action: '', user_id: '' });
- setPagination(prev => ({ ...prev, page: 1 }));
- }}>
- Clear Filters
- </Button>
- </div>
-
- {error && <div className="error-message">{error}</div>}
-
- {loading ? (
- <div className="loading-state">Loading audit logs...</div>
- ) : (
- <>
- <div className="audit-log-list">
- {logs.length === 0 ? (
- <div className="empty-state">No audit logs found</div>
- ) : (
- logs.map(log => (
- <div key={log.id} className={`log-entry ${getActionClass(log.action)}`}>
- <div className="log-icon">
- {getActionIcon(log.action)}
- </div>
- <div className="log-content">
- <div className="log-header">
- <span className="log-action">{formatActionName(log.action)}</span>
- <span className="log-user">
- by {log.username || 'System'}
- </span>
- {log.target_type && (
- <span className="log-target">
- on {log.target_type} {log.target_id ? `#${log.target_id}` : ''}
- </span>
- )}
- </div>
- {renderDetails(log.details)}
- <div className="log-meta">
- <span className="log-time">{formatDate(log.created_at)}</span>
- {log.ip_address && (
- <span className="log-ip">IP: {log.ip_address}</span>
- )}
- </div>
- </div>
- </div>
- ))
- )}
- </div>
-
- {pagination.pages > 1 && (
- <div className="pagination">
- <Button
- variant="ghost"
- size="sm"
- disabled={pagination.page <= 1}
- onClick={() => handlePageChange(pagination.page - 1)}
- >
- Previous
- </Button>
- <span className="pagination-info">
- Page {pagination.page} of {pagination.pages}
- ({pagination.total} total)
- </span>
- <Button
- variant="ghost"
- size="sm"
- disabled={pagination.page >= pagination.pages}
- onClick={() => handlePageChange(pagination.page + 1)}
- >
- Next
- </Button>
- </div>
- )}
- </>
- )}
- </div>
- );
-};
-
-export default AuditLogTab;
diff --git a/frontend/src/components/ui/accordion.jsx b/frontend/src/components/ui/accordion.jsx
deleted file mode 100644
index 7de76e46..00000000
--- a/frontend/src/components/ui/accordion.jsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import * as React from 'react';
-import * as AccordionPrimitive from '@radix-ui/react-accordion';
-import { ChevronDown } from 'lucide-react';
-import { cn } from '@/lib/utils';
-
-const Accordion = AccordionPrimitive.Root;
-
-const AccordionItem = React.forwardRef(({ className, ...props }, ref) => (
- <AccordionPrimitive.Item ref={ref} className={cn('border-b border-border', className)} {...props} />
-));
-AccordionItem.displayName = 'AccordionItem';
-
-const AccordionTrigger = React.forwardRef(({ className, children, ...props }, ref) => (
- <AccordionPrimitive.Header className="flex">
- <AccordionPrimitive.Trigger
- ref={ref}
- className={cn(
- 'flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left',
- '[&[data-state=open]>svg]:rotate-180',
- className
- )}
- {...props}
- >
- {children}
- <ChevronDown className="size-4 shrink-0 text-muted-foreground transition-transform duration-200" />
- </AccordionPrimitive.Trigger>
- </AccordionPrimitive.Header>
-));
-AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
-
-const AccordionContent = React.forwardRef(({ className, children, ...props }, ref) => (
- <AccordionPrimitive.Content
- ref={ref}
- className="overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
- {...props}
- >
- <div className={cn('pb-4 pt-0', className)}>{children}</div>
- </AccordionPrimitive.Content>
-));
-AccordionContent.displayName = AccordionPrimitive.Content.displayName;
-
-export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
diff --git a/frontend/src/components/ui/avatar.jsx b/frontend/src/components/ui/avatar.jsx
deleted file mode 100644
index 509cc7c9..00000000
--- a/frontend/src/components/ui/avatar.jsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import * as React from 'react';
-import * as AvatarPrimitive from '@radix-ui/react-avatar';
-import { cn } from '@/lib/utils';
-
-const Avatar = React.forwardRef(({ className, ...props }, ref) => (
- <AvatarPrimitive.Root
- ref={ref}
- className={cn('relative flex size-8 shrink-0 overflow-hidden rounded-full', className)}
- {...props}
- />
-));
-Avatar.displayName = AvatarPrimitive.Root.displayName;
-
-const AvatarImage = React.forwardRef(({ className, ...props }, ref) => (
- <AvatarPrimitive.Image
- ref={ref}
- className={cn('aspect-square size-full', className)}
- {...props}
- />
-));
-AvatarImage.displayName = AvatarPrimitive.Image.displayName;
-
-const AvatarFallback = React.forwardRef(({ className, ...props }, ref) => (
- <AvatarPrimitive.Fallback
- ref={ref}
- className={cn(
- 'flex size-full items-center justify-center rounded-full bg-muted text-muted-foreground text-sm font-medium',
- className
- )}
- {...props}
- />
-));
-AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
-
-export { Avatar, AvatarImage, AvatarFallback };
diff --git a/frontend/src/components/ui/badge.jsx b/frontend/src/components/ui/badge.jsx
index b1b92ccb..7d4fdbb9 100644
--- a/frontend/src/components/ui/badge.jsx
+++ b/frontend/src/components/ui/badge.jsx
@@ -15,10 +15,4 @@ function Badge({ className, variant, ...props }) {
);
}
-// Backwards-compat shim: a few callers still import { badgeVariants }.
-// It now just returns a className string (no cva).
-function badgeVariants() {
- return '';
-}
-
-export { Badge, badgeVariants };
+export { Badge };
diff --git a/frontend/src/components/ui/progress.jsx b/frontend/src/components/ui/progress.jsx
deleted file mode 100644
index f92cc3c4..00000000
--- a/frontend/src/components/ui/progress.jsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import * as React from 'react';
-import * as ProgressPrimitive from '@radix-ui/react-progress';
-import { cn } from '@/lib/utils';
-
-const Progress = React.forwardRef(({ className, value, ...props }, ref) => (
- <ProgressPrimitive.Root
- ref={ref}
- className={cn('relative h-2 w-full overflow-hidden rounded-full bg-secondary', className)}
- {...props}
- >
- <ProgressPrimitive.Indicator
- className="h-full w-full flex-1 bg-primary transition-all"
- style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
- />
- </ProgressPrimitive.Root>
-));
-Progress.displayName = ProgressPrimitive.Root.displayName;
-
-export { Progress };
diff --git a/frontend/src/components/ui/scroll-area.jsx b/frontend/src/components/ui/scroll-area.jsx
deleted file mode 100644
index a029752e..00000000
--- a/frontend/src/components/ui/scroll-area.jsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import * as React from 'react';
-import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
-import { cn } from '@/lib/utils';
-
-const ScrollArea = React.forwardRef(({ className, children, ...props }, ref) => (
- <ScrollAreaPrimitive.Root
- ref={ref}
- className={cn('relative overflow-hidden', className)}
- {...props}
- >
- <ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
- {children}
- </ScrollAreaPrimitive.Viewport>
- <ScrollBar />
- <ScrollAreaPrimitive.Corner />
- </ScrollAreaPrimitive.Root>
-));
-ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
-
-const ScrollBar = React.forwardRef(({ className, orientation = 'vertical', ...props }, ref) => (
- <ScrollAreaPrimitive.ScrollAreaScrollbar
- ref={ref}
- orientation={orientation}
- className={cn(
- 'flex touch-none select-none transition-colors',
- orientation === 'vertical' && 'h-full w-2.5 border-l border-l-transparent p-[1px]',
- orientation === 'horizontal' && 'h-2.5 flex-col border-t border-t-transparent p-[1px]',
- className
- )}
- {...props}
- >
- <ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
- </ScrollAreaPrimitive.ScrollAreaScrollbar>
-));
-ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
-
-export { ScrollArea, ScrollBar };
diff --git a/frontend/src/components/ui/separator.jsx b/frontend/src/components/ui/separator.jsx
deleted file mode 100644
index f5241af5..00000000
--- a/frontend/src/components/ui/separator.jsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import * as React from 'react';
-import * as SeparatorPrimitive from '@radix-ui/react-separator';
-import { cn } from '@/lib/utils';
-
-const Separator = React.forwardRef(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => (
- <SeparatorPrimitive.Root
- ref={ref}
- decorative={decorative}
- orientation={orientation}
- className={cn(
- 'shrink-0 bg-border',
- orientation === 'horizontal' ? 'h-px w-full' : 'h-full w-px',
- className
- )}
- {...props}
- />
-));
-Separator.displayName = SeparatorPrimitive.Root.displayName;
-
-export { Separator };
diff --git a/frontend/src/components/ui/tooltip.jsx b/frontend/src/components/ui/tooltip.jsx
deleted file mode 100644
index 7885f7ee..00000000
--- a/frontend/src/components/ui/tooltip.jsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import * as React from 'react';
-import * as TooltipPrimitive from '@radix-ui/react-tooltip';
-import { cn } from '@/lib/utils';
-
-const TooltipProvider = TooltipPrimitive.Provider;
-const Tooltip = TooltipPrimitive.Root;
-const TooltipTrigger = TooltipPrimitive.Trigger;
-
-const TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => (
- <TooltipPrimitive.Portal>
- <TooltipPrimitive.Content
- ref={ref}
- sideOffset={sideOffset}
- className={cn(
- 'z-50 overflow-hidden rounded-md bg-popover px-3 py-1.5 text-xs text-popover-foreground border border-border shadow-md',
- 'animate-in fade-in-0 zoom-in-95',
- 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95',
- 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2',
- 'data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
- className
- )}
- {...props}
- />
- </TooltipPrimitive.Portal>
-));
-TooltipContent.displayName = TooltipPrimitive.Content.displayName;
-
-export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
diff --git a/frontend/src/components/workflow/BaseNode.jsx b/frontend/src/components/workflow/BaseNode.jsx
deleted file mode 100644
index ca1fbb36..00000000
--- a/frontend/src/components/workflow/BaseNode.jsx
+++ /dev/null
@@ -1,61 +0,0 @@
-import React, { memo } from 'react';
-import { Handle, Position } from '@xyflow/react';
-import { Box, Server, Database, Globe } from 'lucide-react';
-
-const iconMap = {
- docker: Server,
- database: Database,
- domain: Globe,
- default: Box
-};
-
-// Categorical node tints (redesign palette; docker brand blue kept).
-const colorMap = {
- docker: '#2496ed',
- database: '#f5b945',
- domain: '#3ddc97',
- default: '#6d7cff'
-};
-
-const BaseNode = ({ data, selected }) => {
- const Icon = iconMap[data.nodeType] || iconMap.default;
- const color = colorMap[data.nodeType] || colorMap.default;
-
- return (
- <div className={`workflow-node ${selected ? 'selected' : ''}`}>
- <Handle
- type="target"
- position={Position.Left}
- className="workflow-handle workflow-handle-target"
- />
-
- <div className="workflow-node-header" style={{ borderColor: color }}>
- <div className="workflow-node-icon" style={{ backgroundColor: color }}>
- <Icon size={16} />
- </div>
- <span className="workflow-node-type">
- {data.nodeType || 'Node'}
- </span>
- </div>
-
- <div className="workflow-node-body">
- <div className="workflow-node-label">
- {data.label || 'Untitled'}
- </div>
- {data.status && (
- <div className={`workflow-node-status status-${data.status}`}>
- {data.status}
- </div>
- )}
- </div>
-
- <Handle
- type="source"
- position={Position.Right}
- className="workflow-handle workflow-handle-source"
- />
- </div>
- );
-};
-
-export default memo(BaseNode);