"use client"; import { Package } from "lucide-react"; import { useEffect, useState } from "react"; import { Badge } from "@/components/ui/badge"; import { Checkbox } from "@/components/ui/checkbox"; import { api } from "@/lib/api-client"; import type { ServerFormPanelProps } from "./types"; type Artifact = { id: string; provider: string; name: string; version: string; filename: string; }; export function ArtifactSelector({ formData, updateField }: ServerFormPanelProps) { const [artifacts, setArtifacts] = useState([]); const [error, setError] = useState(null); useEffect(() => { void api.api.registry.artifacts .get() .then(({ data, error: responseError }) => { if (responseError) throw responseError; setArtifacts((data ?? []) as Artifact[]); }) .catch((loadError) => setError(loadError instanceof Error ? loadError.message : "Failed to load plugins") ); }, []); const toggle = (artifactId: string, checked: boolean) => { updateField( "registryArtifactIds", checked ? [...new Set([...formData.registryArtifactIds, artifactId])] : formData.registryArtifactIds.filter((id) => id !== artifactId) ); }; return (

Plugin Library

Select stored artifacts to deploy when this server is saved.

{formData.registryArtifactIds.length} selected
{error &&

{error}

} {artifacts.length === 0 ? (
Store or upload plugins from the global Plugins page first.
) : (
{artifacts.map((artifact) => { const checked = formData.registryArtifactIds.includes(artifact.id); return (
toggle(artifact.id, value === true)} />
); })}
)}
); }