{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "deployments",
  "title": "Deployments",
  "description": "Primitives for deployments: ready, failed, building, queued and rolled back statuses written as coloured words, duration and short commit formatting, DORA bands for deployment frequency, lead time, change failure rate and time to restore, a DORA band label and a run history strip.",
  "registryDependencies": [
    "https://www.dashboardblocks.com/r/radix/status-label.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/deployments.tsx",
      "content": "'use client'\n\nimport {\n  StatusLabel,\n  type StatusLabelProps,\n  type StatusTone,\n} from '@/registry/components/dashboardblocks/status-label'\n\nimport { cn } from '@/lib/utils'\n\ntype DeployStatus = 'success' | 'failed' | 'running' | 'queued' | 'rolled-back'\n\nconst deployStatusConfig: Record<\n  DeployStatus,\n  { cell: string; label: string; tone: StatusTone }\n> = {\n  failed: { cell: 'bg-red-500 dark:bg-red-400', label: 'Failed', tone: 'bad' },\n  queued: {\n    cell: 'border border-dashed border-muted-foreground/60',\n    label: 'Queued',\n    tone: 'neutral',\n  },\n  'rolled-back': {\n    cell: 'bg-orange-500 dark:bg-orange-400',\n    label: 'Rolled back',\n    tone: 'warning',\n  },\n  running: {\n    cell: 'bg-sky-500/60 dark:bg-sky-400/60 motion-safe:animate-pulse',\n    label: 'Building',\n    tone: 'info',\n  },\n  success: { cell: 'bg-emerald-600 dark:bg-emerald-500', label: 'Ready', tone: 'good' },\n}\n\ninterface DeployStatusLabelProps extends Omit<StatusLabelProps, 'tone'> {\n  status: DeployStatus\n}\n\nfunction DeployStatusLabel({ children, status, ...props }: DeployStatusLabelProps) {\n  const config = deployStatusConfig[status]\n  return (\n    <StatusLabel data-status={status} tone={config.tone} {...props}>\n      {children ?? config.label}\n    </StatusLabel>\n  )\n}\n\nfunction formatDuration(seconds: number) {\n  const whole = Math.max(0, Math.round(seconds))\n  if (whole < 60) return `${whole}s`\n  const minutes = Math.floor(whole / 60)\n  if (minutes < 60) return `${minutes}m ${String(whole % 60).padStart(2, '0')}s`\n  return `${Math.floor(minutes / 60)}h ${String(minutes % 60).padStart(2, '0')}m`\n}\n\nfunction shortSha(sha: string) {\n  return sha.slice(0, 7)\n}\n\ntype DoraLevel = 'elite' | 'high' | 'medium' | 'low'\n\ninterface DoraInput {\n  /** Share of deployments causing a failure in production, 0–1. */\n  changeFailureRate: number\n  deploysPerDay: number\n  /** Median hours from commit to production. */\n  leadTimeHours: number\n  /** Median hours to restore service after a failure. */\n  restoreHours: number\n}\n\nfunction getDoraLevels({\n  changeFailureRate,\n  deploysPerDay,\n  leadTimeHours,\n  restoreHours,\n}: DoraInput): Record<keyof DoraInput, DoraLevel> {\n  return {\n    changeFailureRate:\n      changeFailureRate <= 0.05\n        ? 'elite'\n        : changeFailureRate <= 0.1\n          ? 'high'\n          : changeFailureRate <= 0.15\n            ? 'medium'\n            : 'low',\n    deploysPerDay:\n      deploysPerDay >= 1\n        ? 'elite'\n        : deploysPerDay >= 1 / 7\n          ? 'high'\n          : deploysPerDay >= 1 / 30\n            ? 'medium'\n            : 'low',\n    leadTimeHours:\n      leadTimeHours < 24\n        ? 'elite'\n        : leadTimeHours < 24 * 7\n          ? 'high'\n          : leadTimeHours < 24 * 30\n            ? 'medium'\n            : 'low',\n    restoreHours:\n      restoreHours < 1\n        ? 'elite'\n        : restoreHours < 24\n          ? 'high'\n          : restoreHours < 24 * 7\n            ? 'medium'\n            : 'low',\n  }\n}\n\nconst doraLevelConfig: Record<DoraLevel, { label: string; tone: StatusTone }> = {\n  elite: { label: 'Elite', tone: 'good' },\n  high: { label: 'High', tone: 'info' },\n  low: { label: 'Low', tone: 'bad' },\n  medium: { label: 'Medium', tone: 'warning' },\n}\n\ninterface DoraLabelProps extends Omit<StatusLabelProps, 'tone'> {\n  level: DoraLevel\n}\n\nfunction DoraLabel({ children, level, ...props }: DoraLabelProps) {\n  const config = doraLevelConfig[level]\n  return (\n    <StatusLabel data-level={level} tone={config.tone} {...props}>\n      {children ?? config.label}\n    </StatusLabel>\n  )\n}\n\ninterface DeployHistoryProps {\n  className?: string\n  /** Oldest first. */\n  runs: { id: string; status: DeployStatus }[]\n}\n\nfunction DeployHistory({ className, runs }: DeployHistoryProps) {\n  return (\n    <span aria-hidden className={cn('flex h-5 items-stretch gap-0.5', className)}>\n      {runs.map((run) => (\n        <span\n          key={run.id}\n          className={cn(\n            'min-w-1 flex-1 rounded-[2px]',\n            deployStatusConfig[run.status].cell,\n          )}\n        />\n      ))}\n    </span>\n  )\n}\n\nexport {\n  DeployHistory,\n  DeployStatusLabel,\n  DoraLabel,\n  deployStatusConfig,\n  doraLevelConfig,\n  formatDuration,\n  getDoraLevels,\n  shortSha,\n}\n\nexport type {\n  DeployHistoryProps,\n  DeployStatus,\n  DeployStatusLabelProps,\n  DoraInput,\n  DoraLabelProps,\n  DoraLevel,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/deployments.tsx"
    }
  ],
  "type": "registry:component"
}
