()
| 27 | }; |
| 28 | |
| 29 | export function ArtifactLibrary() { |
| 30 | const [searchQuery, setSearchQuery] = useState(''); |
| 31 | const { |
| 32 | library, |
| 33 | libraryLoading, |
| 34 | libraryError, |
| 35 | fetchLibrary, |
| 36 | downloadArtifact, |
| 37 | downloading, |
| 38 | deleteArtifact, |
| 39 | deleting, |
| 40 | } = useArtifactStore(); |
| 41 | const [copiedRemoteUri, setCopiedRemoteUri] = useState<string | null>(null); |
| 42 | const [workflows, setWorkflows] = useState<Record<string, string>>({}); |
| 43 | |
| 44 | useEffect(() => { |
| 45 | const loadWorkflows = async () => { |
| 46 | try { |
| 47 | const list = await api.workflows.list(); |
| 48 | const map: Record<string, string> = {}; |
| 49 | list.forEach((w) => { |
| 50 | if (w.id) map[w.id] = w.name; |
| 51 | }); |
| 52 | setWorkflows(map); |
| 53 | } catch (err) { |
| 54 | console.error('Failed to load workflows', err); |
| 55 | } |
| 56 | }; |
| 57 | loadWorkflows(); |
| 58 | }, []); |
| 59 | |
| 60 | useEffect(() => { |
| 61 | void fetchLibrary(); |
| 62 | }, [fetchLibrary]); |
| 63 | |
| 64 | const handleSearch = (event: React.FormEvent<HTMLFormElement>) => { |
| 65 | event.preventDefault(); |
| 66 | void fetchLibrary({ |
| 67 | search: searchQuery.trim() || undefined, |
| 68 | }); |
| 69 | }; |
| 70 | |
| 71 | const handleRefresh = () => { |
| 72 | void fetchLibrary({ |
| 73 | search: searchQuery.trim() || undefined, |
| 74 | }); |
| 75 | }; |
| 76 | |
| 77 | return ( |
| 78 | <div className="flex-1 bg-background"> |
| 79 | <div className="container mx-auto py-4 md:py-8 px-3 md:px-4"> |
| 80 | <div className="mb-4 md:mb-8"> |
| 81 | <p className="text-sm md:text-base text-muted-foreground"> |
| 82 | Browse artifacts saved across workflow runs and reuse them in new automations. |
| 83 | </p> |
| 84 | </div> |
| 85 | |
| 86 | <div className="flex flex-col gap-3 md:flex-row md:items-center md:justify-between mb-4 md:mb-6"> |
nothing calls this directly
no test coverage detected