/** * The "New Pull Request at {repo}" tab (IntelliJ's `GHPRCreateComponentFactory`): a * vertical splitter with the merge direction and the commits and changes above, and the * title and description, reviewers / assignees / labels, the status line and the * "Create Pull Request" option button (with "Create Draft Pull Request") below. * * Contract: `CreatePanel()` takes no props and renders inside the New Pull Request tab * while the tool window is connected. Its state (`store.ts`) lives as long as the tab. */ import { useEffect, useRef, useState } from "react"; import { useVcs } from "@/features/vcs/store"; import { tx } from "@/platform/i18n"; import { Button, Icon, IconButton, Input, Menu, Popup, SplitGroup, SplitHandle, SplitPanel, Spinner, T, type MenuItem, } from "@/ui"; import { openPullRequest } from "../toolwindow/open"; import { ChangesPanel } from "./ChangesPanel"; import { DirectionSelector } from "./DirectionSelector"; import { MetadataGrid } from "./MetadataGrid"; import { canCreate, createFromForm, initCreate, onRepositoryChanged, refreshBranchesState, resetCreate, setDescription, setTitle, useCreatePr, } from "./store"; import styles from "./Create.module.css"; export function CreatePanel() { const ready = useCreatePr((s) => s.ready); const initError = useCreatePr((s) => s.initError); useEffect(() => { void initCreate(); }, []); // Commits follow the repository (a new commit, a push, a fetch). useEffect( () => useVcs.subscribe((s, prev) => { if (s.version !== prev.version) void onRepositoryChanged(); }), [], ); if (initError) return (
{initError}
); if (!ready) return (
); return (
); } /** `CodeReviewTitleDescriptionComponentFactory`: the title and description editors. */ function TextPanel() { const title = useCreatePr((s) => s.title); const description = useCreatePr((s) => s.description); const templateLoading = useCreatePr((s) => s.templateLoading); return (
setTitle(e.target.value)} />