| 61 | 61 | | import { useAddresses } from "../../lib/addresses"; |
| 62 | 62 | | import { commitChecksFor } from "../../lib/commit-checks.server"; |
| 63 | 63 | | import { CommitChecksSummary } from "../../components/commit-checks"; |
| 64 | | − | import { projectCheckSections } from "../../lib/project-checks"; |
| 64 | + | import { projectCheckSections, hasSeparateAttempt } from "../../lib/project-checks"; |
| 65 | 65 | | import { StatusIcon, Duration, shortRef, standingWord } from "../../components/actions"; |
| 66 | 66 | | import { resolveRange, rangeLabel } from "../../lib/usage"; |
| 67 | 67 | | import { deliveryDays, duration as deliveryDuration } from "../../lib/workspace-insights"; |
| ⋯ |
| 132 | 132 | | const service = telemetry; |
| 133 | 133 | | const telemetryP = service |
| 134 | 134 | | ? projectP.then((found) => |
| 135 | | − | found?.ok |
| 136 | | − | ? forMembers(async () => { |
| 137 | | − | const project_id = found.value.id; |
| 138 | | − | const [overview, errors] = await Promise.all([ |
| 139 | | − | soft(service.overview({ project_id, workspace: params.owner, from_us: (now - DAY_MS) * 1000, to_us: now * 1000, step_s: 3600 })), |
| 140 | | − | soft(service.errors({ project_id, workspace: params.owner, state: "open" })), |
| 141 | | − | ]); |
| 142 | | − | return { overview, errors }; |
| 143 | | − | }) |
| 144 | | − | : null, |
| 145 | | − | ) |
| 135 | + | found?.ok |
| 136 | + | ? forMembers(async () => { |
| 137 | + | const project_id = found.value.id; |
| 138 | + | const [overview, errors] = await Promise.all([ |
| 139 | + | soft(service.overview({ project_id, workspace: params.owner, from_us: (now - DAY_MS) * 1000, to_us: now * 1000, step_s: 3600 })), |
| 140 | + | soft(service.errors({ project_id, workspace: params.owner, state: "open" })), |
| 141 | + | ]); |
| 142 | + | return { overview, errors }; |
| 143 | + | }) |
| 144 | + | : null, |
| 145 | + | ) |
| 146 | 146 | | : Promise.resolve(null); |
| 147 | 147 | | const commitP = soft(repos.log(path, viewer, null, 1)).then((log) => log?.ok ? (log.value[0] ?? null) : null); |
| 148 | 148 | | const range = resolveRange("30d", {}, new Date(now)); |
| ⋯ |
| 284 | 284 | | builds: builds.slice(0, 30), |
| 285 | 285 | | previews: live.filter((app) => app.kind === "preview"), |
| 286 | 286 | | production, |
| 287 | | − | serving: current ? { sha: current.sha, at: current.updated_at } : null, |
| 287 | + | serving: current ? { id: current.id, sha: current.sha, ref: current.ref, at: current.updated_at, creator: current.creator, runUrl: current.run_url } : null, |
| 288 | 288 | | // The screenshot of production on g1t.page, for members (like its builds). |
| 289 | 289 | | productionShot: member && liveProduction ? shotVersion(liveProduction) : null, |
| 290 | 290 | | latestProductionBuild: latestProduction ? { status: latestProduction.status } : null, |
| ⋯ |
| 471 | 471 | | |
| 472 | 472 | | /** The overview's sections as they will sit, while they stream in. */ |
| 473 | 473 | | function OverviewSkeleton() { |
| 474 | | − | return ( |
| 475 | | − | <Loading className="space-y-8" aria-label="Loading the overview"> |
| 476 | | − | {/* Production: its screenshot beside where it is live, then the facts under them. */} |
| 477 | | − | <Card asChild aria-hidden="true" className="overflow-hidden rounded-2xl"> |
| 478 | | − | <section> |
| 479 | | − | <div className="flex flex-col gap-5 p-5 sm:flex-row sm:items-start sm:p-6"> |
| 480 | | − | <Skeleton className="aspect-16/10 w-full shrink-0 rounded-lg sm:w-72" /> |
| 481 | | − | <div className="min-w-0 grow"> |
| 482 | | − | <Skeleton className="h-3 w-24" /> |
| 483 | | − | <Skeleton className="mt-3 h-5 w-72 max-w-full" /> |
| 484 | | − | <Skeleton className="mt-3 h-3 w-48 max-w-full" /> |
| 485 | | − | </div> |
| 486 | | − | </div> |
| 487 | | − | <div className="grid grid-cols-2 gap-px border-t border-line bg-line sm:grid-cols-4"> |
| 488 | | − | {Array.from({ length: 4 }, (_, index) => ( |
| 489 | | − | <div key={index} className="bg-surface px-5 py-4"> |
| 490 | | − | <Skeleton className="h-3 w-16" /> |
| 491 | | − | <Skeleton className="mt-2.5 h-4 w-28" /> |
| 492 | | − | </div> |
| 493 | | − | ))} |
| 494 | | − | </div> |
| 495 | | − | </section> |
| 496 | | − | </Card> |
| 497 | | − | {/* Live now beside the sidebar's cards. */} |
| 498 | | − | <div className="grid gap-x-8 gap-y-8 lg:grid-cols-[minmax(0,1fr)_20rem]"> |
| 499 | | − | <Card> |
| 500 | | − | <SkeletonRows rows={4} /> |
| 501 | | − | </Card> |
| 502 | | − | <Card> |
| 503 | | − | <SkeletonRows rows={4} /> |
| 504 | | − | </Card> |
| 474 | + | return <Loading className="space-y-8" aria-label="Loading the overview"> |
| 475 | + | <Card className="overflow-hidden rounded-2xl"> |
| 476 | + | <div className="border-b border-line p-5"><Skeleton className="h-5 w-48" /></div> |
| 477 | + | <div className="grid gap-6 p-6 md:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]"> |
| 478 | + | <Skeleton className="aspect-16/10 w-full rounded-lg" /> |
| 479 | + | <SkeletonRows rows={5} /> |
| 505 | 480 | | </div> |
| 506 | | − | </Loading> |
| 507 | | − | ); |
| 481 | + | </Card> |
| 482 | + | <div className="grid gap-4 md:grid-cols-2 xl:grid-cols-3">{[0, 1, 2].map((key) => <Card key={key} className="p-5"><SkeletonRows rows={4} /></Card>)}</div> |
| 483 | + | </Loading>; |
| 508 | 484 | | } |
| 509 | 485 | | |
| 510 | 486 | | function OverviewFailed() { |
| ⋯ |
| 512 | 488 | | <Card asChild className="rounded-2xl p-6 text-sm text-muted"> |
| 513 | 489 | | <p>The overview could not be loaded just now. Reload the page to try again.</p> |
| 514 | 490 | | </Card> |
| 515 | | − | ); |
| 516 | | − | } |
| 517 | | − | |
| 518 | | − | /** One of the facts under production: what it is, and where to read more. */ |
| 519 | | − | function Fact({ label, value, to, hint }: { label: string; value: ReactNode; to?: string; hint?: string }) { |
| 520 | | − | const body = ( |
| 521 | | − | <> |
| 522 | | − | <span className="block text-[0.6875rem] text-faint">{label}</span> |
| 523 | | − | <span className="mt-0.5 block text-[0.8125rem] font-medium sm:truncate">{value}</span> |
| 524 | | − | </> |
| 525 | 491 | | ); |
| 526 | | − | const cell = to ? ( |
| 527 | | − | <Link to={to} prefetch="intent" className="block min-w-0 px-5 py-3 transition-colors hover:bg-raised/50"> |
| 528 | | − | {body} |
| 529 | | − | </Link> |
| 530 | | − | ) : ( |
| 531 | | − | <div className="min-w-0 px-5 py-3">{body}</div> |
| 532 | | − | ); |
| 533 | | − | return hint ? <Hint label={hint}>{cell}</Hint> : cell; |
| 534 | 492 | | } |
| 535 | 493 | | |
| 536 | 494 | | function plural(n: number, one: string, many = `${one}s`): string { |
| 537 | 495 | | return `${n.toLocaleString("en-US")} ${n === 1 ? one : many}`; |
| 538 | 496 | | } |
| 539 | 497 | | |
| 540 | | − | /** |
| 541 | | − | * The facts under production, about the project rather than its |
| 542 | | − | * repository: four of them, most telling first. Where the card above |
| 543 | | − | * already shows production's state, the first is its latest release |
| 544 | | − | * instead, so nothing is said twice. |
| 545 | | − | */ |
| 546 | | − | function Facts({ loaderData, base, plan }: { loaderData: Loaded; base: string; plan: string }) { |
| 547 | | − | const { productionLatest, release, library, telemetry, open, environments } = loaderData; |
| 548 | | − | const headShowsProduction = !library && (plan === "production" || plan === "elsewhere"); |
| 549 | | − | const releaseFact = release ? ( |
| 550 | | − | <Fact |
| 551 | | − | label="Latest release" |
| 552 | | − | to={`${base}/tags`} |
| 553 | | − | value={ |
| 554 | | − | <span className="inline-flex items-center gap-1.5"> |
| 555 | | − | <span className="truncate font-mono">{release.name}</span> |
| 556 | | − | {release.at && ( |
| 557 | | − | <span className="shrink-0 font-normal text-muted"> |
| 558 | | − | <TimeAgo at={release.at} /> |
| 559 | | − | </span> |
| 560 | | − | )} |
| 561 | | − | </span> |
| 562 | | − | } |
| 563 | | − | /> |
| 564 | | − | ) : null; |
| 565 | | − | const first = |
| 566 | | − | !headShowsProduction && productionLatest ? ( |
| 567 | | − | <Fact |
| 568 | | − | label="Production" |
| 569 | | − | to={`${base}/deployments/${productionLatest.id}`} |
| 570 | | − | hint={`The newest deployment to ${productionLatest.environment}`} |
| 571 | | − | value={ |
| 572 | | − | <span className="inline-flex items-center gap-1.5"> |
| 573 | | − | <DeploymentStateIcon state={productionLatest.state} size={14} /> |
| 574 | | − | {productionLatest.state === "success" ? "Live" : STATE_WORD[productionLatest.state]} |
| 575 | | − | <span className="font-normal text-muted"> |
| 576 | | − | <TimeAgo at={productionLatest.at} /> |
| 577 | | − | </span> |
| 578 | | − | </span> |
| 579 | | − | } |
| 580 | | − | /> |
| 581 | | − | ) : releaseFact ? ( |
| 582 | | − | releaseFact |
| 583 | | − | ) : environments && environments.total_count > 0 ? ( |
| 584 | | − | <Fact label="Deployments" to={`${base}/deployments`} value={<span className="tabular-nums">{environments.total_count.toLocaleString("en-US")}</span>} /> |
| 585 | | − | ) : ( |
| 586 | | − | <Fact label="Latest release" to={`${base}/tags`} value={<span className="font-normal text-muted">None yet</span>} /> |
| 587 | | − | ); |
| 588 | | − | const branch = <Fact label="Default branch" to={`${base}/code`} value={loaderData.defaultBranch ?? "Unavailable"} />; |
| 589 | | − | return ( |
| 590 | | − | <div className="grid grid-cols-2 divide-line border-t border-line text-sm sm:grid-cols-4 sm:divide-x"> |
| 591 | | − | {first} |
| 592 | | − | {telemetry ? ( |
| 593 | | − | <> |
| 594 | | − | <Fact label="Requests · 24h" to={`${base}/observability`} value={<span className="tabular-nums">{count(telemetry.overview.totals.requests)}</span>} /> |
| 595 | | − | <Fact |
| 596 | | − | label="Errors · 24h" |
| 597 | | − | to={`${base}/observability/errors`} |
| 598 | | − | hint={`${plural(telemetry.overview.totals.errors, "failed request")} in the last day`} |
| 599 | | − | value={ |
| 600 | | − | <span className="inline-flex items-center gap-1.5 tabular-nums"> |
| 601 | | − | <span className={telemetry.overview.totals.error_rate >= 0.01 ? "text-danger" : undefined}>{percent(telemetry.overview.totals.error_rate)}</span> |
| 602 | | − | <span className="font-normal text-muted">· {telemetry.errors.length.toLocaleString("en-US")} open</span> |
| 603 | | − | </span> |
| 604 | | − | } |
| 605 | | − | /> |
| 606 | | − | {branch} |
| 607 | | − | </> |
| 608 | | − | ) : ( |
| 609 | | − | <> |
| 610 | | − | {branch} |
| 611 | | − | <Fact label="Open issues" to={`${base}/issues`} value={open.issues} /> |
| 612 | | − | <Fact label="Open pull requests" to={`${base}/pulls`} value={open.pulls} /> |
| 613 | | − | </> |
| 614 | | − | )} |
| 615 | | − | </div> |
| 616 | | − | ); |
| 617 | | − | } |
| 618 | | − | |
| 619 | 498 | | /** One line to the repository, where its files, branches and commits are: Code. */ |
| 620 | 499 | | function CodeLine({ project, base }: { project: Project; base: string }) { |
| 621 | 500 | | if (project.source.kind !== "hosted") return null; |
| 622 | | − | const { repo, defaultBranch, rootDir } = project.source; |
| 501 | + | const { repo, rootDir } = project.source; |
| 623 | 502 | | return ( |
| 624 | 503 | | <Link |
| 625 | 504 | | to={`${base}/code`} |
| ⋯ |
| 630 | 509 | | <span className="min-w-0 truncate font-mono text-fg-soft"> |
| 631 | 510 | | {repo.namespace}/{repo.name} |
| 632 | 511 | | {rootDir ? `/${rootDir}` : ""} |
| 633 | | − | </span> |
| 634 | | − | <span className="hidden shrink-0 items-center gap-1 font-mono sm:inline-flex"> |
| 635 | | − | <GitBranch size={12} className="text-faint" /> |
| 636 | | − | {defaultBranch} |
| 637 | 512 | | </span> |
| 638 | 513 | | {project.pushedAt && ( |
| 639 | 514 | | <span className="hidden shrink-0 md:inline"> |
| ⋯ |
| 732 | 607 | | ); |
| 733 | 608 | | } |
| 734 | 609 | | |
| 610 | + | /** The running deployment owns these fields; a newer attempt never changes its status. */ |
| 611 | + | function ProductionSummary({ loaderData: d, base, upload, addImage, elsewhere }: { |
| 612 | + | loaderData: Loaded; base: string; upload: { url: string; preferred: boolean } | null; |
| 613 | + | addImage: string | null; elsewhere: boolean; |
| 614 | + | }) { |
| 615 | + | const current = d.serving; |
| 616 | + | const sha = current?.sha ?? d.production?.commit; |
| 617 | + | const url = elsewhere ? d.deployment?.url ?? d.project?.productionUrl : d.settings?.primaryDomain ? `https://${d.settings.primaryDomain}` : d.production?.url; |
| 618 | + | const at = current?.at ?? d.production?.deployedAt; |
| 619 | + | const latest = d.productionLatest; |
| 620 | + | const newerAttempt = latest && hasSeparateAttempt(current?.id, sha, latest); |
| 621 | + | const screenshot = elsewhere ? d.elsewhereShot : d.productionShot ? `${base}/production.jpg?v=${d.productionShot}` : null; |
| 622 | + | return ( |
| 623 | + | <> |
| 624 | + | <div className="grid gap-6 p-5 sm:p-6 md:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] lg:gap-8"> |
| 625 | + | <ProductionShot sources={cardSources(screenshot, upload)} href={url ?? null} label={url ? host(url) : ""} addImage={addImage} className="w-full self-start" /> |
| 626 | + | <dl className="grid min-w-0 content-start grid-cols-2 gap-x-5 gap-y-5 text-sm"> |
| 627 | + | <div className="col-span-2 min-w-0"> |
| 628 | + | <dt className="text-xs text-muted">Deployment</dt> |
| 629 | + | <dd className="mt-1 break-words font-medium"> |
| 630 | + | {current ? <Link to={`${base}/deployments/${current.id}`} className="hover:text-accent">Current production <ArrowUpRight size={14} className="inline text-faint" /></Link> : <span>Production</span>} |
| 631 | + | </dd> |
| 632 | + | </div> |
| 633 | + | <div className="col-span-2 min-w-0"> |
| 634 | + | <dt className="text-xs text-muted">Domain</dt> |
| 635 | + | <dd className="mt-1">{url ? <DeployLink href={url} className="inline-flex max-w-full items-center gap-1.5 font-medium hover:text-accent"><span className="truncate">{host(url)}</span><ArrowUpRight size={14} className="shrink-0 text-faint" /></DeployLink> : <span className="text-muted">No address reported</span>}</dd> |
| 636 | + | {!elsewhere && d.settings?.primaryDomain && d.production && <dd className="mt-1 text-xs text-muted"><DeployLink href={d.production.url} className="break-all hover:text-fg">{host(d.production.url)}</DeployLink></dd>} |
| 637 | + | </div> |
| 638 | + | <div><dt className="text-xs text-muted">Status</dt><dd className="mt-1"><StatusDot status="ready" label="Ready" /></dd></div> |
| 639 | + | <div><dt className="text-xs text-muted">Deployed</dt><dd className="mt-1 text-xs">{at && <TimeAgo at={at} />}{current?.creator && <span className="text-muted"> by {current.creator}</span>}</dd></div> |
| 640 | + | <div className="col-span-2 min-w-0"> |
| 641 | + | <dt className="text-xs text-muted">Source</dt> |
| 642 | + | <dd className="mt-1 flex flex-wrap items-center gap-x-4 gap-y-2"> |
| 643 | + | {current?.ref && current.ref !== sha && <Link to={`${base}/tree/${encodeURIComponent(current.ref)}`} className="inline-flex min-w-0 items-center gap-1.5 hover:text-accent"><GitBranch size={14} className="shrink-0 text-faint" /><span className="truncate">{current.ref}</span></Link>} |
| 644 | + | {sha && <Link to={`${base}/commit/${sha}`} className="inline-flex items-center gap-1.5 font-mono text-xs hover:text-accent"><GitCommitHorizontal size={14} className="text-faint" />{sha.slice(0, 7)}</Link>} |
| 645 | + | {current?.runUrl && <Link to={current.runUrl} className="text-xs text-muted hover:text-fg">View workflow <ArrowUpRight size={12} className="inline" /></Link>} |
| 646 | + | </dd> |
| 647 | + | {sha && sha !== d.commit?.hash && <dd className="mt-3"><CommitChecksSummary checks={d.checks} sha={sha} label="Checks for deployed commit" /></dd>} |
| 648 | + | </div> |
| 649 | + | </dl> |
| 650 | + | </div> |
| 651 | + | {newerAttempt && <Link to={`${base}/deployments/${latest.id}`} className="flex flex-wrap items-center gap-2 border-t border-line bg-raised/30 px-5 py-3 text-xs hover:bg-raised/60 sm:px-6"><DeploymentStateIcon state={latest.state} size={14} /><span>Latest attempt: {STATE_WORD[latest.state]}</span><span className="font-mono text-muted">{latest.sha.slice(0, 7)}</span><span className="text-muted"><TimeAgo at={latest.at} /></span><span className="ml-auto text-muted">View deployment <ArrowRight size={12} className="inline" /></span></Link>} |
| 652 | + | </> |
| 653 | + | ); |
| 654 | + | } |
| 655 | + | |
| 656 | + | /** Branch health belongs to the repository head, independently of what is deployed. */ |
| 657 | + | function BranchCard({ loaderData: d, base }: { loaderData: Loaded; base: string }) { |
| 658 | + | const branch = projectCheckSections(d.commit?.hash, d.defaultBranch, null)[0]; |
| 659 | + | return <Card asChild className="min-w-0 p-5"><section aria-labelledby="overview-branch"> |
| 660 | + | <h2 id="overview-branch" className="flex items-center gap-2 text-sm font-semibold"><GitBranch size={14} className="text-faint" />Latest on {d.defaultBranch ?? "default branch"}</h2> |
| 661 | + | {branch ? <><div className="my-4 flex flex-wrap items-center gap-2 text-xs"><Link to={`${base}/commit/${branch.sha}`} className="font-mono hover:text-accent">{branch.sha.slice(0, 7)}</Link><span className="text-muted">committed {d.commit && <TimeAgo at={d.commit.authoredAt} />}</span></div><CommitChecksSummary checks={d.checks} sha={branch.sha} /></> : <p className="my-4 text-xs text-muted">The latest commit is unavailable.</p>} |
| 662 | + | <dl className="mt-4 space-y-3 border-t border-line pt-4 text-xs"> |
| 663 | + | <div className="flex justify-between gap-3"><dt className="text-muted">Latest release</dt><dd><Link to={`${base}/tags`} className="font-mono hover:text-accent">{d.release?.name ?? "None yet"}</Link>{d.release?.at && <span className="ml-2 text-muted"><TimeAgo at={d.release.at} /></span>}</dd></div> |
| 664 | + | <div className="flex justify-between gap-3"><dt className="text-muted">Open pull requests</dt><dd><Link to={`${base}/pulls`} className="tabular-nums hover:text-accent">{d.open.pulls}</Link></dd></div> |
| 665 | + | </dl> |
| 666 | + | </section></Card>; |
| 667 | + | } |
| 668 | + | |
| 735 | 669 | | /** Production controls share a header, whether g1t or a workflow hosts it. */ |
| 736 | 670 | | function ProductionActions({ loaderData, base, elsewhere }: { loaderData: Loaded; base: string; elsewhere: boolean }) { |
| 737 | 671 | | const { member, settings, production, project, can } = loaderData; |
| ⋯ |
| 740 | 674 | | : production ? (settings?.primaryDomain ? `https://${settings.primaryDomain}` : production.url) : null; |
| 741 | 675 | | return ( |
| 742 | 676 | | <div className="flex flex-wrap items-center gap-2"> |
| 743 | | − | {member && ( |
| 744 | | − | <Hint label="Deployment history"> |
| 745 | | − | <ButtonLink to={`${base}/deployments`} variant="outline" size="icon-sm" aria-label="Deployment history"> |
| 746 | | − | <Rocket size={15} /> |
| 747 | | − | </ButtonLink> |
| 748 | | − | </Hint> |
| 749 | | − | )} |
| 750 | 677 | | {member && (can.run || can.manage_integrations) && ( |
| 751 | 678 | | <Hint disabled label="Instant rollback is coming soon. It is not available yet."> |
| 752 | 679 | | <Button disabled variant="outline" size="sm"> |
| ⋯ |
| 769 | 696 | | <Rocket size={14} /> Turn on deployments |
| 770 | 697 | | </ButtonLink> |
| 771 | 698 | | )} |
| 772 | | − | {member && can.manage_integrations && ( |
| 773 | | − | <Hint label="Deployment settings"> |
| 774 | | − | <ButtonLink to={`${base}/settings/deployments`} variant="outline" size="icon-sm" aria-label="Deployment settings"> |
| 775 | | − | <Settings2 size={15} /> |
| 776 | | − | </ButtonLink> |
| 777 | | − | </Hint> |
| 778 | | − | )} |
| 779 | 699 | | {url && ( |
| 780 | 700 | | <ButtonLink to={url} variant="accent" size="sm" reloadDocument target="_blank" rel="noopener noreferrer"> |
| 781 | 701 | | Visit <ArrowUpRight size={14} /> |
| ⋯ |
| 800 | 720 | | const plan = project ? projectPlan(project) : "production"; |
| 801 | 721 | | const canChange = member && loaderData.can.manage_settings; |
| 802 | 722 | | const deployedSha = loaderData.serving?.sha ?? loaderData.production?.commit; |
| 803 | | − | const checkSections = projectCheckSections(loaderData.commit?.hash, defaultBranch, deployedSha); |
| 723 | + | const productionPlan = plan === "production" || plan === "elsewhere"; |
| 724 | + | const hasProduction = productionPlan && Boolean(deployedSha); |
| 804 | 725 | | const addresses = useAddresses(); |
| 805 | 726 | | // The production card's picture: an uploaded image, served from the |
| 806 | 727 | | // usercontent origin, and where someone who may change it adds one. |
| ⋯ |
| 835 | 756 | | {(plan === "production" || plan === "elsewhere") && <ProductionActions loaderData={loaderData} base={base} elsewhere={plan === "elsewhere"} />} |
| 836 | 757 | | </div> |
| 837 | 758 | | )} |
| 838 | | − | {plan === "elsewhere" && project ? ( |
| 759 | + | {hasProduction ? ( |
| 760 | + | <ProductionSummary loaderData={loaderData} base={base} upload={upload} addImage={addImage} elsewhere={plan === "elsewhere"} /> |
| 761 | + | ) : plan === "elsewhere" && project ? ( |
| 839 | 762 | | <ElsewhereHead |
| 840 | 763 | | project={project} |
| 841 | 764 | | base={base} |
| 842 | 765 | | canChange={canChange} |
| 843 | | − | canDeploy={member && loaderData.can.manage_integrations} |
| 844 | 766 | | deployment={loaderData.deployment} |
| 845 | | − | commit={loaderData.commit} |
| 846 | 767 | | shot={ |
| 847 | 768 | | <ProductionShot |
| 848 | 769 | | sources={cardSources(loaderData.elsewhereShot, upload)} |
| ⋯ |
| 864 | 785 | | ) : ( |
| 865 | 786 | | <ProductionHead loaderData={loaderData} base={base} name={name} upload={upload} addImage={addImage} /> |
| 866 | 787 | | )} |
| 867 | | − | {checkSections.length > 0 && ( |
| 868 | | − | <div className="border-t border-line px-5 py-4 sm:px-6"> |
| 869 | | − | {checkSections.map((section) => section.kind === "branch" ? ( |
| 870 | | − | <div key={section.kind}> |
| 871 | | − | <div className="mb-2 flex flex-wrap items-center gap-2 text-xs text-muted"> |
| 872 | | − | <GitCommitHorizontal size={14} /> |
| 873 | | − | <span>{section.label}</span> |
| 874 | | − | <Link to={`${base}/commit/${section.sha}`} className="font-mono hover:text-fg">{section.sha.slice(0, 7)}</Link> |
| 875 | | − | </div> |
| 876 | | − | <CommitChecksSummary checks={loaderData.checks} sha={section.sha} /> |
| 877 | | − | </div> |
| 878 | | − | ) : ( |
| 879 | | − | <details key={section.kind} className="mt-3 text-xs text-muted"> |
| 880 | | − | <summary className="cursor-pointer hover:text-fg">{section.label} <span className="font-mono">{section.sha.slice(0, 7)}</span></summary> |
| 881 | | − | <p className="my-2">These checks belong to the code deployed to production. Deployment status is shown above.</p> |
| 882 | | − | <Link to={`${base}/commit/${section.sha}`} className="mb-2 inline-block text-accent hover:underline">View deployed commit</Link> |
| 883 | | − | <CommitChecksSummary checks={loaderData.checks} sha={section.sha} /> |
| 884 | | − | </details> |
| 885 | | − | ))} |
| 886 | | − | {deployedSha && <p className="mt-2 text-xs text-muted">Currently serving <Link to={`${base}/commit/${deployedSha}`} className="font-mono text-fg-soft hover:underline">{deployedSha.slice(0, 7)}</Link>{loaderData.serving && <> · deployed <TimeAgo at={loaderData.serving.at} /></>}</p>} |
| 887 | | − | </div> |
| 888 | | − | )} |
| 889 | 788 | | {actionData && ( |
| 890 | 789 | | <p className={`border-t border-line px-6 py-2.5 text-sm ${"error" in actionData ? "text-danger" : "text-success"}`}> |
| 891 | 790 | | {"error" in actionData ? actionData.error : actionData.notice} |
| 892 | 791 | | </p> |
| 893 | 792 | | )} |
| 894 | | − | <Facts loaderData={loaderData} base={base} plan={plan} /> |
| 793 | + | {productionPlan && <div className="flex flex-wrap items-center justify-between gap-3 border-t border-line px-5 py-3 sm:px-6"> |
| 794 | + | <span className="text-xs text-muted">{plan === "elsewhere" ? "Production is deployed by its own pipeline." : !loaderData.settings?.enabled ? "Deployments are not enabled for this project." : <>Push to <span className="font-mono text-fg-soft">{defaultBranch ?? "the default branch"}</span> to update production.</>}</span> |
| 795 | + | <div className="flex flex-wrap items-center gap-2"> |
| 796 | + | {member && loaderData.can.manage_integrations && <ButtonLink to={`${base}/settings/deployments`} variant="ghost" size="sm"><Settings2 size={14} />Deployment settings</ButtonLink>} |
| 797 | + | <ButtonLink to={`${base}/deployments`} variant="outline" size="sm"><Rocket size={14} />Deployments{loaderData.environments && <span className="text-muted">{loaderData.environments.total_count}</span>}</ButtonLink> |
| 798 | + | </div> |
| 799 | + | </div>} |
| 895 | 800 | | {project && <CodeLine project={project} base={base} />} |
| 896 | 801 | | </section> |
| 897 | 802 | | </Card> |
| 898 | 803 | | |
| 899 | | − | <div className="grid gap-x-8 gap-y-8 lg:grid-cols-[minmax(0,1fr)_20rem]"> |
| 900 | | − | <div className="min-w-0 space-y-8"> |
| 901 | | − | {!loaderData.needsLoaded && ( |
| 902 | | − | <Panel title="Needs you" icon={<Hand size={14} className="text-warn" />}> |
| 903 | | − | <Unavailable what="What needs you" /> |
| 904 | | − | </Panel> |
| 905 | | − | )} |
| 906 | | − | {loaderData.needsLoaded && needs.length > 0 && ( |
| 907 | | − | <Panel title="Needs you" icon={<Hand size={14} className="text-warn" />} count={needs.length}> |
| 908 | | − | <NeedsList needs={needs} limit={5} /> |
| 909 | | − | </Panel> |
| 910 | | − | )} |
| 804 | + | <div className={`grid items-start gap-4 md:grid-cols-2 ${loaderData.telemetry || !loaderData.telemetryLoaded ? "xl:grid-cols-3" : ""}`}> |
| 805 | + | <BranchCard loaderData={loaderData} base={base} /> |
| 806 | + | {!loaderData.telemetryLoaded && <Unavailable what="Observability" compact />} |
| 807 | + | {loaderData.telemetry && <ObservabilityCard overview={loaderData.telemetry.overview} errors={loaderData.telemetry.errors} base={base} />} |
| 808 | + | <HealthCard loaderData={loaderData} base={base} plan={plan} /> |
| 809 | + | </div> |
| 911 | 810 | | |
| 912 | | − | <Panel |
| 913 | | − | title="Live now" |
| 914 | | − | icon={<Radio size={14} className={busy ? "text-success" : undefined} />} |
| 915 | | − | extra={ |
| 916 | | − | working ? ( |
| 917 | | − | <span className="text-xs text-muted"> |
| 918 | | − | {plural(awake.length, "session")} · {plural(claims.length, "claim")} |
| 919 | | − | {idle.length > 0 && ` · ${idle.length} idle`} |
| 920 | | − | </span> |
| 921 | | − | ) : null |
| 922 | | − | } |
| 923 | | − | all={{ to: `${base}/work`, label: "Work" }} |
| 924 | | − | > |
| 925 | | − | {!loaderData.liveLoaded ? ( |
| 926 | | − | <Unavailable what="Who is working" /> |
| 927 | | − | ) : working ? ( |
| 928 | | − | <> |
| 929 | | − | <LiveNowList |
| 930 | | − | claims={claims} |
| 931 | | − | sessions={sessions} |
| 932 | | − | titles={titles} |
| 933 | | − | pulls={livePulls} |
| 934 | | − | defaultBranch={defaultBranch} |
| 935 | | − | base={base} |
| 936 | | − | now={Date.now()} |
| 937 | | − | limit={LIVE_SHOWN} |
| 938 | | − | ender={loaderData.ender} |
| 939 | | − | /> |
| 940 | | − | {moreIssues > 0 && ( |
| 941 | | − | <Link to={`${base}/work`} className="mt-2 inline-block px-1 text-xs text-muted hover:text-fg"> |
| 942 | | − | {plural(moreIssues, "more issue")} being worked on |
| 943 | | − | </Link> |
| 944 | | − | )} |
| 945 | | − | </> |
| 946 | | − | ) : member ? ( |
| 947 | | − | <StartHere title={`Nobody is working on ${name} right now`} /> |
| 948 | | − | ) : ( |
| 949 | | − | <Quiet> |
| 950 | | − | Nobody is working on {name} right now. When people and their coding agents claim an issue or start a session, it shows here. |
| 951 | | − | </Quiet> |
| 952 | | − | )} |
| 953 | | − | </Panel> |
| 811 | + | {previews.length > 0 && ( |
| 812 | + | <Panel title="Preview deployments" icon={<GitBranch size={14} />} count={previews.length}> |
| 813 | + | <Card asChild divided className="overflow-hidden"> |
| 814 | + | <ul> |
| 815 | + | {previews.map((app) => ( |
| 816 | + | <li key={app.url} className="flex flex-wrap items-center gap-3 px-5 py-4 text-sm"> |
| 817 | + | <GitBranch size={16} className="shrink-0 text-faint" /> |
| 818 | + | <div className="min-w-0 flex-1"> |
| 819 | + | <div className="flex flex-wrap items-center gap-2"> |
| 820 | + | <span className="truncate font-mono text-[0.8125rem] font-medium">{app.branch}</span> |
| 821 | + | {app.number != null && <Link to={`${base}/pull/${app.number}`} className="text-xs text-muted hover:text-accent">#{app.number}</Link>} |
| 822 | + | </div> |
| 823 | + | <DeployLink href={app.url} className="mt-1 block truncate text-xs text-muted hover:text-accent">{host(app.url)}</DeployLink> |
| 824 | + | </div> |
| 825 | + | <span className="shrink-0 text-xs text-faint"><TimeAgo at={app.deployedAt} /></span> |
| 826 | + | <ButtonLink to={app.url} variant="outline" size="sm" reloadDocument target="_blank" rel="noopener noreferrer">Visit <ArrowUpRight size={14} /></ButtonLink> |
| 827 | + | </li> |
| 828 | + | ))} |
| 829 | + | </ul> |
| 830 | + | </Card> |
| 831 | + | </Panel> |
| 832 | + | )} |
| 954 | 833 | | |
| 955 | | − | <DeliveryPanel loaderData={loaderData} base={base} /> |
| 956 | | − | <WorkflowPanel loaderData={loaderData} base={base} /> |
| 834 | + | {/* Deployments panel (deployments-panel.tsx): each environment's latest deployment. */} |
| 835 | + | {loaderData.environmentsLoaded ? ( |
| 836 | + | <DeploymentsPanel base={base} summary={loaderData.environments} excludeEnvironment={productionPlan ? loaderData.productionLatest?.environment : undefined} className="rounded-xl border border-line bg-surface p-5" /> |
| 837 | + | ) : ( |
| 838 | + | <Unavailable what="Deployments" compact /> |
| 839 | + | )} |
| 957 | 840 | | |
| 958 | | − | {previews.length > 0 && ( |
| 959 | | − | <Panel title="Previews" icon={<GitBranch size={14} />} count={previews.length} all={{ to: `${base}/deployments`, label: "Deployments" }}> |
| 960 | | − | <Card asChild divided className="overflow-hidden"> |
| 961 | | − | <ul> |
| 962 | | − | {previews.map((app) => ( |
| 963 | | − | <li key={app.url} className="flex items-center gap-3 px-4 py-2.5 text-sm"> |
| 964 | | − | <span className="min-w-0 grow"> |
| 965 | | − | <DeployLink href={app.url} className="block truncate font-mono text-[0.8125rem] hover:text-accent"> |
| 966 | | − | {host(app.url)} |
| 967 | | − | </DeployLink> |
| 968 | | − | <span className="text-xs text-muted"> |
| 969 | | − | {app.branch} |
| 970 | | − | {app.number != null && ( |
| 971 | | − | <> |
| 972 | | − | {" · "} |
| 973 | | − | <Link to={`${base}/pull/${app.number}`} className="hover:underline"> |
| 974 | | − | #{app.number} |
| 975 | | − | </Link> |
| 976 | | − | </> |
| 977 | | − | )} |
| 978 | | − | </span> |
| 979 | | − | </span> |
| 980 | | − | <span className="shrink-0 text-xs text-faint"> |
| 981 | | − | <TimeAgo at={app.deployedAt} /> |
| 982 | | − | </span> |
| 983 | | − | </li> |
| 984 | | − | ))} |
| 985 | | − | </ul> |
| 986 | | − | </Card> |
| 987 | | − | </Panel> |
| 988 | | − | )} |
| 989 | | − | </div> |
| 841 | + | <div className="min-w-0 space-y-8"> |
| 842 | + | {!loaderData.needsLoaded && ( |
| 843 | + | <Panel title="Needs you" icon={<Hand size={14} className="text-warn" />}> |
| 844 | + | <Unavailable what="What needs you" /> |
| 845 | + | </Panel> |
| 846 | + | )} |
| 847 | + | {loaderData.needsLoaded && needs.length > 0 && ( |
| 848 | + | <Panel title="Needs you" icon={<Hand size={14} className="text-warn" />} count={needs.length}> |
| 849 | + | <NeedsList needs={needs} limit={5} /> |
| 850 | + | </Panel> |
| 851 | + | )} |
| 990 | 852 | | |
| 991 | | − | <aside className="space-y-4 text-sm"> |
| 992 | | − | {/* Deployments panel (deployments-panel.tsx): each environment's latest deployment. */} |
| 993 | | − | {loaderData.environmentsLoaded ? ( |
| 994 | | − | <DeploymentsPanel base={base} summary={loaderData.environments} className="rounded-xl border border-line bg-surface p-5" /> |
| 853 | + | <Panel |
| 854 | + | title="Live now" |
| 855 | + | icon={<Radio size={14} className={busy ? "text-success" : undefined} />} |
| 856 | + | extra={ |
| 857 | + | working ? ( |
| 858 | + | <span className="text-xs text-muted"> |
| 859 | + | {plural(awake.length, "session")} · {plural(claims.length, "claim")} |
| 860 | + | {idle.length > 0 && ` · ${idle.length} idle`} |
| 861 | + | </span> |
| 862 | + | ) : null |
| 863 | + | } |
| 864 | + | all={{ to: `${base}/work`, label: "Work" }} |
| 865 | + | > |
| 866 | + | {!loaderData.liveLoaded ? ( |
| 867 | + | <Unavailable what="Who is working" /> |
| 868 | + | ) : working ? ( |
| 869 | + | <> |
| 870 | + | <LiveNowList |
| 871 | + | claims={claims} |
| 872 | + | sessions={sessions} |
| 873 | + | titles={titles} |
| 874 | + | pulls={livePulls} |
| 875 | + | defaultBranch={defaultBranch} |
| 876 | + | base={base} |
| 877 | + | now={Date.now()} |
| 878 | + | limit={LIVE_SHOWN} |
| 879 | + | ender={loaderData.ender} |
| 880 | + | /> |
| 881 | + | {moreIssues > 0 && ( |
| 882 | + | <Link to={`${base}/work`} className="mt-2 inline-block px-1 text-xs text-muted hover:text-fg"> |
| 883 | + | {plural(moreIssues, "more issue")} being worked on |
| 884 | + | </Link> |
| 885 | + | )} |
| 886 | + | </> |
| 887 | + | ) : member ? ( |
| 888 | + | <StartHere title={`Nobody is working on ${name} right now`} /> |
| 995 | 889 | | ) : ( |
| 996 | | − | <Unavailable what="Deployments" compact /> |
| 890 | + | <Quiet> |
| 891 | + | Nobody is working on {name} right now. When people and their coding agents claim an issue or start a session, it shows here. |
| 892 | + | </Quiet> |
| 997 | 893 | | )} |
| 998 | | − | {!loaderData.telemetryLoaded && <Unavailable what="Observability" compact />} |
| 999 | | − | {loaderData.telemetry && <ObservabilityCard overview={loaderData.telemetry.overview} errors={loaderData.telemetry.errors} base={base} />} |
| 894 | + | </Panel> |
| 895 | + | |
| 896 | + | <div className="grid items-start gap-6 xl:grid-cols-2"><DeliveryPanel loaderData={loaderData} base={base} /><WorkflowPanel loaderData={loaderData} base={base} /></div> |
| 1000 | 897 | | |
| 1001 | | − | <HealthCard loaderData={loaderData} base={base} plan={plan} /> |
| 1002 | | − | </aside> |
| 1003 | 898 | | </div> |
| 1004 | 899 | | </div> |
| 1005 | 900 | | ); |
| ⋯ |
| 1045 | 940 | | <RequestBars points={overview.points} /> |
| 1046 | 941 | | </div> |
| 1047 | 942 | | <dl className="mt-3 grid grid-cols-2 gap-3 text-xs"> |
| 943 | + | <div><dt className="text-faint">Requests</dt><dd className="mt-0.5 font-medium tabular-nums">{count(overview.totals.requests)}</dd></div> |
| 944 | + | <div><dt className="text-faint">Error rate</dt><dd className="mt-0.5 font-medium tabular-nums"><Link to={`${base}/observability/errors`} className={overview.totals.error_rate >= 0.01 ? "text-danger" : "hover:text-accent"}>{percent(overview.totals.error_rate)}</Link><span className="ml-1 text-muted">({count(overview.totals.errors)})</span></dd></div> |
| 1048 | 945 | | <div> |
| 1049 | 946 | | <dt className="text-faint">Latency p50</dt> |
| 1050 | 947 | | <dd className="mt-0.5 font-medium tabular-nums">{duration(overview.totals.latency.p50)}</dd> |