fix(meilisearch): hide generic new-query entry for meilisearch

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-09-20 00:50:55 +08:00
1 parent fa3925ca52
commit 86115971fa
6 files changed
+56 -11

No files matched your search

+32 -4
View File
@@ -139,7 +139,7 @@ import { countActiveUpdateBlockingTasks } from "@/lib/app/appUpdateTaskGuard";
import { initSavedSqlEditorPositions } from "@/lib/app/savedSqlEditorPosition";
import { hasTreeNodeDatabaseContext } from "@/lib/sidebar/treeNodeContext";
import { objectBrowserTablesToAiTreeNodes } from "@/lib/ai/objectBrowserToAiTargets";
import { isSchemaAware, isSingleDatabase, usesTreeSchemaMode } from "@/lib/database/databaseFeatureSupport";
import { isSchemaAware, isSingleDatabase, supportsConnectionQueryActions, usesTreeSchemaMode } from "@/lib/database/databaseFeatureSupport";
import { codeMirrorSqlDialect, connectionUsesDatabaseObjectTreeMode, effectiveDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";
import { canFormatSqlForDatabaseType, formatSqlForEditing, sqlFormatDialectForDbType } from "@/lib/sql/sqlFormatter";
import { formatSqlSnapshotForSave } from "@/lib/sql/sqlFormatOnSave";
@@ -750,6 +750,17 @@ const activeConnection = computed(() => {
return tab ? connectionStore.getConfig(tab.connectionId) : undefined;
});
function supportsGenericNewQuery(connection: ConnectionConfig | undefined): boolean {
if (!connection) return false;
// Some specialized connections use the same entry to open their dedicated
// workbench (for example MQ or Nacos), so those remain valid actions even
// though they do not support a generic SQL editor.
if (quickConnectionOpenTarget(connection).kind !== "query") return true;
return supportsConnectionQueryActions(effectiveDatabaseTypeForConnection(connection) ?? connection.db_type);
}
const canCreateNewQuery = computed(() => connectionStore.connections.some((connection) => supportsGenericNewQuery(connection)));
// Oracle manual-mode indicator derived from the RESOLVED database type (an
// Oracle connection uses the agent runtime but reports db_type "oracle"), so
// the toolbar's Commit/Rollback visibility can apply the Oracle dirty-state rule
@@ -2571,7 +2582,7 @@ function openConnectionSettings(connectionId: string, initialTab: ConfigTab = "c
}
async function newQuery() {
const target = resolveNewQueryTarget({
let target = resolveNewQueryTarget({
activeTab: activeTab.value,
selectedTreeNode: findTreeNodeById(connectionStore.treeNodes, connectionStore.selectedTreeNodeId),
activeConnectionId: connectionStore.activeConnectionId,
@@ -2579,8 +2590,24 @@ async function newQuery() {
preferredSource: newQueryContextSource.value,
});
if (!target) return;
const conn = connectionStore.getConfig(target.connectionId);
let conn = connectionStore.getConfig(target.connectionId);
if (!conn) return;
// Specialized stores such as Meilisearch expose their own workspaces and
// must not receive a generic query tab. If the current context is such a
// store, fall back to the first connection with a supported query/workbench
// action.
if (!supportsGenericNewQuery(conn)) {
const fallbackConnection = connectionStore.connections.find((connection) => supportsGenericNewQuery(connection));
if (!fallbackConnection) return;
target = resolveNewQueryTarget({
activeConnectionId: fallbackConnection.id,
connections: connectionStore.connections,
});
if (!target) return;
conn = connectionStore.getConfig(target.connectionId);
if (!conn) return;
}
connectionStore.activeConnectionId = target.connectionId;
const connectionTarget = quickConnectionOpenTarget(conn);
if (connectionTarget.kind !== "query") {
@@ -3929,6 +3956,7 @@ onUnmounted(() => {
:agent-driver-update-count="showDriverStoreUpdateBadge"
:has-mcp-update-available="showMcpSettingsUpdateBadge"
:has-connections="connectionStore.connections.length > 0"
:can-new-query="canCreateNewQuery"
:has-sql-file-connections="hasSqlFileConnections"
@new-connection="showConnectionDialog = true"
@expand-sidebar="setSidebarOpen(true)"
@@ -4197,7 +4225,7 @@ onUnmounted(() => {
:recent-connections="recentConnections"
:saved-sql-history-items="savedSqlHistoryItems"
:app-version="appVersion"
:has-connections="connectionStore.connections.length > 0"
:can-new-query="canCreateNewQuery"
@open-connection-query="openConnectionQuery"
@open-saved-sql="openSavedSqlFromWelcome"
@new-connection="showConnectionDialog = true"
@@ -50,6 +50,7 @@ const props = defineProps<{
agentDriverUpdateCount: number;
hasMcpUpdateAvailable: boolean;
hasConnections: boolean;
canNewQuery: boolean;
hasSqlFileConnections: boolean;
}>();
@@ -562,7 +563,7 @@ const toolbarStyle = computed(() => {
</span>
</Button>
<Button variant="ghost" size="sm" :class="toolbarTextButtonClass" @click="emit('new-query')" :disabled="!hasConnections">
<Button v-if="canNewQuery" variant="ghost" size="sm" :class="toolbarTextButtonClass" @click="emit('new-query')">
<FilePlus2 class="h-3.5 w-3.5" />
<span :class="toolbarTextLabelClass">{{ t("toolbar.newQuery") }}</span>
</Button>
@@ -20,7 +20,7 @@ defineProps<{
recentConnections: ConnectionConfig[];
savedSqlHistoryItems: WelcomeSavedSqlHistoryItem[];
appVersion: string;
hasConnections: boolean;
canNewQuery: boolean;
}>();
const emit = defineEmits<{
@@ -94,7 +94,7 @@ function welcomeConnectionSubtitle(connection: ConnectionConfig): string {
<button class="flex min-w-0 items-center gap-2 overflow-hidden rounded-md px-3 py-2 text-left text-sm hover:bg-muted/50" @click="emit('new-connection')">
<Plus class="h-4 w-4 shrink-0" /> <span class="min-w-0 truncate">{{ t("toolbar.newConnection") }}</span>
</button>
<button class="flex min-w-0 items-center gap-2 overflow-hidden rounded-md px-3 py-2 text-left text-sm hover:bg-muted/50" :disabled="!hasConnections" @click="emit('new-query')">
<button v-if="canNewQuery" class="flex min-w-0 items-center gap-2 overflow-hidden rounded-md px-3 py-2 text-left text-sm hover:bg-muted/50" @click="emit('new-query')">
<FilePlus2 class="h-4 w-4 shrink-0" /> <span class="min-w-0 truncate">{{ t("toolbar.newQuery") }}</span>
</button>
<button class="flex min-w-0 items-center gap-2 overflow-hidden rounded-md px-3 py-2 text-left text-sm hover:bg-muted/50" @click="emit('show-history')">
@@ -6078,9 +6078,17 @@ function buildSpecialSidebarMenu(context: SidebarMenuFactoryContext): boolean {
if (node.type === "elasticsearch-index" || node.type === "vector-collection") {
items.push({ label: t("contextMenu.copyName"), action: copyName, icon: Copy, shortcut: shortcutCopyName.value });
items.push({ label: "", separator: true });
items.push({ label: t("contextMenu.viewData"), action: toggle, icon: TableProperties });
items.push({ label: t("contextMenu.newQuery"), action: newQuery, icon: TerminalSquare });
// Meilisearch indexes open through their dedicated search workspace; the
// generic data/query actions are not valid for this connection type.
const isMeilisearchIndex = currentDatabaseType() === "meilisearch";
const hasAdditionalIndexActions = canRenameMongoCollection.value || canManageElasticsearchIndex.value || canDropMilvusCollection.value;
if (!isMeilisearchIndex || hasAdditionalIndexActions) {
items.push({ label: "", separator: true });
}
if (!isMeilisearchIndex) {
items.push({ label: t("contextMenu.viewData"), action: toggle, icon: TableProperties });
items.push({ label: t("contextMenu.newQuery"), action: newQuery, icon: TerminalSquare });
}
if (canRenameMongoCollection.value) {
items.push({ label: t("contextMenu.renameObject"), action: openRenameMongoCollectionDialog, icon: Pencil, shortcut: shortcutRename });
}
@@ -119,6 +119,10 @@ describe("connection query actions", () => {
expect(supportsConnectionQueryActions("mq")).toBe(false);
expect(supportsConnectionQueryActions("mqtt")).toBe(false);
});
it("hides the sidebar new-query entry for Meilisearch", () => {
expect(supportsConnectionQueryActions("meilisearch")).toBe(false);
});
});
describe("message queue query capabilities", () => {
@@ -122,9 +122,13 @@ export function supportsClearableQuerySchema(dbType?: DatabaseType): boolean {
* `mqtt`) belong to the same group: brokers have no SQL engine, and their
* workbench is the MQ/MQTT admin tab. The sidebar entry used to open a plain
* SQL editor against a broker (issue #8415).
*
* Meilisearch exposes its own index search and management workspaces rather
* than a general-purpose SQL query surface, so the generic sidebar action is
* hidden there as well (issue #9609).
*/
export function supportsConnectionQueryActions(dbType?: DatabaseType): boolean {
return dbType !== "nacos" && dbType !== "consul" && dbType !== "hbase" && dbType !== "zookeeper" && dbType !== "plugin" && dbType !== "mq" && dbType !== "mqtt";
return dbType !== "nacos" && dbType !== "consul" && dbType !== "hbase" && dbType !== "zookeeper" && dbType !== "plugin" && dbType !== "mq" && dbType !== "mqtt" && dbType !== "meilisearch";
}
/**