| 60 | 60 | | import { cardSources, externalTarget, externalVersion, productionImageUrl } from "../../lib/production-image"; |
| 61 | 61 | | import { useAddresses } from "../../lib/addresses"; |
| 62 | 62 | | import { commitChecksFor } from "../../lib/commit-checks.server"; |
| 63 | | − | import { CommitChecksBadge, CommitChecksSummary } from "../../components/commit-checks"; |
| 63 | + | import { CommitChecksSummary } from "../../components/commit-checks"; |
| 64 | + | import { projectCheckSections } from "../../lib/project-checks"; |
| 64 | 65 | | import { StatusIcon, Duration, shortRef, standingWord } from "../../components/actions"; |
| 65 | 66 | | import { resolveRange, rangeLabel } from "../../lib/usage"; |
| 66 | 67 | | import { deliveryDays, duration as deliveryDuration } from "../../lib/workspace-insights"; |
| ⋯ |
| 292 | 293 | | : null, |
| 293 | 294 | | commit: commit ? { hash: commit.hash, authoredAt: commit.authoredAt } : null, |
| 294 | 295 | | // The commit's checks, streamed in after the page. |
| 295 | | − | checks: commitChecksFor(path, viewer, [commit?.hash, deployment?.sha, productionLatest?.sha]), |
| 296 | + | checks: commitChecksFor(path, viewer, [commit?.hash, current?.sha, production?.commit]), |
| 296 | 297 | | workflowRuns: ok(workflowRuns), |
| 297 | 298 | | insights, |
| 298 | 299 | | range, |
| ⋯ |
| 798 | 799 | | const name = project?.name ?? params.repo; |
| 799 | 800 | | const plan = project ? projectPlan(project) : "production"; |
| 800 | 801 | | const canChange = member && loaderData.can.manage_settings; |
| 801 | | − | const checkSha = loaderData.productionLatest?.sha ?? loaderData.commit?.hash; |
| 802 | + | const deployedSha = loaderData.serving?.sha ?? loaderData.production?.commit; |
| 803 | + | const checkSections = projectCheckSections(loaderData.commit?.hash, defaultBranch, deployedSha); |
| 802 | 804 | | const addresses = useAddresses(); |
| 803 | 805 | | // The production card's picture: an uploaded image, served from the |
| 804 | 806 | | // usercontent origin, and where someone who may change it adds one. |
| ⋯ |
| 841 | 843 | | canDeploy={member && loaderData.can.manage_integrations} |
| 842 | 844 | | deployment={loaderData.deployment} |
| 843 | 845 | | commit={loaderData.commit} |
| 844 | | − | checks={(loaderData.deployment?.sha ?? loaderData.commit?.hash) ? <CommitChecksBadge checks={loaderData.checks} sha={(loaderData.deployment?.sha ?? loaderData.commit?.hash)!} /> : undefined} |
| 845 | 846 | | shot={ |
| 846 | 847 | | <ProductionShot |
| 847 | 848 | | sources={cardSources(loaderData.elsewhereShot, upload)} |
| ⋯ |
| 863 | 864 | | ) : ( |
| 864 | 865 | | <ProductionHead loaderData={loaderData} base={base} name={name} upload={upload} addImage={addImage} /> |
| 865 | 866 | | )} |
| 866 | | − | {checkSha && ( |
| 867 | + | {checkSections.length > 0 && ( |
| 867 | 868 | | <div className="border-t border-line px-5 py-4 sm:px-6"> |
| 868 | | − | <div className="mb-2 flex flex-wrap items-center gap-2 text-xs text-muted"> |
| 869 | | − | <GitCommitHorizontal size={14} /> |
| 870 | | − | <span>{loaderData.productionLatest ? "Latest production deployment" : `Latest on ${defaultBranch ?? "default branch"}`}</span> |
| 871 | | − | <Link to={`${base}/commit/${checkSha}`} className="font-mono hover:text-fg">{checkSha.slice(0, 7)}</Link> |
| 872 | | − | </div> |
| 873 | | − | <CommitChecksSummary checks={loaderData.checks} sha={checkSha} /> |
| 874 | | − | {loaderData.serving && loaderData.serving.sha !== checkSha && ( |
| 875 | | − | <p className="mt-2 text-xs text-muted">Currently serving <Link to={`${base}/commit/${loaderData.serving.sha}`} className="font-mono text-fg-soft hover:underline">{loaderData.serving.sha.slice(0, 7)}</Link> · deployed <TimeAgo at={loaderData.serving.at} /></p> |
| 876 | | − | )} |
| 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>} |
| 877 | 887 | | </div> |
| 878 | 888 | | )} |
| 879 | 889 | | {actionData && ( |