({ onActionComplete }: QuickActionsProps)
| 26 | } |
| 27 | |
| 28 | export function QuickActions({ onActionComplete }: QuickActionsProps) { |
| 29 | const [loadingAction, setLoadingAction] = useState<string | null>(null); |
| 30 | const [showPasswordModal, setShowPasswordModal] = useState(false); |
| 31 | const [notification, setNotification] = useState<{ |
| 32 | type: "success" | "error"; |
| 33 | message: string; |
| 34 | } | null>(null); |
| 35 | |
| 36 | const showNotification = (type: "success" | "error", message: string) => { |
| 37 | setNotification({ type, message }); |
| 38 | setTimeout(() => setNotification(null), 3000); |
| 39 | }; |
| 40 | |
| 41 | const handleRestartGateway = async () => { |
| 42 | // Placeholder - would call openclaw gateway restart |
| 43 | showNotification("success", "Gateway restart command sent (placeholder)"); |
| 44 | }; |
| 45 | |
| 46 | const handleClearActivityLog = async () => { |
| 47 | setLoadingAction("clear_log"); |
| 48 | try { |
| 49 | const res = await fetch("/api/system", { |
| 50 | method: "POST", |
| 51 | headers: { "Content-Type": "application/json" }, |
| 52 | body: JSON.stringify({ action: "clear_activity_log" }), |
| 53 | }); |
| 54 | |
| 55 | if (!res.ok) throw new Error("Failed to clear logs"); |
| 56 | |
| 57 | showNotification("success", "Activity logs cleared"); |
| 58 | onActionComplete?.(); |
| 59 | } catch { |
| 60 | showNotification("error", "Failed to clear activity logs"); |
| 61 | } finally { |
| 62 | setLoadingAction(null); |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | const handleViewLogs = async () => { |
| 67 | // Placeholder - would open gateway logs |
| 68 | showNotification("success", "Opening gateway logs... (placeholder)"); |
| 69 | }; |
| 70 | |
| 71 | const actions: ActionButton[] = [ |
| 72 | { |
| 73 | id: "restart", |
| 74 | label: "Restart Gateway", |
| 75 | icon: RefreshCw, |
| 76 | color: "blue", |
| 77 | action: handleRestartGateway, |
| 78 | placeholder: true, |
| 79 | }, |
| 80 | { |
| 81 | id: "clear_log", |
| 82 | label: "Clear Activity Logs", |
| 83 | icon: Trash2, |
| 84 | color: "yellow", |
| 85 | action: handleClearActivityLog, |
nothing calls this directly
no test coverage detected