feat(search): open database search as a tab
This commit is contained in:
1 parent
fdb8e37a48
commit
03fc00c33c
28 files changed
+1062
-367
No files matched your search
@@ -295,6 +295,53 @@ describe("openTabsPersistence originalSql round-trip", () => {
|
||||
currentUri: "s3://bucket/reports/",
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves database-search tab state across a round-trip", () => {
|
||||
const [restored] = roundTrip([
|
||||
queryTab({
|
||||
id: "search-tab",
|
||||
title: "Search Database",
|
||||
connectionId: "conn-1",
|
||||
database: "shop",
|
||||
schema: "public",
|
||||
mode: "database-search",
|
||||
databaseSearchState: {
|
||||
keyword: "order_123",
|
||||
perTableLimit: 25,
|
||||
progressDone: 4,
|
||||
progressTotal: 8,
|
||||
results: [
|
||||
{
|
||||
id: "orders:0",
|
||||
tableName: "orders",
|
||||
schema: "public",
|
||||
matchedColumns: ["order_no"],
|
||||
preview: "order_no: order_123",
|
||||
whereInput: "\"order_no\" = 'order_123'",
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(restored.mode).toBe("database-search");
|
||||
expect(restored.databaseSearchState).toEqual({
|
||||
keyword: "order_123",
|
||||
perTableLimit: 25,
|
||||
progressDone: 4,
|
||||
progressTotal: 8,
|
||||
results: [
|
||||
{
|
||||
id: "orders:0",
|
||||
tableName: "orders",
|
||||
schema: "public",
|
||||
matchedColumns: ["order_no"],
|
||||
preview: "order_no: order_123",
|
||||
whereInput: "\"order_no\" = 'order_123'",
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("openTabsPersistence detached connection tabs", () => {
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
tabDisplayTitles,
|
||||
syncTabTitleNumbers,
|
||||
tabIconClass,
|
||||
tabModeLabel,
|
||||
tabTooltipLines,
|
||||
tabularResultItems,
|
||||
dirtyTabTitleStyle,
|
||||
@@ -37,6 +38,7 @@ const translations: Record<string, string> = {
|
||||
"tree.events": "Events",
|
||||
"connectionGroup.ungroupedLabel": "Ungrouped",
|
||||
"editor.noDatabase": "No database",
|
||||
"databaseSearch.title": "Search Database",
|
||||
};
|
||||
|
||||
const translate = (key: string) => translations[key] ?? key;
|
||||
@@ -474,6 +476,17 @@ describe("tab group presentation", () => {
|
||||
expect(tabDisplayTitle(queryTab({ mode: "objects", objectBrowser: { objectType: "tables", initialObjectFilter: "events" } }), translate)).toBe("Events@db");
|
||||
});
|
||||
|
||||
it("formats database-search tab titles with database and schema scope", () => {
|
||||
expect(tabDisplayTitle(queryTab({ mode: "database-search", database: "shop", schema: "public" }), translate)).toBe("Search Database@shop.public");
|
||||
expect(tabDisplayTitle(queryTab({ mode: "database-search", database: "shop" }), translate)).toBe("Search Database@shop");
|
||||
expect(tabModeLabel(queryTab({ mode: "database-search" }), translate)).toBe("Search Database");
|
||||
|
||||
const settings = useSettingsStore();
|
||||
settings.editorSettings.compactTabTitle = true;
|
||||
expect(tabDisplayTitle(queryTab({ mode: "database-search", database: "shop" }), translate)).toBe("Search Database");
|
||||
settings.editorSettings.compactTabTitle = false;
|
||||
});
|
||||
|
||||
it("uses the live database and branch context for Dolt version control tabs", () => {
|
||||
const store = useConnectionStore();
|
||||
store.connections = [{ id: "conn-1", name: "Production Dolt", db_type: "mysql", driver_profile: "dolt", database: "app" } as ConnectionConfig];
|
||||
|
||||
@@ -65,6 +65,7 @@ export interface SavedOpenTab {
|
||||
nacosNamespaceName?: string;
|
||||
structureTableName?: string;
|
||||
structureDraft?: QueryTab["structureDraft"];
|
||||
databaseSearchState?: QueryTab["databaseSearchState"];
|
||||
objectBrowser?: QueryTab["objectBrowser"];
|
||||
objectSource?: QueryTab["objectSource"];
|
||||
sourceView?: boolean;
|
||||
@@ -212,6 +213,7 @@ export function serializeOpenTabs(tabs: QueryTab[]): SavedOpenTab[] {
|
||||
...(tab.nacosNamespaceName !== undefined ? { nacosNamespaceName: tab.nacosNamespaceName } : {}),
|
||||
...(tab.structureTableName !== undefined ? { structureTableName: tab.structureTableName } : {}),
|
||||
...(tab.structureDraft ? { structureDraft: JSON.parse(JSON.stringify(tab.structureDraft)) } : {}),
|
||||
...(tab.databaseSearchState ? { databaseSearchState: tab.databaseSearchState } : {}),
|
||||
objectBrowser: tab.objectBrowser,
|
||||
objectSource: tab.objectSource,
|
||||
...(tab.sourceView ? { sourceView: true } : {}),
|
||||
|
||||
@@ -34,6 +34,7 @@ export const contentSurfaceEventNames = [
|
||||
"editTableStructure",
|
||||
"openObjectSource",
|
||||
"openObjectTable",
|
||||
"openDatabaseSearchTarget",
|
||||
"objectSchemaChange",
|
||||
"objectBrowserViewportChange",
|
||||
"objectBrowserSearchChange",
|
||||
|
||||
@@ -287,6 +287,11 @@ export function tabDisplayTitle(tab: QueryTab, t: Translate): string {
|
||||
if (compact) return t("tabs.users");
|
||||
return `${t("tabs.users")}@${connectionDisplayName(tab.connectionId)}`;
|
||||
}
|
||||
if (tab.mode === "database-search") {
|
||||
const scope = tab.schema ? `${database}.${tab.schema}` : database;
|
||||
if (compact) return t("databaseSearch.title");
|
||||
return `${t("databaseSearch.title")}@${scope}`;
|
||||
}
|
||||
return tab.title;
|
||||
}
|
||||
|
||||
@@ -677,6 +682,7 @@ export function tabModeLabel(tab: QueryTab, t: Translate): string {
|
||||
if (tab.mode === "objects") return t("tabs.objects");
|
||||
if (tab.mode === "users") return t("tabs.users");
|
||||
if (tab.mode === "dolt-version-control") return t("doltVersionControl.title");
|
||||
if (tab.mode === "database-search") return t("databaseSearch.title");
|
||||
return tab.mode;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user