mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
fix(vcs): align the Git Conflicts dialog (#4709)
The Conflicts dialog puts the merge status and file count above a larger, resizable file list; the resolution actions sit beside the list and move below it in narrow windows, and file names keep their width before long directory paths are shortened.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("the conflict actions stay visible beside or below the file list as the dialog resizes", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.evaluate(async () => {
|
||||
const storeModule = "/src/features/vcs/store.ts";
|
||||
const dialogModule = "/src/features/vcs/conflictsUi.tsx";
|
||||
const { useVcs } = await import(/* @vite-ignore */ storeModule);
|
||||
const { showConflictsDialog } = await import(/* @vite-ignore */ dialogModule);
|
||||
const root = "/dev/acme-api";
|
||||
useVcs.setState({
|
||||
root,
|
||||
status: Array.from({ length: 24 }, (_, index) => {
|
||||
const relPath = `services/payment-configuration/environments/env-${index + 1}.txt`;
|
||||
return { path: `${root}/${relPath}`, relPath, staged: null, unstaged: "conflicted", renamedFrom: null };
|
||||
}),
|
||||
});
|
||||
showConflictsDialog();
|
||||
});
|
||||
const dialog = page.getByRole("dialog", { name: "Conflicts", exact: true });
|
||||
const list = dialog.getByRole("listbox", { name: "Conflicted files" });
|
||||
const yours = dialog.getByRole("button", { name: "Accept Yours", exact: true });
|
||||
await expect(list).toBeFocused();
|
||||
const listBox = (await list.boundingBox())!;
|
||||
const first = (await yours.boundingBox())!;
|
||||
expect(first.x).toBeGreaterThan(listBox.x + listBox.width);
|
||||
expect(first.y).toBeLessThan(listBox.y + listBox.height / 2);
|
||||
|
||||
const grip = (await dialog.getByRole("separator", { name: "Resize", exact: true }).boundingBox())!;
|
||||
await page.mouse.move(grip.x + grip.width / 2, grip.y + grip.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(grip.x + 36, grip.y + 68, { steps: 5 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(async () => (await list.boundingBox())!.height).toBeGreaterThan(listBox.height + 40);
|
||||
|
||||
await page.setViewportSize({ width: 430, height: 530 });
|
||||
await expect(yours).toBeInViewport({ ratio: 1 });
|
||||
expect((await yours.boundingBox())!.y).toBeGreaterThan(
|
||||
(await list.boundingBox())!.y + (await list.boundingBox())!.height,
|
||||
);
|
||||
for (const name of ["Accept Theirs", "Merge…"])
|
||||
await expect(dialog.getByRole("button", { name, exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(dialog.locator("[data-dialog-footer]").getByRole("button", { name: "Close" })).toBeInViewport({
|
||||
ratio: 1,
|
||||
});
|
||||
await list.press("End");
|
||||
await expect(list.getByRole("option", { selected: true })).toContainText("env-24.txt");
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(dialog).toBeHidden();
|
||||
});
|
||||
@@ -0,0 +1,121 @@
|
||||
.dialog > [data-dialog-body] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.content {
|
||||
container: conflicts / inline-size;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
min-height: 0;
|
||||
padding: var(--space-3) var(--space-4) 0;
|
||||
}
|
||||
|
||||
.summary {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-1) var(--space-3);
|
||||
font-size: var(--fs-ui);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.count {
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
|
||||
.workspace {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
gap: var(--space-3);
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.listFrame {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-small);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.listHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: var(--h-list-row);
|
||||
padding-inline: var(--space-4);
|
||||
border-bottom: 1px solid var(--border);
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
|
||||
.list {
|
||||
flex: 1 1 300px;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
min-width: 0;
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.fileName,
|
||||
.fileDir {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.fileName {
|
||||
color: var(--vcs-conflict);
|
||||
}
|
||||
|
||||
.fileName:not(:last-child) {
|
||||
flex: none;
|
||||
max-width: 65%;
|
||||
}
|
||||
|
||||
.fileDir {
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
align-self: flex-start;
|
||||
gap: var(--space-2);
|
||||
max-width: min(40%, 180px);
|
||||
}
|
||||
|
||||
.actions button {
|
||||
min-width: 0;
|
||||
min-height: var(--h-button);
|
||||
height: auto;
|
||||
padding: var(--space-1) var(--space-2);
|
||||
line-height: 1.3;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@container conflicts (max-width: 430px) {
|
||||
.workspace {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.actions {
|
||||
align-self: stretch;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from "react";
|
||||
import type { FileStatus } from "@/bindings";
|
||||
import { activeEditor } from "@/editor/api";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { Dialog, Icon, List, fileIconName, T } from "@/ui";
|
||||
import { Button, Dialog, Icon, List, fileIconName, T } from "@/ui";
|
||||
import { editorService, notifications } from "@/workbench/contributions";
|
||||
import { blockAt, parseConflicts, resolutionText, type Resolution } from "./conflicts";
|
||||
import { openDialog } from "./dialogs";
|
||||
@@ -13,9 +13,8 @@ import { controlLabel, controlOperation, inProgress, operationTitle, type InProg
|
||||
import { runOp, writeFileText } from "./ops";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { conflictedFiles, useVcs } from "./store";
|
||||
import styles from "./common.module.css";
|
||||
import styles from "./ConflictsDialog.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
|
||||
/**
|
||||
* The stopped rebase / cherry-pick / revert whose conflicts are being resolved from the
|
||||
@@ -65,7 +64,6 @@ export async function acceptSide(f: FileStatus, side: "ours" | "theirs") {
|
||||
}
|
||||
|
||||
function ConflictsDialog({ onClose }: { onClose: () => void }) {
|
||||
const rowHeight = useRowHeight(22);
|
||||
const files = useVcs((s) => s.status).filter((f) => f.unstaged === "conflicted");
|
||||
const root = useVcs((s) => s.root) ?? "";
|
||||
const op = useVcs((s) => inProgress(s.branch?.operation));
|
||||
@@ -86,6 +84,10 @@ function ConflictsDialog({ onClose }: { onClose: () => void }) {
|
||||
const head = useVcs((s) => s.branch?.head ?? null);
|
||||
const [active, setActive] = useState(0);
|
||||
const current = files[Math.min(active, files.length - 1)];
|
||||
const edit = (file: FileStatus) => {
|
||||
onClose();
|
||||
openMergeEditor(file.path);
|
||||
};
|
||||
// Once everything is resolved the dialog concludes the stopped operation, as IDEA does.
|
||||
const conclude =
|
||||
op && !files.length
|
||||
@@ -98,8 +100,11 @@ function ConflictsDialog({ onClose }: { onClose: () => void }) {
|
||||
open
|
||||
title="Conflicts"
|
||||
onClose={dismiss}
|
||||
width={600}
|
||||
footerStart={<span className={styles.hint}>{op ? operationTitle(op, head) : ""}</span>}
|
||||
className={styles.dialog}
|
||||
width={680}
|
||||
resizable="both"
|
||||
minWidth={360}
|
||||
minHeight={320}
|
||||
buttons={[
|
||||
...(conclude
|
||||
? [
|
||||
@@ -114,58 +119,68 @@ function ConflictsDialog({ onClose }: { onClose: () => void }) {
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{ label: "Accept Yours", disabled: !current, onClick: () => current && void acceptSide(current, "ours") },
|
||||
{ label: "Accept Theirs", disabled: !current, onClick: () => current && void acceptSide(current, "theirs") },
|
||||
{
|
||||
label: "Merge…",
|
||||
role: conclude ? "extra" : "default",
|
||||
autoFocus: !conclude,
|
||||
disabled: !current,
|
||||
onClick: () => {
|
||||
if (!current) return;
|
||||
onClose();
|
||||
openMergeEditor(current.path);
|
||||
},
|
||||
},
|
||||
{ label: "Close", role: "cancel" },
|
||||
]}
|
||||
>
|
||||
<div className={styles.section}>
|
||||
{files.length
|
||||
? files.length === 1
|
||||
? tx`${files.length} file with conflicts`
|
||||
: tx`${files.length} files with conflicts`
|
||||
: tx("All conflicts resolved")}
|
||||
</div>
|
||||
<div style={{ height: 240, display: "flex", flexDirection: "column", padding: "0 14px 14px" }}>
|
||||
<List
|
||||
items={files}
|
||||
getKey={(f) => f.path}
|
||||
activeIndex={Math.min(active, files.length - 1)}
|
||||
onActiveChange={setActive}
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Conflicted files"
|
||||
className={styles.boxList}
|
||||
empty={
|
||||
<span>
|
||||
<T>No conflicts</T>
|
||||
</span>
|
||||
}
|
||||
onActivate={(f, _i, e) => {
|
||||
if (e.type === "click" && (e as unknown as MouseEvent).detail < 2) return;
|
||||
onClose();
|
||||
openMergeEditor(f.path);
|
||||
}}
|
||||
renderItem={(f) => (
|
||||
<span className={styles.fileRow} style={{ flex: 1, padding: 0 }}>
|
||||
<Icon name={fileIconName(baseName(f.path), f.path)} size={14} />
|
||||
<span className={styles.fileName} style={{ color: "var(--vcs-conflict)" }}>
|
||||
{baseName(f.path)}
|
||||
</span>
|
||||
<span className={styles.fileDir}>{dirName(relTo(root, stripSlash(f.path)))}</span>
|
||||
</span>
|
||||
)}
|
||||
/>
|
||||
<div className={styles.content}>
|
||||
<div className={styles.summary}>
|
||||
{op && <span>{operationTitle(op, head)}</span>}
|
||||
<span className={styles.count} role="status">
|
||||
{files.length
|
||||
? files.length === 1
|
||||
? tx`${files.length} file with conflicts`
|
||||
: tx`${files.length} files with conflicts`
|
||||
: tx("All conflicts resolved")}
|
||||
</span>
|
||||
</div>
|
||||
<div className={styles.workspace}>
|
||||
<div className={styles.listFrame}>
|
||||
<div className={styles.listHeader} aria-hidden>
|
||||
<T>Name</T>
|
||||
</div>
|
||||
<List
|
||||
autoFocus={!!current}
|
||||
items={files}
|
||||
getKey={(f) => f.path}
|
||||
activeIndex={Math.min(active, files.length - 1)}
|
||||
onActiveChange={setActive}
|
||||
aria-label={tx("Conflicted files")}
|
||||
className={styles.list}
|
||||
empty={<T>No conflicts</T>}
|
||||
onActivate={(f, _i, e) => {
|
||||
if (e.type === "click" && (e as unknown as MouseEvent).detail < 2) return;
|
||||
edit(f);
|
||||
}}
|
||||
renderItem={(f) => {
|
||||
const path = relTo(root, stripSlash(f.path));
|
||||
const name = baseName(f.path);
|
||||
const dir = dirName(path);
|
||||
return (
|
||||
<span className={styles.row} title={path}>
|
||||
<Icon name={fileIconName(name, f.path)} size={16} />
|
||||
<span className={styles.fileName}>{name}</span>
|
||||
{dir && <span className={styles.fileDir}>{dir}</span>}
|
||||
</span>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.actions} role="group" aria-label={tx("Conflict resolution")}>
|
||||
<Button disabled={!current} onClick={() => current && void acceptSide(current, "ours")}>
|
||||
Accept Yours
|
||||
</Button>
|
||||
<Button disabled={!current} onClick={() => current && void acceptSide(current, "theirs")}>
|
||||
Accept Theirs
|
||||
</Button>
|
||||
<Button
|
||||
variant={conclude ? "secondary" : "primary"}
|
||||
disabled={!current}
|
||||
onClick={() => current && edit(current)}
|
||||
>
|
||||
Merge…
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
@@ -120,6 +120,7 @@
|
||||
"Command": "Command",
|
||||
"Fix ESLint Problems": "Fix ESLint Problems",
|
||||
"Name": "Name",
|
||||
"Conflict resolution": "Conflict resolution",
|
||||
"No ESLint problems to fix": "No ESLint problems to fix",
|
||||
"Pin ({count})": "Pin ({count})",
|
||||
"Start": "Start",
|
||||
|
||||
@@ -1111,6 +1111,7 @@
|
||||
"Confirm rerun with process termination": "重新运行并终止进程前确认",
|
||||
"Confirmation": "确认",
|
||||
"Conflicted files": "冲突的文件",
|
||||
"Conflict resolution": "冲突解决",
|
||||
"Conflicts": "冲突",
|
||||
"Conflicts:": "冲突:",
|
||||
"Connect": "连接",
|
||||
|
||||
Reference in New Issue
Block a user