diff --git a/app/src/pages/ConfigEditor.tsx b/app/src/pages/ConfigEditor.tsx deleted file mode 100644 index a8cb794..0000000 --- a/app/src/pages/ConfigEditor.tsx +++ /dev/null @@ -1,146 +0,0 @@ -import { useState } from "react" -import { Link } from "react-router-dom" -import { ArrowLeft, Check, Loader2, Zap } from "lucide-react" -import { useQuery, useQueryClient } from "@tanstack/react-query" -import { apiClient } from "@/services/api/client" -import type { DeploymentDetail } from "@/types" -import { AddDeployment } from "@/components/AddDeployment" -import { DeploymentEditor } from "@/components/DeploymentEditor" - -interface ApplyResult { - ok: boolean - actions: string[] - errors: string[] -} - -export function ConfigEditorPage() { - const qc = useQueryClient() - const [applying, setApplying] = useState(false) - const [message, setMessage] = useState<{ type: "ok" | "error"; text: string } | null>(null) - const [applyResult, setApplyResult] = useState(null) - - const { data: components, isLoading, refetch } = useQuery({ - queryKey: ["config-components"], - queryFn: async () => { - const list = await apiClient.get<{ id: string }[]>("/components") - const details = await Promise.all( - list.map((c) => apiClient.get(`/components/${c.id}`)) - ) - return details - }, - }) - - const handleSave = async (name: string, config: Record) => { - setMessage(null) - setApplyResult(null) - try { - await apiClient.put(`/config/components/${name}`, { config }) - setMessage({ type: "ok", text: `Saved ${name}` }) - refetch() - qc.invalidateQueries({ queryKey: ["components"] }) - } catch (e: unknown) { - const msg = e instanceof Error ? e.message : String(e) - setMessage({ type: "error", text: msg }) - } - } - - const handleDelete = async (name: string) => { - setMessage(null) - try { - await apiClient.delete(`/config/components/${name}`) - setMessage({ type: "ok", text: `Removed ${name}` }) - refetch() - qc.invalidateQueries({ queryKey: ["components"] }) - } catch (e: unknown) { - const msg = e instanceof Error ? e.message : String(e) - setMessage({ type: "error", text: msg }) - } - } - - const handleApply = async () => { - setApplying(true) - setMessage(null) - setApplyResult(null) - try { - const result = await apiClient.post("/config/apply") - setApplyResult(result) - setMessage({ - type: result.ok ? "ok" : "error", - text: result.ok ? "Applied successfully" : "Applied with errors", - }) - qc.invalidateQueries({ queryKey: ["components"] }) - qc.invalidateQueries({ queryKey: ["status"] }) - } catch (e: unknown) { - const msg = e instanceof Error ? e.message : String(e) - setMessage({ type: "error", text: msg }) - } finally { - setApplying(false) - } - } - - return ( -
-
-
- - Dashboard - -

Configuration

-
- -
- - {message && ( -
- - {message.type === "ok" && } - {message.text} - -
- )} - - {applyResult && ( -
- {applyResult.actions.map((a, i) => ( -
{a}
- ))} - {applyResult.errors.map((e, i) => ( -
{e}
- ))} -
- )} - - {isLoading ? ( -

Loading entries...

- ) : ( -
- {components?.map((comp) => ( - - ))} - c.id) ?? []} - onAdd={handleSave} - /> -
- )} -
- ) -}