import { Dialog } from "./Dialog.tsx"; import { Button } from "./Button.tsx"; import { AlertCircle, Play } from "lucide-react"; import { graphql, useLazyLoadQuery } from "react-relay"; import type { SyncSummaryModalQuery } from "../__generated__/SyncSummaryModalQuery.graphql.ts"; interface SyncSummaryModalProps { open: boolean; onClose: () => void; slice: string; collections: string[]; externalCollections: string[]; onConfirm: () => void; isConfirming?: boolean; } export function SyncSummaryModal({ open, onClose, slice, collections, externalCollections, onConfirm, isConfirming = false, }: SyncSummaryModalProps) { const data = useLazyLoadQuery( graphql` query SyncSummaryModalQuery($slice: String!, $collections: [String!], $externalCollections: [String!]) { getSyncSummary(slice: $slice, collections: $collections, externalCollections: $externalCollections) { totalRepos cappedRepos wouldBeCapped appliedLimit collectionsSummary { collection estimatedRepos isExternal } } } `, { slice, collections: collections.length > 0 ? collections : null, externalCollections: externalCollections.length > 0 ? externalCollections : null, }, { fetchPolicy: 'network-only', } ); const summary = data.getSyncSummary; if (!open || !summary) return null; return (
{/* Repo Stats */}
Total Repos
{summary.totalRepos.toLocaleString()}
{summary.wouldBeCapped && (
Will Sync
{summary.cappedRepos.toLocaleString()}
)}
{/* Capped Warning */} {summary.wouldBeCapped && (
Sync Will Be Limited
Only the first {summary.appliedLimit.toLocaleString()} repos will be synced due to system limits. {summary.totalRepos - summary.cappedRepos}{" "} repos will be excluded.
)} {/* Collections Summary */} {summary.collectionsSummary.length > 0 && (

Collections Breakdown

{/* Primary Collections */} {summary.collectionsSummary.filter((c: { isExternal: boolean }) => !c.isExternal).length > 0 && (

Primary Collections

{summary.collectionsSummary .filter((c: { isExternal: boolean }) => !c.isExternal) .map((col: { collection: string; estimatedRepos: number; isExternal: boolean }) => (
{col.collection}
{col.estimatedRepos.toLocaleString()} repos
))}
)} {/* External Collections */} {summary.collectionsSummary.filter((c: { isExternal: boolean }) => c.isExternal).length > 0 && (

External Collections

{summary.collectionsSummary .filter((c: { isExternal: boolean }) => c.isExternal) .map((col: { collection: string; estimatedRepos: number; isExternal: boolean }) => (
{col.collection}
External data
))}
)}
)} {/* Actions */}
); }