{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "deployments-01",
  "description": "The latest builds, each with its commit, environment, author, duration and status.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/deployments.json",
    "https://www.dashboardblocks.com/r/radix/details.json",
    "https://www.dashboardblocks.com/r/radix/team.json",
    "https://www.dashboardblocks.com/r/radix/format.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/deployments/deployments-01.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  type DeployStatus,\n  DeployStatusLabel,\n  deployStatusConfig,\n  formatDuration,\n  shortSha,\n} from '@/registry/components/dashboardblocks/deployments'\nimport { Details } from '@/registry/components/dashboardblocks/details'\nimport { PersonAvatar } from '@/registry/components/dashboardblocks/team'\nimport { formatRelativeTime } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Deployment {\n  author: string\n  authorAvatar?: string\n  /** Seconds the build and deploy took, or have taken so far. */\n  duration: number\n  environment: string\n  id: string\n  message: string\n  sha: string\n  startedAt: Date\n  status: DeployStatus\n}\n\ninterface Deployments1Props extends BlockStateProps {\n  /** Leave out, or pass none, to show the empty state. */\n  deployments?: Deployment[]\n  /** Defaults to a sentence counting the deploys and any that need a look. */\n  description?: string\n  /** Pass a fixed date, so the block renders the same on the server and in the browser. */\n  now: Date\n  title: string\n}\n\nconst NOW = new Date(Date.UTC(2026, 8, 26, 15, 0))\nconst minutesAgo = (minutes: number) => new Date(NOW.getTime() - minutes * 60_000)\n\nconst exampleProps: Deployments1Props = {\n  deployments: [\n    {\n      author: 'Ana Lima',\n      authorAvatar: '/images/avatar-16.webp',\n      duration: 94,\n      environment: 'Production',\n      id: 'd1',\n      message: 'Fix currency rounding on invoices',\n      sha: '9f3c2a17b',\n      startedAt: minutesAgo(2),\n      status: 'running',\n    },\n    {\n      author: 'Ana Lima',\n      authorAvatar: '/images/avatar-16.webp',\n      duration: 212,\n      environment: 'Preview',\n      id: 'd2',\n      message: 'Fix currency rounding on invoices',\n      sha: '9f3c2a17b',\n      startedAt: minutesAgo(14),\n      status: 'success',\n    },\n    {\n      author: 'Kevin Moore',\n      authorAvatar: '/images/avatar-14.webp',\n      duration: 187,\n      environment: 'Production',\n      id: 'd3',\n      message: 'Add retry to webhook delivery',\n      sha: '41be08d3c',\n      startedAt: minutesAgo(52),\n      status: 'success',\n    },\n    {\n      author: 'Sara Okafor',\n      authorAvatar: '/images/avatar-05.webp',\n      duration: 66,\n      environment: 'Production',\n      id: 'd4',\n      message: 'Upgrade image pipeline',\n      sha: 'c07d9e412',\n      startedAt: minutesAgo(130),\n      status: 'rolled-back',\n    },\n    {\n      author: 'Sara Okafor',\n      authorAvatar: '/images/avatar-05.webp',\n      duration: 143,\n      environment: 'Preview',\n      id: 'd5',\n      message: 'Upgrade image pipeline',\n      sha: 'c07d9e412',\n      startedAt: minutesAgo(155),\n      status: 'failed',\n    },\n  ],\n  now: NOW,\n  title: 'Deployments',\n}\n\nconst summarize = (deployments: Deployment[], now: Date) => {\n  if (deployments.length === 0) return 'Nothing deployed yet.'\n  const oldest = Math.min(\n    ...deployments.map((deployment) => deployment.startedAt.getTime()),\n  )\n  const hours = Math.max(1, Math.ceil((now.getTime() - oldest) / 3_600_000))\n  const span =\n    hours <= 48\n      ? `${hours} ${hours === 1 ? 'hour' : 'hours'}`\n      : `${Math.ceil(hours / 24)} days`\n  const count = `${deployments.length} ${deployments.length === 1 ? 'deploy' : 'deploys'} in the last ${span}.`\n  const notable = (['running', 'failed', 'rolled-back'] as const)\n    .map((status) => {\n      const matching = deployments.filter(\n        (deployment) => deployment.status === status,\n      ).length\n      return matching > 0\n        ? `${matching} ${deployStatusConfig[status].label.toLowerCase()}`\n        : null\n    })\n    .filter(Boolean)\n  return notable.length > 0 ? `${count} ${notable.join(', ')}.` : `${count} All ready.`\n}\n\nconst Deployments1 = (props: Deployments1Props) => {\n  const { deployments = [], now, errorMessage, status, title } = props\n  const { description = summarize(deployments, now) } = props\n\n  return (\n    <Card>\n      <CardContent>\n        <BlockStateProvider\n          errorMessage={errorMessage}\n          state={getBlockState(status, deployments)}\n        >\n          <section className='@container flex flex-col gap-3'>\n            <header className='flex flex-col gap-0.5'>\n              <h2 className='font-semibold tracking-tight'>{title}</h2>\n              <BlockReady className='text-sm'>\n                <p className='text-muted-foreground text-sm'>{description}</p>\n              </BlockReady>\n            </header>\n            <div className='border-t'>\n              <BlockStateRows rows={5} />\n              <ul className='flex flex-col empty:hidden'>\n                {!status &&\n                  deployments.map((deployment) => (\n                    <li\n                      key={deployment.id}\n                      className='flex items-start gap-3 border-b py-2.5 last:border-b-0'\n                    >\n                      <PersonAvatar\n                        className='mt-0.5'\n                        person={{\n                          avatar: deployment.authorAvatar,\n                          name: deployment.author,\n                        }}\n                        size='sm'\n                      />\n                      <div className='flex min-w-0 flex-1 flex-col gap-0.5'>\n                        <div className='flex items-baseline justify-between gap-3'>\n                          <span className='truncate text-sm font-medium'>\n                            {deployment.message}\n                          </span>\n                          <DeployStatusLabel\n                            className='shrink-0'\n                            status={deployment.status}\n                          />\n                        </div>\n                        <div className='flex items-baseline justify-between gap-3 text-xs'>\n                          <p className='text-muted-foreground min-w-0'>\n                            <span className='text-foreground me-2'>\n                              {deployment.environment}\n                            </span>\n                            <Details>\n                              <span className='font-mono'>\n                                {shortSha(deployment.sha)}\n                              </span>\n                              {deployment.author}\n                              <time dateTime={deployment.startedAt.toISOString()}>\n                                {formatRelativeTime(deployment.startedAt, now)}\n                              </time>\n                            </Details>\n                          </p>\n                          <span className='text-muted-foreground shrink-0 tabular-nums'>\n                            <span className='sr-only'>\n                              {deployment.status === 'running'\n                                ? 'Building for '\n                                : 'Took '}\n                            </span>\n                            {formatDuration(deployment.duration)}\n                          </span>\n                        </div>\n                      </div>\n                    </li>\n                  ))}\n              </ul>\n            </div>\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport {\n  Deployments1,\n  exampleProps as deployments1ExampleProps,\n  type Deployment,\n  type Deployments1Props,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/deployments/deployments-01.tsx"
    }
  ],
  "meta": {
    "shows": "The latest builds, each with its commit, environment, author, duration and status.",
    "size": "full",
    "usedWith": [
      "deployments-02",
      "deployments-04",
      "activity-feed-05"
    ],
    "component": "Deployments1",
    "props": "{ deployments?: { author: string; authorAvatar?: string; duration: number; environment: string; id: string; message: string; sha: string; startedAt: Date; status: \"success\" | \"failed\" | \"running\" | \"queued\" | \"rolled-back\" }[]; description?: string; now: Date; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
