From b15e22033e8e3f88342826831bd14a9acf4023d3 Mon Sep 17 00:00:00 2001
From: t8y2 <1156263951@qq.com>
Date: Fri, 15 May 2026 16:57:14 +0800
Subject: [PATCH] feat(editor): add searchable query selectors
---
src/components/layout/EditorToolbar.vue | 77 ++++++------
.../ui/searchable-select/SearchableSelect.vue | 117 ++++++++++++++++++
src/components/ui/searchable-select/index.ts | 1 +
src/i18n/locales/en.ts | 2 +
src/i18n/locales/es.ts | 2 +
src/i18n/locales/zh-CN.ts | 2 +
src/lib/databaseOptionSearch.ts | 14 +++
tests/databaseOptionSearch.test.ts | 19 +++
8 files changed, 197 insertions(+), 37 deletions(-)
create mode 100644 src/components/ui/searchable-select/SearchableSelect.vue
create mode 100644 src/components/ui/searchable-select/index.ts
create mode 100644 src/lib/databaseOptionSearch.ts
create mode 100644 tests/databaseOptionSearch.test.ts
diff --git a/src/components/layout/EditorToolbar.vue b/src/components/layout/EditorToolbar.vue
index 8dc51b4d61..30d11d7435 100644
--- a/src/components/layout/EditorToolbar.vue
+++ b/src/components/layout/EditorToolbar.vue
@@ -16,6 +16,7 @@ import {
} from "lucide-vue-next";
import { Button } from "@/components/ui/button";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
+import { SearchableSelect } from "@/components/ui/searchable-select";
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
import DatabaseIcon from "@/components/icons/DatabaseIcon.vue";
import { useConnectionStore } from "@/stores/connectionStore";
@@ -58,6 +59,7 @@ const activeDatabaseOptions = computed(() => {
return connection ? (databaseOptions.value[connection.id] ?? []) : [];
});
+const connectionOptionIds = computed(() => connectionStore.connections.map((connection) => connection.id));
const activeDatabaseValue = computed(() => props.activeTab.database || "");
const activeConnectionValue = computed(() => props.activeConnection?.id || "");
const activeSchemaValue = computed(() => props.activeTab.schema || "");
@@ -98,6 +100,10 @@ function databaseDisplayName(database: string): string {
if (connection?.db_type === "redis" && database !== "") return `db${database}`;
return database || t("editor.noDatabase");
}
+
+function connectionById(connectionId: string): ConnectionConfig | undefined {
+ return connectionStore.getConfig(connectionId);
+}
@@ -203,55 +209,52 @@ function databaseDisplayName(database: string): string {
class="h-4 w-1 rounded-full shrink-0"
:style="{ backgroundColor: activeConnection.color }"
/>
-
+ {{ t("editor.selectConnection") }}
+
+
+
+
+ {{ label }}
+
+
+
-
+ />