import type { ReactElement, ReactNode } from "react"; import type { ArtifactSummary, DeploymentSummary, RunSummary } from "./models.js"; type LifecycleKind = "artifact" | "deployment" | "run"; type RecordColumnsProps = { readonly artifacts: ReadonlyArray; readonly deployments: ReadonlyArray; readonly runs: ReadonlyArray; readonly selectedArtifactId: string | null; readonly selectedDeploymentId: string | null; readonly selectedRunId: string | null; readonly primaryKind: LifecycleKind; readonly onSelectArtifact: (artifactId: string | null) => void; readonly onSelectDeployment: (deploymentId: string | null) => void; readonly onSelectRun: (runId: string | null) => void; readonly onLoadMoreArtifacts?: () => void; readonly hasMoreArtifacts?: boolean; readonly onLoadMoreRuns?: () => void; readonly hasMoreRuns?: boolean; }; const allKinds: ReadonlyArray = ["artifact", "deployment", "run"]; const LifecycleColumn = ({ kind, primaryKind, children, }: { readonly kind: LifecycleKind; readonly primaryKind: LifecycleKind; readonly children: ReactNode; }) => (
{children}
); export const RecordColumns = ({ artifacts, deployments, runs, selectedArtifactId, selectedDeploymentId, selectedRunId, primaryKind, onSelectArtifact, onSelectDeployment, onSelectRun, onLoadMoreArtifacts, hasMoreArtifacts, onLoadMoreRuns, hasMoreRuns, }: RecordColumnsProps) => { const columns: Record = { artifact: (

Artifacts

{artifacts.length === 0 ? (

No artifacts

) : (
    {artifacts.map((artifact) => (
  • ))}
)} {hasMoreArtifacts && onLoadMoreArtifacts && ( )}
), deployment: (

Deployments

{deployments.length === 0 ? (

No deployments

) : (
    {deployments.map((deployment) => (
  • ))}
)}
), run: (

Runs

{runs.length === 0 ? (

No runs

) : (
    {runs.map((run) => (
  • ))}
)} {hasMoreRuns && onLoadMoreRuns && ( )}
), }; const orderedKinds = [primaryKind, ...allKinds.filter((kind) => kind !== primaryKind)]; return (
{orderedKinds.map((kind) => columns[kind])}
); };