Файли
openidea/src/features/vcs/CommitDialog.tsx
T
l0ng-ai 21bc81c6da fix(ui): remember splitter positions in the Git and other tool windows (#3401)
None of the Git views gave SplitGroup a storageKey, so their splitters reset whenever the view was recreated. They, the Commit dialog and the Todo, Find, Problems, Usages, Build, HTTP Client and Dependency Analyzer splits now store their sizes. A view whose preview comes and goes keys sizes per panel set, and SplitGroup applies that set's sizes when the key changes, without remounting the view.
2026-11-14 23:42:02 +08:00

101 рядки
3.3 KiB
TypeScript
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
/**
* Commit dialog of the modal commit interface (Settings › Version Control › Commit ›
* "Use non-modal commit interface" off): the changes with inclusion checkboxes and
* the Commit Options beside them, the message below. Commits through the same
* pipeline as the Commit tool window.
*/
import { tx } from "@/platform/i18n";
import { Dialog, SplitGroup, SplitHandle, SplitPanel } from "@/ui";
import { CommitOptionsBody } from "./CommitOptions";
import { useCommit } from "./commitStore";
import {
ChangesTree,
CommitMessageField,
commitAndPushLabel,
commitLabel,
useCommitRunner,
useIncludedCount,
} from "./CommitView";
import { openDialog } from "./dialogs";
import { useVcs } from "./store";
import viewStyles from "./CommitView.module.css";
import styles from "./CommitDialog.module.css";
let open = false;
/** Opens the Commit dialog (or focuses the message of the one open). */
export function showCommitDialog() {
useCommit.setState((s) => ({ tab: "changes", focusTick: s.focusTick + 1 }));
if (open) return;
open = true;
openDialog((close) => (
<CommitDialog
onClose={() => {
open = false;
close();
}}
/>
));
}
function CommitDialog({ onClose }: { onClose: () => void }) {
const included = useIncludedCount();
const amend = useCommit((s) => s.amend);
const problems = useCommit((s) => s.checkProblems.length > 0);
const remoteBusy = useVcs((s) => s.remoteBusy);
const runner = useCommitRunner(included, onClose);
return (
<Dialog
open
title="Commit Changes"
onClose={onClose}
width={880}
buttons={[
{
label: commitLabel(amend, problems),
role: "default",
disabled: !runner.canCommit,
title: "⌘↩",
onClick: () => void runner.run(false),
},
{
label: commitAndPushLabel(amend),
role: "extra",
disabled: !runner.canCommit || !!remoteBusy,
title: "⌥⌘↩",
onClick: () => void runner.run(true),
},
{ label: "Cancel", role: "cancel" },
]}
>
<div className={styles.body}>
<SplitGroup orientation="vertical" className={styles.split} storageKey="openidea.vcs.commitDialogSplit">
<SplitPanel id="top" defaultSize="58%" minSize="25%">
<SplitGroup
orientation="horizontal"
className={styles.split}
storageKey="openidea.vcs.commitDialogOptionsSplit"
>
<SplitPanel id="changes" defaultSize="64%" minSize="35%">
<ChangesTree mode="dialog" />
</SplitPanel>
<SplitHandle />
<SplitPanel id="options" defaultSize="36%" minSize="200px">
<div className={styles.options} role="group" aria-label={tx("Commit Options")}>
<CommitOptionsBody />
</div>
</SplitPanel>
</SplitGroup>
</SplitPanel>
<SplitHandle />
<SplitPanel id="message" defaultSize="42%" minSize="120px">
<div className={viewStyles.commit}>
<CommitMessageField included={included} runner={runner} autoFocus />
</div>
</SplitPanel>
</SplitGroup>
</div>
</Dialog>
);
}