import { reviewDeployment } from "~/fns/deployments"; import { useAction } from "~/hooks/use-action"; import { Button } from "~/ui/Button"; import { ErrorBanner } from "~/ui/Callout"; import { Callout } from "~/ui/Callout"; type PendingDeployment = { id: string; environment: string; waitUntil: number | null; needsReview: boolean; canReview: boolean; }; /** Banner for jobs held by environment protection rules, with approve/reject for required reviewers. */ export function DeploymentGate({ owner, repo, deployments, }: { owner: string; repo: string; deployments: PendingDeployment[]; }) { const review = useAction(reviewDeployment); if (deployments.length === 0) return null; return ( {deployments.map((deployment) => (
Deployment to {deployment.environment}{" "} {deployment.needsReview ? "is waiting for a required reviewer" : "is waiting"} {deployment.waitUntil && deployment.waitUntil > Date.now() && ( <> {" "} ยท wait timer ends at{" "} )} {deployment.canReview && ( )}
))}
); }