"use client"; import { useState } from "react"; import { Dialog, Field as MuField, FormField, Radio, RadioGroup, Spinner, Textarea } from "@unlocalhosted/metalui"; import { BranchIcon, CommitIcon, TrashIcon } from "./icons"; import { Alert, Button, RefChip } from "./ui"; type Target = "direct" | "branch"; /** * GitHub-style "Commit changes" dialog, on MetalUI's Dialog. It must be rendered inside the form it * submits. The popup is portaled out of that form, so its fields and its submit cap join the form * through the `form` attribute (`formId` is the form's id); the radio choice rides a hidden input. */ export function CommitDialog({ formId, branch, baseSha, defaultMessage, pending, error, open, onOpenChange, danger, }: { /** The id of the form this dialog submits. */ formId: string; branch: string; baseSha: string; defaultMessage: string; pending: boolean; error?: string; open: boolean; onOpenChange: (open: boolean) => void; danger?: boolean; }) { const [message, setMessage] = useState(""); const [description, setDescription] = useState(""); const [target, setTarget] = useState("direct"); const [newBranch, setNewBranch] = useState(""); return ( <> (next || !pending) && onOpenChange(next)}>
Commit changes
{error && {error}} Commit message setMessage(e.target.value)} placeholder={defaultMessage} /> Extended description · optional