import type { ReactNode } from "react"; import { CreatePrMenu } from "../create-pr-menu"; import { LoadingSpinner } from "../session-item/session-item-loading"; import { Button } from "../../ui/button"; import { buttonVariants } from "../../lib/button-variants"; import { SplitButton } from "../../ui/split-button"; import { Tooltip, TooltipContent, TooltipTrigger } from "../../ui/tooltip"; import type { DiffViewPr } from "./types"; import { IconMerge, IconPullRequest, IconPullRequestClosed } from "../../icons"; function PrIcon({ state }: { state: DiffViewPr["state"] }) { if (state === "closed") { return ; } if (state === "merged") { return ; } if (state === "draft") { return ; } return ; } function PrAction({ pr, creatingPr = false, preparingPr = false, onOpenPr, onCreatePr, onCreateDraftPr, onManualCreatePr, }: { pr?: DiffViewPr; creatingPr?: boolean; preparingPr?: boolean; onOpenPr?: () => void; onCreatePr?: () => void; onCreateDraftPr?: () => void; onManualCreatePr?: () => void; }) { if (pr) { let content = ( <> {pr.number} ); if (pr.url && !onOpenPr) { return ( {content} ); } return ( ); } let busy = creatingPr || preparingPr; let label = preparingPr ? "Preparing PR" : creatingPr ? "Creating PR" : "Create PR"; if (!busy && !onCreatePr) return null; let content = ( <> {busy ? ( ) : null} {label} ); if (onCreateDraftPr) { return ( } menuLabel="Create PR options" > {content} ); } return ( ); } function ToolButton({ label, pressed, onClick, children, }: { label: string; pressed?: boolean; onClick: () => void; children: ReactNode; }) { return ( {children} } /> {label} ); } export { PrAction, ToolButton };