/**
* The commits and changes of the new pull request (`GHPRCreateComponentFactory.changesPanel`):
* "Changes" / "Changes from" with the commit chooser ("{n} commits", "All commits (n)"),
* the selected commit's details (Show / Hide details) and the changes tree, whose
* Show Diff opens the files in the diff viewer as one chain.
*/
import { useMemo, useRef, useState, type MouseEvent, type ReactNode } from "react";
import { buildFileTree, dirKeys, type FileTreeNode } from "@/features/vcs/fileTree";
import { openDiff, withChain } from "@/features/vcs/diffInput";
import { KIND_COLOR, fileCount, renameFrom, type EffectiveKind } from "@/features/vcs/model";
import type { Commit } from "@/platform/ipc";
import { tx } from "@/platform/i18n";
import { Icon, IconButton, Spinner, T, Tree, fileIconName, showContextMenu, type MenuItem } from "@/ui";
import { ChooserPopup } from "../ui/ChooserPopup";
import { prettyDate } from "../ui/prettyDate";
import { commitDescription } from "./model";
import { selectCommit, useCreatePr, type CreateChange } from "./store";
import styles from "./Create.module.css";
function Centered({ children, error }: { children: ReactNode; error?: boolean }) {
return
{children}
;
}
export function ChangesPanel() {
const commits = useCreatePr((s) => s.commits);
if (!commits)
return (
Select pull request base and head to view changes
);
if (commits.state === "loading")
return (
);
if (commits.state === "error")
return (
Failed to load commits
{commits.error}
);
if (!commits.value.length)
return (
Pull request does not contain any commits
);
return ;
}
function CommitsAndChanges({ commits }: { commits: Commit[] }) {
const selectedId = useCreatePr((s) => s.selectedCommit);
const index = commits.findIndex((c) => c.id === selectedId);
const selected = index >= 0 ? commits[index]! : null;
return (