mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-08 08:08:16 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c7704663b |
No files matched your search
@@ -0,0 +1,73 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
for (const kind of ["external", "ssh", "target"] as const) {
|
||||
test(`${kind} settings keep long names and details inside their selection row`, async ({ workbench: page }) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
await expect(page.getByRole("dialog", { name: "Settings", exact: true })).toBeVisible();
|
||||
await page.evaluate(async (kind) => {
|
||||
const path = "/src/features/settings/model/staging.ts";
|
||||
const { selectPage, stage } = await import(/* @vite-ignore */ path);
|
||||
const remotePath = "/src/platform/remoteSettings.ts";
|
||||
const workflowPath = "/src/platform/workflowSettings.ts";
|
||||
const { DEFAULT_SSH_CONFIG, DEFAULT_RUN_TARGET } = await import(/* @vite-ignore */ remotePath);
|
||||
const { DEFAULT_EXTERNAL_TOOL } = await import(/* @vite-ignore */ workflowPath);
|
||||
const name = "Run integration tests for the current project with the configured environment";
|
||||
const detail = "Shared infrastructure for the staging environment";
|
||||
if (kind === "external") {
|
||||
stage("tools.externalTools", "global", "externalTools", [
|
||||
{ ...DEFAULT_EXTERNAL_TOOL, id: "qa", name, group: detail },
|
||||
]);
|
||||
selectPage("tools.externalTools");
|
||||
} else if (kind === "ssh") {
|
||||
stage("tools.sshConfigurations", "global", "ssh.configs", [
|
||||
{ ...DEFAULT_SSH_CONFIG, id: "qa", name, host: detail, user: "qa" },
|
||||
]);
|
||||
selectPage("tools.sshConfigurations");
|
||||
} else {
|
||||
stage("build.runTargets", "global", "runTargets", [
|
||||
{ ...DEFAULT_RUN_TARGET, id: "qa", name, kind: "docker", image: detail },
|
||||
]);
|
||||
selectPage("build.runTargets");
|
||||
}
|
||||
}, kind);
|
||||
const row = page.getByRole("dialog", { name: "Settings", exact: true }).getByRole("option").first();
|
||||
await expect(row).toBeVisible();
|
||||
for (const width of [1000, 640, 520]) {
|
||||
await page.setViewportSize({ width, height: 760 });
|
||||
const fits = await row.evaluate((row) => {
|
||||
const box = row.getBoundingClientRect();
|
||||
return [...row.querySelectorAll(":scope > span")].every((span) => {
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(span);
|
||||
return [...range.getClientRects()].every((r) => r.top >= box.top - 1 && r.bottom <= box.bottom + 1);
|
||||
});
|
||||
});
|
||||
expect(fits).toBe(true);
|
||||
}
|
||||
await expect(row.locator(":scope > span").first()).toHaveAttribute(
|
||||
"title",
|
||||
"Run integration tests for the current project with the configured environment",
|
||||
);
|
||||
await page.evaluate(async (kind) => {
|
||||
const path = "/src/features/settings/model/staging.ts";
|
||||
const { stage } = await import(/* @vite-ignore */ path);
|
||||
const [id, key] =
|
||||
kind === "external"
|
||||
? ["tools.externalTools", "externalTools"]
|
||||
: kind === "ssh"
|
||||
? ["tools.sshConfigurations", "ssh.configs"]
|
||||
: ["build.runTargets", "runTargets"];
|
||||
stage(id, "global", key, []);
|
||||
}, kind);
|
||||
const empty = page.getByRole("dialog", { name: "Settings", exact: true }).getByRole("listbox");
|
||||
await expect(row).toHaveCount(0);
|
||||
const hintFits = await empty.evaluate((list) => {
|
||||
const hint = list.firstElementChild!;
|
||||
const box = hint.getBoundingClientRect();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(hint);
|
||||
return [...range.getClientRects()].every((r) => r.top >= box.top - 1 && r.bottom <= box.bottom + 1);
|
||||
});
|
||||
expect(hintFits).toBe(true);
|
||||
});
|
||||
}
|
||||
@@ -3,11 +3,14 @@
|
||||
* (opened by `openPullRequestFileDiff` / the details panel's commit diffs, context
|
||||
* `PULL_REQUEST_DIFF`) get their review threads as inlays, the gutter "+" with single- and
|
||||
* multi-line comments, Start Review / Add Single Comment, the review toolbar and the viewed
|
||||
* toggle, through the vcs diff viewer provider point. The editor actions also serve review mode's editors.
|
||||
* toggle, through the vcs diff viewer provider point. Also registers the editor actions and
|
||||
* Settings › Version Control › GitHub. The editor actions also serve review mode's editors.
|
||||
*/
|
||||
import { registerDiffViewerProvider } from "@/features/vcs/diffViewerProviders";
|
||||
import { registerActions } from "@/platform/actions";
|
||||
import { getContext } from "@/platform/context";
|
||||
import { lazyComponent } from "@/ui";
|
||||
import { registerSettingsPage } from "@/workbench/contributions";
|
||||
import { useGhRepository } from "../data/repository";
|
||||
import { activeReviewEditor } from "../reviewMode/editor";
|
||||
import { clearNewComments } from "./newComments";
|
||||
@@ -79,6 +82,13 @@ export function activateReviewDiff(): () => void {
|
||||
run: () => reviewTarget()?.refresh(),
|
||||
},
|
||||
]),
|
||||
registerSettingsPage({
|
||||
id: "vcs.github",
|
||||
title: "GitHub",
|
||||
order: 9,
|
||||
keywords: ["pull request", "viewed", "review"],
|
||||
component: lazyComponent(() => import("./GithubSettingsPage").then((m) => m.GithubSettingsPage)),
|
||||
}),
|
||||
useGhRepository.subscribe((s, prev) => {
|
||||
const a = s.connection?.coordinates;
|
||||
const b = prev.connection?.coordinates;
|
||||
|
||||
@@ -46,10 +46,6 @@ function load(): ReviewDiffSettings {
|
||||
|
||||
export const useReviewDiffSettings = create<ReviewDiffSettings>(load);
|
||||
|
||||
globalThis.addEventListener?.("storage", (event: StorageEvent) => {
|
||||
if (event.key === KEY || event.key === null) useReviewDiffSettings.setState(load(), true);
|
||||
});
|
||||
|
||||
export function setReviewDiffSettings(patch: Partial<ReviewDiffSettings>) {
|
||||
useReviewDiffSettings.setState(patch);
|
||||
try {
|
||||
|
||||
@@ -22,9 +22,6 @@ import {
|
||||
import { useGithubShell } from "./shell";
|
||||
import { githubHandler, handlerContextKey } from "./toolwindow/handlers";
|
||||
import { GithubDialogHost } from "./ui/dialogs";
|
||||
import { activateSettingsPages } from "./settingsPages";
|
||||
|
||||
export { activateSettingsPages } from "./settingsPages";
|
||||
|
||||
const WINDOW = "pullRequests";
|
||||
const TIMELINE_KIND = "github.timeline";
|
||||
@@ -258,7 +255,6 @@ export function activate(): () => void {
|
||||
active = true;
|
||||
setContext("githubPrTab", "list");
|
||||
const disposers = [
|
||||
activateSettingsPages(),
|
||||
registerCloneSource({
|
||||
id: "github",
|
||||
label: "GitHub",
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { act, fireEvent, render, screen } from "@testing-library/react";
|
||||
import { useSettingsPages } from "@/workbench/contributions";
|
||||
import { activateSettingsPages } from "./settingsPages";
|
||||
import { GithubSettingsPage } from "./diff/GithubSettingsPage";
|
||||
import { setReviewDiffSettings, useReviewDiffSettings } from "./diff/settings";
|
||||
|
||||
const KEY = "openidea.github.reviewDiff.v1";
|
||||
|
||||
beforeEach(() => {
|
||||
localStorage.removeItem(KEY);
|
||||
window.dispatchEvent(new StorageEvent("storage", { key: KEY }));
|
||||
});
|
||||
|
||||
describe("GitHub settings pages", () => {
|
||||
it("registers independently of the pull request runtime", () => {
|
||||
const dispose = activateSettingsPages();
|
||||
expect(useSettingsPages.getState().pages.get("vcs.github")).toMatchObject({ title: "GitHub" });
|
||||
expect(useSettingsPages.getState().pages.get("vcs.github")?.component).toBeDefined();
|
||||
dispose();
|
||||
expect(useSettingsPages.getState().pages.has("vcs.github")).toBe(false);
|
||||
});
|
||||
|
||||
it("updates an open page when another window saves or clears review settings", () => {
|
||||
render(<GithubSettingsPage />);
|
||||
const checkbox = screen.getByRole("checkbox", { name: "Automatically mark opened files as viewed" });
|
||||
expect(checkbox).not.toBeChecked();
|
||||
act(() => {
|
||||
localStorage.setItem(KEY, JSON.stringify({ autoMarkViewed: true, threadsView: "all" }));
|
||||
window.dispatchEvent(new StorageEvent("storage", { key: KEY }));
|
||||
});
|
||||
expect(checkbox).toBeChecked();
|
||||
expect(useReviewDiffSettings.getState().threadsView).toBe("all");
|
||||
act(() => {
|
||||
localStorage.clear();
|
||||
window.dispatchEvent(new StorageEvent("storage", { key: null }));
|
||||
});
|
||||
expect(checkbox).not.toBeChecked();
|
||||
fireEvent.click(checkbox);
|
||||
expect(JSON.parse(localStorage.getItem(KEY)!)).toMatchObject({ autoMarkViewed: true });
|
||||
});
|
||||
|
||||
it("ignores unrelated storage changes and recovers from invalid saved settings", () => {
|
||||
setReviewDiffSettings({ autoMarkViewed: true });
|
||||
localStorage.removeItem(KEY);
|
||||
window.dispatchEvent(new StorageEvent("storage", { key: "other" }));
|
||||
expect(useReviewDiffSettings.getState().autoMarkViewed).toBe(true);
|
||||
localStorage.setItem(KEY, "invalid JSON");
|
||||
window.dispatchEvent(new StorageEvent("storage", { key: KEY }));
|
||||
expect(useReviewDiffSettings.getState().autoMarkViewed).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,12 +0,0 @@
|
||||
import { lazyComponent } from "@/ui";
|
||||
import { registerSettingsPage } from "@/workbench/contributions";
|
||||
|
||||
export function activateSettingsPages(): () => void {
|
||||
return registerSettingsPage({
|
||||
id: "vcs.github",
|
||||
title: "GitHub",
|
||||
order: 9,
|
||||
keywords: ["pull request", "viewed", "review"],
|
||||
component: lazyComponent(() => import("./diff/GithubSettingsPage").then((m) => m.GithubSettingsPage)),
|
||||
});
|
||||
}
|
||||
@@ -43,7 +43,7 @@ import { activate as notebook } from "./notebook";
|
||||
import { activate as web } from "./web";
|
||||
import { activate as analysis } from "./analysis";
|
||||
import { activate as services } from "./services";
|
||||
import { activate as github, activateSettingsPages as githubPages } from "./github";
|
||||
import { activate as github } from "./github";
|
||||
import { activate as httpClient } from "./http-client";
|
||||
import { activate as database } from "./database";
|
||||
import { activate as graphql } from "./graphql";
|
||||
@@ -166,7 +166,6 @@ export function activateSettingsWindowFeatures(parent: string): () => void {
|
||||
["agents", agentsPages],
|
||||
["vim", vimPages],
|
||||
["vcs", vcsPages],
|
||||
["github", githubPages],
|
||||
];
|
||||
return activateAll("settings pages", pages);
|
||||
}
|
||||
@@ -166,6 +166,21 @@
|
||||
padding: 0 8px;
|
||||
cursor: default;
|
||||
}
|
||||
.toolRow > span {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.toolName {
|
||||
flex: 1;
|
||||
}
|
||||
.toolRow.empty {
|
||||
height: auto;
|
||||
min-height: var(--h-list-row);
|
||||
padding-block: 4px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.toolRow:hover {
|
||||
background: var(--bg-tree-hover);
|
||||
}
|
||||
@@ -174,6 +189,7 @@
|
||||
background: var(--bg-tree-selected);
|
||||
}
|
||||
.toolGroup {
|
||||
max-width: 45%;
|
||||
color: var(--fg-subtle);
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
@@ -491,8 +491,13 @@ function RunTargetsEditor() {
|
||||
className={clsx(styles.toolRow, t.id === selected && styles.toolRowSelected)}
|
||||
onMouseDown={() => setSelected(t.id)}
|
||||
>
|
||||
<span>{t.name || t.id}</span>
|
||||
<span className={styles.toolGroup}>
|
||||
<span className={styles.toolName} title={t.name || t.id}>
|
||||
{t.name || t.id}
|
||||
</span>
|
||||
<span
|
||||
className={styles.toolGroup}
|
||||
title={t.kind === "ssh" ? (t.sshConfig ? sshName(t.sshConfig) : "") : containerSummary(t)}
|
||||
>
|
||||
{t.kind === "ssh" ? (t.sshConfig ? sshName(t.sshConfig) : "") : containerSummary(t)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -339,8 +339,12 @@ function SshConfigsEditor() {
|
||||
className={clsx(styles.toolRow, c.id === selected && styles.toolRowSelected)}
|
||||
onMouseDown={() => setSelected(c.id)}
|
||||
>
|
||||
<span>{c.name.trim() || sshLabel(c) || c.id}</span>
|
||||
<span className={styles.toolGroup}>{sshLabel(c)}</span>
|
||||
<span className={styles.toolName} title={c.name.trim() || sshLabel(c) || c.id}>
|
||||
{c.name.trim() || sshLabel(c) || c.id}
|
||||
</span>
|
||||
<span className={styles.toolGroup} title={sshLabel(c)}>
|
||||
{sshLabel(c)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -480,8 +480,12 @@ function ExternalToolsEditor() {
|
||||
checked={t.enabled}
|
||||
onChange={(on) => setTools(tools.map((x) => (x.id === t.id ? { ...x, enabled: on } : x)))}
|
||||
/>
|
||||
<span>{t.name}</span>
|
||||
<span className={styles.toolGroup}>{t.group}</span>
|
||||
<span className={styles.toolName} title={t.name}>
|
||||
{t.name}
|
||||
</span>
|
||||
<span className={styles.toolGroup} title={t.group}>
|
||||
{t.group}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user