{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "deployments-02",
  "description": "What each environment is running, and how many commits are waiting to be promoted to the next one.",
  "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/format.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/deployments/deployments-02.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateText,\n  type BlockStateProps,\n  SkeletonText,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  type DeployStatus,\n  DeployStatusLabel,\n  shortSha,\n} from '@/registry/components/dashboardblocks/deployments'\nimport { Details } from '@/registry/components/dashboardblocks/details'\nimport { formatRelativeTime } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Environment {\n  deployedAt: Date\n  deployedBy: string\n  id: string\n  name: string\n  sha: string\n  status: DeployStatus\n  version: string\n}\n\ninterface Deployments2Props extends BlockStateProps {\n  /** How many commits each environment is ahead of the next, in order. */\n  ahead?: number[]\n  /** Defaults to a sentence naming what the last environment runs and what is waiting. */\n  description?: string\n  /** In promotion order, ending with the one customers use. Leave out, or pass none, to show the empty state. */\n  environments?: Environment[]\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 hoursAgo = (hours: number) => new Date(NOW.getTime() - hours * 3_600_000)\n\nconst exampleProps: Deployments2Props = {\n  ahead: [4, 2],\n  environments: [\n    {\n      deployedAt: hoursAgo(0.3),\n      deployedBy: 'Ana Lima',\n      id: 'dev',\n      name: 'Development',\n      sha: '9f3c2a17b',\n      status: 'success',\n      version: 'v3.2.0-rc.4',\n    },\n    {\n      deployedAt: hoursAgo(5),\n      deployedBy: 'Kevin Moore',\n      id: 'staging',\n      name: 'Staging',\n      sha: '41be08d3c',\n      status: 'success',\n      version: 'v3.2.0-rc.2',\n    },\n    {\n      deployedAt: hoursAgo(28),\n      deployedBy: 'Sara Okafor',\n      id: 'production',\n      name: 'Production',\n      sha: '7a21c5e90',\n      status: 'success',\n      version: 'v3.1.4',\n    },\n  ],\n  now: NOW,\n  title: 'Environments',\n}\n\nconst summarize = (environments: Environment[], ahead: number[]) => {\n  const live = environments[environments.length - 1]\n  if (!live) return 'No environments yet.'\n  const waiting = ahead.reduce((sum, count) => sum + count, 0)\n  const runs = `${live.name} runs ${live.version}`\n  if (waiting === 0) return `${runs}, the same build as every other environment.`\n  return `${runs}, with ${waiting} ${waiting === 1 ? 'commit' : 'commits'} waiting to reach it.`\n}\n\nconst Deployments2 = (props: Deployments2Props) => {\n  const { ahead = [], environments = [], now, errorMessage, status, title } = props\n  const { description = summarize(environments, ahead) } = props\n  const state = getBlockState(status, environments)\n\n  return (\n    <Card>\n      <CardContent>\n        <BlockStateProvider errorMessage={errorMessage} state={state}>\n          <section className='@container flex flex-col gap-4'>\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            {state === 'loading' && (\n              <div className='grid gap-x-6 gap-y-5 @xl:auto-cols-fr @xl:grid-flow-col'>\n                <span className='sr-only'>Loading</span>\n                {Array.from({ length: 3 }, (_, index) => (\n                  <div\n                    key={index}\n                    aria-hidden\n                    className='flex min-w-0 flex-col gap-1 border-t pt-3'\n                  >\n                    <span className='text-sm'>\n                      <SkeletonText className='w-24' />\n                    </span>\n                    <span className='text-2xl'>\n                      <SkeletonText className='w-28' />\n                    </span>\n                    <span className='text-xs'>\n                      <SkeletonText className='w-32' />\n                    </span>\n                  </div>\n                ))}\n              </div>\n            )}\n            {(state === 'empty' || state === 'error') && (\n              <div className='border-t pt-3'>\n                <BlockStateText\n                  className='text-2xl font-light tracking-tight'\n                  variant='short'\n                />\n              </div>\n            )}\n            {!state && (\n              <ol className='grid gap-x-6 gap-y-5 @xl:auto-cols-fr @xl:grid-flow-col'>\n                {environments.map((environment, index) => {\n                  const next = environments[index + 1]\n                  const waiting = ahead[index] ?? 0\n                  return (\n                    <li\n                      key={environment.id}\n                      className='flex min-w-0 flex-col gap-1 border-t pt-3'\n                    >\n                      <div className='flex items-baseline justify-between gap-2'>\n                        <span className='text-muted-foreground text-sm'>\n                          {environment.name}\n                        </span>\n                        <DeployStatusLabel status={environment.status} />\n                      </div>\n                      <span className='truncate text-2xl font-light tracking-tight tabular-nums'>\n                        {environment.version}\n                      </span>\n                      <Details className='text-muted-foreground text-xs'>\n                        <span className='font-mono'>{shortSha(environment.sha)}</span>\n                        {environment.deployedBy}\n                        <time dateTime={environment.deployedAt.toISOString()}>\n                          {formatRelativeTime(environment.deployedAt, now, {\n                            style: 'long',\n                          })}\n                        </time>\n                      </Details>\n                      {next && (\n                        <p className='text-muted-foreground mt-2 text-sm'>\n                          <span\n                            className={\n                              waiting > 0\n                                ? 'text-foreground font-medium tabular-nums'\n                                : 'tabular-nums'\n                            }\n                          >\n                            {waiting} {waiting === 1 ? 'commit' : 'commits'}\n                          </span>{' '}\n                          ahead of {next.name}\n                        </p>\n                      )}\n                    </li>\n                  )\n                })}\n              </ol>\n            )}\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport {\n  Deployments2,\n  exampleProps as deployments2ExampleProps,\n  type Deployments2Props,\n  type Environment,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/deployments/deployments-02.tsx"
    }
  ],
  "meta": {
    "shows": "What each environment is running, and how many commits are waiting to be promoted to the next one.",
    "size": "half",
    "usedWith": [
      "deployments-01",
      "deployments-04",
      "status-01"
    ],
    "component": "Deployments2",
    "props": "{ ahead?: number[]; description?: string; environments?: { deployedAt: Date; deployedBy: string; id: string; name: string; sha: string; status: \"success\" | \"failed\" | \"running\" | \"queued\" | \"rolled-back\"; version: string }[]; now: Date; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
