mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
fix(vcs): align the target changelist dialog (#4947)
Put existing and new target changelists in one editable **Name** field. Open the list to pick an existing target or enter a name to make a new one. The comment and active status sit in the same place for both choices. Undo Commit offers the commit subject as a suggested name.
This commit is contained in:
@@ -37,7 +37,15 @@ test("changelist forms align the fields and preserve multiline comments through
|
||||
const listModule = "/src/features/vcs/changelists.ts";
|
||||
const { initialChangelists, useChangelists } = await import(/* @vite-ignore */ listModule);
|
||||
useChangelists.setState({
|
||||
state: { ...initialChangelists(), files: { "build.gradle.kts": "default" } },
|
||||
state: {
|
||||
...initialChangelists(),
|
||||
lists: [
|
||||
...initialChangelists().lists,
|
||||
{ id: "inbox", name: "Review inbox", comment: "Choose a reviewer before merging." },
|
||||
{ id: "unsorted", name: "Unsorted" },
|
||||
],
|
||||
files: { "build.gradle.kts": "default" },
|
||||
},
|
||||
loaded: true,
|
||||
});
|
||||
window.__ipc.handlers.vcs_changelists_save = () => null;
|
||||
@@ -94,16 +102,41 @@ test("changelist forms align the fields and preserve multiline comments through
|
||||
|
||||
await action(page, "vcs.changelist.move", ["/dev/acme-api/build.gradle.kts"]);
|
||||
const move = page.getByRole("dialog", { name: "Move Changes to Another Changelist" });
|
||||
await move.getByRole("radio", { name: "New changelist:" }).check();
|
||||
await page.setViewportSize({ width: 400, height: 540 });
|
||||
const newName = move.getByRole("textbox", { name: "Name:", exact: true });
|
||||
const targetComment = move.getByRole("textbox", { name: "Comment:", exact: true });
|
||||
const moveOk = move.getByRole("button", { name: "OK", exact: true });
|
||||
await expect(newName).toBeFocused();
|
||||
await expect(newName).toHaveValue("Release review");
|
||||
await expect(targetComment).toHaveAttribute("readonly", "");
|
||||
await newName.press("ArrowDown");
|
||||
const options = page.getByRole("listbox", { name: "Target changelist" });
|
||||
await expect(options).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(options).toBeHidden();
|
||||
await expect(newName).toBeFocused();
|
||||
await newName.press("ArrowDown");
|
||||
await expect(options.getByRole("option", { name: "Changes", exact: true })).toHaveCount(0);
|
||||
await options.getByRole("option", { name: "Review inbox", exact: true }).click();
|
||||
await expect(newName).toHaveValue("Review inbox");
|
||||
await expect(targetComment).toHaveValue("Choose a reviewer before merging.");
|
||||
await newName.fill("Changes");
|
||||
await expect(newName).toHaveAccessibleDescription(/already exists/);
|
||||
await expect(moveOk).toBeDisabled();
|
||||
|
||||
await page.setViewportSize({ width: 400, height: 540 });
|
||||
const stackedName = (await newName.boundingBox())!;
|
||||
const stackedLabel = (await move.getByText("Name:", { exact: true }).boundingBox())!;
|
||||
expect(stackedLabel.y + stackedLabel.height).toBeLessThanOrEqual(stackedName.y);
|
||||
expect(Math.abs(stackedLabel.x - stackedName.x)).toBeLessThan(1);
|
||||
await newName.fill("Ready to ship");
|
||||
await move.getByRole("textbox", { name: "Comment:", exact: true }).fill("Move the reviewed change here.");
|
||||
await move.getByRole("button", { name: "OK", exact: true }).click();
|
||||
await expect(targetComment).toBeEditable();
|
||||
await targetComment.fill("Move the reviewed change here.");
|
||||
await newName.fill("Unsorted");
|
||||
await expect(targetComment).toHaveAttribute("readonly", "");
|
||||
await expect(targetComment).toHaveValue("");
|
||||
await newName.fill("Ready to ship");
|
||||
await expect(targetComment).toHaveValue("Move the reviewed change here.");
|
||||
await moveOk.click();
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const state = await savedLists(page);
|
||||
|
||||
@@ -26,9 +26,45 @@
|
||||
gap: var(--space-1);
|
||||
min-width: 0;
|
||||
}
|
||||
.hint {
|
||||
grid-column: 1 / -1;
|
||||
color: var(--fg-subtle);
|
||||
}
|
||||
.picker {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
min-width: 0;
|
||||
padding-inline-end: var(--space-1);
|
||||
border-radius: var(--radius-control);
|
||||
background: var(--bg-field, var(--bg-button));
|
||||
box-shadow: inset 0 0 0 1px var(--border-button);
|
||||
}
|
||||
.picker:focus-within,
|
||||
.picker[data-open] {
|
||||
box-shadow:
|
||||
inset 0 0 0 1px var(--focus-ring),
|
||||
0 0 0 1px var(--focus-ring);
|
||||
}
|
||||
.picker[data-invalid] {
|
||||
box-shadow:
|
||||
inset 0 0 0 1px var(--danger),
|
||||
0 0 0 1px var(--danger);
|
||||
}
|
||||
.picker > input {
|
||||
flex: 1;
|
||||
padding-inline-start: var(--space-2);
|
||||
}
|
||||
.newName {
|
||||
color: var(--vcs-added);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.form > textarea {
|
||||
min-width: 0;
|
||||
}
|
||||
.form > textarea[readonly] {
|
||||
color: var(--fg-secondary);
|
||||
}
|
||||
.active {
|
||||
grid-column: 1 / -1;
|
||||
justify-self: start;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/** Change list dialogs: New / Edit Changelist, Move to Another Changelist, delete. */
|
||||
import { useId, useState } from "react";
|
||||
import { Checkbox, Dialog, Input, Select, T } from "@/ui";
|
||||
import { useId, useRef, useState, type ChangeEvent } from "react";
|
||||
import { Checkbox, Dialog, IconButton, Input, Popup, SelectListbox, T, type SelectOption } from "@/ui";
|
||||
import type { InputProps } from "@/ui/Input";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import {
|
||||
activeList,
|
||||
@@ -32,33 +33,116 @@ interface FormValue {
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
function ChangelistNamePicker({
|
||||
field,
|
||||
options,
|
||||
newName,
|
||||
onChoose,
|
||||
}: {
|
||||
field: InputProps;
|
||||
options: readonly SelectOption[];
|
||||
newName: boolean;
|
||||
onChoose: (name: string) => void;
|
||||
}) {
|
||||
const anchor = useRef<HTMLDivElement>(null);
|
||||
const input = useRef<HTMLInputElement>(null);
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
ref={anchor}
|
||||
className={formStyles.picker}
|
||||
data-invalid={field.invalid || undefined}
|
||||
data-open={open || undefined}
|
||||
>
|
||||
<Input
|
||||
{...field}
|
||||
ref={input}
|
||||
variant="bare"
|
||||
autoSelect
|
||||
onKeyDown={(event) => {
|
||||
if (event.key !== "ArrowDown" || event.nativeEvent.isComposing || !options.length) return;
|
||||
event.preventDefault();
|
||||
setOpen(true);
|
||||
}}
|
||||
/>
|
||||
{newName && (
|
||||
<span className={formStyles.newName}>
|
||||
<T>New</T>
|
||||
</span>
|
||||
)}
|
||||
<IconButton
|
||||
icon="chevron-down"
|
||||
title="Choose changelist"
|
||||
size="small"
|
||||
aria-haspopup="listbox"
|
||||
aria-expanded={open}
|
||||
disabled={!options.length}
|
||||
onClick={() => {
|
||||
input.current?.focus();
|
||||
setOpen(!open);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<Popup open={open} onClose={() => setOpen(false)} anchor={anchor} matchWidth role="presentation">
|
||||
<SelectListbox
|
||||
options={options}
|
||||
value={typeof field.value === "string" ? field.value : null}
|
||||
aria-label="Target changelist"
|
||||
onChoose={(name) => {
|
||||
onChoose(name);
|
||||
setOpen(false);
|
||||
}}
|
||||
/>
|
||||
</Popup>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ChangelistForm({
|
||||
value,
|
||||
onChange,
|
||||
error,
|
||||
activeDisabled,
|
||||
nameOptions,
|
||||
existingDetails,
|
||||
hint,
|
||||
}: {
|
||||
value: FormValue;
|
||||
onChange: (v: FormValue) => void;
|
||||
error: string | null;
|
||||
activeDisabled?: boolean;
|
||||
nameOptions?: readonly SelectOption[];
|
||||
existingDetails?: Pick<FormValue, "comment" | "active">;
|
||||
hint?: string;
|
||||
}) {
|
||||
const id = useId();
|
||||
const errorId = value.name && error ? `${id}-error` : undefined;
|
||||
const nameField = {
|
||||
id: `${id}-name`,
|
||||
"data-autofocus": "",
|
||||
value: value.name,
|
||||
invalid: !!errorId,
|
||||
"aria-describedby": errorId,
|
||||
onChange: (e: ChangeEvent<HTMLInputElement>) => onChange({ ...value, name: e.target.value }),
|
||||
};
|
||||
return (
|
||||
<div className={formStyles.form}>
|
||||
{hint && <div className={formStyles.hint}>{hint}</div>}
|
||||
<label className={formStyles.nameLabel} htmlFor={`${id}-name`}>
|
||||
<T>Name:</T>
|
||||
</label>
|
||||
<div className={formStyles.nameField}>
|
||||
<Input
|
||||
id={`${id}-name`}
|
||||
data-autofocus
|
||||
value={value.name}
|
||||
invalid={!!errorId}
|
||||
aria-describedby={errorId}
|
||||
onChange={(e) => onChange({ ...value, name: e.target.value })}
|
||||
/>
|
||||
{nameOptions ? (
|
||||
<ChangelistNamePicker
|
||||
field={nameField}
|
||||
options={nameOptions}
|
||||
newName={!existingDetails && !error}
|
||||
onChoose={(name) => onChange({ ...value, name })}
|
||||
/>
|
||||
) : (
|
||||
<Input {...nameField} />
|
||||
)}
|
||||
{errorId && (
|
||||
<div className={styles.error} id={errorId}>
|
||||
{error}
|
||||
@@ -72,13 +156,14 @@ function ChangelistForm({
|
||||
id={`${id}-comment`}
|
||||
className={styles.textarea}
|
||||
rows={4}
|
||||
value={value.comment}
|
||||
value={existingDetails?.comment ?? value.comment}
|
||||
readOnly={!!existingDetails}
|
||||
onChange={(e) => onChange({ ...value, comment: e.target.value })}
|
||||
/>
|
||||
<Checkbox
|
||||
className={formStyles.active}
|
||||
checked={value.active}
|
||||
disabled={activeDisabled}
|
||||
checked={existingDetails?.active ?? value.active}
|
||||
disabled={activeDisabled || !!existingDetails}
|
||||
onChange={(active) => onChange({ ...value, active })}
|
||||
label="Set active"
|
||||
/>
|
||||
@@ -299,13 +384,26 @@ function TargetListDialog({
|
||||
const state = useChangelists((s) => s.state);
|
||||
const [currentLists] = useState(() => new Set(exclude));
|
||||
const others = state.lists.filter((l) => !(currentLists.size === 1 && currentLists.has(l.id)));
|
||||
const [mode, setMode] = useState<"existing" | "new">(others.length ? "existing" : "new");
|
||||
const [target, setTarget] = useState((others.find((l) => l.id === state.active) ?? others[0])?.id ?? state.active);
|
||||
const [value, setValue] = useState<FormValue>({ name: suggestedName, comment: "", active: false });
|
||||
const error = mode === "new" ? validateListName(state, value.name) : null;
|
||||
const [value, setValue] = useState<FormValue>(() => ({
|
||||
name: (others.find((l) => l.id === state.active) ?? others[0])?.name ?? suggestedName,
|
||||
comment: "",
|
||||
active: false,
|
||||
}));
|
||||
const target = others.find((l) => l.name.toLowerCase() === value.name.trim().toLowerCase());
|
||||
const error = target ? null : validateListName(state, value.name);
|
||||
const nameOptions: SelectOption[] = others.map((l) => ({
|
||||
value: l.name,
|
||||
label: l.id === state.active ? tx`${l.name} (active)` : l.name,
|
||||
verbatim: true,
|
||||
}));
|
||||
if (!validateListName(state, suggestedName)) {
|
||||
nameOptions.unshift({ value: suggestedName, label: suggestedName, detail: "New", verbatim: true });
|
||||
}
|
||||
const choose = () => {
|
||||
if (error) return;
|
||||
if (mode === "new") {
|
||||
if (target) {
|
||||
onChoose(target.id);
|
||||
} else {
|
||||
let id = "";
|
||||
updateChangelists((s) => {
|
||||
const r = addList(s, value.name, { comment: value.comment, makeActive: value.active });
|
||||
@@ -313,8 +411,6 @@ function TargetListDialog({
|
||||
return r.state;
|
||||
});
|
||||
onChoose(id);
|
||||
} else {
|
||||
onChoose(target);
|
||||
}
|
||||
onClose();
|
||||
};
|
||||
@@ -329,35 +425,14 @@ function TargetListDialog({
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
]}
|
||||
>
|
||||
<div className={styles.form} role="radiogroup" aria-label={tx("Target changelist")}>
|
||||
{hint && <div className={styles.hint}>{hint}</div>}
|
||||
<label className={styles.radioRow}>
|
||||
<input
|
||||
type="radio"
|
||||
name="target"
|
||||
checked={mode === "existing"}
|
||||
disabled={!others.length}
|
||||
onChange={() => setMode("existing")}
|
||||
/>
|
||||
<span className={styles.radioText}>
|
||||
<T>Existing changelist:</T>
|
||||
</span>
|
||||
</label>
|
||||
<Select
|
||||
value={target}
|
||||
disabled={mode !== "existing"}
|
||||
aria-label="Existing changelist"
|
||||
onChange={setTarget}
|
||||
options={others.map((l) => ({ value: l.id, label: l.id === state.active ? tx`${l.name} (active)` : l.name }))}
|
||||
/>
|
||||
<label className={styles.radioRow}>
|
||||
<input type="radio" name="target" checked={mode === "new"} onChange={() => setMode("new")} />
|
||||
<span className={styles.radioText}>
|
||||
<T>New changelist:</T>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
{mode === "new" && <ChangelistForm value={value} onChange={setValue} error={error} />}
|
||||
<ChangelistForm
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
error={error}
|
||||
hint={hint}
|
||||
nameOptions={nameOptions}
|
||||
existingDetails={target ? { comment: target.comment ?? "", active: target.id === state.active } : undefined}
|
||||
/>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1539,6 +1539,7 @@
|
||||
"Show Incoming and Outgoing Commits": "Show Incoming and Outgoing Commits",
|
||||
"Open in Git Log": "Open in Git Log",
|
||||
"Could not show diff": "Could not show diff",
|
||||
"Choose changelist": "Choose changelist",
|
||||
"Comparison actions": "Comparison actions",
|
||||
"This branch has no upstream. Push it to compare with a remote branch.": "This branch has no upstream. Push it to compare with a remote branch.",
|
||||
"Highlight occurrences of selected text": "Highlight occurrences of selected text",
|
||||
|
||||
@@ -797,8 +797,6 @@
|
||||
"Execute Maven Goal…": "Ejecutar objetivo de Maven…",
|
||||
"Execute SQL Statement": "Ejecutar instrucción SQL",
|
||||
"Execute a statement in a query console with ⌘↩.": "Ejecuta una instrucción en una consola de consultas con ⌘↩.",
|
||||
"Existing changelist": "Lista de cambios existente",
|
||||
"Existing changelist:": "Lista de cambios existente:",
|
||||
"Existing environment": "Entorno existente",
|
||||
"Exit": "Salir",
|
||||
"Expand": "Expandir",
|
||||
@@ -1284,7 +1282,6 @@
|
||||
"New Tag…": "Nueva etiqueta…",
|
||||
"New Terminal Tab": "Nueva pestaña de terminal",
|
||||
"New branch name:": "Nombre de la nueva rama:",
|
||||
"New changelist:": "Nueva lista de cambios:",
|
||||
"New environment": "Nuevo entorno",
|
||||
"New file from template": "Nuevo archivo desde plantilla",
|
||||
"New from Template…": "Nuevo desde plantilla…",
|
||||
|
||||
@@ -734,8 +734,6 @@
|
||||
"Execute Maven Goal…": "Exécuter un goal Maven…",
|
||||
"Execute SQL Statement": "Exécuter l'instruction SQL",
|
||||
"Execute a statement in a query console with ⌘↩.": "Exécutez une instruction dans une console de requêtes avec ⌘↩.",
|
||||
"Existing changelist": "Liste de modifications existante",
|
||||
"Existing changelist:": "Liste de modifications existante :",
|
||||
"Existing environment": "Environnement existant",
|
||||
"Exit": "Quitter",
|
||||
"Expand": "Développer",
|
||||
@@ -1219,7 +1217,6 @@
|
||||
"New Tag…": "Nouveau tag…",
|
||||
"New Terminal Tab": "Nouvel onglet de terminal",
|
||||
"New branch name:": "Nom de la nouvelle branche :",
|
||||
"New changelist:": "Nouvelle liste de modifications :",
|
||||
"New environment": "Nouvel environnement",
|
||||
"New file from template": "Nouveau fichier depuis un modèle",
|
||||
"New from Template…": "Nouveau depuis un modèle…",
|
||||
|
||||
@@ -833,8 +833,6 @@
|
||||
"Execute Maven Goal…": "Maven 목표 실행…",
|
||||
"Execute SQL Statement": "SQL 문 실행",
|
||||
"Execute a statement in a query console with ⌘↩.": "쿼리 콘솔에서 ⌘↩로 문을 실행하세요.",
|
||||
"Existing changelist": "기존 변경 목록",
|
||||
"Existing changelist:": "기존 변경 목록:",
|
||||
"Existing environment": "기존 환경",
|
||||
"Exit": "종료",
|
||||
"Expand": "펼치기",
|
||||
@@ -1320,7 +1318,6 @@
|
||||
"New Tag…": "새 태그…",
|
||||
"New Terminal Tab": "새 터미널 탭",
|
||||
"New branch name:": "새 브랜치 이름:",
|
||||
"New changelist:": "새 변경 목록:",
|
||||
"New environment": "새 환경",
|
||||
"New file from template": "템플릿에서 새 파일",
|
||||
"New from Template…": "템플릿에서 새로 만들기…",
|
||||
|
||||
@@ -789,8 +789,6 @@
|
||||
"Execute Maven Goal…": "Wykonaj cel (goal) Maven…",
|
||||
"Execute SQL Statement": "Wykonaj instrukcję SQL",
|
||||
"Execute a statement in a query console with ⌘↩.": "Wykonaj instrukcję w konsoli zapytań za pomocą ⌘↩.",
|
||||
"Existing changelist": "Istniejąca lista zmian",
|
||||
"Existing changelist:": "Istniejąca lista zmian:",
|
||||
"Existing environment": "Istniejące środowisko",
|
||||
"Exit": "Wyjście",
|
||||
"Expand": "Rozwiń",
|
||||
@@ -1274,7 +1272,6 @@
|
||||
"New Tag…": "Nowy tag…",
|
||||
"New Terminal Tab": "Nowa karta terminala",
|
||||
"New branch name:": "Nazwa nowej gałęzi:",
|
||||
"New changelist:": "Nowa lista zmian:",
|
||||
"New environment": "Nowe środowisko",
|
||||
"New file from template": "Nowy plik z szablonu",
|
||||
"New from Template…": "Nowy z szablonu…",
|
||||
|
||||
@@ -789,8 +789,6 @@
|
||||
"Execute Maven Goal…": "Executar goal do Maven…",
|
||||
"Execute SQL Statement": "Executar instrução SQL",
|
||||
"Execute a statement in a query console with ⌘↩.": "Execute uma instrução em um console de consulta com ⌘↩.",
|
||||
"Existing changelist": "Lista de alterações existente",
|
||||
"Existing changelist:": "Lista de alterações existente:",
|
||||
"Existing environment": "Ambiente existente",
|
||||
"Exit": "Sair",
|
||||
"Expand": "Expandir",
|
||||
@@ -1274,7 +1272,6 @@
|
||||
"New Tag…": "Nova tag…",
|
||||
"New Terminal Tab": "Nova aba do terminal",
|
||||
"New branch name:": "Nome da nova branch:",
|
||||
"New changelist:": "Nova lista de alterações:",
|
||||
"New environment": "Novo ambiente",
|
||||
"New file from template": "Novo arquivo a partir de modelo",
|
||||
"New from Template…": "Novo a partir de modelo…",
|
||||
|
||||
@@ -3589,8 +3589,6 @@
|
||||
"Execute Maven Goal…": "Maven Hedefini Yürüt…",
|
||||
"Execute SQL Statement": "SQL İfadesini Yürüt",
|
||||
"Execute a statement in a query console with ⌘↩.": "Sorgu konsolunda ⌘↩ ile bir SQL ifadesi yürütün.",
|
||||
"Existing changelist": "Mevcut değişiklik listesi",
|
||||
"Existing changelist:": "Mevcut değişiklik listesi:",
|
||||
"Existing environment": "Mevcut ortam",
|
||||
"Exit": "Çıkış",
|
||||
"Expand": "Genişlet",
|
||||
@@ -4058,7 +4056,6 @@
|
||||
"New Tag…": "Yeni Etiket…",
|
||||
"New Terminal Tab": "Yeni Terminal Sekmesi",
|
||||
"New branch name:": "Yeni dal adı:",
|
||||
"New changelist:": "Yeni değişiklik listesi:",
|
||||
"New environment": "Yeni ortam",
|
||||
"New file from template": "Şablondan yeni dosya",
|
||||
"New from Template…": "Şablondan Yeni…",
|
||||
|
||||
@@ -1456,8 +1456,6 @@
|
||||
"Execute Maven Goal…": "执行 Maven 目标…",
|
||||
"Execute SQL Statement": "执行 SQL 语句",
|
||||
"Execute a statement in a query console with ⌘↩.": "在查询控制台中按 ⌘↩ 执行语句。",
|
||||
"Existing changelist": "现有更改列表",
|
||||
"Existing changelist:": "现有更改列表:",
|
||||
"Existing environment": "现有环境",
|
||||
"Exit": "退出",
|
||||
"Expand": "展开",
|
||||
@@ -1954,7 +1952,6 @@
|
||||
"New Tag…": "新建标签…",
|
||||
"New Terminal Tab": "新建终端标签页",
|
||||
"New branch name:": "新分支名称:",
|
||||
"New changelist:": "新更改列表:",
|
||||
"New environment": "新环境",
|
||||
"New file from template": "从模板新建文件",
|
||||
"New from Template…": "从模板新建…",
|
||||
@@ -3056,6 +3053,7 @@
|
||||
"Tag value": "标签值",
|
||||
"Tags to push": "要推送的标签",
|
||||
"Target changelist": "目标更改列表",
|
||||
"Choose changelist": "选择更改列表",
|
||||
"Target directory": "目标目录",
|
||||
"Teal": "蓝绿色",
|
||||
"Template body": "模板正文",
|
||||
|
||||
Reference in New Issue
Block a user