Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore(sql-editor): SQL Editor data table performance optimization (#13822)
Liu Ji36851b5b77ea
diff --git a/frontend/src/utils/dom.ts b/frontend/src/utils/dom.tsindex 5f0184bcf1..1b93907440 100644--- a/frontend/src/utils/dom.ts+++ b/frontend/src/utils/dom.ts@@ -1,4 +1,9 @@-import { onBeforeUnmount, onMounted, unref, type Ref } from "vue";+import {+ onBeforeUnmount,+ unref,+ watch,+ type Ref,+} from "vue";export const isDescendantOf = (node: Element | null | undefined,@@ -66,11 +71,19 @@ export const usePreventBackAndForward = (};let unregister: () => void;- onMounted(() => {- const elem = unref(elemRef);- if (!elem) return;- unregister = preventBackForward(elem);- });+ watch(+ () => unref(elemRef),+ (elem) => {+ if (!elem) return;+ if (unregister) {+ unregister();+ }+ unregister = preventBackForward(elem);+ },+ {+ immediate: true,+ }+ );onBeforeUnmount(() => {unregister && unregister();diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.tsindex 0c9898fc72..1731f8eb47 100644--- a/frontend/src/utils/index.ts+++ b/frontend/src/utils/index.ts@@ -22,6 +22,7 @@ export * from "./slowQuery";export * from "./resource-composer";export * from "./TinyTimer";export * from "./sheet";+export * from "./naive-ui";export * from "./v1";export * from "./iam";diff --git a/frontend/src/utils/naive-ui.ts b/frontend/src/utils/naive-ui.tsnew file mode 100644index 0000000000..139560f762--- /dev/null+++ b/frontend/src/utils/naive-ui.ts@@ -0,0 +1,82 @@+import { pausableWatch, useElementSize } from "@vueuse/core";+import type { DataTableInst, VirtualListInst } from "naive-ui";+import { computed, ref, unref, type MaybeRef } from "vue";+import { nextAnimationFrame } from "./dom";++export type AutoHeightDataTableOptions = {+ maxHeight: number | null;+};+const defaultAutoHeightDataTableOptions = (): AutoHeightDataTableOptions => ({+ maxHeight: null,+});++export const useAutoHeightDataTable = (+ data?: MaybeRef<unknown[]>,+ options?: MaybeRef<Partial<AutoHeightDataTableOptions>>+) => {+ const opts = computed(() => ({+ ...defaultAutoHeightDataTableOptions(),+ ...unref(options),+ }));+ const GAP_HEIGHT = 2;+ const dataTableRef = ref<DataTableInst>();+ const containerElRef = ref<HTMLElement>();+ const tableHeaderElRef = computed(+ () =>+ containerElRef.value?.querySelector("thead.n-data-table-thead") as+ | HTMLElement+ | undefined+ );+ const { height: containerHeight } = useElementSize(containerElRef);+ const { height: tableHeaderHeight } = useElementSize(tableHeaderElRef);+ const tableBodyHeight = ref(0);++ const { pause: pauseWatch, resume: resumeWatch } = pausableWatch(+ [() => unref(data), containerHeight, tableHeaderHeight, opts],+ async () => {+ if (containerHeight.value === 0 || tableHeaderHeight.value === 0) return;+ if (opts.value.maxHeight === null) {+ // The table height is always limited by the container height+ // and need not to be adjusted automatically+ tableBodyHeight.value =+ containerHeight.value - tableHeaderHeight.value - GAP_HEIGHT;+ return;+ }++ pauseWatch();+ const experimentalMaxBodyHeight =+ opts.value.maxHeight - tableHeaderHeight.value - GAP_HEIGHT;+ tableBodyHeight.value = experimentalMaxBodyHeight;+ await nextAnimationFrame();+ resumeWatch();+ },+ { immediate: true }+ );++ // Use this to avoid unnecessary initial rendering+ const layoutReady = computed(() => tableHeaderHeight.value > 0);++ const virtualListRef = computed(() => {+ return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef+ ?.virtualListRef as VirtualListInst | undefined;+ });++ const scrollerRef = computed(() => {+ const getter = (dataTableRef.value as any)?.$refs.mainTableInstRef.$refs+ .bodyInstRef.virtualListContainer;+ if (typeof getter === "function") {+ return getter() as HTMLElement | undefined;+ }+ return undefined;+ });++ return {+ dataTableRef,+ containerElRef,+ tableHeaderElRef,+ tableBodyHeight,+ layoutReady,+ virtualListRef,+ scrollerRef,+ };+};diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/ColumnHeader.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/ColumnHeader.vuenew file mode 100644index 0000000000..fb1d0215b6--- /dev/null+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/ColumnHeader.vue@@ -0,0 +1,69 @@+<template>+ <div+ class="relative px-2 py-2 min-w-[2rem] text-left bg-gray-50 dark:bg-gray-700 text-xs font-medium text-gray-500 dark:text-gray-300 tracking-wider"+ >+ <div+ class="flex items-center overflow-hidden cursor-pointer"+ @click="header.column.getToggleSortingHandler()?.($event)"+ >+ <span class="flex flex-row items-center select-none">+ <template v-if="String(header.column.columnDef.header).length > 0">+ {{ header.column.columnDef.header }}+ </template>+ <br v-else class="min-h-[1rem] inline-flex" />+ </span>++ <SensitiveDataIcon+ v-if="isSensitiveColumn(header.index)"+ class="ml-0.5 shrink-0"+ />+ <template v-else-if="isColumnMissingSensitive(header.index)">+ <FeatureBadgeForInstanceLicense+ v-if="hasSensitiveFeature"+ :show="true"+ custom-class="ml-0.5 shrink-0"+ feature="bb.feature.sensitive-data"+ />+ <FeatureBadge+ v-else+ feature="bb.feature.sensitive-data"+ custom-class="ml-0.5 shrink-0"+ />+ </template>++ <ColumnSortedIcon :is-sorted="header.column.getIsSorted()" />+ </div>++ <!-- The drag-to-resize handler -->+ <div+ class="group absolute w-[8px] right-0 top-0 bottom-0 cursor-col-resize"+ @pointerdown="$emit('start-resizing')"+ >+ <div+ class="absolute w-[3px] right-0 top-0 bottom-0 group-hover:bg-accent/30"+ />+ </div>+ </div>+</template>++<script setup lang="ts">+import type { Header } from "@tanstack/vue-table";+import FeatureBadge from "@/components/FeatureGuard/FeatureBadge.vue";+import FeatureBadgeForInstanceLicense from "@/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue";+import { featureToRef } from "@/store";+import type { QueryRow } from "@/types/proto/v1/sql_service";+import ColumnSortedIcon from "./ColumnSortedIcon.vue";+import SensitiveDataIcon from "./SensitiveDataIcon.vue";++defineProps<{+ header: Header<QueryRow, any>;+ isSensitiveColumn: (index: number) => boolean;+ isColumnMissingSensitive: (index: number) => boolean;+}>();++defineEmits<{+ (event: "start-resizing"): void;+}>();++const hasSensitiveFeature = featureToRef("bb.feature.sensitive-data");+</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/ColumnSortedIcon.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/ColumnSortedIcon.vuenew file mode 100644index 0000000000..8b6dece5d9--- /dev/null+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/ColumnSortedIcon.vue@@ -0,0 +1,19 @@+<template>+ <span class="w-4 h-auto opacity-80 ml-1">+ <ArrowDownWideNarrow+ v-if="!isSorted || isSorted === 'desc'"+ class="w-full h-auto"+ :class="[isSorted ? 'text-accent' : 'text-gray-300']"+ />+ <ArrowUpWideNarrow v-else class="w-full h-auto text-accent" />+ </span>+</template>++<script lang="ts" setup>+import type { SortDirection } from "@tanstack/vue-table";+import { ArrowUpWideNarrow, ArrowDownWideNarrow } from "lucide-vue-next";++defineProps<{+ isSorted: false | SortDirection;+}>();+</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/DataTableLite.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/DataTableLite.vuenew file mode 100644index 0000000000..23bb5ad1ae--- /dev/null+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/DataTableLite.vue@@ -0,0 +1,157 @@+<template>+ <div+ ref="containerElRef"+ class="relative w-full flex-1 overflow-hidden flex flex-col"+ :data-width="containerWidth"+ :data-height="containerHeight"+ >+ <NDataTable+ ref="dataTableRef"+ :columns="columns"+ :data="layoutReady ? rows : []"+ :max-height="tableBodyHeight"+ :row-props="rowProps"+ :virtual-scroll="true"+ table-layout="fixed"+ size="small"+ class="relative z-[1]"+ style="--n-th-padding: 0; --n-td-padding: 0; --n-border-radius: 0"+ :style="{+ width: `calc(min(100%, ${tableResize.tableWidth.value + 2}px))`,+ }"+ />+ </div>+</template>++<script lang="ts" setup>+import type { Header, Row, Table } from "@tanstack/vue-table";+import { useElementSize } from "@vueuse/core";+import { type DataTableColumn, NDataTable } from "naive-ui";+import { computed, h, nextTick, watch } from "vue";+import { QueryRow, type RowValue } from "@/types/proto/v1/sql_service";+import {+ nextAnimationFrame,+ useAutoHeightDataTable,+ usePreventBackAndForward,+} from "@/utils";+import { useSQLResultViewContext } from "../context";+import ColumnHeader from "./ColumnHeader.vue";+import TableCell from "./TableCell.vue";+import useTableColumnWidthLogic from "./useTableResize";++const DEFAULT_COLUMN_WIDTH = 128; // 8rem++const props = defineProps<{+ table: Table<QueryRow>;+ setIndex: number;+ offset: number;+ isSensitiveColumn: (index: number) => boolean;+ isColumnMissingSensitive: (index: number) => boolean;+}>();++const { keyword } = useSQLResultViewContext();++const headers = computed(() => {+ return props.table.getFlatHeaders() as Header<QueryRow, RowValue>[];+});+const rows = computed(() => {+ return props.table.getRowModel().rows;+});+const {+ dataTableRef,+ containerElRef,+ tableBodyHeight,+ scrollerRef,+ layoutReady,+} = useAutoHeightDataTable(rows);+const { height: containerHeight, width: containerWidth } =+ useElementSize(containerElRef);+usePreventBackAndForward(scrollerRef);++const tableResize = useTableColumnWidthLogic({+ scrollerRef,+ columnCount: computed(() => headers.value.length),+ defaultWidth: DEFAULT_COLUMN_WIDTH,+ minWidth: 64, // 4rem+ maxWidth: 640, // 40rem+});++const columns = computed(() => {+ return headers.value.map<DataTableColumn<Row<QueryRow>>>(+ (header, colIndex) => {+ return {+ key: header.id,+ title: () => {+ return h(ColumnHeader, {+ header,+ isSensitiveColumn: props.isSensitiveColumn,+ isColumnMissingSensitive: props.isColumnMissingSensitive,+ onStartResizing: () => {+ tableResize.startResizing(colIndex);+ },+ });+ },+ render: (row, rowIndex) => {+ const cell = row.getVisibleCells()[colIndex];+ const value = cell.getValue() as RowValue;+ return h(TableCell, {+ table: props.table,+ value,+ width:+ tableResize.state.columns[colIndex]?.width ??+ DEFAULT_COLUMN_WIDTH,+ keyword: keyword.value,+ setIndex: props.setIndex,+ rowIndex: props.offset + rowIndex,+ colIndex,+ });+ },+ width: tableResize.state.columns[colIndex]?.width ?? 32,+ };+ }+ );+});++const rowProps = (row: Row<QueryRow>) => {+ return {+ class: "group",+ "data-row-index": row.index,+ };+};++const scrollTo = async (x: number, y: number) => {+ await nextAnimationFrame();+ const table = dataTableRef.value;+ table?.scrollTo(x, y);+};++watch(+ () =>+ props.table+ .getFlatHeaders()+ .map((header) => String(header.column.columnDef.header))+ .join("|"),+ () => {+ nextTick(() => {+ // Re-calculate the column widths once the column definition changed.+ scrollTo(0, 0);+ tableResize.reset();+ });+ },+ { immediate: true }+);++watch(+ () => props.offset,+ () => {+ // When the offset changed, we need to reset the scroll position.+ scrollTo(0, 0);+ }+);+</script>++<style lang="postcss" scoped>+:deep(.n-data-table-th .n-data-table-resize-button::after) {+ @apply bg-control-bg h-2/3;+}+</style>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/SensitiveDataIcon.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/SensitiveDataIcon.vuenew file mode 100644index 0000000000..17aee5430e--- /dev/null+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/SensitiveDataIcon.vue@@ -0,0 +1,38 @@+<template>+ <NTooltip :animated="false" :delay="250">+ <template #trigger>+ <heroicons-outline:eye-slash+ class="w-[12px] h-[12px] -mb-[2px]"+ :class="[clickable && 'cursor-pointer']"+ v-bind="$attrs"+ @click="handleClick"+ />+ </template>++ <span class="whitespace-nowrap">+ {{ $t("sensitive-data.self") }}+ </span>+ </NTooltip>+</template>++<script lang="ts" setup>+import { NTooltip } from "naive-ui";+import { computed } from "vue";+import { useRouter } from "vue-router";+import { WORKSPACE_ROUTE_DATA_ACCESS_CONTROL } from "@/router/dashboard/workspaceRoutes";+import { hasWorkspacePermissionV2 } from "@/utils";++const router = useRouter();++const clickable = computed(() => {+ return hasWorkspacePermissionV2("bb.policies.update");+});++const handleClick = () => {+ if (!clickable.value) {+ return;+ }+ const url = router.resolve({ name: WORKSPACE_ROUTE_DATA_ACCESS_CONTROL });+ window.open(url.href, "_BLANK");+};+</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/TableCell.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/TableCell.vuenew file mode 100644index 0000000000..ced3efe5a4--- /dev/null+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/TableCell.vue@@ -0,0 +1,127 @@+<!-- eslint-disable vue/no-v-html -->+<template>+ <div+ class="relative px-2 py-1 text-sm dark:text-gray-100 leading-5 whitespace-nowrap break-all group-even:bg-gray-50/50 dark:group-even:bg-gray-700/50"+ :class="classes"+ @click="handleClick"+ >+ <div+ ref="wrapperRef"+ class="whitespace-nowrap font-mono text-start line-clamp-1"+ v-html="html"+ ></div>+ <div v-if="clickable" class="absolute right-1 top-1/2 translate-y-[-45%]">+ <NButton+ size="tiny"+ circle+ class="dark:!bg-dark-bg"+ @click.stop="showDetail"+ >+ <template #icon>+ <heroicons:arrows-pointing-out class="w-3 h-3" />+ </template>+ </NButton>+ </div>+ </div>+</template>++<script setup lang="ts">+import { type Table } from "@tanstack/vue-table";+import { escape } from "lodash-es";+import { NButton } from "naive-ui";+import { computed, ref } from "vue";+import { useConnectionOfCurrentSQLEditorTab } from "@/store";+import { Engine } from "@/types/proto/v1/common";+import type { QueryRow, RowValue } from "@/types/proto/v1/sql_service";+import { extractSQLRowValue, getHighlightHTMLByRegExp } from "@/utils";+import { useSQLResultViewContext } from "../context";++const props = defineProps<{+ table: Table<QueryRow>;+ value: RowValue;+ width: number;+ setIndex: number;+ rowIndex: number;+ colIndex: number;+}>();++const { dark, disallowCopyingData, detail, keyword } =+ useSQLResultViewContext();+const wrapperRef = ref<HTMLDivElement>();+const plainValue = computed(() => {+ return extractSQLRowValue(props.value).plain;+});+const truncated = computed(() => {+ // not that accurate+ const xPadding = 8;+ const availChars = (props.width - xPadding * 2) / 10;+ return String(plainValue.value).length >= availChars;+});++const { database } = useConnectionOfCurrentSQLEditorTab();++const clickable = computed(() => {+ if (truncated.value) return true;+ if (database.value.instanceResource.engine === Engine.MONGODB) {+ // A cheap way to check JSON string without paying the parsing cost.+ const maybeJSON = String(props.value).trim();+ return (+ (maybeJSON.startsWith("{") && maybeJSON.endsWith("}")) ||+ (maybeJSON.startsWith("[") && maybeJSON.endsWith("]"))+ );+ }+ return false;+});++const classes = computed(() => {+ const classes: string[] = [];+ if (disallowCopyingData.value) {+ classes.push("select-none");+ }+ if (clickable.value) {+ classes.push("cursor-pointer");+ classes.push(dark.value ? "hover:!bg-white/20" : "hover:!bg-black/5");+ }+ return classes;+});++const html = computed(() => {+ const value = plainValue.value;+ if (value === undefined) {+ return `<span class="text-gray-400 italic">UNSET</span>`;+ }+ if (value === null) {+ return `<span class="text-gray-400 italic">NULL</span>`;+ }+ const str = String(value);+ if (str.length === 0) {+ return `<br style="min-width: 1rem; display: inline-flex;" />`;+ }++ const kw = keyword.value.trim();+ if (!kw) {+ return escape(str);+ }++ return getHighlightHTMLByRegExp(+ escape(str),+ escape(kw),+ false /* !caseSensitive */+ );+});++const handleClick = () => {+ if (!clickable.value) return;+ showDetail();+};++const showDetail = () => {+ detail.value = {+ show: true,+ set: props.setIndex,+ row: props.rowIndex,+ col: props.colIndex,+ table: props.table,+ };+};+</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/index.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/index.tsnew file mode 100644index 0000000000..df93d7811d--- /dev/null+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/index.ts@@ -0,0 +1,3 @@+import DataTableLite from "./DataTableLite.vue";++export default DataTableLite;diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/useTableResize.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/useTableResize.tsnew file mode 100644index 0000000000..717d3fce9d--- /dev/null+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/useTableResize.ts@@ -0,0 +1,160 @@+import { useEventListener, usePointer } from "@vueuse/core";+import { sumBy } from "lodash-es";+import type { Ref } from "vue";+import { computed, onBeforeUnmount, reactive, unref, watch } from "vue";++export type TableResizeOptions = {+ scrollerRef: Ref<HTMLElement | undefined>;+ columnCount: Ref<number>;+ defaultWidth: number;+ minWidth: number;+ maxWidth: number;+};++type ColumnProps = {+ width: number;+};++type DragState = {+ start: number;+ index: number;+ initialWidth: number;+};++type LocalState = {+ columns: ColumnProps[];+ drag?: DragState;+};++const useTableResize = (options: TableResizeOptions) => {+ const state = reactive<LocalState>({+ columns: [],+ drag: undefined,+ });+ const pointer = usePointer();+ const scroller = options.scrollerRef;++ const containerWidth = computed(() => {+ return scroller.value?.scrollWidth || 0;+ });+ const tableWidth = computed(() => {+ return sumBy(state.columns, (col) => col.width);+ });++ const normalizeWidth = (width: number) => {+ if (state.columns.length === 1) {+ // When there is only one column, display it with full width.+ // minus 1px to avoid unexpected horizontal scrollbar.+ return containerWidth.value - 1;+ }+ const { maxWidth, minWidth } = options;+ if (width > maxWidth) return maxWidth;+ if (width < minWidth) return minWidth;+ return width;+ };++ const reset = () => {+ state.drag = undefined;++ const columnCount = unref(options.columnCount);+ state.columns = new Array(columnCount);++ for (let i = 0; i < columnCount; i++) {+ state.columns[i] = {+ width: options.defaultWidth,+ };+ }+ };++ // Record the initial state of dragging.+ const startResizing = (index: number) => {+ state.drag = {+ start: pointer.x.value,+ index,+ initialWidth: state.columns[index].width,+ };+ toggleDragStyle(scroller, true);+ };++ // Watch the drag moving.+ watch(pointer.x, () => {+ const { drag } = state;+ if (!drag) return;+ const { start, index, initialWidth } = drag;++ // Calculate the expectedWidth according to the pointer's position.+ const offset = pointer.x.value - start;+ const expectedWidth = initialWidth + offset;+ state.columns[index].width = normalizeWidth(expectedWidth);+ if (index === state.columns.length - 1) {+ // When resizing the last column, Keep the horizontal scroll at the end of the container.+ scrollMaxX(scroller.value);+ }+ });++ // Reset dragging state when mouse button released.+ useEventListener("pointerup", () => {+ if (state.drag) {+ state.drag = undefined;+ toggleDragStyle(scroller, false);+ }+ });++ const getCellProps = (index: number) => {+ const column = state.columns[index];+ if (!column) return {};+ return {+ style: {+ width: `${column.width}px`,+ },+ class: "truncate",+ "data-index": index,+ };+ };++ const getTableProps = () => {+ return {+ style: {+ width: `${tableWidth.value}px`,+ },+ };+ };++ onBeforeUnmount(() => {+ toggleDragStyle(scroller, false);+ });++ return {+ reset,+ state,+ tableWidth,+ getCellProps,+ getTableProps,+ startResizing,+ };+};++export default useTableResize;++const scrollMaxX = (elem: HTMLElement | undefined) => {+ if (!elem) return;+ const max = elem.scrollWidth;+ elem.scrollTo(max, elem.scrollTop);+};++const toggleDragStyle = (+ element: Ref<HTMLElement | undefined>,+ on: boolean+) => {+ if (on) {+ // Prevent text selection while dragging.+ element.value?.classList.add("select-none");+ // Set the cursor style.+ document.body.classList.add("cursor-col-resize");+ } else {+ requestAnimationFrame(() => {+ element.value?.classList.remove("select-none");+ document.body.classList.remove("cursor-col-resize");+ });+ }+};diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vueindex dc5f373478..bd45b864ab 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue@@ -19,6 +19,7 @@type="card"size="small"class="flex-1 flex flex-col overflow-hidden"+ style="--n-tab-padding: 4px 12px"><NTabPanev-for="(result, i) in resultSet.results"diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vueindex f5c3eb99a4..91acd264f1 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue@@ -125,7 +125,7 @@:is-sensitive-column="isSensitiveColumn":is-column-missing-sensitive="isColumnMissingSensitive"/>- <DataTable+ <DataTableLitev-else:table="table":set-index="setIndex"@@ -230,7 +230,7 @@ import {isNullOrUndefined,} from "@/utils";import DataBlock from "./DataBlock.vue";-import DataTable from "./DataTable";+import DataTableLite from "./DataTableLite";import EmptyView from "./EmptyView.vue";import ErrorView from "./ErrorView";import { useSQLResultViewContext } from "./context";diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTableColumnsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTableColumnsTable.vueindex f1173e7f84..d1332c5841 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTableColumnsTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTableColumnsTable.vue@@ -30,8 +30,7 @@ import type {SchemaMetadata,ExternalTableMetadata,} from "@/types/proto/v1/database_service";-import { getHighlightHTMLByRegExp } from "@/utils";-import { useAutoHeightDataTable } from "../../common";+import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";import { useEditorPanelContext } from "../../context";const props = defineProps<{@@ -43,13 +42,9 @@ const props = defineProps<{}>();const { viewState } = useEditorPanelContext();-const { containerElRef, tableBodyHeight, layoutReady } =+const { containerElRef, tableBodyHeight, layoutReady, virtualListRef } =useAutoHeightDataTable();const dataTableRef = ref<DataTableInst>();-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});const { t } = useI18n();const filteredColumns = computed(() => {@@ -130,7 +125,7 @@ const columns = computed(() => {});watch(- [() => viewState.value?.detail.column, vlRef],+ [() => viewState.value?.detail.column, virtualListRef],([column, vl]) => {if (column && vl) {requestAnimationFrame(() => {diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesTable.vueindex 52ff6c2d1f..8311f5dafc 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ExternalTablesPanel/ExternalTablesTable.vue@@ -28,8 +28,7 @@ import type {SchemaMetadata,ExternalTableMetadata,} from "@/types/proto/v1/database_service";-import { getHighlightHTMLByRegExp } from "@/utils";-import { useAutoHeightDataTable } from "../../common";+import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";import { useEditorPanelContext } from "../../context";const props = defineProps<{@@ -64,17 +63,18 @@ const filteredExternalTables = computed(() => {return props.externalTables;});-const { dataTableRef, containerElRef, tableBodyHeight, layoutReady } =- useAutoHeightDataTable(- filteredExternalTables,- computed(() => ({- maxHeight: props.maxHeight ? props.maxHeight : null,- }))- );-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});+const {+ dataTableRef,+ containerElRef,+ virtualListRef,+ tableBodyHeight,+ layoutReady,+} = useAutoHeightDataTable(+ filteredExternalTables,+ computed(() => ({+ maxHeight: props.maxHeight ? props.maxHeight : null,+ }))+);const columns = computed(() => {const columns: (DataTableColumn<ExternalTableMetadata> & {@@ -123,7 +123,7 @@ const rowProps = (externalTable: ExternalTableMetadata) => {};watch(- [() => viewState.value?.detail.externalTable, vlRef],+ [() => viewState.value?.detail.externalTable, virtualListRef],([externalTable, vl]) => {if (externalTable && vl) {vl.scrollTo({ key: externalTable });diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsTable.vueindex 360a5b9e76..682658ccf2 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/FunctionsPanel/FunctionsTable.vue@@ -28,9 +28,8 @@ import type {FunctionMetadata,SchemaMetadata,} from "@/types/proto/v1/database_service";-import { getHighlightHTMLByRegExp } from "@/utils";+import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";import { keyWithPosition } from "@/views/sql-editor/EditorCommon";-import { useAutoHeightDataTable } from "../../common";import { useEditorPanelContext } from "../../context";type FunctionWithPosition = { func: FunctionMetadata; position: number };@@ -76,17 +75,18 @@ const filteredFuncs = computed(() => {return funcsWithPosition.value;});-const { dataTableRef, containerElRef, tableBodyHeight, layoutReady } =- useAutoHeightDataTable(- filteredFuncs,- computed(() => ({- maxHeight: props.maxHeight ? props.maxHeight : null,- }))- );-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});+const {+ dataTableRef,+ containerElRef,+ tableBodyHeight,+ layoutReady,+ virtualListRef,+} = useAutoHeightDataTable(+ filteredFuncs,+ computed(() => ({+ maxHeight: props.maxHeight ? props.maxHeight : null,+ }))+);const columns = computed(() => {const columns: (DataTableColumn<FunctionWithPosition> & {@@ -121,7 +121,7 @@ const rowProps = ({ func, position }: FunctionWithPosition) => {};watch(- [() => viewState.value?.detail.func, vlRef],+ [() => viewState.value?.detail.func, virtualListRef],([func, vl]) => {if (func && vl) {vl.scrollTo({ key: func });diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresTable.vueindex c2521ca77d..b6c209d479 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ProceduresPanel/ProceduresTable.vue@@ -30,9 +30,8 @@ import type {ProcedureMetadata,SchemaMetadata,} from "@/types/proto/v1/database_service";-import { getHighlightHTMLByRegExp } from "@/utils";+import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";import { keyWithPosition } from "@/views/sql-editor/EditorCommon";-import { useAutoHeightDataTable } from "../../common";import { useEditorPanelContext } from "../../context";type ProcedureWithPosition = {@@ -81,17 +80,18 @@ const filteredProcedures = computed(() => {return proceduresWithPosition.value;});-const { dataTableRef, containerElRef, tableBodyHeight, layoutReady } =- useAutoHeightDataTable(- filteredProcedures,- computed(() => ({- maxHeight: props.maxHeight ? props.maxHeight : null,- }))- );-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});+const {+ dataTableRef,+ containerElRef,+ virtualListRef,+ tableBodyHeight,+ layoutReady,+} = useAutoHeightDataTable(+ filteredProcedures,+ computed(() => ({+ maxHeight: props.maxHeight ? props.maxHeight : null,+ }))+);const columns = computed(() => {const columns: (DataTableColumn<ProcedureWithPosition> & {@@ -129,7 +129,7 @@ const rowProps = ({ procedure, position }: ProcedureWithPosition) => {};watch(- [() => viewState.value?.detail.procedure, vlRef],+ [() => viewState.value?.detail.procedure, virtualListRef],([procedure, vl]) => {if (procedure && vl) {vl.scrollTo({ key: procedure });diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ColumnsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ColumnsTable.vueindex f20006e99c..02acb258bb 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ColumnsTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ColumnsTable.vue@@ -34,8 +34,7 @@ import type {SchemaMetadata,TableMetadata,} from "@/types/proto/v1/database_service";-import { getHighlightHTMLByRegExp } from "@/utils";-import { useAutoHeightDataTable } from "../../common";+import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";import { useEditorPanelContext } from "../../context";const props = defineProps<{@@ -47,13 +46,9 @@ const props = defineProps<{}>();const { viewState } = useEditorPanelContext();-const { containerElRef, tableBodyHeight, layoutReady } =+const { containerElRef, virtualListRef, tableBodyHeight, layoutReady } =useAutoHeightDataTable();const dataTableRef = ref<DataTableInst>();-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});const { t } = useI18n();const filteredColumns = computed(() => {@@ -185,7 +180,7 @@ const isColumnPrimaryKey = (column: ColumnMetadata): boolean => {};watch(- [() => viewState.value?.detail.column, vlRef],+ [() => viewState.value?.detail.column, virtualListRef],([column, vl]) => {if (column && vl) {requestAnimationFrame(() => {diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ForeignKeysTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ForeignKeysTable.vueindex 3b95ed0988..605ed84273 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ForeignKeysTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/ForeignKeysTable.vue@@ -30,8 +30,7 @@ import type {SchemaMetadata,TableMetadata,} from "@/types/proto/v1/database_service";-import { getHighlightHTMLByRegExp } from "@/utils";-import { useAutoHeightDataTable } from "../../common";+import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";import { useEditorPanelContext } from "../../context";const props = defineProps<{@@ -43,13 +42,9 @@ const props = defineProps<{}>();const { viewState } = useEditorPanelContext();-const { containerElRef, tableBodyHeight, layoutReady } =+const { containerElRef, virtualListRef, tableBodyHeight, layoutReady } =useAutoHeightDataTable();const dataTableRef = ref<DataTableInst>();-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});const { t } = useI18n();const filteredForeignKeys = computed(() => {@@ -145,7 +140,7 @@ const columns = computed(() => {});watch(- [() => viewState.value?.detail.foreignKey, vlRef],+ [() => viewState.value?.detail.foreignKey, virtualListRef],([fk, vl]) => {if (fk && vl) {requestAnimationFrame(() => {diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/IndexesTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/IndexesTable.vueindex d6fa77a11e..d2b1e13f47 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/IndexesTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/IndexesTable.vue@@ -18,9 +18,9 @@</template><script lang="ts" setup>-import type { DataTableColumn, DataTableInst } from "naive-ui";+import type { DataTableColumn } from "naive-ui";import { NCheckbox, NDataTable } from "naive-ui";-import { computed, h, ref, watch } from "vue";+import { computed, h, watch } from "vue";import { useI18n } from "vue-i18n";import type { ComposedDatabase } from "@/types";import type {@@ -29,8 +29,7 @@ import type {SchemaMetadata,TableMetadata,} from "@/types/proto/v1/database_service";-import { getHighlightHTMLByRegExp } from "@/utils";-import { useAutoHeightDataTable } from "../../common";+import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";import { useEditorPanelContext } from "../../context";const props = defineProps<{@@ -42,13 +41,13 @@ const props = defineProps<{}>();const { viewState } = useEditorPanelContext();-const { containerElRef, tableBodyHeight, layoutReady } =- useAutoHeightDataTable();-const dataTableRef = ref<DataTableInst>();-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});+const {+ containerElRef,+ dataTableRef,+ virtualListRef,+ tableBodyHeight,+ layoutReady,+} = useAutoHeightDataTable();const { t } = useI18n();const filteredIndexes = computed(() => {@@ -120,7 +119,7 @@ const columns = computed(() => {});watch(- [() => viewState.value?.detail.index, vlRef],+ [() => viewState.value?.detail.index, virtualListRef],([index, vl]) => {if (index && vl) {requestAnimationFrame(() => {diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/PartitionsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/PartitionsTable.vueindex 37f3eb8192..e3bc743251 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/PartitionsTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/PartitionsTable.vue@@ -19,8 +19,8 @@<script setup lang="tsx">import { ChevronDownIcon } from "lucide-vue-next";-import { NDataTable, type DataTableColumn, type DataTableInst } from "naive-ui";-import { computed, h, ref, watch } from "vue";+import { NDataTable, type DataTableColumn } from "naive-ui";+import { computed, h, watch } from "vue";import { useI18n } from "vue-i18n";import type { ComposedDatabase } from "@/types";import {@@ -29,8 +29,7 @@ import {type SchemaMetadata,type TableMetadata,} from "@/types/proto/v1/database_service";-import { getHighlightHTMLByRegExp } from "@/utils";-import { useAutoHeightDataTable } from "../../common";+import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";import { useEditorPanelContext } from "../../context";type FlattenTablePartitionMetadata = {@@ -48,13 +47,13 @@ const props = defineProps<{const { t } = useI18n();const { viewState } = useEditorPanelContext();-const { containerElRef, tableBodyHeight, layoutReady } =- useAutoHeightDataTable();-const dataTableRef = ref<DataTableInst>();-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});+const {+ dataTableRef,+ containerElRef,+ virtualListRef,+ tableBodyHeight,+ layoutReady,+} = useAutoHeightDataTable();const filteredPartitions = computed(() => {const keyword = props.keyword?.trim().toLowerCase();@@ -155,7 +154,7 @@ const columns = computed(() => {});watch(- [() => viewState.value?.detail.partition, vlRef],+ [() => viewState.value?.detail.partition, virtualListRef],([partition, vl]) => {if (partition && vl) {requestAnimationFrame(() => {diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vueindex 7f44bffb8e..747607cf8a 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/TablesPanel/TablesTable.vue@@ -34,8 +34,8 @@ import {hasCollationProperty,hasIndexSizeProperty,hasTableEngineProperty,+ useAutoHeightDataTable,} from "@/utils";-import { useAutoHeightDataTable } from "../../common";import { useEditorPanelContext } from "../../context";const props = defineProps<{@@ -73,17 +73,18 @@ const filteredTables = computed(() => {}return props.tables;});-const { dataTableRef, containerElRef, tableBodyHeight, layoutReady } =- useAutoHeightDataTable(- filteredTables,- computed(() => ({- maxHeight: props.maxHeight ? props.maxHeight : null,- }))- );-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});+const {+ dataTableRef,+ containerElRef,+ virtualListRef,+ tableBodyHeight,+ layoutReady,+} = useAutoHeightDataTable(+ filteredTables,+ computed(() => ({+ maxHeight: props.maxHeight ? props.maxHeight : null,+ }))+);const columns = computed(() => {const columns: (DataTableColumn<TableMetadata> & { hide?: boolean })[] = [@@ -171,7 +172,7 @@ const rowProps = (table: TableMetadata) => {};watch(- [() => viewState.value?.detail.table, vlRef],+ [() => viewState.value?.detail.table, virtualListRef],([table, vl]) => {if (table && vl) {vl.scrollTo({ key: table });diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ColumnsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ColumnsTable.vueindex 860af945cc..985995adf8 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ColumnsTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ColumnsTable.vue@@ -30,8 +30,7 @@ import type {SchemaMetadata,ViewMetadata,} from "@/types/proto/v1/database_service";-import { getHighlightHTMLByRegExp } from "@/utils";-import { useAutoHeightDataTable } from "../../common";+import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";import { useEditorPanelContext } from "../../context";const props = defineProps<{@@ -43,12 +42,13 @@ const props = defineProps<{}>();const { viewState } = useEditorPanelContext();-const { dataTableRef, containerElRef, tableBodyHeight, layoutReady } =- useAutoHeightDataTable();-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});+const {+ dataTableRef,+ containerElRef,+ virtualListRef,+ tableBodyHeight,+ layoutReady,+} = useAutoHeightDataTable();const { t } = useI18n();const filteredColumns = computed(() => {@@ -129,7 +129,7 @@ const columns = computed(() => {});watch(- [() => viewState.value?.detail.column, vlRef],+ [() => viewState.value?.detail.column, virtualListRef],([column, vl]) => {if (column && vl) {requestAnimationFrame(() => {diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/DependentColumnsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/DependentColumnsTable.vueindex dbeeb0ee4b..4331f5a2af 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/DependentColumnsTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/DependentColumnsTable.vue@@ -34,8 +34,8 @@ import {getHighlightHTMLByRegExp,hasSchemaProperty,keyForDependentColumn,+ useAutoHeightDataTable,} from "@/utils";-import { useAutoHeightDataTable } from "../../common";import { useEditorPanelContext } from "../../context";const props = defineProps<{@@ -47,12 +47,13 @@ const props = defineProps<{}>();const { viewState, updateViewState } = useEditorPanelContext();-const { dataTableRef, containerElRef, tableBodyHeight, layoutReady } =- useAutoHeightDataTable();-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});+const {+ dataTableRef,+ containerElRef,+ virtualListRef,+ tableBodyHeight,+ layoutReady,+} = useAutoHeightDataTable();const { t } = useI18n();const filteredDependentColumns = computed(() => {@@ -128,7 +129,7 @@ const rowProps = (dep: DependentColumn) => {};watch(- [() => viewState.value?.detail.column, vlRef],+ [() => viewState.value?.detail.column, virtualListRef],([column, vl]) => {if (column && vl) {requestAnimationFrame(() => {diff --git a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsTable.vue b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsTable.vueindex b53a469500..cc44998801 100644--- a/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsTable.vue+++ b/frontend/src/views/sql-editor/EditorPanel/Panels/ViewsPanel/ViewsTable.vue@@ -28,8 +28,7 @@ import type {ViewMetadata,SchemaMetadata,} from "@/types/proto/v1/database_service";-import { getHighlightHTMLByRegExp } from "@/utils";-import { useAutoHeightDataTable } from "../../common";+import { getHighlightHTMLByRegExp, useAutoHeightDataTable } from "@/utils";import { useEditorPanelContext } from "../../context";const props = defineProps<{@@ -65,17 +64,18 @@ const filteredViews = computed(() => {return props.views;});-const { dataTableRef, containerElRef, tableBodyHeight, layoutReady } =- useAutoHeightDataTable(- filteredViews,- computed(() => ({- maxHeight: props.maxHeight ? props.maxHeight : null,- }))- );-const vlRef = computed(() => {- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef- ?.virtualListRef;-});+const {+ dataTableRef,+ containerElRef,+ virtualListRef,+ tableBodyHeight,+ layoutReady,+} = useAutoHeightDataTable(+ filteredViews,+ computed(() => ({+ maxHeight: props.maxHeight ? props.maxHeight : null,+ }))+);const columns = computed(() => {const columns: (DataTableColumn<ViewMetadata> & { hide?: boolean })[] = [@@ -113,7 +113,7 @@ const rowProps = (view: ViewMetadata) => {};watch(- [() => viewState.value?.detail.view, vlRef],+ [() => viewState.value?.detail.view, virtualListRef],([view, vl]) => {if (view && vl) {vl.scrollTo({ key: view });diff --git a/frontend/src/views/sql-editor/EditorPanel/common.ts b/frontend/src/views/sql-editor/EditorPanel/common.tsindex 48cb89779f..acda164bb0 100644--- a/frontend/src/views/sql-editor/EditorPanel/common.ts+++ b/frontend/src/views/sql-editor/EditorPanel/common.ts@@ -1,13 +1,12 @@-import { pausableWatch, useElementSize } from "@vueuse/core";import { first } from "lodash-es";-import type { DataTableInst, SelectOption } from "naive-ui";-import { computed, ref, unref, watch, type MaybeRef } from "vue";+import type { SelectOption } from "naive-ui";+import { computed, watch } from "vue";import {useConnectionOfCurrentSQLEditorTab,useDBSchemaV1Store,} from "@/store";import { DatabaseMetadataView } from "@/types/proto/v1/database_service";-import { hasSchemaProperty, nextAnimationFrame } from "@/utils";+import { hasSchemaProperty } from "@/utils";import { useEditorPanelContext } from "./context";export const useSelectSchema = () => {@@ -41,65 +40,3 @@ export const useSelectSchema = () => {return { selectedSchemaName, showSchemaSelect, options };};--export type AutoHeightDataTableOptions = {- maxHeight: number | null;-};-const defaultAutoHeightDataTableOptions = (): AutoHeightDataTableOptions => ({- maxHeight: null,-});--export const useAutoHeightDataTable = (- data?: MaybeRef<unknown[]>,- options?: MaybeRef<Partial<AutoHeightDataTableOptions>>-) => {- const opts = computed(() => ({- ...defaultAutoHeightDataTableOptions(),- ...unref(options),- }));- const GAP_HEIGHT = 2;- const dataTableRef = ref<DataTableInst>();- const containerElRef = ref<HTMLElement>();- const tableHeaderElRef = computed(- () =>- containerElRef.value?.querySelector("thead.n-data-table-thead") as- | HTMLElement- | undefined- );- const { height: containerHeight } = useElementSize(containerElRef);- const { height: tableHeaderHeight } = useElementSize(tableHeaderElRef);- const tableBodyHeight = ref(0);-- const { pause: pauseWatch, resume: resumeWatch } = pausableWatch(- [() => unref(data), containerHeight, tableHeaderHeight, opts],- async () => {- if (containerHeight.value === 0 || tableHeaderHeight.value === 0) return;- if (opts.value.maxHeight === null) {- // The table height is always limited by the container height- // and need not to be adjusted automatically- tableBodyHeight.value =- containerHeight.value - tableHeaderHeight.value - GAP_HEIGHT;- return;- }-- pauseWatch();- const experimentalMaxBodyHeight =- opts.value.maxHeight - tableHeaderHeight.value - GAP_HEIGHT;- tableBodyHeight.value = experimentalMaxBodyHeight;- await nextAnimationFrame();- resumeWatch();- },- { immediate: true }- );-- // Use this to avoid unnecessary initial rendering- const layoutReady = computed(() => tableHeaderHeight.value > 0);-- return {- dataTableRef,- containerElRef,- tableHeaderElRef,- tableBodyHeight,- layoutReady,- };-};