perf(zookeeper): optimize connection initialization
This commit is contained in:
1 parent
c1bda3be87
commit
0d57c39a78
10 files changed
+286
-34
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted, computed, watch } from "vue";
|
||||
import { ref, onMounted, onUnmounted, computed, watch, nextTick } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { Activity, ExternalLink, Cpu, FolderOpen, FolderSync, MemoryStick, Search, Square, Trash2, Download, RotateCcw, Loader2, RefreshCw, Check, Clock3, FileUp } from "@lucide/vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -20,6 +20,7 @@ import type { AgentDriverInfo, DriverRuntimeInfo, DriverRuntimeSummary, DriverSt
|
||||
import { formatRuntimeBytes, formatRuntimeCpu, formatRuntimeUptime, runtimeHealthClass, runtimeStatusClass, runtimeStatusDotClass } from "@/lib/connection/driverRuntimePresentation";
|
||||
import { addDriverInstallQueue, driverInstallProgressPercent, isDriverInstallProgressTarget, removeDriverInstallQueue, takeNextDriverInstallQueue, type DriverInstallProgress } from "@/lib/connection/driverInstallProgressUi";
|
||||
import { PRESTOSQL_DRIVER_DB_TYPE, prestoSqlBuiltinDriverRow, prestoSqlMavenBundle } from "@/lib/database/prestoSqlBuiltinDriver";
|
||||
import type { DriverStoreFocus } from "@/lib/connection/agentDriverInstallHint";
|
||||
|
||||
const { t } = useI18n();
|
||||
const { toast } = useToast();
|
||||
@@ -29,10 +30,12 @@ const props = withDefaults(
|
||||
defineProps<{
|
||||
updateNotificationsEnabled?: boolean;
|
||||
activeTab?: "agent" | "jdbc" | "storage" | "runtime";
|
||||
focusTarget?: DriverStoreFocus | null;
|
||||
}>(),
|
||||
{
|
||||
updateNotificationsEnabled: true,
|
||||
activeTab: "agent",
|
||||
focusTarget: null,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -664,6 +667,35 @@ const filteredAgentDrivers = computed(() => {
|
||||
return builtinDriverRows.value.filter((driver) => [driver.label, driver.db_type, driver.version, driver.installed_version, driverRequiresJavaRuntime(driver) ? driver.jre : ""].filter(Boolean).join(" ").toLowerCase().includes(query));
|
||||
});
|
||||
|
||||
const highlightedFocusKey = ref<string | null>(null);
|
||||
let focusHighlightTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
|
||||
function focusElementKey(focus: DriverStoreFocus): string {
|
||||
return focus.target === "driver" ? `driver:${focus.driver ?? ""}` : "jre";
|
||||
}
|
||||
|
||||
watch(
|
||||
[() => props.focusTarget, builtinDriverRows],
|
||||
async ([focus]) => {
|
||||
if (!focus || focus.target === "tab") return;
|
||||
driverStoreTab.value = "agent";
|
||||
if (focus.target === "driver") {
|
||||
// Wait until the requested driver row is loaded before scrolling to it.
|
||||
if (!focus.driver || !builtinDriverRows.value.some((driver) => driver.db_type === focus.driver)) return;
|
||||
agentDriverSearch.value = "";
|
||||
}
|
||||
const key = focusElementKey(focus);
|
||||
highlightedFocusKey.value = key;
|
||||
await nextTick();
|
||||
document.querySelector(`[data-driver-store-focus="${CSS.escape(key)}"]`)?.scrollIntoView({ block: "center", behavior: "smooth" });
|
||||
clearTimeout(focusHighlightTimer);
|
||||
focusHighlightTimer = setTimeout(() => {
|
||||
if (highlightedFocusKey.value === key) highlightedFocusKey.value = null;
|
||||
}, 6000);
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const jdbcDriverListItems = computed<JdbcDriverListItem[]>(() => {
|
||||
const localBundleItems = jdbcLocalBundles.value.map((bundle) => ({
|
||||
kind: "local" as const,
|
||||
@@ -1099,7 +1131,7 @@ watch(driverStoreTab, (tab) => {
|
||||
<!-- Agent Tab -->
|
||||
<TabsContent value="agent" class="driver-store-tab driver-store-agent-tab mt-5 space-y-5">
|
||||
<!-- Java Runtime -->
|
||||
<div class="rounded-xl border bg-muted/20 p-4 space-y-3">
|
||||
<div class="rounded-xl border bg-muted/20 p-4 space-y-3" data-driver-store-focus="jre" :class="{ 'driver-store-focus-highlight': highlightedFocusKey === 'jre' }">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<Label class="shrink-0">{{ t("driverStore.javaRuntime") }}</Label>
|
||||
<Select :model-value="javaRuntimeConfig.mode" @update:model-value="setJavaRuntimeMode">
|
||||
@@ -1173,7 +1205,13 @@ watch(driverStoreTab, (tab) => {
|
||||
{{ upgradingAll ? t("driverStore.upgradingProgress", { current: upgradingIndex, total: upgradingTotal }) : t("driverStore.upgradeAll") }}
|
||||
</Button>
|
||||
</div>
|
||||
<div v-for="driver in filteredAgentDrivers" :key="driver.db_type" class="driver-store-agent-row flex items-center gap-3 px-4 py-2 transition hover:bg-muted/30">
|
||||
<div
|
||||
v-for="driver in filteredAgentDrivers"
|
||||
:key="driver.db_type"
|
||||
:data-driver-store-focus="`driver:${driver.db_type}`"
|
||||
class="driver-store-agent-row flex items-center gap-3 px-4 py-2 transition hover:bg-muted/30"
|
||||
:class="{ 'driver-store-focus-highlight': highlightedFocusKey === `driver:${driver.db_type}` }"
|
||||
>
|
||||
<span class="flex h-8 w-8 items-center justify-center rounded-lg bg-muted/60 shrink-0">
|
||||
<DatabaseIcon :db-type="driver.db_type" class="h-4 w-4" />
|
||||
</span>
|
||||
@@ -1541,6 +1579,12 @@ watch(driverStoreTab, (tab) => {
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.driver-store-focus-highlight {
|
||||
background-color: hsl(var(--primary) / 0.08);
|
||||
box-shadow: inset 0 0 0 1.5px hsl(var(--primary) / 0.45);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.driver-store-view,
|
||||
.driver-store-scroll {
|
||||
overflow-x: hidden;
|
||||
|
||||
@@ -36,7 +36,7 @@ import { MQ_PINNED_VERSION_OPTIONS, pinnedVersionToSelection, selectionToPinnedV
|
||||
import { mongodbAuthFailureHint, mongoUrlParam, mongoUrlParamIsTrue, normalizeMongoTlsFormState, setMongoUrlParam, setMongoUrlParamBoolean } from "@/lib/mongo/mongoConnectionOptions";
|
||||
import { mysqlCleartextPasswordAuthEnabled, setMysqlCleartextPasswordAuthEnabled } from "@/lib/database/mysqlConnectionOptions";
|
||||
import { copyToClipboard } from "@/lib/common/clipboard";
|
||||
import { agentDriverInstallKey, appendAgentDriverUpdateHint, hasAgentDriverUpdate, showAgentDriverInstallHint, type AgentDriverInstallState } from "@/lib/connection/agentDriverInstallHint";
|
||||
import { agentDriverInstallKey, appendAgentDriverUpdateHint, hasAgentDriverUpdate, showAgentDriverInstallHint, type AgentDriverInstallState, type DriverStoreFocus } from "@/lib/connection/agentDriverInstallHint";
|
||||
import { prestoSqlBuiltinDriverPaths } from "@/lib/database/prestoSqlBuiltinDriver";
|
||||
import { SQLITE_DATABASE_FILE_EXTENSIONS } from "@/lib/database/databaseFileDetection";
|
||||
import { connectionAttemptOriginalErrorMessage, connectionAttemptTimeoutMessage, connectionAttemptTimeoutMs } from "@/lib/connection/connectionAttemptTimeout";
|
||||
@@ -117,7 +117,7 @@ const emit = defineEmits<{
|
||||
connectStarted: [name: string];
|
||||
connectSucceeded: [name: string];
|
||||
connectFailed: [message: string];
|
||||
openDriverStore: [tab?: "jdbc"];
|
||||
openDriverStore: [focus?: DriverStoreFocus];
|
||||
openTunnelProfileSettings: [];
|
||||
}>();
|
||||
|
||||
@@ -1958,6 +1958,7 @@ const zookeeperConnectString = computed({
|
||||
const canUseTransportLayers = computed(() => form.value.db_type !== "sqlite" && form.value.db_type !== "access" && !isCloudflareD1Connection(form.value) && !isH2FileMode.value);
|
||||
const shouldShowAgentDriverInstallHint = computed(() => showAgentDriverInstallHint(form.value.db_type, agentDrivers.value, form.value.driver_profile));
|
||||
const h2DriverMissing = computed(() => form.value.db_type === "h2" && isH2FileMode.value && agentDrivers.value.find((d) => d.db_type === "h2")?.installed !== true);
|
||||
const agentDriverFocus = computed<DriverStoreFocus>(() => ({ target: "driver", driver: agentDriverInstallKey(form.value.db_type, form.value.driver_profile) }));
|
||||
const canChooseVisibleDatabases = computed(() => connectionCanChooseVisibleDatabases(form.value));
|
||||
const visibleFilterUsesSchemas = computed(() => connectionUsesVisibleSchemaFilter(form.value));
|
||||
const hasVisibleDatabaseFilter = computed(() => Array.isArray(form.value.visible_databases));
|
||||
@@ -4055,7 +4056,7 @@ function openExternalUrl(url: string) {
|
||||
<div v-if="h2DriverMissing" class="grid grid-cols-4 items-center gap-4">
|
||||
<span />
|
||||
<p class="col-span-3 text-xs text-muted-foreground">
|
||||
{{ t("connection.driverInstallHintPrefix") }}<a class="underline cursor-pointer text-primary hover:text-primary/80" @click="emit('openDriverStore')">{{ t("toolbar.driverManager") }}</a
|
||||
{{ t("connection.driverInstallHintPrefix") }}<a class="underline cursor-pointer text-primary hover:text-primary/80" @click="emit('openDriverStore', agentDriverFocus)">{{ t("toolbar.driverManager") }}</a
|
||||
>{{ t("connection.driverInstallHintSuffix") }}
|
||||
</p>
|
||||
</div>
|
||||
@@ -4135,7 +4136,7 @@ function openExternalUrl(url: string) {
|
||||
{{ t("connection.jdbcPluginHint") }}
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<Button type="button" variant="outline" size="sm" @click="emit('openDriverStore', 'jdbc')">
|
||||
<Button type="button" variant="outline" size="sm" @click="emit('openDriverStore', { target: 'tab', tab: 'jdbc' })">
|
||||
<FolderOpen class="h-3.5 w-3.5" />
|
||||
{{ t("toolbar.driverManager") }}
|
||||
</Button>
|
||||
@@ -4971,7 +4972,7 @@ function openExternalUrl(url: string) {
|
||||
<div v-if="shouldShowAgentDriverInstallHint" class="grid grid-cols-4 items-center gap-4">
|
||||
<span />
|
||||
<p class="col-span-3 text-xs text-muted-foreground">
|
||||
{{ t("connection.driverInstallHintPrefix") }}<a class="underline cursor-pointer text-primary hover:text-primary/80" @click="emit('openDriverStore')">{{ t("toolbar.driverManager") }}</a
|
||||
{{ t("connection.driverInstallHintPrefix") }}<a class="underline cursor-pointer text-primary hover:text-primary/80" @click="emit('openDriverStore', agentDriverFocus)">{{ t("toolbar.driverManager") }}</a
|
||||
>{{ t("connection.driverInstallHintSuffix") }}
|
||||
</p>
|
||||
</div>
|
||||
@@ -5060,7 +5061,7 @@ function openExternalUrl(url: string) {
|
||||
{{ t("connection.jdbcPluginHint") }}
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<Button type="button" variant="outline" size="sm" @click="emit('openDriverStore', 'jdbc')">
|
||||
<Button type="button" variant="outline" size="sm" @click="emit('openDriverStore', { target: 'tab', tab: 'jdbc' })">
|
||||
<FolderOpen class="h-3.5 w-3.5" />
|
||||
{{ t("toolbar.driverManager") }}
|
||||
</Button>
|
||||
|
||||
@@ -21,6 +21,7 @@ import { useConnectionStore } from "@/stores/connectionStore";
|
||||
import { useProductionSafetyStore } from "@/stores/productionSafetyStore";
|
||||
import { useDialogSources } from "@/composables/useDialogSources";
|
||||
import type { ConnectionDeepLinkDraft } from "@/lib/connection/connectionDeepLink";
|
||||
import type { DriverStoreFocus } from "@/lib/connection/agentDriverInstallHint";
|
||||
import type { SqlParameterDescriptor, SqlParameterSyntax } from "@/lib/sql/sqlParameters";
|
||||
import type { ConfigTab } from "@/components/connection/ConnectionDialog.vue";
|
||||
import type { DatabaseType } from "@/types/database";
|
||||
@@ -49,7 +50,7 @@ const emit = defineEmits<{
|
||||
connectStarted: [name: string];
|
||||
connectSucceeded: [name: string];
|
||||
connectFailed: [message: string];
|
||||
openDriverStore: [tab?: "jdbc"];
|
||||
openDriverStore: [focus?: DriverStoreFocus];
|
||||
openTunnelProfileSettings: [];
|
||||
openLineageTarget: [
|
||||
target: {
|
||||
|
||||
@@ -78,6 +78,7 @@ import { canTreeNodePin, canTreeNodeShowExpander, treeItemPaddingLeft, treeLabel
|
||||
import { buildTableSelectSql } from "@/lib/table/tableSelectSql";
|
||||
import { buildTableDeleteTemplate, buildTableInsertTemplate, buildTableSelectTemplate, buildTableUpdateTemplate } from "@/lib/table/tableSqlTemplates";
|
||||
import { connectionFilePath, defaultSqliteBackupFileName, isMemorySqlitePath, sqliteBackupSourcePath } from "@/lib/connection/connectionFile";
|
||||
import { driverStoreFocusForInstallError } from "@/lib/connection/agentDriverInstallHint";
|
||||
import { revealPathInFileManager } from "@/lib/backend/tauri";
|
||||
import { clearActiveTableReferencePayload, createTableReferencePayload, createTableReferenceDropEvent, setActiveTableReferencePayload, type QueryEditorTableReferencePayload } from "@/lib/editor/queryEditorTableDrop";
|
||||
import { usesSyntheticRowIdKey } from "@/lib/table/tableEditing";
|
||||
@@ -813,9 +814,7 @@ async function toggle() {
|
||||
const errMsg = e?.message || String(e);
|
||||
if (errMsg.includes(CONNECTION_ATTEMPT_CANCELLED_MESSAGE)) return;
|
||||
toast(t("connection.connectFailed", { message: translateBackendError(t, errMsg) }), 5000);
|
||||
if (errMsg.includes("driver is not installed") || errMsg.includes("is not installed")) {
|
||||
window.dispatchEvent(new Event("dbx-open-driver-store"));
|
||||
}
|
||||
openDriverStoreForInstallError(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -854,6 +853,12 @@ function refreshActiveKvBrowserAfterOpen(mode: "etcd" | "zookeeper", connectionI
|
||||
});
|
||||
}
|
||||
|
||||
function openDriverStoreForInstallError(errMsg: string) {
|
||||
const config = props.node.connectionId ? connectionStore.getConfig(props.node.connectionId) : undefined;
|
||||
const focus = driverStoreFocusForInstallError(errMsg, config?.db_type, config?.driver_profile);
|
||||
if (focus) window.dispatchEvent(new CustomEvent("dbx-open-driver-store", { detail: focus }));
|
||||
}
|
||||
|
||||
async function loadMoreObjectGroupChildren() {
|
||||
try {
|
||||
await connectionStore.loadMoreObjectGroupChildren(props.node);
|
||||
@@ -1247,9 +1252,7 @@ async function openObjectBrowser() {
|
||||
}
|
||||
} catch (e: any) {
|
||||
toast(t("connection.connectFailed", { message: translateBackendError(t, e?.message || String(e)) }), 5000);
|
||||
if (e?.message?.includes("driver is not installed") || (e?.message?.includes("JRE") && e?.message?.includes("not installed"))) {
|
||||
window.dispatchEvent(new Event("dbx-open-driver-store"));
|
||||
}
|
||||
openDriverStoreForInstallError(e?.message || String(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1611,9 +1614,7 @@ async function newQuery() {
|
||||
queryStore.createTab(node.connectionId, resolveDefaultDatabase(connection, options), undefined, "query");
|
||||
} catch (e: any) {
|
||||
toast(t("connection.connectFailed", { message: translateBackendError(t, e?.message || String(e)) }), 5000);
|
||||
if (e?.message?.includes("driver is not installed") || (e?.message?.includes("JRE") && e?.message?.includes("not installed"))) {
|
||||
window.dispatchEvent(new Event("dbx-open-driver-store"));
|
||||
}
|
||||
openDriverStoreForInstallError(e?.message || String(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1787,9 +1788,7 @@ async function refresh() {
|
||||
await connectionStore.refreshTreeNode(props.node);
|
||||
} catch (e: any) {
|
||||
toast(t("connection.connectFailed", { message: translateBackendError(t, e?.message || String(e)) }), 5000);
|
||||
if (e?.message?.includes("driver is not installed") || (e?.message?.includes("JRE") && e?.message?.includes("not installed"))) {
|
||||
window.dispatchEvent(new Event("dbx-open-driver-store"));
|
||||
}
|
||||
openDriverStoreForInstallError(e?.message || String(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user