дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-23 18:10:45 +02:00
Порівняти коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
c2e2088ebf | ||
|
|
331e5858e3 | ||
|
|
adb8178336 |
No files matched your search
@@ -1,29 +1,5 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("data source tabs share a stable layout and scroll within a short window", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 560, height: 480 });
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/features/database/store.ts";
|
||||
const { openSourceDialog } = await import(/* @vite-ignore */ path);
|
||||
openSourceDialog(null, { name: "Local development", driver: "postgres", host: "localhost" });
|
||||
});
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "New Data Source" });
|
||||
const panel = dialog.getByRole("tabpanel");
|
||||
const dialogSize = () => dialog.evaluate((element) => [element.offsetWidth, element.offsetHeight]);
|
||||
await expect(panel.getByRole("textbox", { name: "Host:" })).toBeVisible();
|
||||
const size = await dialogSize();
|
||||
await dialog.getByRole("tab", { name: "SSH/SSL" }).click();
|
||||
await expect(dialog.getByRole("tab", { name: "SSH/SSL" })).toHaveAttribute("aria-selected", "true");
|
||||
expect(await dialogSize()).toEqual(size);
|
||||
|
||||
await dialog.getByRole("tab", { name: "General" }).click();
|
||||
const canScroll = await panel.evaluate((element) => element.scrollHeight > element.clientHeight);
|
||||
expect(canScroll).toBe(true);
|
||||
await panel.getByRole("textbox", { name: "URL:" }).scrollIntoViewIfNeeded();
|
||||
await expect(dialog.getByRole("button", { name: "Cancel" })).toBeInViewport();
|
||||
});
|
||||
|
||||
for (const kind of ["password", "sshSecret", "params"] as const) {
|
||||
test(`database ${kind} dialog keeps its fields inside the window`, async ({ workbench: page }) => {
|
||||
await page.evaluate(async (kind) => {
|
||||
|
||||
@@ -1,40 +1,6 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, openFromTree, test } from "./fixtures";
|
||||
|
||||
test("managed console tabs identify their data source and ordinary SQL tabs keep the file name", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.evaluate(async () => {
|
||||
const database = "/src/features/database/store.ts";
|
||||
const workbench = "/src/workbench/contributions.ts";
|
||||
const { useDatabase, bindConsole } = await import(database);
|
||||
const { editorService } = await import(workbench);
|
||||
const console = "/app-data/consoles/db/demo/console.sql";
|
||||
useDatabase.setState({ loaded: true, sources: [{ id: "demo", name: "Shop Demo", driver: "sqlite" }] });
|
||||
bindConsole(console, "demo");
|
||||
bindConsole("/acme-api/console.sql", "demo");
|
||||
await editorService().openFile("/acme-api/console.sql", { focus: true });
|
||||
await editorService().openFile(console, { focus: true });
|
||||
});
|
||||
|
||||
const consoleTab = page.getByRole("tab", { name: "console [Shop Demo]", exact: true });
|
||||
await expect(consoleTab).toHaveAttribute("aria-selected", "true");
|
||||
await expect(page.getByRole("tab", { name: "console.sql", exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("toolbar", { name: "Query Console", exact: true })).toContainText("main");
|
||||
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/features/database/store.ts";
|
||||
const { useDatabase } = await import(path);
|
||||
useDatabase.setState((state: { sources: Array<{ name: string }> }) => ({
|
||||
sources: state.sources.map((source) => ({ ...source, name: "Shop QA" })),
|
||||
}));
|
||||
});
|
||||
await expect(page.getByRole("tab", { name: "console [Shop QA]", exact: true })).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
});
|
||||
|
||||
const edgeTitle = "Result 3 — a long query result at the edge of the Services pane";
|
||||
const bindings = { "alpha-console.sql": "alpha", "beta-console.sql": "beta" };
|
||||
|
||||
|
||||
@@ -19,33 +19,6 @@ async function openChain(page: Page) {
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
test("a narrow diff keeps navigation, settings and the difference count visible", async ({ workbench: page }) => {
|
||||
const toolbar = await openChain(page);
|
||||
await page.setViewportSize({ width: 400, height: 600 });
|
||||
const clipped = await toolbar.evaluate((bar) => {
|
||||
const bounds = bar.getBoundingClientRect();
|
||||
const items = [...bar.querySelectorAll("button, span")].filter(
|
||||
(el) => el.matches("button") || el.textContent === "1 difference",
|
||||
);
|
||||
return items.flatMap((el) => {
|
||||
const box = el.getBoundingClientRect();
|
||||
if (el.matches("button") && !box.width) return [];
|
||||
return !box.width ||
|
||||
box.right > bounds.right + 1 ||
|
||||
box.bottom > bounds.bottom + 1 ||
|
||||
el.scrollWidth > el.clientWidth + 1
|
||||
? [el.getAttribute("aria-label") || el.textContent]
|
||||
: [];
|
||||
});
|
||||
});
|
||||
expect(clipped).toEqual([]);
|
||||
await toolbar.getByRole("button", { name: "Settings", exact: true }).click();
|
||||
await page.getByRole("menuitemcheckbox", { name: "Unified Viewer", exact: true }).click();
|
||||
await expect(toolbar.locator("..").locator(".cm-editor")).toHaveCount(1);
|
||||
await toolbar.getByRole("button", { name: "Next Difference", exact: true }).click();
|
||||
await expect(toolbar).toContainText("1 of 1 differences");
|
||||
});
|
||||
|
||||
test("maximizes a diff preview tab and restores its previous layout", async ({ workbench: page }) => {
|
||||
const toolbar = await openChain(page);
|
||||
const viewer = toolbar.locator("..");
|
||||
|
||||
@@ -48,51 +48,6 @@ async function move(page: Page, source: string, target: string) {
|
||||
await page.mouse.up();
|
||||
}
|
||||
|
||||
test("Services favors details and stacks the panes when docked to the side", async ({ workbench: page }) => {
|
||||
await configure(page);
|
||||
const services = page.getByRole("region", { name: "Services", exact: true });
|
||||
const items = services.locator("[data-panel][id=services-items]");
|
||||
const detail = services.locator("[data-panel][id=services-detail]");
|
||||
const handle = services.locator("[data-separator]");
|
||||
const share = async (axis: "width" | "height") => {
|
||||
const treeSize = (await items.boundingBox())![axis];
|
||||
return treeSize / (treeSize + (await detail.boundingBox())![axis]);
|
||||
};
|
||||
const dock = (anchor: "bottom" | "right" | "left") =>
|
||||
page.evaluate(async (anchor) => {
|
||||
const path = "/src/workbench/toolwindows/store.ts";
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ path);
|
||||
moveToolWindow("services", anchor);
|
||||
if (anchor !== "bottom") setToolWindowSize(anchor, 280);
|
||||
}, anchor);
|
||||
|
||||
await expect(handle).toHaveAttribute("aria-orientation", "vertical");
|
||||
await expect.poll(() => share("width")).toBeCloseTo(0.3, 2);
|
||||
await handle.press("ArrowRight");
|
||||
await expect.poll(() => share("width")).toBeGreaterThan(0.31);
|
||||
const bottom = await share("width");
|
||||
|
||||
for (const anchor of ["right", "left"] as const) {
|
||||
await dock(anchor);
|
||||
await expect(handle).toHaveAttribute("aria-orientation", "horizontal");
|
||||
const treeBox = (await items.boundingBox())!;
|
||||
const detailBox = (await detail.boundingBox())!;
|
||||
expect(detailBox.width).toBeCloseTo(treeBox.width, 0);
|
||||
expect(detailBox.y).toBeGreaterThanOrEqual(treeBox.y + treeBox.height - 1);
|
||||
await expect.poll(() => share("height")).toBeCloseTo(0.3, 2);
|
||||
}
|
||||
await handle.press("ArrowDown");
|
||||
await expect.poll(() => share("height")).toBeGreaterThan(0.31);
|
||||
const side = await share("height");
|
||||
|
||||
await dock("bottom");
|
||||
await expect(handle).toHaveAttribute("aria-orientation", "vertical");
|
||||
await expect.poll(() => share("width")).toBeCloseTo(bottom, 2);
|
||||
await dock("right");
|
||||
await expect(handle).toHaveAttribute("aria-orientation", "horizontal");
|
||||
await expect.poll(() => share("height")).toBeCloseTo(side, 2);
|
||||
});
|
||||
|
||||
test("service pointer ordering works for Java and npm and survives reload", async ({ workbench: page }) => {
|
||||
await configure(page);
|
||||
const tree = page.getByRole("tree", { name: "Services", exact: true });
|
||||
|
||||
@@ -15,10 +15,10 @@ function parents(path: string): string[] {
|
||||
* For every path whose file name occurs more than once in `paths`, the
|
||||
* distinguishing directory hint. Paths with a unique name are absent.
|
||||
*/
|
||||
export function disambiguateTitles(paths: readonly string[], titleOf = baseName): Map<string, string> {
|
||||
export function disambiguateTitles(paths: readonly string[]): Map<string, string> {
|
||||
const groups = new Map<string, string[]>();
|
||||
for (const p of new Set(paths)) {
|
||||
const name = titleOf(p);
|
||||
const name = baseName(p);
|
||||
const list = groups.get(name);
|
||||
if (list) list.push(p);
|
||||
else groups.set(name, [p]);
|
||||
|
||||
@@ -161,11 +161,7 @@ function useTitleHints(): Map<string, string> {
|
||||
return out.sort();
|
||||
}),
|
||||
);
|
||||
const labels = useFileDecorations(useShallow(() => paths.map((p) => getFileDecoration(p)?.tabTitle ?? basename(p))));
|
||||
return useMemo(() => {
|
||||
const byPath = new Map(paths.map((p, i) => [p, labels[i]!]));
|
||||
return disambiguateTitles(paths, (p) => byPath.get(p) ?? basename(p));
|
||||
}, [paths, labels]);
|
||||
return useMemo(() => disambiguateTitles(paths), [paths]);
|
||||
}
|
||||
|
||||
const virtualData = (input: EditorInput) => input.data as VirtualInputData | undefined;
|
||||
@@ -184,8 +180,6 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
const dirty = tabs.map((tab, i) => inputDirty(tab.input, kinds) ?? textDirty[i] ?? false);
|
||||
const colors = useFileDecorations(useShallow(() => paths.map((p) => (p ? (getFileDecoration(p)?.color ?? "") : ""))));
|
||||
const tints = useFileDecorations(useShallow(() => paths.map((p) => (p ? (getFileDecoration(p)?.tint ?? "") : ""))));
|
||||
const tabLabels = useFileDecorations(useShallow(() => paths.map((p) => getFileDecoration(p)?.tabTitle)));
|
||||
const tabIcons = useFileDecorations(useShallow(() => paths.map((p) => getFileDecoration(p)?.tabIcon)));
|
||||
const errors = useFileDecorations(useShallow(() => paths.map((p) => !!p && !!getFileDecoration(p)?.error)));
|
||||
const fileColors = useFileColors("editorTabs");
|
||||
|
||||
@@ -206,7 +200,7 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
return tabs.map((t, i) => {
|
||||
const full = names[i]!;
|
||||
const dot = full.lastIndexOf(".");
|
||||
const name = tabLabels[i] ?? (t.input.kind === "file" && !showExtension && dot > 0 ? full.slice(0, dot) : full);
|
||||
const name = t.input.kind === "file" && !showExtension && dot > 0 ? full.slice(0, dot) : full;
|
||||
const dupe = !showDirectoryForNonUnique
|
||||
? null
|
||||
: t.input.kind === "file" && t.input.path
|
||||
@@ -229,7 +223,7 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
text: dupe ? `${name} — ${dupe}` : name,
|
||||
icon: showFileIcon
|
||||
? t.input.kind === "file" && t.input.path
|
||||
? (tabIcons[i] ?? file?.icon)
|
||||
? file?.icon
|
||||
: tabIcon(t.input, kinds)
|
||||
: undefined,
|
||||
italic: t.preview,
|
||||
@@ -261,8 +255,6 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
colors,
|
||||
errors,
|
||||
tints,
|
||||
tabLabels,
|
||||
tabIcons,
|
||||
fileColors,
|
||||
hints,
|
||||
showExtension,
|
||||
|
||||
@@ -210,14 +210,7 @@ export function ImportDialog({ id, schema, table }: { id: string; schema: string
|
||||
<T>File:</T>
|
||||
</span>
|
||||
<div className={styles.formRow}>
|
||||
<Input
|
||||
className={styles.fill}
|
||||
readOnly
|
||||
aria-label="File"
|
||||
value={file ?? ""}
|
||||
placeholder="Choose a CSV or TSV file"
|
||||
title={file ?? undefined}
|
||||
/>
|
||||
<Input readOnly aria-label="File" value={file ?? ""} placeholder="Choose a CSV or TSV file" />
|
||||
<IconButton icon="folder" title="Choose File…" onClick={() => void choose()} />
|
||||
</div>
|
||||
<span className={styles.formLabel}>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Record / Value / Aggregates side panel following the selection.
|
||||
*/
|
||||
import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { useMemo, useRef, useState, type KeyboardEvent, type ReactNode, type RefObject } from "react";
|
||||
import { useMemo, useRef, useState, type KeyboardEvent, type RefObject } from "react";
|
||||
import clsx from "clsx";
|
||||
import { Button, Checkbox, Icon, IconButton, Input, Popup, SearchField, Select, Tabs, T, type MenuItem } from "@/ui";
|
||||
import { EXPORT_FORMATS, exportData, type ExportData, type ExportFormat } from "./export";
|
||||
@@ -99,7 +99,6 @@ export interface DataViewProps extends Pick<
|
||||
/** Rows from here on (the table editor's added rows) are never filtered or sorted. */
|
||||
fixedRows?: number;
|
||||
firstRowNumber?: number;
|
||||
pager?: ReactNode;
|
||||
/** The side panel shown (`null`: hidden). */
|
||||
panel: DataPanel | null;
|
||||
onPanelChange: (panel: DataPanel | null) => void;
|
||||
@@ -248,7 +247,6 @@ export function DataView(props: DataViewProps) {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{props.pager && <div className={styles.pagerDock}>{props.pager}</div>}
|
||||
</div>
|
||||
{filterAt && (
|
||||
<FilterPopup
|
||||
|
||||
@@ -73,11 +73,10 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
padding: 0 var(--space-1);
|
||||
padding: 0 6px;
|
||||
color: var(--fg-line-number);
|
||||
background: var(--bg-editor-gutter);
|
||||
border-right: 1px solid var(--border);
|
||||
border-bottom: 1px solid var(--border);
|
||||
user-select: none;
|
||||
}
|
||||
.cell {
|
||||
@@ -140,10 +139,9 @@
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-0-5);
|
||||
min-height: 32px;
|
||||
padding: var(--space-0-5) var(--space-2);
|
||||
height: var(--h-header);
|
||||
padding: 0 6px;
|
||||
flex: none;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
@@ -235,16 +233,14 @@
|
||||
flex-direction: column;
|
||||
}
|
||||
.dbToolbar {
|
||||
min-height: 32px;
|
||||
height: 32px;
|
||||
flex: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-0-5);
|
||||
padding: var(--space-0-5) var(--space-2);
|
||||
padding: 0 6px;
|
||||
}
|
||||
.dbToolbarSep {
|
||||
flex: none;
|
||||
width: 1px;
|
||||
height: 16px;
|
||||
margin: 0 4px;
|
||||
@@ -290,22 +286,15 @@
|
||||
.consoleBar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-0-5);
|
||||
min-height: 32px;
|
||||
padding: var(--space-0-5) var(--space-2);
|
||||
gap: var(--space-1);
|
||||
height: var(--h-header);
|
||||
padding: 0 8px;
|
||||
background: var(--bg-editor);
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-family: var(--font-ui);
|
||||
font-size: var(--fs-ui);
|
||||
color: var(--fg-secondary);
|
||||
}
|
||||
.consoleSchema {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
padding-inline: var(--space-2);
|
||||
}
|
||||
|
||||
/* Inline statement errors in consoles. */
|
||||
:global(.cm-openidea-db-error) {
|
||||
@@ -318,9 +307,9 @@
|
||||
/* Table editor. */
|
||||
/* The table editor's WHERE | ORDER BY row (IDEA). */
|
||||
.filterBar {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
|
||||
display: flex;
|
||||
flex: none;
|
||||
height: var(--h-header);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.filterField {
|
||||
@@ -329,26 +318,29 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
padding: 0 var(--space-2);
|
||||
padding: 0 8px;
|
||||
color: var(--fg-muted);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-small);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.filterField + .filterField {
|
||||
border-left: 1px solid var(--border);
|
||||
}
|
||||
.filterField:focus-within {
|
||||
box-shadow: inset 0 -1px var(--focus-ring);
|
||||
.filterField > input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.filterField:has(input[aria-invalid="true"]) {
|
||||
box-shadow: inset 0 -1px var(--danger);
|
||||
.pager {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-0-5);
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-small);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.notice {
|
||||
padding: var(--space-1) var(--space-2);
|
||||
padding: 4px 8px;
|
||||
font-size: var(--fs-small);
|
||||
color: var(--fg-secondary);
|
||||
background: var(--bg-elev);
|
||||
background: var(--bg-editor-banner);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
@@ -435,28 +427,6 @@
|
||||
display: none;
|
||||
}
|
||||
/* Data source dialog. */
|
||||
.sourceLayout {
|
||||
display: grid;
|
||||
grid-template-rows: auto auto minmax(0, 1fr) auto;
|
||||
height: clamp(220px, calc(100dvh - 150px), 560px);
|
||||
}
|
||||
.sourceLayout .form {
|
||||
grid-template-columns: minmax(112px, 19%) minmax(0, 1fr);
|
||||
align-content: start;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
}
|
||||
.sourceLayout .formLabel {
|
||||
text-align: left;
|
||||
}
|
||||
.sourceLayout .formRow {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.sourceLayout .formRow > .fill {
|
||||
flex: 1 1 160px;
|
||||
}
|
||||
.sourcePanel {
|
||||
overflow: auto;
|
||||
}
|
||||
.formSection {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
@@ -579,16 +549,10 @@
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.testResult {
|
||||
grid-column: 1 / -1;
|
||||
font-size: var(--fs-small);
|
||||
max-height: 25vh;
|
||||
padding: var(--space-2) var(--space-4);
|
||||
overflow: auto;
|
||||
overflow-wrap: anywhere;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
.testResult:empty {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
min-height: 16px;
|
||||
word-break: break-word;
|
||||
}
|
||||
.ok {
|
||||
color: var(--success);
|
||||
@@ -773,28 +737,17 @@
|
||||
.modifyBody {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
height: clamp(320px, 68vh, 560px);
|
||||
padding: var(--space-4);
|
||||
gap: 10px;
|
||||
padding: 14px;
|
||||
}
|
||||
.modifyMain {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(108px, 34%) minmax(0, 1fr);
|
||||
min-height: 0;
|
||||
grid-template-columns: 260px 1fr;
|
||||
height: 240px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-small);
|
||||
overflow: hidden;
|
||||
}
|
||||
.modifyBody > .previewBlock {
|
||||
flex: 0 0 38%;
|
||||
min-height: 0;
|
||||
}
|
||||
.modifyBody .sqlPreview {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
max-height: none;
|
||||
}
|
||||
.modifyColumns {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -833,17 +786,13 @@
|
||||
}
|
||||
.modifyProps {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 27%) minmax(0, 1fr);
|
||||
grid-template-columns: max-content 1fr;
|
||||
align-content: start;
|
||||
align-items: center;
|
||||
gap: var(--space-2) var(--space-3);
|
||||
padding: 12px;
|
||||
overflow: auto;
|
||||
}
|
||||
.modifyProps .formLabel {
|
||||
text-align: left;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.quickDoc {
|
||||
width: 460px;
|
||||
max-width: calc(100vw - 32px);
|
||||
@@ -882,6 +831,9 @@
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
.dataView > .fill {
|
||||
min-width: 0;
|
||||
}
|
||||
.headerFilter {
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
@@ -986,8 +938,7 @@
|
||||
flex: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: clamp(160px, 38%, 300px);
|
||||
max-width: 50%;
|
||||
width: 320px;
|
||||
min-height: 0;
|
||||
border-left: 1px solid var(--border);
|
||||
}
|
||||
@@ -1214,42 +1165,29 @@
|
||||
|
||||
/* Export / history / import dialogs. */
|
||||
.exportDialog {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
|
||||
display: flex;
|
||||
gap: var(--space-4);
|
||||
height: min(440px, 65vh);
|
||||
min-height: 340px;
|
||||
padding: var(--space-4);
|
||||
height: 420px;
|
||||
padding: 14px;
|
||||
}
|
||||
.exportOptions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.exportOptions .formRow > input {
|
||||
flex: 1;
|
||||
width: 300px;
|
||||
flex: none;
|
||||
}
|
||||
.exportOptions .formLabel,
|
||||
.exportPreview .formLabel {
|
||||
text-align: left;
|
||||
}
|
||||
.exportPreview {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
@media (max-width: 620px) {
|
||||
.exportDialog {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
height: auto;
|
||||
}
|
||||
.exportPreviewText {
|
||||
height: 200px;
|
||||
flex: none;
|
||||
}
|
||||
}
|
||||
.exportPreviewText,
|
||||
.historyPreview {
|
||||
flex: 1;
|
||||
@@ -1430,7 +1368,6 @@
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1);
|
||||
padding: 4px 8px;
|
||||
background: var(--bg-elev);
|
||||
@@ -1438,8 +1375,8 @@
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.gridSearchField {
|
||||
flex: 0 1 320px;
|
||||
min-width: min(100%, 160px);
|
||||
flex: 0 1 360px;
|
||||
min-width: 160px;
|
||||
}
|
||||
.gridSearchCount {
|
||||
font-family: var(--font-mono);
|
||||
@@ -1459,19 +1396,14 @@
|
||||
background: var(--bg-text-search-result-current);
|
||||
}
|
||||
|
||||
.pagerDock {
|
||||
flex: none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: var(--space-1) var(--space-2) var(--space-2);
|
||||
background: var(--bg-editor);
|
||||
}
|
||||
/* IDEA's floating pager at the bottom of a result: |< < 1-500 of 501+ > >| and the page size. */
|
||||
.resultPager {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: 12px;
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
max-width: 100%;
|
||||
gap: var(--space-0-5);
|
||||
padding: 2px 4px;
|
||||
border: 1px solid var(--border-popup, var(--border));
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
Icon,
|
||||
IconButton,
|
||||
Menu,
|
||||
Toolbar,
|
||||
Tree,
|
||||
showContextMenu,
|
||||
tooltipAttrs,
|
||||
@@ -524,7 +523,6 @@ export function DatabaseView() {
|
||||
return color ? `var(--db-color-${color})` : undefined;
|
||||
}}
|
||||
speedSearchField
|
||||
horizontalScroll
|
||||
renderNode={(n: Node, state) => {
|
||||
const i = icon(n);
|
||||
const d = detail(n);
|
||||
@@ -613,7 +611,7 @@ function DatabaseToolbar() {
|
||||
const active = !!target && [...connected].some((t) => splitTarget(t).id === splitTarget(target).id);
|
||||
const button = { size: "small", iconSize: 16 } as const;
|
||||
return (
|
||||
<Toolbar className={styles.dbToolbar} aria-label="Database actions">
|
||||
<div className={styles.dbToolbar} role="toolbar" aria-label={tx("Database actions")}>
|
||||
<IconButton
|
||||
ref={plus}
|
||||
{...button}
|
||||
@@ -650,7 +648,7 @@ function DatabaseToolbar() {
|
||||
>
|
||||
<T>DDL</T>
|
||||
</button>
|
||||
</Toolbar>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ interface Sel {
|
||||
}
|
||||
|
||||
const ROW_H = 24;
|
||||
const NUM_W = 48;
|
||||
|
||||
/** Wide enough for the whole header (icon, name, filter, sort) and the longest sampled value. */
|
||||
function initialWidth(c: GridColumn, sample: Cell[], decorations: number): number {
|
||||
@@ -168,7 +169,6 @@ export function Grid(props: GridProps) {
|
||||
copyFormat = "tsv",
|
||||
} = props;
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
const numberWidth = Math.max(40, String(firstRowNumber + rowCount - 1).length * 8 + 8);
|
||||
const [sel, setSel] = useState<Sel | null>(null);
|
||||
const dragging = useRef(false);
|
||||
useEffect(() => {
|
||||
@@ -225,8 +225,8 @@ export function Grid(props: GridProps) {
|
||||
const scrollColumnIntoView = (c: number) => {
|
||||
const el = scrollRef.current;
|
||||
if (!el || c < 0 || c >= widths.length) return;
|
||||
const left = c ? numberWidth + widths.slice(0, c).reduce((a, b) => a + b, 0) : 0;
|
||||
const right = numberWidth + widths.slice(0, c + 1).reduce((a, b) => a + b, 0);
|
||||
const left = c ? NUM_W + widths.slice(0, c).reduce((a, b) => a + b, 0) : 0;
|
||||
const right = NUM_W + widths.slice(0, c + 1).reduce((a, b) => a + b, 0);
|
||||
if (left < el.scrollLeft) el.scrollLeft = left;
|
||||
else if (right > el.scrollLeft + el.clientWidth) el.scrollLeft = Math.min(left, right - el.clientWidth);
|
||||
};
|
||||
@@ -252,8 +252,8 @@ export function Grid(props: GridProps) {
|
||||
// Runs once per request.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [revealColumn]);
|
||||
const totalWidth = useMemo(() => numberWidth + widths.reduce((a, b) => a + b, 0), [numberWidth, widths]);
|
||||
const template = `${numberWidth}px ${widths.map((w) => `${w}px`).join(" ")}`;
|
||||
const totalWidth = useMemo(() => NUM_W + widths.reduce((a, b) => a + b, 0), [widths]);
|
||||
const template = `${NUM_W}px ${widths.map((w) => `${w}px`).join(" ")}`;
|
||||
|
||||
const selected = (r: number, c: number) => {
|
||||
if (!sel) return false;
|
||||
|
||||
@@ -577,7 +577,7 @@ export function Result({ tab, onClose }: { tab: ResultTab; onClose?: () => void
|
||||
{notice}
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.fill}>
|
||||
<div className={clsx(styles.fill, styles.gridHost)}>
|
||||
<DataView
|
||||
columns={gridColumns}
|
||||
rowCount={rowCount}
|
||||
@@ -590,7 +590,6 @@ export function Result({ tab, onClose }: { tab: ResultTab; onClose?: () => void
|
||||
searchOpen={searchOpen}
|
||||
onSearchOpenChange={setSearchOpen}
|
||||
firstRowNumber={(tab.page ?? 0) * (tab.pageSize ?? 0) + 1}
|
||||
pager={<Pager tab={busy ? { ...tab, busy: true } : tab} />}
|
||||
aria-label={tab.title}
|
||||
rowState={(row) => (row >= loaded ? "inserted" : edits.deletes.has(row) ? "deleted" : null)}
|
||||
isModified={(row, col) => !!edits.updates.get(row)?.has(resultNames[col]!)}
|
||||
@@ -612,6 +611,7 @@ export function Result({ tab, onClose }: { tab: ResultTab; onClose?: () => void
|
||||
: []
|
||||
}
|
||||
/>
|
||||
<Pager tab={busy ? { ...tab, busy: true } : tab} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
@@ -817,7 +817,7 @@ export function ResultsView() {
|
||||
...results.map((r) => ({
|
||||
id: String(r.id),
|
||||
label: r.title,
|
||||
icon: r.plan ? "db-plan" : "db-table",
|
||||
icon: r.plan ? "db-plan" : "database",
|
||||
closable: true,
|
||||
pinned: r.pinned,
|
||||
tooltip: r.outcome.statement.text,
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
height: clamp(350px, 68vh, 620px);
|
||||
padding: var(--space-4);
|
||||
height: 560px;
|
||||
padding: 14px;
|
||||
}
|
||||
.pickers {
|
||||
display: flex;
|
||||
@@ -35,8 +35,7 @@
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.panes {
|
||||
display: grid;
|
||||
grid-template-rows: minmax(0, 5fr) minmax(0, 4fr);
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
@@ -44,6 +43,7 @@
|
||||
.tree {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1.2;
|
||||
min-width: 0;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-control);
|
||||
@@ -54,19 +54,8 @@
|
||||
min-height: 0;
|
||||
}
|
||||
.preview {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
.previewLabel {
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.preview > :last-child {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.row {
|
||||
display: inline-flex;
|
||||
|
||||
@@ -328,12 +328,7 @@ export function SchemaCompareDialog({ initial }: { initial: Side | null }) {
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.preview}>
|
||||
<span className={styles.previewLabel}>
|
||||
<T>Migration script</T>
|
||||
</span>
|
||||
<CodePreview sql aria-label="Migration script" text={sql} />
|
||||
</div>
|
||||
<CodePreview sql className={styles.preview} aria-label="Migration script" text={sql} />
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
@@ -1404,7 +1404,7 @@ export function SourceDialog({
|
||||
open
|
||||
onClose={closeDialog}
|
||||
title={initial ? tx`Data Source: ${initial.name}` : "New Data Source"}
|
||||
width={760}
|
||||
width={640}
|
||||
footerStart={
|
||||
<Button onClick={() => void runTest()} disabled={busy || !valid}>
|
||||
<T>Test Connection</T>
|
||||
@@ -1415,76 +1415,74 @@ export function SourceDialog({
|
||||
{ label: "OK", role: "default", disabled: busy || !valid, onClick: () => void save() },
|
||||
]}
|
||||
>
|
||||
<div className={styles.sourceLayout}>
|
||||
<div className={styles.form}>
|
||||
<label className={styles.formLabel} htmlFor="db-name">
|
||||
<T>Name:</T>
|
||||
</label>
|
||||
<div className={styles.formRow}>
|
||||
<Input
|
||||
id="db-name"
|
||||
className={styles.fill}
|
||||
value={s.name ?? ""}
|
||||
placeholder={name}
|
||||
onChange={(e) => set({ name: e.target.value })}
|
||||
<div className={styles.form}>
|
||||
<label className={styles.formLabel} htmlFor="db-name">
|
||||
<T>Name:</T>
|
||||
</label>
|
||||
<div className={styles.formRow}>
|
||||
<Input
|
||||
id="db-name"
|
||||
className={styles.fill}
|
||||
value={s.name ?? ""}
|
||||
placeholder={name}
|
||||
onChange={(e) => set({ name: e.target.value })}
|
||||
/>
|
||||
<span className={styles.formLabel}>
|
||||
<T>Color:</T>
|
||||
</span>
|
||||
<Select
|
||||
aria-label="Color"
|
||||
className={styles.narrowSelect}
|
||||
value={s.color ?? "none"}
|
||||
options={COLORS}
|
||||
onChange={(c) => set({ color: c === "none" ? null : c })}
|
||||
renderValue={(o) => (
|
||||
<span className={styles.colorValue}>
|
||||
{o && o.value !== "none" && (
|
||||
<span className={styles.colorSwatch} style={{ background: colorVar(o.value as DbColor) }} />
|
||||
)}
|
||||
<T>{o?.label ?? "No color"}</T>
|
||||
</span>
|
||||
)}
|
||||
/>
|
||||
{/* IDEA's Make Global: stored with the IDE and listed in every project. */}
|
||||
<span title={tx("Available in all projects")}>
|
||||
<Checkbox
|
||||
checked={!!s.global}
|
||||
disabled={!!s.pluginOwner}
|
||||
onChange={(global) => set({ global })}
|
||||
label="Global"
|
||||
/>
|
||||
<span className={styles.formLabel}>
|
||||
<T>Color:</T>
|
||||
</span>
|
||||
<Select
|
||||
aria-label="Color"
|
||||
className={styles.narrowSelect}
|
||||
value={s.color ?? "none"}
|
||||
options={COLORS}
|
||||
onChange={(c) => set({ color: c === "none" ? null : c })}
|
||||
renderValue={(o) => (
|
||||
<span className={styles.colorValue}>
|
||||
{o && o.value !== "none" && (
|
||||
<span className={styles.colorSwatch} style={{ background: colorVar(o.value as DbColor) }} />
|
||||
)}
|
||||
<T>{o?.label ?? "No color"}</T>
|
||||
</span>
|
||||
)}
|
||||
/>
|
||||
{/* IDEA's Make Global: stored with the IDE and listed in every project. */}
|
||||
<span title={tx("Available in all projects")}>
|
||||
<Checkbox
|
||||
checked={!!s.global}
|
||||
disabled={!!s.pluginOwner}
|
||||
onChange={(global) => set({ global })}
|
||||
label="Global"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<span />
|
||||
{showComment ? (
|
||||
<textarea
|
||||
className={styles.textArea}
|
||||
aria-label={tx("Comment")}
|
||||
autoFocus={!s.comment}
|
||||
rows={2}
|
||||
value={s.comment ?? ""}
|
||||
placeholder={tx("Comment")}
|
||||
onChange={(e) => set({ comment: e.target.value })}
|
||||
/>
|
||||
) : (
|
||||
<button type="button" className={styles.linkButton} onClick={() => setShowComment(true)}>
|
||||
<T>Add comment</T>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<Tabs
|
||||
variant="compact"
|
||||
className={styles.dialogTabs}
|
||||
activeId={current}
|
||||
onSelect={(id) => setTab(id as Tab)}
|
||||
aria-label="Data source settings"
|
||||
panelIdPrefix="db-source"
|
||||
items={tabs}
|
||||
/>
|
||||
<div className={`${styles.form} ${styles.sourcePanel}`} role="tabpanel" id={`db-source-panel-${current}`}>
|
||||
{body[current]}
|
||||
</span>
|
||||
</div>
|
||||
<span />
|
||||
{showComment ? (
|
||||
<textarea
|
||||
className={styles.textArea}
|
||||
aria-label={tx("Comment")}
|
||||
autoFocus={!s.comment}
|
||||
rows={2}
|
||||
value={s.comment ?? ""}
|
||||
placeholder={tx("Comment")}
|
||||
onChange={(e) => set({ comment: e.target.value })}
|
||||
/>
|
||||
) : (
|
||||
<button type="button" className={styles.linkButton} onClick={() => setShowComment(true)}>
|
||||
<T>Add comment</T>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<Tabs
|
||||
variant="compact"
|
||||
className={styles.dialogTabs}
|
||||
activeId={current}
|
||||
onSelect={(id) => setTab(id as Tab)}
|
||||
aria-label="Data source settings"
|
||||
panelIdPrefix="db-source"
|
||||
items={tabs}
|
||||
/>
|
||||
<div className={styles.form} role="tabpanel" id={`db-source-panel-${current}`}>
|
||||
{body[current]}
|
||||
<div className={`${styles.testResult} ${test?.ok ? styles.ok : styles.bad}`} role="status">
|
||||
{busy && !test ? tx("Connecting…") : test?.text}
|
||||
{test?.trust && (
|
||||
|
||||
@@ -101,6 +101,7 @@ export function SqlFilterInput({
|
||||
variant="bare"
|
||||
mono
|
||||
aria-label={kind === "where" ? "WHERE filter" : "ORDER BY"}
|
||||
placeholder={kind === "where" ? "WHERE" : "ORDER BY"}
|
||||
invalid={invalid}
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
type DbTablePage,
|
||||
type RequestId,
|
||||
} from "@/platform/ipc";
|
||||
import { EmptyState, Icon, IconButton, Select, Spinner, Toolbar, showContextMenu } from "@/ui";
|
||||
import { Button, EmptyState, Icon, IconButton, Select, Spinner, T, showContextMenu, tooltipAttrs } from "@/ui";
|
||||
import { notifications, type EditorInput } from "@/workbench/contributions";
|
||||
import { SqlFilterInput } from "./SqlFilterInput";
|
||||
import { ColumnsPopup } from "./ColumnsPopup";
|
||||
@@ -35,7 +35,6 @@ import styles from "./Database.module.css";
|
||||
import { registerTableEditor, tableEditorChanged, type TableEditorHandle } from "./tableEditorFocus";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { pageWindow } from "./resultView";
|
||||
|
||||
const PAGE_SIZES = ["100", "500", "1000", "5000"];
|
||||
|
||||
@@ -284,18 +283,9 @@ export function TableEditor({ input }: { input: EditorInput }) {
|
||||
useEffect(() => registerTableEditor(viewRef.current!, handle), [handle]);
|
||||
useEffect(() => tableEditorChanged(handle), [handle, dirty, editable]);
|
||||
const orderInvalid = orderDraft !== null && !parseOrderBy(orderDraft, names);
|
||||
const hasMore = page?.result.hasMore ?? false;
|
||||
const { first, last, total } = pageWindow({
|
||||
page: offset / limit,
|
||||
pageSize: limit,
|
||||
rows: loaded,
|
||||
hasMore,
|
||||
total: null,
|
||||
});
|
||||
const singlePage = offset === 0 && !hasMore;
|
||||
return (
|
||||
<div className={styles.view} ref={viewRef} data-db-table-editor="">
|
||||
<Toolbar className={styles.toolbar} aria-label="Table actions">
|
||||
<div className={styles.toolbar}>
|
||||
<IconButton
|
||||
icon="refresh"
|
||||
title="Reload Page"
|
||||
@@ -303,31 +293,55 @@ export function TableEditor({ input }: { input: EditorInput }) {
|
||||
onClick={reload}
|
||||
disabled={loading}
|
||||
/>
|
||||
<IconButton
|
||||
icon="search"
|
||||
title="Search"
|
||||
shortcut={shortcutLabel("find.inFile")}
|
||||
aria-pressed={searchOpen}
|
||||
onClick={() => setSearchOpen(!searchOpen)}
|
||||
/>
|
||||
<div className={styles.pager}>
|
||||
<IconButton
|
||||
icon="chevron-left"
|
||||
title="Previous Page"
|
||||
shortcut={shortcutLabel("db.previousPage")}
|
||||
disabled={!canPrevious}
|
||||
onClick={() => setOffset(Math.max(0, offset - limit))}
|
||||
/>
|
||||
<span>
|
||||
{loaded ? `${offset + 1}–${offset + loaded}` : "0"}
|
||||
{page?.result.hasMore ? " of more" : ""}
|
||||
</span>
|
||||
<IconButton
|
||||
icon="chevron-right"
|
||||
title="Next Page"
|
||||
shortcut={shortcutLabel("db.nextPage")}
|
||||
disabled={!canNext}
|
||||
onClick={() => setOffset(offset + limit)}
|
||||
/>
|
||||
<Select
|
||||
aria-label="Page size"
|
||||
value={String(limit)}
|
||||
options={PAGE_SIZES.map((v) => ({ value: v, label: v }))}
|
||||
onChange={(v) => {
|
||||
setOffset(0);
|
||||
setLimit(Number(v));
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{editable && (
|
||||
<>
|
||||
<span className={styles.toolbarSeparator} />
|
||||
<IconButton icon="plus" title="Add Row" shortcut={shortcutLabel("db.addRow")} onClick={addRow} />
|
||||
<IconButton
|
||||
icon="revert"
|
||||
title="Revert"
|
||||
shortcut={shortcutLabel("db.revertChanges")}
|
||||
disabled={!dirty}
|
||||
onClick={() => setEdits(emptyEdits())}
|
||||
/>
|
||||
<IconButton
|
||||
icon="arrow-up"
|
||||
title="Submit"
|
||||
shortcut={shortcutLabel("db.submitChanges")}
|
||||
<Button
|
||||
size="small"
|
||||
variant="primary"
|
||||
disabled={!dirty}
|
||||
onClick={() => void submit()}
|
||||
/>
|
||||
{...tooltipAttrs("Submit", shortcutLabel("db.submitChanges"))}
|
||||
>
|
||||
<T>Submit</T>
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
disabled={!dirty}
|
||||
onClick={() => setEdits(emptyEdits())}
|
||||
{...tooltipAttrs("Revert", shortcutLabel("db.revertChanges"))}
|
||||
>
|
||||
<T>Revert</T>
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{loading && <Spinner size={12} />}
|
||||
@@ -347,12 +361,18 @@ export function TableEditor({ input }: { input: EditorInput }) {
|
||||
disabled={!editable}
|
||||
onClick={() => openDialog({ kind: "import", id: ref.id, schema: ref.schema, table: ref.table })}
|
||||
/>
|
||||
<IconButton
|
||||
icon="search"
|
||||
title="Search"
|
||||
shortcut={shortcutLabel("find.inFile")}
|
||||
aria-pressed={searchOpen}
|
||||
onClick={() => setSearchOpen(!searchOpen)}
|
||||
/>
|
||||
<PanelToggle panel={panel} onChange={setPanel} />
|
||||
</Toolbar>
|
||||
</div>
|
||||
<div className={styles.filterBar}>
|
||||
<label className={styles.filterField}>
|
||||
<Icon name="filter" size={14} />
|
||||
<span aria-hidden="true">WHERE</span>
|
||||
<SqlFilterInput
|
||||
kind="where"
|
||||
schema={ref.schema}
|
||||
@@ -371,7 +391,6 @@ export function TableEditor({ input }: { input: EditorInput }) {
|
||||
</label>
|
||||
<label className={styles.filterField}>
|
||||
<Icon name="db-sort" size={14} />
|
||||
<span aria-hidden="true">ORDER BY</span>
|
||||
<SqlFilterInput
|
||||
kind="order"
|
||||
schema={ref.schema}
|
||||
@@ -432,44 +451,6 @@ export function TableEditor({ input }: { input: EditorInput }) {
|
||||
driver={source?.driver}
|
||||
sort={sort}
|
||||
onSort={onSort}
|
||||
pager={
|
||||
<Toolbar className={styles.resultPager} aria-label="Table pages">
|
||||
{!singlePage && (
|
||||
<>
|
||||
<IconButton
|
||||
size="small"
|
||||
icon="chevron-left"
|
||||
title="Previous Page"
|
||||
shortcut={shortcutLabel("db.previousPage")}
|
||||
disabled={!canPrevious}
|
||||
onClick={() => setOffset(Math.max(0, offset - limit))}
|
||||
/>
|
||||
<span className={styles.resultPagerRange}>
|
||||
{loaded ? tx`${first}-${last} of ${total ?? `${last + 1}+`}` : tx`${loaded} rows`}
|
||||
</span>
|
||||
<IconButton
|
||||
size="small"
|
||||
icon="chevron-right"
|
||||
title="Next Page"
|
||||
shortcut={shortcutLabel("db.nextPage")}
|
||||
disabled={!canNext}
|
||||
onClick={() => setOffset(offset + limit)}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Page size"
|
||||
value={String(limit)}
|
||||
options={PAGE_SIZES.map((v) => ({ value: v, label: v }))}
|
||||
renderValue={singlePage ? () => tx`${loaded} rows` : undefined}
|
||||
onChange={(v) => {
|
||||
setOffset(0);
|
||||
setLimit(Number(v));
|
||||
}}
|
||||
/>
|
||||
</Toolbar>
|
||||
}
|
||||
rowMenu={(rows) =>
|
||||
editable
|
||||
? [
|
||||
|
||||
@@ -45,9 +45,9 @@ import type { EditorDocContext } from "@/editor/api";
|
||||
import { iconNode } from "@/ui/iconNode";
|
||||
import { call, commands, type DbDriver, type DbSessionContext, type DbStatementOutcome } from "@/platform/ipc";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { Icon, IconButton, Select, Toolbar, lazyComponent } from "@/ui";
|
||||
import { IconButton, Select, lazyComponent } from "@/ui";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { activeSchema, schemaSwitchable, sourceIcon, sourceLabel, splitTarget, targetOf } from "./model";
|
||||
import { activeSchema, schemaSwitchable, sourceLabel, splitTarget, targetOf } from "./model";
|
||||
import { loadSavedCatalog, offerIntrospection } from "./introspection";
|
||||
import { analyze, templateContexts, valuesSlot } from "./sql/analyze";
|
||||
import {
|
||||
@@ -477,11 +477,10 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
// SQL resolution scopes in the settings can move the console to another data source.
|
||||
useProject((s) => s.settings);
|
||||
const boundId = bound ? splitTarget(bound).id : null;
|
||||
const driver = sources.find((s) => s.id === boundId)?.driver;
|
||||
const jdbc = driver === "jdbc";
|
||||
const supportsTransactions = driver !== "clickhouse" && !jdbc;
|
||||
const sqlServer = driver === "sqlServer";
|
||||
const switchable = schemaSwitchable(driver);
|
||||
const jdbc = sourceById(boundId)?.driver === "jdbc";
|
||||
const supportsTransactions = sourceById(boundId)?.driver !== "clickhouse" && !jdbc;
|
||||
const sqlServer = sourceById(boundId)?.driver === "sqlServer";
|
||||
const switchable = schemaSwitchable(sourceById(boundId)?.driver);
|
||||
// The console's active schema: its pick, else the connection's default (`completion.defaultSchema`).
|
||||
const pickedSchema = useDatabase((s) => s.consoleSchemas[path]);
|
||||
const defaultSchema = useDatabase((s) => (bound ? s.completion[bound]?.defaultSchema : undefined));
|
||||
@@ -504,10 +503,9 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
: schemaList?.status === "ok"
|
||||
? schemaList.value
|
||||
: [];
|
||||
const out = names.map((n) => ({ value: n, label: n, icon: "db-schema" }));
|
||||
const out = names.map((n) => ({ value: n, label: n }));
|
||||
// The connection's default is offered even before its schema list loads.
|
||||
if (defaultSchema && !names.includes(defaultSchema))
|
||||
out.unshift({ value: defaultSchema, label: defaultSchema, icon: "db-schema" });
|
||||
if (defaultSchema && !names.includes(defaultSchema)) out.unshift({ value: defaultSchema, label: defaultSchema });
|
||||
return out;
|
||||
}, [switchable, schemaList, defaultSchema, sqlServer, boundId, databases]);
|
||||
const targets = useMemo(() => {
|
||||
@@ -522,9 +520,9 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
value: targetOf(id, name, dbs.value.current),
|
||||
label: `${s.name ?? ""}: ${name}`,
|
||||
detail: host,
|
||||
icon: sourceIcon(s),
|
||||
icon: "database",
|
||||
});
|
||||
} else out.push({ value: id, label: s.name ?? "", detail: host, icon: sourceIcon(s) });
|
||||
} else out.push({ value: id, label: s.name ?? "", detail: host, icon: "db-schema" });
|
||||
}
|
||||
// A console bound to a database whose list is not loaded yet still shows it.
|
||||
if (bound && !out.some((o) => o.value === bound))
|
||||
@@ -538,7 +536,7 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
if (bound) void loadCompletion(bound);
|
||||
}, [bound]);
|
||||
return (
|
||||
<Toolbar className={styles.consoleBar} aria-label="Query Console">
|
||||
<div className={styles.consoleBar}>
|
||||
<IconButton
|
||||
icon="run"
|
||||
title="Execute"
|
||||
@@ -552,8 +550,6 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
disabled={!bound || running}
|
||||
onClick={() => void executeScriptInView(view, path)}
|
||||
/>
|
||||
<span className={styles.toolbarSeparator} />
|
||||
<IconButton icon="history" title="Browse Query History" disabled={!bound} onClick={() => openHistory(path)} />
|
||||
{!jdbc && (
|
||||
<IconButton
|
||||
icon="db-plan"
|
||||
@@ -562,6 +558,14 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
onClick={() => void explainInView(view, path)}
|
||||
/>
|
||||
)}
|
||||
<IconButton
|
||||
icon="stop"
|
||||
title="Cancel Running Statement"
|
||||
disabled={!running}
|
||||
onClick={() => cancelConsole(path)}
|
||||
/>
|
||||
<span className={styles.toolbarSeparator} />
|
||||
<IconButton icon="history" title="Browse Query History" disabled={!bound} onClick={() => openHistory(path)} />
|
||||
<IconButton
|
||||
icon="db-in-editor-results"
|
||||
title="In-Editor Results"
|
||||
@@ -569,18 +573,28 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
onClick={() => void setInEditorResults(!inEditor)}
|
||||
/>
|
||||
<span className={styles.toolbarSeparator} />
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Row limit"
|
||||
value={String(maxRows)}
|
||||
options={ROW_LIMITS.map((v) => ({ value: v, label: tx`${Number(v).toLocaleString("en")} rows` }))}
|
||||
onChange={(v) => useDatabase.setState({ maxRows: Number(v) })}
|
||||
/>
|
||||
{supportsTransactions && (
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Transaction mode"
|
||||
value={manual ? "manual" : "auto"}
|
||||
options={[
|
||||
{ value: "auto", label: "Tx: Auto" },
|
||||
{ value: "manual", label: "Tx: Manual" },
|
||||
]}
|
||||
onChange={(v) => bound && void setManualCommit(bound, v === "manual")}
|
||||
disabled={!bound}
|
||||
/>
|
||||
<>
|
||||
<span className={styles.toolbarSeparator} />
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Transaction mode"
|
||||
value={manual ? "manual" : "auto"}
|
||||
options={[
|
||||
{ value: "auto", label: "Tx: Auto" },
|
||||
{ value: "manual", label: "Tx: Manual" },
|
||||
]}
|
||||
onChange={(v) => bound && void setManualCommit(bound, v === "manual")}
|
||||
disabled={!bound}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{supportsTransactions && manual && (
|
||||
<>
|
||||
@@ -598,31 +612,8 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<IconButton
|
||||
icon="stop"
|
||||
title="Cancel Running Statement"
|
||||
disabled={!running}
|
||||
onClick={() => cancelConsole(path)}
|
||||
/>
|
||||
<span className={styles.toolbarSeparator} />
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Row limit"
|
||||
value={String(maxRows)}
|
||||
options={ROW_LIMITS.map((v) => ({ value: v, label: tx`${Number(v).toLocaleString("en")} rows` }))}
|
||||
onChange={(v) => useDatabase.setState({ maxRows: Number(v) })}
|
||||
/>
|
||||
<span className={styles.spacer} />
|
||||
{bound && driver === "snowflake" && <SnowflakeSession target={bound} idle={!running} />}
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Data source"
|
||||
value={bound ?? null}
|
||||
placeholder={sources.length ? "<data source>" : "None configured"}
|
||||
options={targets}
|
||||
onChange={(id) => bindConsole(path, id)}
|
||||
disabled={!sources.length}
|
||||
/>
|
||||
{bound && sourceById(boundId)?.driver === "snowflake" && <SnowflakeSession target={bound} idle={!running} />}
|
||||
{switchable && (
|
||||
<Select
|
||||
variant="ghost"
|
||||
@@ -635,13 +626,16 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
disabled={!bound}
|
||||
/>
|
||||
)}
|
||||
{driver === "sqlite" && (
|
||||
<span className={styles.consoleSchema} title={tx("Schema")}>
|
||||
<Icon name="db-schema" size={14} />
|
||||
{schema || "main"}
|
||||
</span>
|
||||
)}
|
||||
</Toolbar>
|
||||
<Select
|
||||
variant="ghost"
|
||||
aria-label="Data source"
|
||||
value={bound ?? null}
|
||||
placeholder={sources.length ? "<data source>" : "None configured"}
|
||||
options={targets}
|
||||
onChange={(id) => bindConsole(path, id)}
|
||||
disabled={!sources.length}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import {
|
||||
DB_TOOL_WINDOW,
|
||||
RESULTS_VIEW,
|
||||
consoleSource,
|
||||
consoleDecorations,
|
||||
consoleTints,
|
||||
inEditorResults,
|
||||
setInEditorResults,
|
||||
loadSources,
|
||||
@@ -161,9 +161,9 @@ export function activate(): () => void {
|
||||
newMenuOpen: false,
|
||||
});
|
||||
}),
|
||||
// Consoles of coloured data sources get a tinted tab.
|
||||
useDatabase.subscribe((s, prev) => {
|
||||
if (s.consoles !== prev.consoles || s.sources !== prev.sources)
|
||||
setFileDecorations("database", consoleDecorations(s));
|
||||
if (s.consoles !== prev.consoles || s.sources !== prev.sources) setFileDecorations("database", consoleTints(s));
|
||||
}),
|
||||
() => setFileDecorations("database", new Map()),
|
||||
watchIdleConnections(),
|
||||
|
||||
@@ -45,7 +45,6 @@ import {
|
||||
effectiveSsh,
|
||||
idleTargets,
|
||||
newSourceId,
|
||||
sourceIcon,
|
||||
splitTarget,
|
||||
targetOf,
|
||||
} from "./model";
|
||||
@@ -602,21 +601,13 @@ export function watchIdleConnections(everyMs = 5000): () => void {
|
||||
return () => clearInterval(timer);
|
||||
}
|
||||
|
||||
/** Managed consoles show their source in the tab. Ordinary SQL files can also inherit a source tint. */
|
||||
export function consoleDecorations(s: Pick<DatabaseState, "consoles" | "sources">): Map<string, FileDecoration> {
|
||||
/** Console files of coloured data sources, tinted like IDEA's (file decorations). */
|
||||
export function consoleTints(s: Pick<DatabaseState, "consoles" | "sources">): Map<string, FileDecoration> {
|
||||
const out = new Map<string, FileDecoration>();
|
||||
for (const [path, target] of Object.entries(s.consoles)) {
|
||||
const { id, database } = splitTarget(target);
|
||||
const source = s.sources.find((x) => x.id === id);
|
||||
if (!source) continue;
|
||||
const tint = colorVar(source.color);
|
||||
// db_console_path and db_consoles own this directory, including already saved consoles.
|
||||
const consoleName = /(?:^|\/)consoles\/db\/[^/]+\/(console(?:_\d+)?)\.sql$/.exec(path.replaceAll("\\", "/"))?.[1];
|
||||
if (consoleName) {
|
||||
const name = source.name || id;
|
||||
const label = database ? `${name}: ${database}` : name;
|
||||
out.set(path, { tint, tabTitle: `${consoleName} [${label}]`, tabIcon: sourceIcon(source) });
|
||||
} else if (tint) out.set(path, { tint });
|
||||
const id = splitTarget(target).id;
|
||||
const tint = colorVar(s.sources.find((x) => x.id === id)?.color);
|
||||
if (tint) out.set(path, { tint });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
type TreeReorder,
|
||||
} from "@/ui";
|
||||
import {
|
||||
SERVICES_WINDOW,
|
||||
useServiceProviders,
|
||||
useToolWindowShown,
|
||||
serviceProviders,
|
||||
@@ -31,7 +30,6 @@ import {
|
||||
type ServiceTreeItem,
|
||||
type ServiceItemAction,
|
||||
} from "@/workbench/contributions";
|
||||
import { useToolWindowLayout } from "@/workbench/toolwindows/store";
|
||||
import {
|
||||
addServiceMenu,
|
||||
clearProviderRoots,
|
||||
@@ -90,9 +88,6 @@ export function ServicesTreeView() {
|
||||
const selectedKey = useServicesTree((s) => s.selectedKey);
|
||||
const selectedKeys = useServicesTree((s) => s.selectedKeys);
|
||||
const expanded = useServicesTree((s) => s.expanded);
|
||||
const anchor = useToolWindowLayout((s) => s.placements[SERVICES_WINDOW]?.anchor ?? "bottom");
|
||||
const sideDocked = anchor !== "bottom";
|
||||
const orientation = sideDocked ? "vertical" : "horizontal";
|
||||
const addRef = useRef<HTMLButtonElement>(null);
|
||||
const filterRef = useRef<HTMLButtonElement>(null);
|
||||
|
||||
@@ -224,13 +219,8 @@ export function ServicesTreeView() {
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<SplitGroup
|
||||
key={orientation}
|
||||
orientation={orientation}
|
||||
className={styles.split}
|
||||
storageKey={sideDocked ? "openidea.services.detailSplit.vertical" : "openidea.services.detailSplit"}
|
||||
>
|
||||
<SplitPanel id="services-items" defaultSize="30%" minSize={sideDocked ? "80px" : "160px"}>
|
||||
<SplitGroup orientation="horizontal" className={styles.split} storageKey="openidea.services.detailSplit">
|
||||
<SplitPanel id="services-items" defaultSize="40%" minSize="160px">
|
||||
<div className={styles.tree}>
|
||||
<Tree<ServiceTreeItem>
|
||||
key={location}
|
||||
@@ -284,7 +274,7 @@ export function ServicesTreeView() {
|
||||
<SplitHandle />
|
||||
<SplitPanel
|
||||
id="services-detail"
|
||||
minSize={sideDocked ? "120px" : "200px"}
|
||||
minSize="200px"
|
||||
// The panel library puts `overflow: auto` inline; the detail content
|
||||
// (a console, a log) owns its scrolling, so the pane must not add a second
|
||||
// bar. A column flex box lets that content fill the pane.
|
||||
|
||||
@@ -47,22 +47,9 @@
|
||||
}
|
||||
}
|
||||
@container diff-editor (max-width: 380px) {
|
||||
.toolbar {
|
||||
height: auto;
|
||||
min-height: var(--h-header);
|
||||
flex-wrap: wrap;
|
||||
align-content: center;
|
||||
padding-block: var(--space-0-5);
|
||||
}
|
||||
.toolbar > .sep,
|
||||
.toolbar > .inlineOption {
|
||||
.toolbar > .sep {
|
||||
display: none;
|
||||
}
|
||||
.toolbar > .count {
|
||||
flex: 1 1 auto;
|
||||
order: 1;
|
||||
text-align: end;
|
||||
}
|
||||
}
|
||||
.labels {
|
||||
flex: none;
|
||||
|
||||
@@ -1447,7 +1447,6 @@ export function DiffEditor({
|
||||
{canSwap && <IconButton icon="swap-panels" title="Swap Sides" size="small" onClick={() => void swapSides()} />}
|
||||
<IconButton
|
||||
icon="diff-side-by-side"
|
||||
className={styles.inlineOption}
|
||||
title="Side-by-side Viewer"
|
||||
size="small"
|
||||
pressed={viewMode === "split"}
|
||||
@@ -1456,7 +1455,6 @@ export function DiffEditor({
|
||||
/>
|
||||
<IconButton
|
||||
icon="diff-unified"
|
||||
className={styles.inlineOption}
|
||||
title="Unified Viewer"
|
||||
size="small"
|
||||
pressed={viewMode === "unified"}
|
||||
@@ -1480,7 +1478,6 @@ export function DiffEditor({
|
||||
/>
|
||||
<IconButton
|
||||
icon="collapse-all"
|
||||
className={styles.inlineOption}
|
||||
title="Collapse Unchanged Fragments"
|
||||
size="small"
|
||||
pressed={opts.collapse}
|
||||
@@ -1489,7 +1486,6 @@ export function DiffEditor({
|
||||
{viewMode === "split" && (
|
||||
<IconButton
|
||||
icon="lock"
|
||||
className={styles.inlineOption}
|
||||
title="Synchronize Scrolling"
|
||||
size="small"
|
||||
pressed={opts.syncScroll}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{
|
||||
"Table actions": "Table actions",
|
||||
"Table pages": "Table pages",
|
||||
"Problems actions": "Problems actions",
|
||||
"TODO actions": "TODO actions",
|
||||
"Same as the existing configuration '{existing}'": "Same as the existing configuration '{existing}'",
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{
|
||||
"Table actions": "表数据操作",
|
||||
"Table pages": "表数据分页",
|
||||
"Problems actions": "问题操作",
|
||||
"Windows file and folder names cannot end with a period or space": "Windows 文件和文件夹名称不能以句点或空格结尾",
|
||||
"Use URL template": "使用 URL 模板",
|
||||
|
||||
@@ -1063,9 +1063,6 @@ export interface FileDecoration {
|
||||
suffixColor?: string;
|
||||
/** CSS colour tinting the editor tab (a data source's colour on its console). */
|
||||
tint?: string;
|
||||
/** Display name and icon for a specialized file tab. The path still identifies the document. */
|
||||
tabTitle?: string;
|
||||
tabIcon?: string;
|
||||
/** Short badge text, e.g. a problem count. */
|
||||
badge?: string;
|
||||
tooltip?: string;
|
||||
|
||||
Reference in new issue
Заблокувати користувача