import { useEffect, useState } from "react"; import { Save, Settings2, X } from "lucide-react"; import { appopsClient } from "@/api/appopsClient"; import type { App } from "@/types/appops"; import { showError, showSuccess } from "@/utils/toast"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { formatOperatorError } from "@/lib/operatorError"; const criticalities: App["criticality"][] = ["low", "medium", "high", "critical"]; interface AppMetadataEditorProps { app: App; onSaved: (app: App) => void; } export const AppMetadataEditor = ({ app, onSaved }: AppMetadataEditorProps) => { const [editing, setEditing] = useState(false); const [busy, setBusy] = useState(false); const [name, setName] = useState(app.name); const [category, setCategory] = useState(app.category); const [criticality, setCriticality] = useState(app.criticality); useEffect(() => { if (editing) return; setName(app.name); setCategory(app.category); setCriticality(app.criticality); }, [app, editing]); const save = async () => { if (!name.trim() || !category.trim() || busy) return; setBusy(true); try { const result = await appopsClient.updateAppMetadata(app.id, { name: name.trim(), category: category.trim(), criticality, }); if (!result.success || !result.app) { showError(result.message || "App-metadata kon niet worden opgeslagen."); return; } onSaved(result.app); setEditing(false); showSuccess("App-metadata opgeslagen."); } catch (error) { showError(formatOperatorError(error, "App-metadata kon niet worden opgeslagen.")); } finally { setBusy(false); } }; if (!editing) { return ( ); } return (
setName(event.target.value)} maxLength={80} className="border-slate-800 bg-slate-950" />
setCategory(event.target.value)} maxLength={40} placeholder="Bijv. Productivity, Monitoring of Dev" className="border-slate-800 bg-slate-950" />
{criticalities.map(level => ( ))}

Wijzigt alleen de AppOps-catalogus. Containers, connectorconfig, protection en voice blijven ongewijzigd.

); };