mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
fix(vcs): give commit subjects room beside compact refs (#5191)
Give Git Log commit subjects room beside long reference labels. Compact References View keeps labels within about a third of the available text column, with the full reference on hover. References in the log use the small UI font and the layout works on either side of the subject.
This commit is contained in:
@@ -117,7 +117,7 @@ test("fits a wide graph and saved columns without horizontal scrolling", async (
|
||||
expect(await list.evaluate((element) => element.scrollLeft)).toBe(0);
|
||||
});
|
||||
|
||||
test("keeps ref names visible when a long commit subject competes for space", async ({ workbench: page }) => {
|
||||
test("keeps expanded ref names visible when a long commit subject competes for space", async ({ workbench: page }) => {
|
||||
const branch = "origin/feature/workspace-settings";
|
||||
const tag = "v2.1";
|
||||
const summary = "Keep workspace settings and commit references visible ".repeat(4).trim();
|
||||
@@ -127,7 +127,7 @@ test("keeps ref names visible when a long commit subject competes for space", as
|
||||
const options = "/src/features/vcs/logOptions.ts";
|
||||
const { useGitLog } = await import(/* @vite-ignore */ log);
|
||||
const { useLogOptions } = await import(/* @vite-ignore */ options);
|
||||
useLogOptions.setState({ tagNames: true });
|
||||
useLogOptions.setState({ tagNames: true, compactRefs: false });
|
||||
const [first, ...rest] = useGitLog.getState().commits;
|
||||
useGitLog.setState({ commits: [{ ...first, summary, refs: [branch, `tag: ${tag}`] }, ...rest] });
|
||||
},
|
||||
|
||||
@@ -112,6 +112,57 @@ test("Git Log separates commit message typography from compact metadata", async
|
||||
await expect(author).toHaveCSS("font-size", "12px");
|
||||
});
|
||||
|
||||
test("compact Git Log refs give the subject room on either side", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 630, height: 720 });
|
||||
const refSubject = "Reconcile shipping credits";
|
||||
const longReference = "release-quarterly-settlement-and-backoffice-invoice-reconciliation";
|
||||
await page.evaluate(
|
||||
async ({ refSubject, longReference }) => {
|
||||
const optionsModule = "/src/features/vcs/logOptions.ts";
|
||||
const logModule = "/src/features/vcs/logStore.ts";
|
||||
const { setLogOptions } = await import(/* @vite-ignore */ optionsModule);
|
||||
const { useGitLog } = await import(/* @vite-ignore */ logModule);
|
||||
setLogOptions({ showBranches: false, showDetails: false });
|
||||
const [first, ...rest] = useGitLog.getState().commits;
|
||||
useGitLog.setState({
|
||||
commits: [{ ...first, summary: refSubject, message: refSubject, refs: [longReference] }, ...rest],
|
||||
});
|
||||
},
|
||||
{ refSubject, longReference },
|
||||
);
|
||||
const row = page.getByRole("listbox", { name: "Commits" }).getByRole("option").filter({ hasText: refSubject });
|
||||
const subject = row.getByText(refSubject, { exact: true });
|
||||
const ref = row.getByTitle(longReference, { exact: true });
|
||||
const expectLayout = async () => {
|
||||
await expect
|
||||
.poll(() =>
|
||||
subject.evaluate((el) => {
|
||||
const text = document.createRange();
|
||||
text.selectNodeContents(el);
|
||||
return el.getBoundingClientRect().width + 0.02 >= text.getBoundingClientRect().width;
|
||||
}),
|
||||
)
|
||||
.toBe(true);
|
||||
await expect
|
||||
.poll(() =>
|
||||
ref.evaluate((el) => {
|
||||
const refs = el.parentElement!;
|
||||
return refs.clientWidth / refs.parentElement!.clientWidth;
|
||||
}),
|
||||
)
|
||||
.toBeLessThanOrEqual(0.34);
|
||||
await expect(ref).toHaveCSS("font-size", "12px");
|
||||
await expect(subject).toHaveCSS("font-size", "13px");
|
||||
};
|
||||
await expectLayout();
|
||||
await expect.poll(async () => (await subject.boundingBox())!.x < (await ref.boundingBox())!.x).toBe(true);
|
||||
|
||||
await page.getByRole("toolbar", { name: "Log filters" }).getByRole("button", { name: "View Options" }).click();
|
||||
await page.getByRole("menuitemcheckbox", { name: "References on the Left" }).click();
|
||||
await expectLayout();
|
||||
await expect.poll(async () => (await subject.boundingBox())!.x > (await ref.boundingBox())!.x).toBe(true);
|
||||
});
|
||||
|
||||
test("a second click on a Git Log toolbar button closes its popup", async ({ workbench: page }) => {
|
||||
const toolbar = page.getByRole("toolbar", { name: "Log filters" });
|
||||
const branchPopup = page.getByRole("dialog", { name: "Filter by Branch" });
|
||||
|
||||
@@ -405,9 +405,12 @@
|
||||
.subject {
|
||||
flex: 0 1 auto;
|
||||
min-width: var(--log-subject-min);
|
||||
color: var(--fg);
|
||||
}
|
||||
.subjectText {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--fg);
|
||||
}
|
||||
.headSubject {
|
||||
font-weight: 600;
|
||||
@@ -437,6 +440,22 @@
|
||||
flex: none;
|
||||
max-width: calc(100% - var(--log-subject-min) - var(--space-1-5));
|
||||
}
|
||||
.commitText > .refsCompact {
|
||||
flex: 0 1 auto;
|
||||
max-width: calc(100% / 3);
|
||||
}
|
||||
.commitText:has(> .refsCompact) > .subject {
|
||||
/* Protect a short subject while leaving room for compact reference names. */
|
||||
flex: 0 1000 max-content;
|
||||
min-width: auto;
|
||||
width: min(75%, 24ch);
|
||||
}
|
||||
.commitText > .refs .ref {
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.refsCompact .ref {
|
||||
min-width: 11px;
|
||||
}
|
||||
.refsLeft {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export function RefLabels({
|
||||
}) {
|
||||
const labels = refLabels(refs, { compact, tagNames }, remoteNames);
|
||||
return (
|
||||
<span className={clsx(styles.refs, left && styles.refsLeft)}>
|
||||
<span className={clsx(styles.refs, compact && styles.refsCompact, left && styles.refsLeft)}>
|
||||
{labels.map((l) => (
|
||||
<span key={`${l.kind}:${l.title}`} className={clsx(styles.ref, REF_KIND_CLASS[l.kind])} title={l.title}>
|
||||
{l.text && <span className={styles.refText}>{l.text}</span>}
|
||||
|
||||
@@ -134,7 +134,9 @@ function CommitRowView({
|
||||
setTooltip(false);
|
||||
}}
|
||||
>
|
||||
<IssueText text={c.summary} />
|
||||
<span className={styles.subjectText}>
|
||||
<IssueText text={c.summary} />
|
||||
</span>
|
||||
</span>
|
||||
{!opts.refsOnLeft && refs}
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user