feat(data-grid): color cells by database-aware types

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-08-13 02:10:37 +08:00
1 parent 0b5c0bdcc0
commit 433626f5c9
25 files changed
+619 -46

No files matched your search

@@ -0,0 +1,105 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
import { resolveDataGridCellTextRole } from "@/lib/dataGrid/dataGridCellTextVisual";
import { resolveDataGridTypeVisualKind, resolveHeaderColumnType, type DataGridTypeVisualKind } from "@/lib/dataGrid/dataGridColumnType";
const dataGridSource = readFileSync(new URL("../../../components/grid/DataGrid.vue", import.meta.url), "utf8");
const globalStylesSource = readFileSync(new URL("../../../styles/globals.css", import.meta.url), "utf8");
describe("data grid type visual kind", () => {
it.each<[string, DataGridTypeVisualKind]>([
["BIGINT", "integer"],
["Nullable(UInt64)", "integer"],
["DECIMAL(18, 4)", "numeric"],
["DOUBLE PRECISION", "numeric"],
["character varying(255)", "string"],
["BOOLEAN", "boolean"],
["timestamp with time zone", "temporal"],
["JSONB", "structured"],
["Array(Nullable(UInt64))", "structured"],
["text[]", "structured"],
["_int4", "structured"],
["_text", "structured"],
["_jsonb", "structured"],
["_uuid", "structured"],
["UUID", "identifier"],
["BYTEA", "binary"],
["SDO_GEOMETRY", "spatial"],
["inet", "unknown"],
])("maps %s to %s", (dataType, expected) => {
expect(resolveDataGridTypeVisualKind(dataType)).toBe(expected);
});
it("keeps an absent type neutral", () => {
expect(resolveDataGridTypeVisualKind(undefined)).toBe("unknown");
expect(resolveDataGridTypeVisualKind(" ")).toBe("unknown");
});
it.each([
["timestamp", "sqlserver", "binary"],
["rowversion", "sqlserver", "binary"],
["bit(8)", "postgres", "binary"],
["bit varying(8)", "postgres", "binary"],
] as const)("maps %s for %s to %s", (dataType, databaseType, expected) => {
expect(resolveDataGridTypeVisualKind(dataType, databaseType)).toBe(expected);
});
it("keeps ambiguous types on their generic defaults without a matching dialect", () => {
expect(resolveDataGridTypeVisualKind("timestamp")).toBe("temporal");
expect(resolveDataGridTypeVisualKind("timestamp", "postgres")).toBe("temporal");
expect(resolveDataGridTypeVisualKind("bit")).toBe("boolean");
expect(resolveDataGridTypeVisualKind("bit", "sqlserver")).toBe("boolean");
});
});
describe("data grid header type color", () => {
it("uses the displayed metadata type for the standard header color", () => {
const displayedType = resolveHeaderColumnType({
tableColumnType: "decimal(10,2)",
resultColumnTypes: ["text"],
actualColIdx: 0,
});
expect(displayedType).toBe("decimal(10,2)");
expect(resolveDataGridTypeVisualKind(displayedType)).toBe("numeric");
expect(dataGridSource).toContain(':type-class="typeColorClass(headerColumnType(col.name, col.actualColIdx))"');
expect(dataGridSource).not.toContain("typeColorClass(allColumnTypes[col.actualColIdx]");
});
});
describe("data grid cell text visual priority", () => {
const ordinaryInteger = {
colorizeTypes: true,
typeKind: "integer" as const,
};
it("uses a type color only for an ordinary typed value", () => {
expect(resolveDataGridCellTextRole(ordinaryInteger)).toBe("type");
});
it.each([{ colorizeTypes: false }, { typeKind: "unknown" as const }, { isEditing: true }, { isControl: true }, { isSelected: true }, { isCurrentSearchMatch: true }, { isSearchMatch: true }, { isDirty: true }, { isDeleted: true }])("keeps interaction state visually dominant for %o", (override) => {
expect(resolveDataGridCellTextRole({ ...ordinaryInteger, ...override })).toBe("neutral");
});
it.each([{ isNull: true }, { isDraft: true }, { isNull: true, isSelected: true }])("keeps null and draft placeholders muted for %o", (override) => {
expect(resolveDataGridCellTextRole({ ...ordinaryInteger, ...override })).toBe("muted");
});
it("uses a neutral foreground on editable DOM hover surfaces", () => {
expect(dataGridSource).toContain("'hover:bg-gray-200 hover:text-foreground dark:hover:bg-gray-800':");
expect(dataGridSource).toContain("'cursor-text hover:bg-gray-200 hover:text-foreground dark:hover:bg-gray-800':");
});
it("returns before reading cell state when type colors are disabled", () => {
expect(dataGridSource).toContain('function gridCellTextColorClass(item: RowItem, actualColIdx: number, visibleColIdx: number): string {\n if (!colorizeDataGridCellTypes.value) return "text-foreground";\n const value = item.data[actualColIdx];');
expect(dataGridSource).toContain('function transposeCellTextColorClass(recordIndex: number, actualColIdx: number): string {\n if (!colorizeDataGridCellTypes.value) return "text-foreground";\n const item = displayItems.value[recordIndex];');
});
it("places data-grid type selectors in the components layer", () => {
const componentsLayerStart = globalStylesSource.indexOf("@layer components {");
const integerTypeSelector = globalStylesSource.indexOf(".data-grid-type-integer");
expect(componentsLayerStart).toBeGreaterThan(-1);
expect(integerTypeSelector).toBeGreaterThan(componentsLayerStart);
});
});
@@ -3,6 +3,8 @@ import { readFileSync } from "node:fs";
import { DATA_GRID_DARK_ACTIVE_ROW_BG, DATA_GRID_LIGHT_ACTIVE_ROW_BG, dataGridActiveRowBackground, resolveDataGridPaintTheme } from "@/lib/dataGrid/dataGridPaintTheme";
function parseRgb(value: string): { r: number; g: number; b: number } | null {
const hex = value.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i);
if (hex) return { r: Number.parseInt(hex[1], 16), g: Number.parseInt(hex[2], 16), b: Number.parseInt(hex[3], 16) };
const match = value.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);
if (!match) return null;
return { r: Number(match[1]), g: Number(match[2]), b: Number(match[3]) };
@@ -112,6 +114,39 @@ describe("data grid paint theme", () => {
expect(theme.cellDirty).toBe("rgb(94, 56, 57)");
});
it("resolves accessible semantic type colors for light and dark grids", () => {
const emptyCssVariable = () => "";
const light = resolveDataGridPaintTheme({ getVar: emptyCssVariable, isDark: false });
const dark = resolveDataGridPaintTheme({ getVar: emptyCssVariable, isDark: true });
expect(light.typeForegrounds.integer).toBe("#1d4ed8");
expect(light.typeForegrounds.boolean).toBe("#c2410c");
expect(dark.typeForegrounds.integer).toBe("#93c5fd");
expect(dark.typeForegrounds.boolean).toBe("#fdba74");
expect(light.typeForegrounds.unknown).toBe(light.foreground);
expect(dark.typeForegrounds.unknown).toBe(dark.foreground);
for (const [kind, color] of Object.entries(light.typeForegrounds)) {
if (kind === "unknown") continue;
expect(contrastRatio(color, "#ffffff")).toBeGreaterThanOrEqual(4.5);
expect(contrastRatio(color, "#f0f0f0")).toBeGreaterThanOrEqual(4.5);
}
for (const [kind, color] of Object.entries(dark.typeForegrounds)) {
if (kind === "unknown") continue;
expect(contrastRatio(color, "#131416")).toBeGreaterThanOrEqual(4.5);
expect(contrastRatio(color, "#28282b")).toBeGreaterThanOrEqual(4.5);
}
});
it("honors a custom semantic type color token", () => {
const theme = resolveDataGridPaintTheme({
getVar: (name) => (name === "--data-grid-type-spatial-fg" ? "rgb(12, 98, 74)" : ""),
isDark: false,
});
expect(theme.typeForegrounds.spatial).toBe("rgb(12, 98, 74)");
});
});
describe("dbx-control-chrome cascade contract", () => {
@@ -1,9 +1,11 @@
import { firstLineCellDisplayValue, type CellValue } from "@/lib/dataGrid/cellValue";
import { BOOLEAN_CHECKBOX_SIZE, isBooleanCellValue, normalizeBooleanCellValue } from "@/lib/dataGrid/dataGridBooleanColumn";
import { resolveDataGridCellTextRole } from "@/lib/dataGrid/dataGridCellTextVisual";
import type { DataGridTypeVisualKind } from "@/lib/dataGrid/dataGridColumnType";
import { dataGridFrameCoversRow, dataGridFrameIsMultiCell, dataGridSelectionFrameKindAtCell, dataGridSelectionUsesOuterFrame } from "@/lib/dataGrid/dataGridSelectionFrames";
import type { CellSelectionRange } from "@/lib/dataGrid/gridSelection";
import type { RowStatus } from "@/lib/dataGrid/gridRowStatus";
import { DATA_GRID_DARK_SEARCH_COLORS, resolveDataGridPaintTheme, type DataGridPaintTheme } from "@/lib/dataGrid/dataGridPaintTheme";
import { DATA_GRID_DARK_SEARCH_COLORS, dataGridTypeForeground, resolveDataGridPaintTheme, type DataGridPaintTheme } from "@/lib/dataGrid/dataGridPaintTheme";
export const CANVAS_DATA_GRID_ROW_HEIGHT = 26;
export const MAX_CANVAS_DATA_GRID_PIXEL_RATIO = 4;
@@ -89,6 +91,8 @@ export interface DrawCanvasDataGridOptions {
pageOffset: number;
frozenColumnCount?: number;
columnAligns?: readonly ("left" | "right")[];
columnTypeVisualKinds?: readonly DataGridTypeVisualKind[];
colorizeDataTypes?: boolean;
rightAlignedActionCell?: CanvasRightAlignedActionCell | null;
booleanDisplayMode?: "checkbox" | "dropdown";
}
@@ -344,6 +348,8 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions) {
pageOffset,
frozenColumnCount = 0,
columnAligns,
columnTypeVisualKinds,
colorizeDataTypes = false,
rightAlignedActionCell,
columnIsBoolean,
booleanDisplayMode = "dropdown",
@@ -534,8 +540,23 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions) {
const isEditingThisCell = editingCell?.rowId === item.id && editingCell.col === actualColIdx;
const isBooleanNullCell = booleanDisplayMode === "checkbox" && isBooleanCell && value === null && !isEditingThisCell;
const shouldRenderBooleanCheckbox = booleanDisplayMode === "checkbox" && isBooleanCell && value !== null && !isEditingThisCell;
const typeKind = columnTypeVisualKinds?.[visibleColIdx] ?? "unknown";
const textRole = resolveDataGridCellTextRole({
colorizeTypes: colorizeDataTypes,
typeKind,
isNull: value === null,
isDraft: item.isDraft && value === null,
isEditing: isEditingThisCell,
isControl: shouldRenderBooleanCheckbox,
isSelected: selectedFillVisual,
isCurrentSearchMatch,
isSearchMatch,
isDirty: isDirtyCell,
isDeleted: item.isDeleted,
});
const cellTextColor = textRole === "muted" ? theme.mutedForeground : textRole === "type" ? dataGridTypeForeground(theme, typeKind) : theme.foreground;
ctx.textAlign = isBooleanNullCell ? "center" : isRightAlign ? "right" : "left";
ctx.fillStyle = value === null ? theme.mutedForeground : theme.foreground;
ctx.fillStyle = cellTextColor;
ctx.font = value === null ? italicFont : tabularFont;
setCanvasNumericVariant(ctx, value === null ? "normal" : "tabular-nums");
const reservedWidth = rightAlignedActionCell?.rowIndex === item.displayIndex && rightAlignedActionCell.visibleColIdx === visibleColIdx ? rightAlignedActionCell.reservedWidth : 0;
@@ -545,7 +566,7 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions) {
if (item.isDeleted) {
const boxX = alignCanvasPixel(drawX + (colWidth - BOOLEAN_CHECKBOX_SIZE) / 2, scaleX);
const strikeY = alignCanvasPixel(y + CANVAS_DATA_GRID_ROW_HEIGHT / 2, scaleY);
ctx.strokeStyle = theme.foreground;
ctx.strokeStyle = cellTextColor;
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(boxX - 1, strikeY);
@@ -561,7 +582,7 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions) {
if (item.isDeleted && text) {
const textWidth = ctx.measureText(text).width;
const lineStartX = isBooleanNullCell ? anchorX - textWidth / 2 : isRightAlign ? textAnchorX - textWidth : textAnchorX;
ctx.strokeStyle = theme.foreground;
ctx.strokeStyle = cellTextColor;
ctx.beginPath();
ctx.moveTo(lineStartX, textY);
ctx.lineTo(alignCanvasPixel(lineStartX + textWidth, scaleX), textY);
@@ -0,0 +1,50 @@
import type { DataGridTypeVisualKind } from "@/lib/dataGrid/dataGridColumnType";
export type DataGridCellTextRole = "muted" | "neutral" | "type";
export interface DataGridCellTextVisualState {
colorizeTypes: boolean;
typeKind: DataGridTypeVisualKind;
isNull?: boolean;
isDraft?: boolean;
isEditing?: boolean;
isControl?: boolean;
isSelected?: boolean;
isCurrentSearchMatch?: boolean;
isSearchMatch?: boolean;
isDirty?: boolean;
isDeleted?: boolean;
}
const DATA_GRID_TYPE_VISUAL_CLASSES: Record<DataGridTypeVisualKind, string> = {
integer: "data-grid-type-integer",
numeric: "data-grid-type-numeric",
string: "data-grid-type-string",
boolean: "data-grid-type-boolean",
temporal: "data-grid-type-temporal",
structured: "data-grid-type-structured",
identifier: "data-grid-type-identifier",
binary: "data-grid-type-binary",
spatial: "data-grid-type-spatial",
unknown: "text-muted-foreground",
};
export function dataGridTypeVisualClass(kind: DataGridTypeVisualKind): string {
return DATA_GRID_TYPE_VISUAL_CLASSES[kind];
}
/** Keep interaction and edit state more prominent than the optional type cue. */
export function resolveDataGridCellTextRole(state: DataGridCellTextVisualState): DataGridCellTextRole {
if (state.isNull || state.isDraft) return "muted";
if (!state.colorizeTypes || state.typeKind === "unknown" || state.isEditing || state.isControl || state.isSelected || state.isCurrentSearchMatch || state.isSearchMatch || state.isDirty || state.isDeleted) {
return "neutral";
}
return "type";
}
export function dataGridCellTextClass(state: DataGridCellTextVisualState): string {
const role = resolveDataGridCellTextRole(state);
if (role === "muted") return "text-muted-foreground italic";
if (role === "neutral") return "text-foreground";
return dataGridTypeVisualClass(state.typeKind);
}
@@ -1,3 +1,5 @@
import type { DatabaseType } from "@/types/database";
/**
* Resolve the data type to display in a data-grid column header.
*
@@ -138,3 +140,133 @@ export function isNumericColumnType(dataType: string | undefined): boolean {
const base = normalized.split(/[\s([]/, 1)[0];
return NUMERIC_COLUMN_TYPE_BASES.has(base);
}
export const DATA_GRID_TYPE_VISUAL_KINDS = ["integer", "numeric", "string", "boolean", "temporal", "structured", "identifier", "binary", "spatial", "unknown"] as const;
export type DataGridTypeVisualKind = (typeof DATA_GRID_TYPE_VISUAL_KINDS)[number];
const INTEGER_COLUMN_TYPE_BASES = new Set([
"tinyint",
"smallint",
"mediumint",
"int",
"integer",
"bigint",
"serial",
"smallserial",
"bigserial",
"int1",
"int2",
"int4",
"int8",
"int16",
"int32",
"int64",
"int128",
"int256",
"intn",
"uint",
"uint8",
"uint16",
"uint32",
"uint64",
"uint128",
"uint256",
"year",
]);
const STRING_COLUMN_TYPE_BASES = new Set([
"varchar",
"varchar2",
"nvarchar",
"nvarchar2",
"text",
"char",
"nchar",
"ntext",
"string",
"fixedstring",
"tinytext",
"mediumtext",
"longtext",
"clob",
"nclob",
"long",
"enum",
"enum8",
"enum16",
"set",
"character",
"character varying",
"national character",
"national character varying",
]);
const BOOLEAN_COLUMN_TYPE_BASES = new Set(["bool", "boolean", "bit"]);
const TEMPORAL_COLUMN_TYPE_BASES = new Set(["date", "date32", "daten", "time", "time64", "timen", "timetz", "datetime", "datetime2", "datetime4", "datetime64", "datetimen", "datetimeoffset", "datetimeoffsetn", "smalldatetime", "timestamp", "timestampdty", "timestamptz", "interval"]);
const STRUCTURED_COLUMN_TYPE_BASES = new Set(["json", "jsonb", "jsonpath", "xml", "xmltype", "array", "map", "tuple", "struct", "row", "object", "document", "variant"]);
const IDENTIFIER_COLUMN_TYPE_BASES = new Set(["uuid", "uniqueidentifier", "rowid", "urowid"]);
const BINARY_COLUMN_TYPE_BASES = new Set(["bytea", "blob", "tinyblob", "mediumblob", "longblob", "binary", "varbinary", "image", "raw", "long raw", "bfile"]);
const SPATIAL_COLUMN_TYPE_BASES = new Set(["geometry", "geography", "sdo_geometry", "point", "linestring", "polygon", "multipoint", "multilinestring", "multipolygon", "geometrycollection"]);
const TYPE_VISUAL_TRANSPARENT_WRAPPERS = new Set(["nullable", "lowcardinality"]);
function unwrapDataGridColumnType(dataType: string): { normalized: string; array: boolean } {
let normalized = dataType.trim().toLowerCase().replace(/\s+/g, " ");
let array = false;
while (normalized) {
if (/\[\s*\]$/.test(normalized)) {
array = true;
normalized = normalized.replace(/(?:\[\s*\])+$/, "").trim();
continue;
}
const wrapper = normalized.match(/^([a-z][a-z0-9_]*)\s*\((.*)\)$/s);
if (!wrapper) break;
const wrapperName = wrapper[1] ?? "";
if (wrapperName === "array") {
array = true;
normalized = wrapper[2]?.trim() ?? "";
continue;
}
if (!TYPE_VISUAL_TRANSPARENT_WRAPPERS.has(wrapperName)) break;
normalized = wrapper[2]?.trim() ?? "";
}
// PostgreSQL exposes array type names through Type.name() using its catalog
// convention (`_int4`, `_text`, `_jsonb`, including custom arrays).
if (normalized.length > 1 && normalized.startsWith("_")) array = true;
return { normalized, array };
}
function dataGridColumnTypeBase(dataType: string): { base: string; array: boolean } {
const unwrapped = unwrapDataGridColumnType(dataType);
let base = unwrapped.normalized.replace(/\s+unsigned\b/g, "").trim();
const parameterStart = base.indexOf("(");
if (parameterStart >= 0) base = base.slice(0, parameterStart).trim();
if (base.startsWith("timestamp with ")) base = "timestamptz";
else if (base.startsWith("timestamp without ")) base = "timestamp";
else if (base.startsWith("time with ")) base = "timetz";
else if (base.startsWith("time without ")) base = "time";
else if (base === "double precision") base = "double";
return { base, array: unwrapped.array };
}
/**
* Collapse driver-specific SQL type names into the small semantic palette used
* by grid headers and values. Unknown types deliberately stay neutral.
*/
export function resolveDataGridTypeVisualKind(dataType: string | undefined, databaseType?: DatabaseType): DataGridTypeVisualKind {
if (!dataType?.trim()) return "unknown";
const { base, array } = dataGridColumnTypeBase(dataType);
if (array) return "structured";
if (databaseType === "sqlserver" && (base === "timestamp" || base === "rowversion")) return "binary";
if (databaseType === "postgres" && (base === "bit" || base === "bit varying")) return "binary";
if (INTEGER_COLUMN_TYPE_BASES.has(base)) return "integer";
if (isNumericColumnType(dataType)) return "numeric";
if (BOOLEAN_COLUMN_TYPE_BASES.has(base)) return "boolean";
if (TEMPORAL_COLUMN_TYPE_BASES.has(base) || base.startsWith("timestamp_")) return "temporal";
if (STRUCTURED_COLUMN_TYPE_BASES.has(base)) return "structured";
if (IDENTIFIER_COLUMN_TYPE_BASES.has(base)) return "identifier";
if (BINARY_COLUMN_TYPE_BASES.has(base)) return "binary";
if (SPATIAL_COLUMN_TYPE_BASES.has(base)) return "spatial";
if (STRING_COLUMN_TYPE_BASES.has(base)) return "string";
return "unknown";
}
@@ -1,3 +1,7 @@
import type { DataGridTypeVisualKind } from "@/lib/dataGrid/dataGridColumnType";
export type DataGridTypeForegrounds = Record<DataGridTypeVisualKind, string>;
export interface DataGridPaintTheme {
background: string;
border: string;
@@ -28,6 +32,7 @@ export interface DataGridPaintTheme {
rowNumberTextNew: string;
rowNumberTextEdited: string;
rowNumberTextDeleted: string;
typeForegrounds: DataGridTypeForegrounds;
}
export const DATA_GRID_DARK_SEARCH_COLORS = {
@@ -266,6 +271,18 @@ export function resolveDataGridPaintTheme(options: { getVar: (name: string) => s
const rowNumberDeleted = isDark ? DATA_GRID_DARK_ROW_NUMBER_DELETED_BG : DATA_GRID_LIGHT_ROW_NUMBER_DELETED_BG;
const rowNumberActive = activeSurface;
const rowNumberSelected = isDark ? "rgb(30, 64, 96)" : "rgb(191, 219, 254)";
const typeForegrounds: DataGridTypeForegrounds = {
integer: paintToken(getVar, "--data-grid-type-integer-fg", isDark ? "#93c5fd" : "#1d4ed8"),
numeric: paintToken(getVar, "--data-grid-type-numeric-fg", isDark ? "#67e8f9" : "#0e7490"),
string: paintToken(getVar, "--data-grid-type-string-fg", isDark ? "#86efac" : "#166534"),
boolean: paintToken(getVar, "--data-grid-type-boolean-fg", isDark ? "#fdba74" : "#c2410c"),
temporal: paintToken(getVar, "--data-grid-type-temporal-fg", isDark ? "#d8b4fe" : "#7e22ce"),
structured: paintToken(getVar, "--data-grid-type-structured-fg", isDark ? "#f9a8d4" : "#be185d"),
identifier: paintToken(getVar, "--data-grid-type-identifier-fg", isDark ? "#fcd34d" : "#92400e"),
binary: paintToken(getVar, "--data-grid-type-binary-fg", isDark ? "#fca5a5" : "#b91c1c"),
spatial: paintToken(getVar, "--data-grid-type-spatial-fg", isDark ? "#6ee7b7" : "#047857"),
unknown: foreground,
};
return {
background,
@@ -297,5 +314,10 @@ export function resolveDataGridPaintTheme(options: { getVar: (name: string) => s
rowNumberTextNew: isDark ? "rgb(94, 233, 181)" : "rgb(0, 122, 85)",
rowNumberTextEdited: isDark ? "rgb(255, 210, 48)" : "rgb(187, 77, 0)",
rowNumberTextDeleted: destructive,
typeForegrounds,
};
}
export function dataGridTypeForeground(theme: Pick<DataGridPaintTheme, "foreground" | "typeForegrounds">, kind: DataGridTypeVisualKind): string {
return theme.typeForegrounds[kind] ?? theme.foreground;
}
@@ -60,6 +60,10 @@ describe("EDITOR_SETTINGS_DRAFT_KEYS", () => {
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("dataTabReuseMode");
});
it("includes data grid type colors", () => {
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("colorizeDataGridCellTypes");
});
it("includes completionTriggerMode", () => {
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("completionTriggerMode");
});
@@ -86,6 +90,10 @@ describe("editorSettingsDraftFromSettings", () => {
expect(draft.continueOnErrorOnBatch).toBe(false);
});
it("maps the data grid type color preference from settings", () => {
expect(editorSettingsDraftFromSettings(makeSettings({ colorizeDataGridCellTypes: false })).colorizeDataGridCellTypes).toBe(false);
});
it("preserves the table-open default for legacy settings", () => {
const settings = makeSettings();
delete (settings as Partial<EditorSettings>).tableOpenPageSize;
@@ -137,6 +137,7 @@ describe("settings search", () => {
{ titleKey: "settings.confirmDangerousSqlExecution", category: "editor", targetId: "editor" },
{ titleKey: "settings.continueOnErrorOnBatch", category: "editor", targetId: "editor" },
{ titleKey: "settings.dataGridQuickEntry", category: "data", targetId: "data" },
{ titleKey: "settings.colorizeDataGridCellTypes", category: "data", targetId: "data" },
{ titleKey: "transfer.dataTransfer", category: "appearance", targetId: "appearance" },
{ titleKey: "toolbar.driverManager", category: "appearance", targetId: "appearance" },
{ titleKey: "toolbar.theme", category: "appearance", targetId: "appearance" },
@@ -31,6 +31,7 @@ export const EDITOR_SETTINGS_DRAFT_KEYS = [
"tabLayout",
"showColumnCommentsInHeader",
"showColumnTypesInHeader",
"colorizeDataGridCellTypes",
"showIndexIndicatorsInHeader",
"compactColumnHeaderActions",
"dataGridQuickEntry",
@@ -173,6 +173,7 @@ export const SETTINGS_SEARCH_DEFINITIONS: readonly SettingsSearchDefinition[] =
{ id: "query-result-max-rows", category: "data", titleKey: "settings.queryResultMaxRows", descriptionKey: "settings.queryResultMaxRowsDescription", targetId: "data" },
{ id: "data-grid-header-comments", category: "data", titleKey: "settings.showColumnCommentsInHeader", descriptionKey: "settings.showColumnCommentsInHeaderDescription", targetId: "data" },
{ id: "data-grid-header-types", category: "data", titleKey: "settings.showColumnTypesInHeader", descriptionKey: "settings.showColumnTypesInHeaderDescription", targetId: "data" },
{ id: "data-grid-cell-type-colors", category: "data", titleKey: "settings.colorizeDataGridCellTypes", descriptionKey: "settings.colorizeDataGridCellTypesDescription", targetId: "data" },
{ id: "data-grid-index-indicators", category: "data", titleKey: "settings.showIndexIndicatorsInHeader", descriptionKey: "settings.showIndexIndicatorsInHeaderDescription", targetId: "data" },
{ id: "data-grid-compact-header-actions", category: "data", titleKey: "settings.compactColumnHeaderActions", descriptionKey: "settings.compactColumnHeaderActionsDescription", targetId: "data" },
{ id: "data-grid-auto-total", category: "data", titleKey: "settings.autoCalculateTotalRows", descriptionKey: "settings.autoCalculateTotalRowsDescription", targetId: "data" },