mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
fix(vcs): align the New Worktree dialog (#5367)
- Align the repository, checkout, branch, name, location and setup fields in one label-and-control grid. Use the standard dialog type size for labels and keep the worktree path preview beneath the Location field. - Let the `.worktreeinclude` edit action wrap below its checkbox in narrow windows. With setup expanded, the standard dialog is about 118 logical pixels shorter, and the setup field fits without scrolling in a 440 × 520 window.
This commit is contained in:
@@ -100,6 +100,7 @@ function WorktreeForm({
|
||||
onRepoChange: (repo: string) => void;
|
||||
}) {
|
||||
const [projectRoot] = useState(() => useProject.getState().project?.root);
|
||||
const [hasRepositories] = useState(() => useVcs.getState().roots.length > 1);
|
||||
const [data, setData] = useState<RepositoryData>();
|
||||
const [sourceRef, setSourceRef] = useState(initialSource);
|
||||
const [createBranch, setCreateBranch] = useState<boolean>();
|
||||
@@ -367,128 +368,142 @@ function WorktreeForm({
|
||||
]}
|
||||
>
|
||||
<div className={styles.form}>
|
||||
{!initialSource && (
|
||||
<RepoPicker
|
||||
repo={repo}
|
||||
onChange={(next) => {
|
||||
if (!submitting.current) onRepoChange(next);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{main?.submodule && (
|
||||
<div className={styles.worktreeTarget}>
|
||||
{tx("This worktree has its own checkout, separate from the submodule in the parent repository.")}
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.fieldLabel}>
|
||||
<T>Check out:</T>
|
||||
</div>
|
||||
<Select
|
||||
aria-label="Check out"
|
||||
searchable
|
||||
disabled={formBusy || !data}
|
||||
value={source?.ref ?? null}
|
||||
placeholder="Select branch or tag"
|
||||
options={(data?.sources ?? []).map((ref) => ({
|
||||
value: ref.ref,
|
||||
label: ref.name,
|
||||
icon: ref.kind === "tag" ? "tag" : "branch",
|
||||
verbatim: true,
|
||||
}))}
|
||||
onChange={(ref) => {
|
||||
setSourceRef(ref);
|
||||
setCreateBranch(undefined);
|
||||
setBranch(undefined);
|
||||
setError(undefined);
|
||||
}}
|
||||
/>
|
||||
<Checkbox label="Create a new branch" disabled={formBusy} checked={createLocal} onChange={setCreateBranch} />
|
||||
{createLocal && (
|
||||
<Input
|
||||
ref={branchInput}
|
||||
aria-label="New branch name"
|
||||
mono
|
||||
disabled={formBusy}
|
||||
value={branch ?? branchName}
|
||||
onChange={(e) => setBranch(cleanBranch(e))}
|
||||
/>
|
||||
)}
|
||||
<label className={styles.fieldLabel} htmlFor="worktree-name">
|
||||
<T>Name:</T>
|
||||
</label>
|
||||
<Input
|
||||
id="worktree-name"
|
||||
mono
|
||||
disabled={formBusy}
|
||||
value={name ?? folderName}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
<label className={styles.fieldLabel} htmlFor="worktree-location">
|
||||
<T>Location:</T>
|
||||
</label>
|
||||
<div className={styles.worktreeLocation}>
|
||||
<Input
|
||||
id="worktree-location"
|
||||
mono
|
||||
disabled={formBusy}
|
||||
value={location ?? parent}
|
||||
onChange={(e) => setLocation(e.target.value)}
|
||||
/>
|
||||
<IconButton icon="folder-open" title="Browse" disabled={formBusy} onClick={() => void browse()} />
|
||||
</div>
|
||||
{parent && folderName && <div className={styles.worktreeTarget}>{tx`Worktree location: ${target}`}</div>}
|
||||
<div className={styles.worktreeLocation}>
|
||||
<Checkbox
|
||||
label="Copy local files listed in .worktreeinclude"
|
||||
disabled={formBusy || !include?.exists}
|
||||
checked={copyLocal}
|
||||
onChange={setCopyConfig}
|
||||
/>
|
||||
{include && (
|
||||
<Button disabled={formBusy} onClick={() => void editInclude()}>
|
||||
<T>{include.exists ? "Edit .worktreeinclude…" : "Create .worktreeinclude…"}</T>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{includeError && (
|
||||
<div className={styles.error} role="alert">
|
||||
{includeError}
|
||||
</div>
|
||||
)}
|
||||
<Checkbox
|
||||
label="Run setup script"
|
||||
disabled={formBusy}
|
||||
checked={runSetup}
|
||||
onChange={(enabled) => {
|
||||
setRunSetup(enabled);
|
||||
setError(undefined);
|
||||
}}
|
||||
/>
|
||||
{runSetup && (
|
||||
<>
|
||||
<label className={styles.fieldLabel} htmlFor="worktree-setup-script">
|
||||
<T>Setup script:</T>
|
||||
</label>
|
||||
<div className={styles.worktreeLocation}>
|
||||
<Input
|
||||
id="worktree-setup-script"
|
||||
mono
|
||||
disabled={formBusy}
|
||||
value={setupPath}
|
||||
onChange={(e) => {
|
||||
setSetupPath(e.target.value);
|
||||
setError(undefined);
|
||||
<div className={styles.worktreeFields}>
|
||||
{!initialSource && hasRepositories && (
|
||||
<>
|
||||
<label className={styles.worktreeLabel} htmlFor="worktree-repository">
|
||||
<T>Repository:</T>
|
||||
</label>
|
||||
<RepoPicker
|
||||
id="worktree-repository"
|
||||
repo={repo}
|
||||
onChange={(next) => {
|
||||
if (!submitting.current) onRepoChange(next);
|
||||
}}
|
||||
/>
|
||||
<IconButton
|
||||
icon="folder-open"
|
||||
title="Choose Setup Script"
|
||||
disabled={formBusy}
|
||||
onClick={() => void browseSetupScript()}
|
||||
</>
|
||||
)}
|
||||
<label className={styles.worktreeLabel} htmlFor="worktree-source">
|
||||
<T>Check out:</T>
|
||||
</label>
|
||||
<Select
|
||||
id="worktree-source"
|
||||
aria-label="Check out"
|
||||
searchable
|
||||
disabled={formBusy || !data}
|
||||
value={source?.ref ?? null}
|
||||
placeholder="Select branch or tag"
|
||||
options={(data?.sources ?? []).map((ref) => ({
|
||||
value: ref.ref,
|
||||
label: ref.name,
|
||||
icon: ref.kind === "tag" ? "tag" : "branch",
|
||||
verbatim: true,
|
||||
}))}
|
||||
onChange={(ref) => {
|
||||
setSourceRef(ref);
|
||||
setCreateBranch(undefined);
|
||||
setBranch(undefined);
|
||||
setError(undefined);
|
||||
}}
|
||||
/>
|
||||
<Checkbox
|
||||
className={styles.worktreeLabel}
|
||||
label="Create a new branch"
|
||||
disabled={formBusy}
|
||||
checked={createLocal}
|
||||
onChange={setCreateBranch}
|
||||
/>
|
||||
{createLocal && (
|
||||
<Input
|
||||
ref={branchInput}
|
||||
aria-label="New branch name"
|
||||
mono
|
||||
disabled={formBusy}
|
||||
value={branch ?? branchName}
|
||||
onChange={(e) => setBranch(cleanBranch(e))}
|
||||
/>
|
||||
)}
|
||||
<label className={styles.worktreeLabel} htmlFor="worktree-name">
|
||||
<T>Name:</T>
|
||||
</label>
|
||||
<Input
|
||||
id="worktree-name"
|
||||
disabled={formBusy}
|
||||
value={name ?? folderName}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
<label className={styles.worktreeLabel} htmlFor="worktree-location">
|
||||
<T>Location:</T>
|
||||
</label>
|
||||
<div className={styles.worktreeLocation}>
|
||||
<Input
|
||||
id="worktree-location"
|
||||
disabled={formBusy}
|
||||
value={location ?? parent}
|
||||
onChange={(e) => setLocation(e.target.value)}
|
||||
/>
|
||||
<IconButton icon="folder-open" title="Browse" disabled={formBusy} onClick={() => void browse()} />
|
||||
</div>
|
||||
{parent && folderName && <div className={styles.worktreeTarget}>{tx`Worktree location: ${target}`}</div>}
|
||||
<div className={styles.worktreeOptions}>
|
||||
<div className={styles.worktreeCopyOptions}>
|
||||
<Checkbox
|
||||
label="Copy local files listed in .worktreeinclude"
|
||||
disabled={formBusy || !include?.exists}
|
||||
checked={copyLocal}
|
||||
onChange={setCopyConfig}
|
||||
/>
|
||||
{include && (
|
||||
<Button disabled={formBusy} onClick={() => void editInclude()}>
|
||||
<T>{include.exists ? "Edit .worktreeinclude…" : "Create .worktreeinclude…"}</T>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{includeError && (
|
||||
<div className={styles.error} role="alert">
|
||||
{includeError}
|
||||
</div>
|
||||
)}
|
||||
<Checkbox
|
||||
label="Run setup script"
|
||||
disabled={formBusy}
|
||||
checked={runSetup}
|
||||
onChange={(enabled) => {
|
||||
setRunSetup(enabled);
|
||||
setError(undefined);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{runSetup && (
|
||||
<>
|
||||
<label className={styles.worktreeLabel} htmlFor="worktree-setup-script">
|
||||
<T>Setup script:</T>
|
||||
</label>
|
||||
<div className={styles.worktreeLocation}>
|
||||
<Input
|
||||
id="worktree-setup-script"
|
||||
disabled={formBusy}
|
||||
value={setupPath}
|
||||
onChange={(e) => {
|
||||
setSetupPath(e.target.value);
|
||||
setError(undefined);
|
||||
}}
|
||||
/>
|
||||
<IconButton
|
||||
icon="folder-open"
|
||||
title="Choose Setup Script"
|
||||
disabled={formBusy}
|
||||
onClick={() => void browseSetupScript()}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{busy && (
|
||||
<div className={styles.worktreeTarget} role="status">
|
||||
{setupRequest && !skippingSetup ? tx("Creating worktree and running setup…") : tx("Creating worktree…")}
|
||||
|
||||
@@ -791,6 +791,36 @@
|
||||
align-items: center;
|
||||
gap: var(--space-0-5);
|
||||
}
|
||||
.worktreeFields {
|
||||
display: grid;
|
||||
grid-template-columns: fit-content(44%) minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: var(--space-2) var(--space-3);
|
||||
}
|
||||
.worktreeFields > :not(.worktreeLabel) {
|
||||
grid-column: 2;
|
||||
min-width: 0;
|
||||
}
|
||||
.worktreeLabel {
|
||||
grid-column: 1;
|
||||
min-width: 0;
|
||||
font-size: var(--fs-ui);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.worktreeFields > .worktreeOptions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
grid-column: 1 / -1;
|
||||
gap: var(--space-2);
|
||||
border-top: 1px solid var(--border);
|
||||
padding-top: var(--space-2);
|
||||
}
|
||||
.worktreeCopyOptions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-1) var(--space-2);
|
||||
}
|
||||
.worktreeLocation {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
@@ -801,6 +831,9 @@
|
||||
color: var(--fg-muted);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.worktreeFields > .worktreeTarget {
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.comparisonDialog > [data-dialog-body] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in New Issue
Block a user