Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai edb92495b0 Merge remote-tracking branch 'origin/main' into fix/vcs-push-layout
# Conflicts:
#	src/features/vcs/remoteUi.tsx
2026-11-20 04:49:54 +08:00
l0ng-ai 8629a3c6c7 fix(vcs): keep push review readable in narrow windows 2026-11-20 03:01:51 +08:00
5 змінених файлів з 444 додано та 234 видалено

No files matched your search

+120 -42
Переглянути файл
@@ -9,50 +9,75 @@ import { expect, stubDesktop, test } from "./fixtures";
const ROOT = "/dev/acme-api"; const ROOT = "/dev/acme-api";
const HUGE = `feature/wrap-${"x".repeat(140)}`; const HUGE = `feature/wrap-${"x".repeat(140)}`;
async function openPushDialog(page: Page) { const OUTGOING = "Apply order-level discounts before calculating checkout taxes";
async function openPushDialog(page: Page, { outgoing = false, multi = false } = {}) {
await stubDesktop(page); await stubDesktop(page);
await page.evaluate(async (root) => { await page.evaluate(
const h = window.__ipc.handlers; async ({ root, outgoing, multi, subject }) => {
h.vcs_roots = () => [{ root, operation: null, head: "main", headCommit: "1111111" }]; const h = window.__ipc.handlers;
h.vcs_branch_info = () => ({ const head = multi ? "feature/refine-checkout-pricing-and-order-summary-for-regional-release" : "main";
head: "main", const roots = multi ? [root, `${root}/billing-and-refunds`] : [root];
headCommit: "1111111", h.vcs_roots = () => roots.map((root) => ({ root, operation: null, head, headCommit: "1111111" }));
upstream: "origin/main", h.vcs_branch_info = () => ({
ahead: 0, head,
behind: 0, headCommit: "1111111",
operation: null, upstream: `origin/${head}`,
}); ahead: outgoing ? 1 : 0,
h.vcs_status = () => []; behind: 0,
h.vcs_log = () => []; operation: null,
h.vcs_remotes = () => [{ name: "origin", url: "[email protected]:acme/api.git" }]; });
const branch = (name: string, remote: boolean, upstream: string | null = null) => ({ h.vcs_status = () => [];
name, h.vcs_log = () =>
remote, outgoing
current: !remote, ? [
upstream, {
ahead: 0, id: "2222222",
behind: 0, shortId: "2222222",
lastCommitMs: 0, parents: ["1111111"],
}); summary: subject,
h.vcs_branches = () => [ message: subject + "\n\nKeep the new totals consistent with receipts.",
branch("main", false, "origin/main"), author: "Sam Rivera",
branch("feature/login", false), email: "[email protected]",
branch("origin/main", true), timeMs: 1795100000000,
branch("origin/feature/login", true), },
branch("origin/fix/error-auth", true), ]
branch("origin/feature/PLATFORM-12345-order-history-export", true), : [];
branch(`origin/feature/wrap-${"x".repeat(140)}`, true), h.vcs_commit_files = () => [{ path: "checkout.ts", oldPath: null, kind: "modified" }];
]; h.vcs_has_hook = () => false;
const vcsModule = "/src/features/vcs/store.ts"; h.vcs_remotes = () => [{ name: "origin", url: "[email protected]:acme/api.git" }];
const { useVcs, refreshNow } = await import(/* @vite-ignore */ vcsModule); const branch = (name: string, remote: boolean, upstream: string | null = null) => ({
useVcs.setState({ available: true, root, repo: root, branchesLoaded: false, stashesLoaded: false }); name,
await refreshNow(); remote,
const actionsModule = "/src/platform/actions.ts"; current: !remote,
const { executeAction } = await import(/* @vite-ignore */ actionsModule); upstream,
void executeAction("vcs.push"); ahead: 0,
}, ROOT); behind: 0,
lastCommitMs: 0,
});
h.vcs_branches = () => [
branch("main", false, "origin/main"),
branch("feature/login", false),
branch("origin/main", true),
branch("origin/feature/login", true),
branch("origin/fix/error-auth", true),
branch("origin/feature/PLATFORM-12345-order-history-export", true),
branch(`origin/feature/wrap-${"x".repeat(140)}`, true),
];
const vcsModule = "/src/features/vcs/store.ts";
const { useVcs, refreshNow } = await import(/* @vite-ignore */ vcsModule);
useVcs.setState({ available: true, root, repo: root, branchesLoaded: false, stashesLoaded: false });
await refreshNow();
const actionsModule = "/src/platform/actions.ts";
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
void executeAction("vcs.push");
},
{ root: ROOT, outgoing, multi, subject: OUTGOING },
);
const dialog = page.getByRole("dialog", { name: /Push/ }); const dialog = page.getByRole("dialog", { name: /Push/ });
const input = dialog.getByRole("combobox", { name: "Target branch" }); const input = multi
? dialog.getByRole("textbox", { name: "Target branch of acme-api" })
: dialog.getByRole("combobox", { name: "Target branch" });
await expect(input).toBeVisible(); await expect(input).toBeVisible();
return { dialog, input }; return { dialog, input };
} }
@@ -127,3 +152,56 @@ test("Escape closes the list but keeps the dialog", async ({ workbench: page })
await expect(page.getByRole("listbox", { name: "Remote branches" })).toHaveCount(0); await expect(page.getByRole("listbox", { name: "Remote branches" })).toHaveCount(0);
await expect(dialog).toBeVisible(); await expect(dialog).toBeVisible();
}); });
test("Push keeps commit subjects and changed files readable in a narrow window", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1140, height: 760 });
const { dialog, input } = await openPushDialog(page, { outgoing: true });
const outgoing = dialog.getByRole("listbox", { name: "Outgoing commits" });
const files = dialog.getByRole("tree", { name: "Changed files" });
const commit = outgoing.getByRole("option", { name: new RegExp(OUTGOING) });
await commit.click();
await expect(files.getByText("checkout.ts")).toBeVisible();
const filesBelowCommits = async () => {
const [list, tree] = await Promise.all([outgoing.boundingBox(), files.boundingBox()]);
return !!list && !!tree && tree.y >= list.y + list.height;
};
await expect.poll(filesBelowCommits).toBe(false);
await page.setViewportSize({ width: 540, height: 630 });
await expect.poll(filesBelowCommits).toBe(true);
await expect(commit).toHaveAttribute("aria-selected", "true");
const subject = commit.getByText(OUTGOING, { exact: true });
await expect(subject).toHaveAttribute("title", /Sam Rivera/);
await expect.poll(() => subject.evaluate((el) => el.scrollWidth <= el.clientWidth)).toBe(true);
await expect(input).toHaveValue("main");
await expect(dialog.getByRole("button", { name: "Push", exact: true })).toBeInViewport();
const details = dialog.getByRole("region", { name: "Commit details" });
await expect(details).toContainText("Keep the new totals consistent with receipts.");
await expect
.poll(async () => {
const [tree, message] = await Promise.all([files.boundingBox(), details.boundingBox()]);
return !!tree && !!message && message.y >= tree.y + tree.height;
})
.toBe(true);
});
test("Push keeps per-repository targets editable with long source branches", async ({ workbench: page }) => {
await page.setViewportSize({ width: 475, height: 620 });
const { dialog, input } = await openPushDialog(page, { outgoing: true, multi: true });
const other = dialog.getByRole("textbox", { name: "Target branch of billing-and-refunds" });
for (const field of [input, other]) {
await expect
.poll(() =>
field.evaluate((target) => {
const row = target.closest('[role="treeitem"]')!.getBoundingClientRect();
const bounds = target.getBoundingClientRect();
return bounds.width >= 42 && bounds.left >= row.left && bounds.right <= row.right;
}),
)
.toBe(true);
}
await input.fill("release/checkout");
await expect(input).toHaveValue("release/checkout");
await expect(other).toHaveValue(/^feature\//);
await expect(dialog.getByRole("checkbox", { name: "acme-api" })).toBeChecked();
});
+4 -4
Переглянути файл
@@ -134,12 +134,12 @@ export function PushChanges({
</div> </div>
{count === 1 ? ( {count === 1 ? (
<SplitGroup orientation="vertical" storageKey={DETAILS_SPLIT_KEY} className={styles.pushDetailsSplit}> <SplitGroup orientation="vertical" storageKey={DETAILS_SPLIT_KEY} className={styles.pushDetailsSplit}>
<SplitPanel id="details" minSize="40px" defaultSize="25%" className={styles.pushDetailsPanel}> <SplitPanel id="files" minSize="40%" defaultSize="67%" className={styles.pushDetailsPanel}>
<PushCommitDetails commit={commits[0]!} /> {files}
</SplitPanel> </SplitPanel>
<SplitHandle /> <SplitHandle />
<SplitPanel id="files" minSize="80px" className={styles.pushDetailsPanel}> <SplitPanel id="details" minSize="24%" className={styles.pushDetailsPanel}>
{files} <PushCommitDetails commit={commits[0]!} />
</SplitPanel> </SplitPanel>
</SplitGroup> </SplitGroup>
) : ( ) : (
+49 -7
Переглянути файл
@@ -1,4 +1,5 @@
import { useState, type ReactNode } from "react"; import { useLayoutEffect, useRef, useState, type ReactNode } from "react";
import type { GroupImperativeHandle } from "react-resizable-panels";
import { tx } from "@/platform/i18n"; import { tx } from "@/platform/i18n";
import { IconButton, SplitGroup, SplitHandle, SplitPanel, lazyComponent } from "@/ui"; import { IconButton, SplitGroup, SplitHandle, SplitPanel, lazyComponent } from "@/ui";
import { diffInput } from "./diffInput"; import { diffInput } from "./diffInput";
@@ -8,6 +9,10 @@ import styles from "./common.module.css";
const DiffEditor = lazyComponent(() => import("./DiffEditor").then((m) => m.DiffEditor)); const DiffEditor = lazyComponent(() => import("./DiffEditor").then((m) => m.DiffEditor));
const PUSH_DIFF_SPLIT_KEY = "openidea.vcs.push.diffSplit"; const PUSH_DIFF_SPLIT_KEY = "openidea.vcs.push.diffSplit";
const PUSH_SIDES_SPLIT_KEY = "openidea.vcs.pushSides";
const PUSH_STACKED_SPLIT_KEY = "openidea.vcs.push.stackedSplit";
const SIDE_LAYOUT = { commits: 50, changes: 50 };
const STACKED_LAYOUT = { commits: 34, changes: 66 };
export function usePushDiff(shownKey: string) { export function usePushDiff(shownKey: string) {
const [state, setState] = useState<{ key: string; change: LogChange } | null>(null); const [state, setState] = useState<{ key: string; change: LogChange } | null>(null);
@@ -18,22 +23,59 @@ export function usePushDiff(shownKey: string) {
}; };
} }
interface PushDiffSplitProps { interface PushReviewProps {
diff: LogChange | null; diff: LogChange | null;
onClose: () => void; onClose: () => void;
children: ReactNode; commits: ReactNode;
changes: ReactNode;
} }
export function PushDiffSplit({ diff, onClose, children }: PushDiffSplitProps) { export function PushReview({ diff, onClose, commits, changes }: PushReviewProps) {
const summary = useRef<HTMLDivElement>(null);
const group = useRef<GroupImperativeHandle>(null);
const [stacked, setStacked] = useState(false);
const previous = useRef(stacked);
const layout = stacked ? STACKED_LAYOUT : SIDE_LAYOUT;
useLayoutEffect(() => {
const el = summary.current;
if (!el) return;
const measure = () => setStacked(el.clientWidth < 640);
measure();
if (typeof ResizeObserver === "undefined") return;
const observer = new ResizeObserver(measure);
observer.observe(el);
return () => observer.disconnect();
}, []);
useLayoutEffect(() => {
if (previous.current === stacked) return;
previous.current = stacked;
group.current?.setLayout(layout);
}, [stacked, layout]);
return ( return (
<SplitGroup orientation="vertical" storageKey={diff ? PUSH_DIFF_SPLIT_KEY : undefined} className={styles.pushSplit}> <SplitGroup orientation="vertical" storageKey={diff ? PUSH_DIFF_SPLIT_KEY : undefined} className={styles.pushSplit}>
<SplitPanel id="sides" minSize="120px" defaultSize="50%" className={styles.pushSplitPanel}> <SplitPanel id="sides" minSize="32%" defaultSize="58%" className={styles.pushSplitPanel}>
{children} <SplitGroup
elementRef={summary}
groupRef={group}
orientation={stacked ? "vertical" : "horizontal"}
storageKey={stacked ? PUSH_STACKED_SPLIT_KEY : PUSH_SIDES_SPLIT_KEY}
defaultLayout={layout}
className={styles.pushSides}
>
<SplitPanel id="commits" minSize={stacked ? "24%" : "240px"} className={styles.pushSplitPanel}>
{commits}
</SplitPanel>
<SplitHandle />
<SplitPanel id="changes" minSize={stacked ? "32%" : "240px"} className={styles.pushSplitPanel}>
{changes}
</SplitPanel>
</SplitGroup>
</SplitPanel> </SplitPanel>
{diff && ( {diff && (
<> <>
<SplitHandle /> <SplitHandle />
<SplitPanel id="diff" minSize="120px" defaultSize="50%" className={styles.pushSplitPanel}> <SplitPanel id="diff" minSize="25%" className={styles.pushSplitPanel}>
<PushDiff change={diff} onClose={onClose} /> <PushDiff change={diff} onClose={onClose} />
</SplitPanel> </SplitPanel>
</> </>
+84 -14
Переглянути файл
@@ -150,22 +150,58 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.pushOptions,
.pushTagOptions {
display: flex;
align-items: center;
gap: var(--space-2);
}
.pushOptions {
flex-wrap: wrap;
max-width: 100%;
font-size: var(--fs-ui);
}
.pushTargetBar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-1) var(--space-2);
padding: var(--space-2) var(--space-3) 0;
}
.pushTargetSource {
max-width: 100%;
overflow-wrap: anywhere;
color: var(--fg-secondary);
}
.pushTargetControls {
display: flex;
align-items: center;
flex: 1 1 240px;
min-width: 0;
gap: var(--space-1);
}
.pushTargetControls .targetInput {
flex: 0 1 330px;
min-width: 8ch;
width: auto;
margin: 0;
}
.pushTreeWrap { .pushTreeWrap {
flex: 1; flex: 1;
min-height: 220px; min-height: 220px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 14px; padding: var(--space-2) var(--space-3) var(--space-3);
} }
.pushListWrap { .pushListWrap {
flex: 1; flex: 1;
min-height: 180px; min-height: 180px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 0 14px 14px; padding: var(--space-2) var(--space-3) var(--space-3);
} }
.pushSplit { .pushSplit {
flex: 1 1 min(540px, 60vh); flex: 1 1 min(450px, 65vh);
min-height: 0; min-height: 0;
} }
/* The panel's own `height: 100%` doesn't resolve against a flex-basis height in WebKit: stretch instead. */ /* The panel's own `height: 100%` doesn't resolve against a flex-basis height in WebKit: stretch instead. */
@@ -209,8 +245,8 @@
.pushSplitPanel > .pushTreeWrap { .pushSplitPanel > .pushTreeWrap {
min-height: 0; min-height: 0;
} }
.pushTreeWrap .commitRow[data-idle], .pushRepoRow[data-idle],
.pushTreeWrap .commitRow[data-idle] label { .pushRepoRow[data-idle] label {
color: var(--fg-subtle); color: var(--fg-subtle);
} }
.pushChanges { .pushChanges {
@@ -218,21 +254,23 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 0; min-height: 0;
padding-top: 8px; padding-top: var(--space-2);
} }
.pushChanges .comparison { .pushChanges .comparison {
flex: 1; flex: 1;
height: auto; height: auto;
min-height: 0; min-height: 0;
padding: 0 14px 14px; padding: 0 var(--space-3) var(--space-2);
} }
.pushChangesTitle { .pushChangesTitle {
display: flex; display: flex;
align-items: center; align-items: center;
flex-wrap: wrap;
gap: var(--space-2); gap: var(--space-2);
min-height: 24px; min-height: var(--h-control);
padding: 0 14px 6px; padding: 0 var(--space-3) var(--space-1);
color: var(--fg-subtle); color: var(--fg-subtle);
font-size: var(--fs-small);
} }
.pushGrouping { .pushGrouping {
margin-left: auto; margin-left: auto;
@@ -250,8 +288,8 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: var(--space-1); gap: var(--space-1);
margin: 0 14px 8px; margin: var(--space-1) var(--space-3);
padding: 6px 8px; padding: var(--space-1) var(--space-2);
overflow: auto; overflow: auto;
border: 1px solid var(--border); border: 1px solid var(--border);
border-radius: var(--radius-small); border-radius: var(--radius-small);
@@ -416,23 +454,55 @@
white-space: nowrap; white-space: nowrap;
} }
/* Fits the remote and target fields into a 22px tree row. */ /* Fits the remote and target fields into a 22px tree row. */
.pushRepoRow {
display: flex;
align-items: center;
gap: var(--space-1);
flex: 1;
min-width: 0;
}
.pushRepoName {
min-width: 20px;
}
.pushRepoLabel,
.pushSourceBranch,
.pushRemoteName {
display: block;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.pushSourceBranch,
.pushRemoteName {
color: var(--fg-subtle);
font-size: var(--fs-small);
}
.pushRemoteName {
flex: none;
max-width: 14ch;
}
.pushRowTarget { .pushRowTarget {
--h-field: var(--h-control-small); --h-field: var(--h-control-small);
--h-control: var(--h-control-small); --h-control: var(--h-control-small);
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: var(--space-0-5); gap: var(--space-0-5);
min-width: 0; min-width: 10ch;
font-size: var(--fs-small); font-size: var(--fs-small);
} }
.pushRowTarget button { .pushTargetControls > button,
.pushRowTarget > button {
min-width: 0;
max-width: 18ch;
font-size: var(--fs-small); font-size: var(--fs-small);
} }
.pushRowSeparator { .pushRowSeparator {
flex: none;
color: var(--fg-faint); color: var(--fg-faint);
} }
.pushRowInput { .pushRowInput {
min-width: 0; min-width: 7ch;
font-size: var(--fs-small); font-size: var(--fs-small);
} }
.pushRowInput[data-changed]:not(:focus-visible) { .pushRowInput[data-changed]:not(:focus-visible) {
+187 -167
Переглянути файл
@@ -5,27 +5,14 @@ import { call, commands } from "@/platform/ipc";
import { tx } from "@/platform/i18n"; import { tx } from "@/platform/i18n";
import { workflowSettings, type UpdateMethod } from "@/platform/workflowSettings"; import { workflowSettings, type UpdateMethod } from "@/platform/workflowSettings";
import { notifications } from "@/workbench/contributions"; import { notifications } from "@/workbench/contributions";
import { import { Button, Checkbox, Dialog, Input, List, Select, Spinner, T, Tree } from "@/ui";
Button,
Checkbox,
Dialog,
Input,
List,
Select,
Spinner,
SplitGroup,
SplitHandle,
SplitPanel,
T,
Tree,
} from "@/ui";
import { ask } from "@/workbench/messages"; import { ask } from "@/workbench/messages";
import { openDialog } from "./dialogs"; import { openDialog } from "./dialogs";
import { saveVcsSetting } from "./settingsUi"; import { saveVcsSetting } from "./settingsUi";
import { formatTime } from "./model"; import { formatTime } from "./model";
import { allRepos, lastRemoteFailure, runRemote, saveAll } from "./ops"; import { allRepos, lastRemoteFailure, runRemote, saveAll } from "./ops";
import { PushChanges, pushChangesKey } from "./PushChanges"; import { PushChanges, pushChangesKey } from "./PushChanges";
import { PushDiffSplit, usePushDiff } from "./PushDiff"; import { PushReview, usePushDiff } from "./PushDiff";
import { pushOperation, splitTracked, type PushChoice } from "./pushTarget"; import { pushOperation, splitTracked, type PushChoice } from "./pushTarget";
import { currentRepo, currentRepoRoot, loadBranches, refreshNow, repoName, useVcs } from "./store"; import { currentRepo, currentRepoRoot, loadBranches, refreshNow, repoName, useVcs } from "./store";
import { stripRemotePrefix, TargetBranchInput } from "./TargetBranchInput"; import { stripRemotePrefix, TargetBranchInput } from "./TargetBranchInput";
@@ -246,10 +233,18 @@ interface PushNode {
children?: PushNode[]; children?: PushNode[];
} }
// A long outgoing list scrolls inside the dialog instead of growing it to the screen (IDEA: 800×450 centre panel).
const PUSH_DIALOG_MAX_HEIGHT = 720; const PUSH_DIALOG_MAX_HEIGHT = 720;
const PUSH_DIALOG_WIDTH = 960; const PUSH_DIALOG_WIDTH = 800;
const PUSH_SPLIT_KEY = "openidea.vcs.pushSides"; const PUSH_DIALOG_MIN_WIDTH = 420;
function PushCommitSubject({ commit }: { commit: Commit }) {
const metadata = [commit.shortId, commit.author, formatTime(commit.timeMs)].filter(Boolean).join(" · ");
return (
<span className={styles.commitSubject} title={`${metadata}\n${commit.message.trimEnd() || commit.summary}`}>
{commit.summary}
</span>
);
}
interface MultiPushDialogProps { interface MultiPushDialogProps {
only?: string; only?: string;
@@ -412,15 +407,17 @@ function MultiPushDialog({ only, onClose }: MultiPushDialogProps) {
title={only === undefined ? "Push Commits" : tx`Push Commits to ${repoName(only)}`} title={only === undefined ? "Push Commits" : tx`Push Commits to ${repoName(only)}`}
onClose={onClose} onClose={onClose}
width={PUSH_DIALOG_WIDTH} width={PUSH_DIALOG_WIDTH}
minWidth={PUSH_DIALOG_MIN_WIDTH}
minHeight={340}
maxHeight={PUSH_DIALOG_MAX_HEIGHT} maxHeight={PUSH_DIALOG_MAX_HEIGHT}
className={styles.pushDialog} className={styles.pushDialog}
resizable="both" resizable="both"
footerStart={ footerStart={
<> <div className={styles.pushOptions}>
<Checkbox checked={force} onChange={setForce} label="Force (with lease)" /> <Checkbox checked={force} onChange={setForce} label="Force (with lease)" />
{hasHook && <Checkbox checked={runHooks} onChange={setRunHooks} label="Run Git hooks" />} {hasHook && <Checkbox checked={runHooks} onChange={setRunHooks} label="Run Git hooks" />}
{!retargeted && ( {!retargeted && (
<> <span className={styles.pushTagOptions}>
<Checkbox checked={pushTags} onChange={setPushTags} label="Push tags:" /> <Checkbox checked={pushTags} onChange={setPushTags} label="Push tags:" />
<Select<PushTags> <Select<PushTags>
value={tagsMode} value={tagsMode}
@@ -432,9 +429,9 @@ function MultiPushDialog({ only, onClose }: MultiPushDialogProps) {
{ value: "currentBranch", label: "Current Branch" }, { value: "currentBranch", label: "Current Branch" },
]} ]}
/> />
</> </span>
)} )}
</> </div>
} }
buttons={[ buttons={[
{ {
@@ -447,107 +444,114 @@ function MultiPushDialog({ only, onClose }: MultiPushDialogProps) {
{ label: "Cancel", role: "cancel" }, { label: "Cancel", role: "cancel" },
]} ]}
> >
<PushDiffSplit diff={diff} onClose={closeDiff}> <PushReview
<SplitGroup orientation="horizontal" storageKey={PUSH_SPLIT_KEY} className={styles.pushSides}> diff={diff}
<SplitPanel id="commits" minSize="240px" defaultSize="50%" className={styles.pushSplitPanel}> onClose={closeDiff}
<div className={styles.pushTreeWrap}> commits={
{error ? ( <div className={styles.pushTreeWrap}>
<div className={styles.error}>{error}</div> {error ? (
) : !repos ? ( <div className={styles.error}>{error}</div>
<div className={styles.empty}> ) : !repos ? (
<Spinner size={14} /> <div className={styles.empty}>
</div> <Spinner size={14} />
) : ( </div>
<Tree<PushNode> ) : (
roots={nodes} <Tree<PushNode>
getKey={(n) => n.key} roots={nodes}
getLabel={(n) => (n.commit ? n.commit.summary : repoName(n.repo.root))} getKey={(n) => n.key}
getChildren={(n) => n.children} getLabel={(n) => (n.commit ? n.commit.summary : repoName(n.repo.root))}
isExpandable={(n) => !!n.children?.length} getChildren={(n) => n.children}
expanded={expanded} isExpandable={(n) => !!n.children?.length}
onExpandedChange={(_next, node, open) => expanded={expanded}
setExpanded((e) => { onExpandedChange={(_next, node, open) =>
const s = new Set(e); setExpanded((e) => {
if (open) s.add(node.key); const s = new Set(e);
else s.delete(node.key); if (open) s.add(node.key);
return s; else s.delete(node.key);
}) return s;
} })
selected={new Set(shown ? [shown.key] : [])} }
multiSelect={false} selected={new Set(shown ? [shown.key] : [])}
onSelectionChange={(_sel, lead) => setShown(lead)} multiSelect={false}
rowHeight={rowHeight} onSelectionChange={(_sel, lead) => setShown(lead)}
aria-label="Outgoing commits" rowHeight={rowHeight}
className={styles.boxList} aria-label="Outgoing commits"
empty={ className={styles.boxList}
<span> empty={
<T>Everything is up to date</T> <span>
</span> <T>Everything is up to date</T>
} </span>
renderNode={(n) => }
n.commit ? ( renderNode={(n) =>
<span className={styles.commitRow} style={{ flex: 1, padding: 0 }}> n.commit ? (
<span className={styles.commitHash}>{n.commit.shortId}</span> <PushCommitSubject commit={n.commit} />
<span className={styles.commitSubject}>{n.commit.summary}</span> ) : (
<span className={styles.commitMeta}>{n.commit.author}</span> <span
<span className={styles.commitMeta}>{formatTime(n.commit.timeMs)}</span> className={styles.pushRepoRow}
</span> data-idle={hasNothingToPush(n.repo) || undefined}
) : ( // A row click toggles the checkbox, like before; only the chevron collapses.
<span onClick={(e) => {
className={styles.commitRow} if (only === undefined && !(e.target as HTMLElement | null)?.closest?.("label"))
data-idle={hasNothingToPush(n.repo) || undefined} toggle(n.repo.root);
style={{ flex: 1, padding: 0 }} }}
// A row click toggles the checkbox, like before; only the chevron collapses. >
onClick={(e) => { {only === undefined ? (
if (only === undefined && !(e.target as HTMLElement | null)?.closest?.("label")) <Checkbox
toggle(n.repo.root); checked={checked.has(n.repo.root)}
}} onChange={() => toggle(n.repo.root)}
> className={styles.pushRepoName}
{only === undefined ? ( label={
<Checkbox <span className={styles.pushRepoLabel} title={repoName(n.repo.root)}>
checked={checked.has(n.repo.root)} {repoName(n.repo.root)}
onChange={() => toggle(n.repo.root)} </span>
label={repoName(n.repo.root)} }
/>
) : (
<span className={styles.commitSubject}>{repoName(n.repo.root)}</span>
)}
<span className={styles.commitMeta}>{n.repo.branch.head} →</span>
<PushRowTarget
name={repoName(n.repo.root)}
remotes={remotesOf[n.repo.root] ?? []}
remote={shownRemoteOf(n.repo)}
onRemote={(remote) => edit(n.repo.root, { remote })}
target={edits[n.repo.root]?.target ?? targetOf(n.repo)}
onTarget={(target) => edit(n.repo.root, { target })}
changed={pushOperation(choiceOf(n.repo, null)).op === "pushBranch"}
onEnter={() => {
if (picked.length) void push();
}}
/> />
{!n.repo.branch.upstream && ( ) : (
<span className={styles.commitMeta}>{tx("new remote branch")}</span> <span className={styles.pushRepoLabel} title={repoName(n.repo.root)}>
)} {repoName(n.repo.root)}
</span>
)}
<span className={styles.pushSourceBranch} title={n.repo.branch.head ?? undefined}>
{n.repo.branch.head}
</span> </span>
) <span className={styles.pushRowSeparator} aria-hidden>
} →
/> </span>
)} <PushRowTarget
</div> name={repoName(n.repo.root)}
</SplitPanel> remotes={remotesOf[n.repo.root] ?? []}
<SplitHandle /> remote={shownRemoteOf(n.repo)}
<SplitPanel id="changes" minSize="240px" className={styles.pushSplitPanel}> onRemote={(remote) => edit(n.repo.root, { remote })}
{shownRepo && ( target={edits[n.repo.root]?.target ?? targetOf(n.repo)}
<PushChanges onTarget={(target) => edit(n.repo.root, { target })}
key={pushChangesKey(shownRepo.root, shownCommits)} changed={pushOperation(choiceOf(n.repo, null)).op === "pushBranch"}
repo={shownRepo.root} onEnter={() => {
commits={shownCommits} if (picked.length) void push();
onSelectFile={showDiff} }}
/>
{!n.repo.branch.upstream && (
<span className={styles.pushSourceBranch} title={tx("new remote branch")}>
{tx("new remote branch")}
</span>
)}
</span>
)
}
/> />
)} )}
</SplitPanel> </div>
</SplitGroup> }
</PushDiffSplit> changes={
shownRepo && (
<PushChanges
key={pushChangesKey(shownRepo.root, shownCommits)}
repo={shownRepo.root}
commits={shownCommits}
onSelectFile={showDiff}
/>
)
}
/>
</Dialog> </Dialog>
); );
} }
@@ -583,7 +587,11 @@ function PushRowTarget(props: {
options={props.remotes.map((r) => ({ value: r, label: r }))} options={props.remotes.map((r) => ({ value: r, label: r }))}
/> />
) : ( ) : (
props.remote && <span className={styles.commitMeta}>{props.remote}</span> props.remote && (
<span className={styles.pushRemoteName} title={props.remote}>
{props.remote}
</span>
)
)} )}
{props.remote && <span className={styles.pushRowSeparator}>/</span>} {props.remote && <span className={styles.pushRowSeparator}>/</span>}
<Input <Input
@@ -744,14 +752,7 @@ function PushDialog({ target: pushTarget, onClose }: { target: PushTarget; onClo
aria-label="Outgoing commits" aria-label="Outgoing commits"
className={styles.boxList} className={styles.boxList}
empty={<span>{upstream ? tx("Everything is up to date") : tx("No commits")}</span>} empty={<span>{upstream ? tx("Everything is up to date") : tx("No commits")}</span>}
renderItem={(c) => ( renderItem={(c) => <PushCommitSubject commit={c} />}
<span className={styles.commitRow} style={{ flex: 1, padding: 0 }}>
<span className={styles.commitHash}>{c.shortId}</span>
<span className={styles.commitSubject}>{c.summary}</span>
<span className={styles.commitMeta}>{c.author}</span>
<span className={styles.commitMeta}>{formatTime(c.timeMs)}</span>
</span>
)}
/> />
)} )}
</div> </div>
@@ -762,11 +763,13 @@ function PushDialog({ target: pushTarget, onClose }: { target: PushTarget; onClo
title={head ? tx`Push Commits to ${upstream ?? "remote"}` : "Push"} title={head ? tx`Push Commits to ${upstream ?? "remote"}` : "Push"}
onClose={onClose} onClose={onClose}
width={commits?.length ? PUSH_DIALOG_WIDTH : 620} width={commits?.length ? PUSH_DIALOG_WIDTH : 620}
minWidth={PUSH_DIALOG_MIN_WIDTH}
minHeight={340}
maxHeight={PUSH_DIALOG_MAX_HEIGHT} maxHeight={PUSH_DIALOG_MAX_HEIGHT}
className={styles.pushDialog} className={styles.pushDialog}
resizable="both" resizable="both"
footerStart={ footerStart={
<> <div className={styles.pushOptions}>
<span title={protectedTarget ? `Force push to protected branch '${target}' is prohibited` : undefined}> <span title={protectedTarget ? `Force push to protected branch '${target}' is prohibited` : undefined}>
<Checkbox <Checkbox
checked={force && !protectedTarget} checked={force && !protectedTarget}
@@ -785,7 +788,7 @@ function PushDialog({ target: pushTarget, onClose }: { target: PushTarget; onClo
/> />
)} )}
{!explicit && !retarget && !remoteChanged && ( {!explicit && !retarget && !remoteChanged && (
<> <span className={styles.pushTagOptions}>
<Checkbox checked={pushTags} onChange={setPushTags} label="Push tags:" /> <Checkbox checked={pushTags} onChange={setPushTags} label="Push tags:" />
<Select<PushTags> <Select<PushTags>
value={tagsMode} value={tagsMode}
@@ -797,9 +800,9 @@ function PushDialog({ target: pushTarget, onClose }: { target: PushTarget; onClo
{ value: "currentBranch", label: "Current Branch" }, { value: "currentBranch", label: "Current Branch" },
]} ]}
/> />
</> </span>
)} )}
</> </div>
} }
buttons={[ buttons={[
{ {
@@ -812,45 +815,62 @@ function PushDialog({ target: pushTarget, onClose }: { target: PushTarget; onClo
{ label: "Cancel", role: "cancel" }, { label: "Cancel", role: "cancel" },
]} ]}
> >
<div className={styles.section}> <div className={styles.pushTargetBar}>
{!head <span className={styles.pushTargetSource}>
? tx("HEAD is detached; check out a branch to push.") {!head
: trackedBranch ? tx("HEAD is detached; check out a branch to push.")
? `${head}${revision ? ` up to ${revision.slice(0, 8)}` : ""} → ${remote ?? trackedRemote ?? ""}/` : trackedBranch
: revision ? `${head}${revision ? ` up to ${revision.slice(0, 8)}` : ""} →`
? tx`${head} has no upstream: commits up to ${revision.slice(0, 8)} will be pushed as a new branch:` : revision
: tx`${head} has no upstream: it will be pushed as a new branch and tracked:`} ? tx`${head} has no upstream: commits up to ${revision.slice(0, 8)} will be pushed as a new branch:`
{head && remotes.length > 1 && ( : tx`${head} has no upstream: it will be pushed as a new branch and tracked:`}
<Select<string> </span>
value={remote ?? ""}
aria-label="Remote"
onChange={setRemote}
options={remotes.map((r) => ({ value: r, label: r }))}
/>
)}
{head && ( {head && (
<TargetBranchInput value={targetName} onChange={setTargetName} branches={remoteBranchNames} remote={remote} /> <div className={styles.pushTargetControls}>
{remotes.length > 1 ? (
<Select<string>
value={remote ?? ""}
aria-label="Remote"
onChange={setRemote}
options={remotes.map((r) => ({ value: r, label: r }))}
/>
) : (
remote && (
<span className={styles.pushRemoteName} title={remote}>
{remote}
</span>
)
)}
{remote && (
<span className={styles.pushRowSeparator} aria-hidden>
/
</span>
)}
<TargetBranchInput
value={targetName}
onChange={setTargetName}
branches={remoteBranchNames}
remote={remote}
/>
{retarget && !remoteBranchNames.includes(edited) && <span className={styles.hint}>{tx("New")}</span>}
</div>
)} )}
{retarget && !remoteBranchNames.includes(edited) && <span className={styles.hint}> {tx("New")}</span>}
</div> </div>
{commits?.length && !error ? ( {commits?.length && !error ? (
<PushDiffSplit diff={diff} onClose={closeDiff}> <PushReview
<SplitGroup orientation="horizontal" storageKey={PUSH_SPLIT_KEY} className={styles.pushSides}> diff={diff}
<SplitPanel id="commits" minSize="240px" defaultSize="50%" className={styles.pushSplitPanel}> onClose={closeDiff}
{commitList} commits={commitList}
</SplitPanel> changes={
<SplitHandle /> <PushChanges
<SplitPanel id="changes" minSize="240px" className={styles.pushSplitPanel}> key={pushChangesKey(repo, shownCommits)}
<PushChanges repo={repo}
key={pushChangesKey(repo, shownCommits)} commits={shownCommits}
repo={repo} onShowAll={shownCommit >= 0 && commits.length > 1 ? () => setShownCommit(-1) : undefined}
commits={shownCommits} onSelectFile={showDiff}
onShowAll={shownCommit >= 0 && commits.length > 1 ? () => setShownCommit(-1) : undefined} />
onSelectFile={showDiff} }
/> />
</SplitPanel>
</SplitGroup>
</PushDiffSplit>
) : ( ) : (
commitList commitList
)} )}