Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: query result view (#18369)
ecmadao1ba7727fdf3a
diff --git a/frontend/package.json b/frontend/package.jsonindex 4275f02e4c..ebba1b216e 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -32,9 +32,6 @@"@connectrpc/connect": "^2.1.1","@connectrpc/connect-web": "^2.1.1","@markdoc/markdoc": "0.5.4",- "@soerenmartius/vue3-clipboard": "0.1.2",- "@tanstack/vue-table": "8.21.3",- "@tanstack/vue-virtual": "^3.13.12","@vueuse/core": "13.9.0","bootstrap": "5.3.8","crypto-js": "^4.2.0",diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yamlindex c40d62b91f..fe741cc1db 100644--- a/frontend/pnpm-lock.yaml+++ b/frontend/pnpm-lock.yaml@@ -46,15 +46,6 @@ importers:'@markdoc/markdoc':specifier: 0.5.4version: 0.5.4- '@soerenmartius/vue3-clipboard':- specifier: 0.1.2- version: 0.1.2- '@tanstack/vue-table':- specifier: 8.21.3- version: 8.21.3([email protected]([email protected]))- '@tanstack/vue-virtual':- specifier: ^3.13.12- version: 3.13.12([email protected]([email protected]))'@vueuse/core':specifier: 13.9.0version: 13.9.0([email protected]([email protected]))@@ -2225,9 +2216,6 @@ packages:cpu: [x64]os: [win32]- '@soerenmartius/[email protected]':- resolution: {integrity: sha512-a5er6cFGcFIQ/3qg6kWvU0yFqIz9iWoQGEVs9azjevyRyMAKvj1w3JuLH9y6+u0WhMNby3kn7nuR8nktSnDesg==}-'@standard-schema/[email protected]':resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==}@@ -2331,24 +2319,6 @@ packages:peerDependencies:vite: ^5.2.0 || ^6 || ^7- '@tanstack/[email protected]':- resolution: {integrity: sha512-ldZXEhOBb8Is7xLs01fR3YEc3DERiz5silj8tnGkFZytt1abEvl/GhUmCE0PMLaMPTa3Jk4HbKmRlHmu+gCftg==}- engines: {node: '>=12'}-- '@tanstack/[email protected]':- resolution: {integrity: sha512-1YBOJfRHV4sXUmWsFSf5rQor4Ss82G8dQWLRbnk3GA4jeP8hQt1hxXh0tmflpC0dz3VgEv/1+qwPyLeWkQuPFA==}-- '@tanstack/[email protected]':- resolution: {integrity: sha512-rusRyd77c5tDPloPskctMyPLFEQUeBzxdQ+2Eow4F7gDPlPOB1UnnhzfpdvqZ8ZyX2rRNGmqNnQWm87OI2OQPw==}- engines: {node: '>=12'}- peerDependencies:- vue: '>=3.2'-- '@tanstack/[email protected]':- resolution: {integrity: sha512-vhF7kEU9EXWXh+HdAwKJ2m3xaOnTTmgcdXcF2pim8g4GvI7eRrk2YRuV5nUlZnd/NbCIX4/Ja2OZu5EjJL06Ww==}- peerDependencies:- vue: ^2.7.0 || ^3.0.0-'@tsconfig/[email protected]':resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==}@@ -7922,10 +7892,6 @@ snapshots:'@rollup/[email protected]':optional: true- '@soerenmartius/[email protected]':- dependencies:- clipboard: 2.0.11-'@standard-schema/[email protected]': {}'@tailwindcss/[email protected]([email protected])':@@ -8006,20 +7972,6 @@ snapshots:tailwindcss: 4.1.17vite: 7.2.6(@types/[email protected])([email protected])([email protected])([email protected])([email protected])- '@tanstack/[email protected]': {}-- '@tanstack/[email protected]': {}-- dependencies:- '@tanstack/table-core': 8.21.3- vue: 3.5.25([email protected])-- dependencies:- '@tanstack/virtual-core': 3.13.12- vue: 3.5.25([email protected])-'@tsconfig/[email protected]': {}'@tsconfig/[email protected]': {}diff --git a/frontend/src/components/AdvancedSearch/AdvancedSearch.vue b/frontend/src/components/AdvancedSearch/AdvancedSearch.vueindex e2ce7e1ecd..b57798057c 100644--- a/frontend/src/components/AdvancedSearch/AdvancedSearch.vue+++ b/frontend/src/components/AdvancedSearch/AdvancedSearch.vue@@ -12,9 +12,6 @@<template #prefix><divclass="flex flex-row items-center justify-start gap-x-2"- :style="{- 'max-width': `calc(${containerWidth}px - 14rem)`,- }"><div class="flex items-center gap-x-2"><FilterIcon class="w-4 h-4 text-control-placeholder" />@@ -83,7 +80,7 @@</template><script lang="ts" setup>-import { onClickOutside, useDebounceFn, useElementSize } from "@vueuse/core";+import { onClickOutside, useDebounceFn } from "@vueuse/core";import { cloneDeep, last } from "lodash-es";import { FilterIcon, XIcon } from "lucide-vue-next";import { type InputInst, NButton, NInput } from "naive-ui";@@ -115,7 +112,7 @@ const props = withDefaults(scopeOptions?: ScopeOption[];placeholder?: string | undefined;autofocus?: boolean;- overrideRouteQuery?: boolean;+ cacheQuery?: boolean;// Fallback params when no URL params and no cache.// Precedence: URL params > cache > defaultParams.// Readonly scopes from props.params are always preserved.@@ -125,18 +122,18 @@ const props = withDefaults(scopeOptions: () => [],autofocus: false,placeholder: undefined,- overrideRouteQuery: true,+ cacheQuery: true,defaultParams: undefined,});const emit = defineEmits<{+ (event: "keyup:enter"): void;(event: "update:params", params: SearchParams): void;(event: "select-unsupported-scope", id: SearchScopeId): void;}>();interface LocalState {- searchText: string;currentScope?: SearchScopeId;menuView?: "value" | "scope";scopeOptions: ScopeOption[];@@ -170,19 +167,7 @@ const defaultSearchParams = () => {return params;};-const buildSearchTextByParams = (params: SearchParams | undefined): string => {- const prefix = (params?.scopes ?? [])- .map((scope) => `${scope.id}:${scope.value}`)- .join(" ");- const query = params?.query ?? "";- if (!prefix && !query) {- return "";- }- return `${prefix} ${query}`;-};-const state = reactive<LocalState>({- searchText: buildSearchTextByParams(props.params),scopeOptions: [],fetchDataStateMap: new Map(),});@@ -199,21 +184,13 @@ const containerRef = ref<HTMLElement>();const tagsContainerRef = ref<HTMLElement>();const inputText = ref(props.params.query);const inputRef = ref<InputInst>();-const menuIndex = ref(-1);-const { width: containerWidth } = useElementSize(containerRef);+const menuIndex = ref(0);const focusedTagId = ref<SearchScopeId>();const editableScopes = computed(() => {return props.params.scopes.filter((s) => !s.readonly);});-watch(- () => props.params,- (params) => {- state.searchText = buildSearchTextByParams(params);- }-);-const valueOptions = computed(() => {if (state.menuView === "value" && currentScopeOption.value) {return currentScopeOption.value.options ?? [];@@ -565,42 +542,35 @@ const handleKeyUp = (e: KeyboardEvent) => {return;}}- if (maybeSelectMatchedScope()) {- maybeEmitIncompleteValue();- return;- }- if (maybeDeselectMismatchedScope()) {- maybeEmitIncompleteValue();- return;- }if (key === "Enter") {// Press enter to select scope (dive into the next step)// or select valueconst index = menuIndex.value;- if (index < 0) {- hideMenu();- return;- }if (state.menuView === "scope") {const option = visibleScopeOptions.value[index];if (option) {selectScope(option.id);- maybeEmitIncompleteValue();- return;+ return maybeEmitIncompleteValue();}}if (state.menuView === "value") {if (visibleValueOptions.value.length === 0) {const val = extractValue();if (val) {- selectValue(val);- return;+ return selectValue(val);}} else if (visibleValueOptions.value[index]) {- selectValue(visibleValueOptions.value[index].value);- return;+ return selectValue(visibleValueOptions.value[index].value);}}+ return emit("keyup:enter");+ }++ if (maybeSelectMatchedScope()) {+ return maybeEmitIncompleteValue();+ }+ if (maybeDeselectMismatchedScope()) {+ return maybeEmitIncompleteValue();}maybeEmitIncompleteValue();@@ -682,7 +652,7 @@ watch(() => state.menuView,() => {focusedTagId.value = undefined;- menuIndex.value = -1;+ menuIndex.value = 0;if (state.menuView === "value" && state.currentScope) {const value = getValueFromSearchParams(props.params, state.currentScope);if (value) {@@ -725,10 +695,8 @@ watch(visibleValueOptions, (newOptions, oldOptions) => {watch(() => props.params,(params) => {- if (!inputText.value) {- inputText.value = params.query;- }- if (props.overrideRouteQuery) {+ inputText.value = params.query;+ if (props.cacheQuery) {cachedQuery.value = buildSearchTextBySearchParams(params);}},diff --git a/frontend/src/components/AdvancedSearch/ScopeMenu.vue b/frontend/src/components/AdvancedSearch/ScopeMenu.vueindex 184ded6068..2380a96488 100644--- a/frontend/src/components/AdvancedSearch/ScopeMenu.vue+++ b/frontend/src/components/AdvancedSearch/ScopeMenu.vue@@ -1,42 +1,43 @@<template>- <div v-if="options.length > 0" v-show="show">- <NVirtualList- ref="virtualListRef"- :items="options"- :key-field="`id`"- :item-resizable="false"- :item-size="38"+ <div v-if="options.length > 0" ref="scrollbarContainerRef" v-show="show">+ <NScrollbar+ ref="scrollbarRef":style="{'max-height': `${maxListHeight}px`,}">- <template- #default="{ item: option, index }: { item: ScopeOption; index: number }"+ <div+ v-for="option, index in options"+ :key="`${option.id}-${index}`"+ class="flex gap-x-2 gap-y-0.5 px-3 py-2 cursor-pointer border-t text-sm"+ :class="[+ index === menuIndex && 'bg-gray-200/75',+ index === 0 ? 'border-transparent' : 'border-block-border',+ compactSize ? 'flex-col items-start' : 'flex-row items-center'+ ]"+ :data-index="index"+ :data-id="option.id"+ @mouseenter.prevent.stop="$emit('hover-item', index)"+ @mousedown.prevent.stop="$emit('select-scope', option.id)">- <div- class="h-[38px] flex gap-x-1 px-3 items-center cursor-pointer border-t text-sm"- :class="[- index === menuIndex && 'bg-gray-200/75',- index === 0 ? 'border-transparent' : 'border-block-border',- ]"- :data-index="index"- :data-id="option.id"- @mouseenter.prevent.stop="$emit('hover-item', index)"- @mousedown.prevent.stop="$emit('select-scope', option.id)"- >- <span class="text-accent">- {{ option.id }}{{ Boolean(option.description) ? ":" : "" }}- </span>+ <span class="text-accent">+ {{ option.id }}+ </span>+ <NEllipsis><span class="text-control-light">{{ option.description }}</span>- </div>- </template>- </NVirtualList>+ </NEllipsis>+ </div>+ </NScrollbar></div></template><script setup lang="ts">-import { useElementBounding, useWindowSize } from "@vueuse/core";-import { NVirtualList } from "naive-ui";+import {+ useElementBounding,+ useElementSize,+ useWindowSize,+} from "@vueuse/core";+import { NEllipsis, NScrollbar } from "naive-ui";import { computed, nextTick, ref, watch } from "vue";import type { SearchScopeId } from "@/utils";import type { ScopeOption } from "./types";@@ -52,10 +53,13 @@ defineEmits<{(event: "hover-item", index: number): void;}>();-const containerRef = ref<HTMLElement>();-const virtualListRef = ref<InstanceType<typeof NVirtualList>>();-const { top: containerTop } = useElementBounding(containerRef);+const scrollbarRef = ref<InstanceType<typeof NScrollbar>>();+const scrollbarContainerRef = ref<HTMLElement>();+const { top: containerTop } = useElementBounding(scrollbarContainerRef);const { height: windowHeight } = useWindowSize();+const { width: scrollbarWidth } = useElementSize(scrollbarContainerRef);++const compactSize = computed(() => scrollbarWidth.value <= 550);const maxListHeight = computed(() => {const MAX_HEIGHT = 480;@@ -67,26 +71,24 @@ const maxListHeight = computed(() => {);});-const highlightedItem = computed(() => {+const highlightedIndex = computed(() => {if (!props.show) return undefined;- const { options, menuIndex: index } = props;- const item = options[index];- if (item) {- return { item, index };+ const { options, menuIndex } = props;+ if (options[menuIndex]) {+ return menuIndex;}return undefined;});watch(- [highlightedItem, () => props.show],- ([item, show]) => {+ [highlightedIndex, () => props.show],+ ([index, show]) => {if (!show) return;- if (!item) return;+ if (index === undefined) return;nextTick(() => {- const virtualList = virtualListRef.value;- if (!virtualList) return;- virtualList.scrollTo({- index: item.index,+ scrollbarRef.value?.scrollTo({+ top: index * (compactSize.value ? 59 : 38),+ behavior: "auto",});});},diff --git a/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue b/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vueindex 31e16639b8..918d807400 100644--- a/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue+++ b/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue@@ -11,7 +11,7 @@:autofocus="false":placeholder="$t('database.filter-database')":scope-options="scopeOptions"- :override-route-query="false"+ :cache-query="false"/><PagedDatabaseTablemode="PROJECT_SHORT"diff --git a/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vue b/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vueindex 8f12d6b34d..d104f6b631 100644--- a/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vue+++ b/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/DatabaseResourceSelector.vue@@ -5,7 +5,7 @@:autofocus="false":placeholder="$t('database.filter-database')":scope-options="scopeOptions"- :override-route-query="false"+ :cache-query="false"/><NTransferid="database-resource-selector"diff --git a/frontend/src/components/SchemaEditorLite/Panels/PreviewPane.vue b/frontend/src/components/SchemaEditorLite/Panels/PreviewPane.vueindex 9d62ff082a..576f70873e 100644--- a/frontend/src/components/SchemaEditorLite/Panels/PreviewPane.vue+++ b/frontend/src/components/SchemaEditorLite/Panels/PreviewPane.vue@@ -89,7 +89,6 @@ const panelHeight = computed(() => {const mocked = toRef(props, "mocked");-// Simple replacement for useQuery to avoid @tanstack/vue-query dependencyconst status = ref<"pending" | "success" | "error">("success");const data = ref<string>("");const error = ref<Error | null>(null);diff --git a/frontend/src/components/SyncDatabaseSchemaV1/TargetDatabasesSelectPanel.vue b/frontend/src/components/SyncDatabaseSchemaV1/TargetDatabasesSelectPanel.vueindex 75fe6a7f2e..4a330a0b74 100644--- a/frontend/src/components/SyncDatabaseSchemaV1/TargetDatabasesSelectPanel.vue+++ b/frontend/src/components/SyncDatabaseSchemaV1/TargetDatabasesSelectPanel.vue@@ -17,7 +17,7 @@:autofocus="false":placeholder="$t('database.filter-database')":scope-options="scopeOptions"- :override-route-query="false"+ :cache-query="false"/><PagedDatabaseTablediff --git a/frontend/src/components/TwoFactorSecretModal.vue b/frontend/src/components/TwoFactorSecretModal.vueindex a3bdcbd3c4..17f4385bdd 100644--- a/frontend/src/components/TwoFactorSecretModal.vue+++ b/frontend/src/components/TwoFactorSecretModal.vue@@ -12,7 +12,7 @@<NButton @click="dismissModal">{{ $t("common.close") }}</NButton>- <NButton type="primary" @click="copySecret">+ <NButton v-if="isSupported" type="primary" @click="copySecret">{{ $t("common.copy") }}</NButton></div>@@ -20,11 +20,11 @@</template><script lang="ts" setup>+import { useClipboard } from "@vueuse/core";import { NButton } from "naive-ui";import { useI18n } from "vue-i18n";import { BBModal } from "@/bbkit";import { pushNotification } from "@/store";-import { toClipboard } from "@/utils";const props = defineProps({secret: {@@ -43,8 +43,12 @@ const dismissModal = () => {emit("close");};+const { copy: copyTextToClipboard, isSupported } = useClipboard({+ legacy: true,+});+const copySecret = () => {- toClipboard(props.secret).then(() => {+ copyTextToClipboard(props.secret).then(() => {pushNotification({module: "bytebase",style: "INFO",diff --git a/frontend/src/components/User/Settings/UserDataTable/index.vue b/frontend/src/components/User/Settings/UserDataTable/index.vueindex 9800967884..143cd9477c 100644--- a/frontend/src/components/User/Settings/UserDataTable/index.vue+++ b/frontend/src/components/User/Settings/UserDataTable/index.vue@@ -23,6 +23,7 @@<script lang="ts" setup>import { create } from "@bufbuild/protobuf";import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";+import { useClipboard } from "@vueuse/core";import type { DataTableColumn } from "naive-ui";import { NDataTable } from "naive-ui";import { computed, h, reactive, watchEffect } from "vue";@@ -40,7 +41,6 @@ import {UpdateUserRequestSchema,type User,} from "@/types/proto-es/v1/user_service_pb";-import { toClipboard } from "@/utils";import GroupsCell from "./cells/GroupsCell.vue";import UserOperationsCell from "./cells/UserOperationsCell.vue";import UserRolesCell from "./cells/UserRolesCell.vue";@@ -71,6 +71,10 @@ const userStore = useUserStore();const groupStore = useGroupStore();const workspaceStore = useWorkspaceV1Store();+const { copy: copyTextToClipboard, isSupported } = useClipboard({+ legacy: true,+});+watchEffect(async () => {const groupNames = new Set<string>();for (const user of props.userList) {@@ -171,8 +175,8 @@ const resetServiceKey = () => {).then((updatedUser) => {emit("update-user", updatedUser);- if (updatedUser.serviceKey) {- toClipboard(updatedUser.serviceKey).then(() => {+ if (updatedUser.serviceKey && isSupported.value) {+ copyTextToClipboard(updatedUser.serviceKey).then(() => {pushNotification({module: "bytebase",style: "INFO",diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex a2fe93dc76..fe1795ee88 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2028,7 +2028,6 @@"sql-editor": {"self": "SQL Editor","select-connection": "Please select connections",- "search-results": "Search Results","loading-databases": "Loading Databases...","show-databases-without-query-permission": "Show databases without query permissions","loading-data": "Loading Data...",@@ -2149,7 +2148,6 @@"result-limit": {"self": "Result limit"},- "n-per-page": "{n} / page","add-a-new-instance": "Add a new instance","web-socket": {"errors": {@@ -2176,7 +2174,8 @@"format-default": "Default","column-display-format": "Column Display Format","next-row": "Next Row",- "previous-row": "Previous Row"+ "previous-row": "Previous Row",+ "search-scope-column-description": "The column with {type} type. Input the value then press Enter to relocate to the matched row."},"schema-editor": {"self": "Schema Editor",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex fbcca64bd7..058d413051 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2028,7 +2028,6 @@"sql-editor": {"self": "Editor de SQL","select-connection": "Por favor seleccione conexiones",- "search-results": "Resultados de búsqueda","loading-databases": "Cargando bases de datos...","show-databases-without-query-permission": "Muestra las bases de datos que no tienen permisos de consulta","loading-data": "Cargando datos...",@@ -2149,7 +2148,6 @@"result-limit": {"self": "Límite de resultados"},- "n-per-page": "{n} / página","add-a-new-instance": "Agregar una nueva instancia","web-socket": {"errors": {@@ -2176,7 +2174,8 @@"format-default": "Por defecto","column-display-format": "Formato de visualización de columna","next-row": "siguiente fila",- "previous-row": "Fila anterior"+ "previous-row": "Fila anterior",+ "search-scope-column-description": "La columna con tipo {type}. Ingrese el valor y presione Enter para ir a la fila coincidente."},"schema-editor": {"self": "Editor de esquema",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 76347d95da..8821b5638b 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -2028,7 +2028,6 @@"sql-editor": {"self": "SQLエディタ","select-connection": "データ接続を選択してください",- "search-results": "の検索結果","loading-databases": "データベース情報をロードしています...","show-databases-without-query-permission": "クエリ権限のないデータベースを表示します","loading-data": "データのロード...",@@ -2149,7 +2148,6 @@"result-limit": {"self": "結果の制限"},- "n-per-page": "{n} / ページ","add-a-new-instance": "新しいインスタンスを追加する","web-socket": {"errors": {@@ -2176,7 +2174,8 @@"format-default": "デフォルト","column-display-format": "列表示形式","next-row": "次の行",- "previous-row": "前の行"+ "previous-row": "前の行",+ "search-scope-column-description": "{type}型の列。値を入力してEnterキーを押すと、一致する行に移動します。"},"schema-editor": {"self": "スキーマエディタ",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex d7ab34c97e..2322250e5e 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -2028,7 +2028,6 @@"sql-editor": {"self": "Trình soạn thảo SQL","select-connection": "Vui lòng chọn kết nối",- "search-results": "Kết quả tìm kiếm","loading-databases": "Đang tải Cơ sở dữ liệu...","show-databases-without-query-permission": "Hiển thị cơ sở dữ liệu không có quyền truy vấn","loading-data": "Đang tải Dữ liệu...",@@ -2149,7 +2148,6 @@"result-limit": {"self": "Giới hạn kết quả"},- "n-per-page": "{n} / trang","add-a-new-instance": "Thêm một phiên bản mới","web-socket": {"errors": {@@ -2176,7 +2174,8 @@"format-default": "Mặc định","column-display-format": "Định dạng hiển thị cột","next-row": "Dòng tiếp theo",- "previous-row": "Dòng trước"+ "previous-row": "Dòng trước",+ "search-scope-column-description": "Cột có kiểu {type}. Nhập giá trị và nhấn Enter để chuyển đến dòng phù hợp."},"schema-editor": {"self": "Trình soạn thảo lược đồ",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex e77752286e..18b12943cb 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2028,7 +2028,6 @@"sql-editor": {"self": "SQL 编辑器","select-connection": "请选择数据连接",- "search-results": "搜索结果","loading-databases": "加载数据库信息...","show-databases-without-query-permission": "显示没有查询权限的数据库","loading-data": "加载数据中...",@@ -2149,7 +2148,6 @@"result-limit": {"self": "结果限制"},- "n-per-page": "{n} / 页","add-a-new-instance": "添加实例","web-socket": {"errors": {@@ -2176,7 +2174,8 @@"format-default": "默认","column-display-format": "列显示格式","next-row": "下一行",- "previous-row": "上一行"+ "previous-row": "上一行",+ "search-scope-column-description": "{type} 类型的列。输入值后按回车键跳转到匹配的行。"},"schema-editor": {"self": "Schema 编辑器",diff --git a/frontend/src/utils/clipboard.ts b/frontend/src/utils/clipboard.tsdeleted file mode 100644index 7a95256f07..0000000000--- a/frontend/src/utils/clipboard.ts+++ /dev/null@@ -1,6 +0,0 @@-import type { toClipboard as ToClipboard } from "@soerenmartius/vue3-clipboard";--export const toClipboard: typeof ToClipboard = async (text, action) => {- const { toClipboard } = await import("@soerenmartius/vue3-clipboard");- return toClipboard(text, action);-};diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.tsindex dbb9848988..388d31af6a 100644--- a/frontend/src/utils/index.ts+++ b/frontend/src/utils/index.ts@@ -1,5 +1,4 @@export * from "./css";-export * from "./clipboard";export * from "./collections";export * from "./link";export * from "./role";diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.tsindex 0a298a2b5a..d9242d593c 100644--- a/frontend/src/utils/util.ts+++ b/frontend/src/utils/util.ts@@ -235,13 +235,13 @@ export function getHighlightHTMLByKeyWords(s: string, k: string) {* @returns HTML-safe string with highlighted matches*/export function getHighlightHTMLByRegExp(- s: string,+ target: string,pattern: string | string[],caseSensitive = false,className = "text-accent") {// Step 1: Escape HTML entities to prevent XSS- const escapedText = escapeHtml(s);+ const escapedText = escapeHtml(target);if (!pattern || (Array.isArray(pattern) && pattern.length === 0)) {return escapedText;}diff --git a/frontend/src/utils/v1/advanced-search/common.ts b/frontend/src/utils/v1/advanced-search/common.tsindex 38c48b6aa5..762bdf269d 100644--- a/frontend/src/utils/v1/advanced-search/common.ts+++ b/frontend/src/utils/v1/advanced-search/common.ts@@ -38,7 +38,8 @@ export const AllSearchScopeIdList = [export type SearchScopeId =| (typeof AllSearchScopeIdList)[number]- | CommonFilterScopeId;+ | CommonFilterScopeId+ | string;export type SearchScope = {id: SearchScopeId;diff --git a/frontend/src/utils/v1/instance.ts b/frontend/src/utils/v1/instance.tsindex f8ccb7685d..000a13645d 100644--- a/frontend/src/utils/v1/instance.ts+++ b/frontend/src/utils/v1/instance.ts@@ -143,14 +143,6 @@ export const instanceV1HasCreateDatabase = (return enginesSupportCreateDatabase().includes(engine);};-export const instanceV1HasStructuredQueryResult = (- instanceOrEngine: Instance | InstanceResource | Engine-): boolean => {- const engine = engineOfInstanceV1(instanceOrEngine);- if (engine === Engine.REDIS) return false;- return true;-};-export const instanceV1HasSSL = (instanceOrEngine: Instance | InstanceResource | Engine): boolean => {diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsxindex 3e2807bc51..be0098edc0 100644--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx@@ -1,3 +1,4 @@+import { useClipboard } from "@vueuse/core";import { cloneDeep, head } from "lodash-es";import {CodeIcon,@@ -53,7 +54,6 @@ import {isSimilarSQLEditorTab,sortByDictionary,supportGetStringSchema,- toClipboard,} from "@/utils";import { type SQLEditorEvents, useSQLEditorContext } from "../../context";import { keyWithPosition } from "../../EditorCommon";@@ -570,7 +570,13 @@ const applyContentToCurrentTabOrCopyToClipboard = async (};const copyToClipboard = (content: string) => {- toClipboard(content).then(() => {+ const { copy: copyTextToClipboard, isSupported } = useClipboard({+ legacy: true,+ });+ if (!isSupported.value) {+ return;+ }+ copyTextToClipboard(content).then(() => {pushNotification({module: "bytebase",style: "SUCCESS",diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vueindex 4ec093e7e8..6d6b5113bc 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue@@ -78,7 +78,7 @@:autofocus="false":placeholder="$t('database.filter-database')":scope-options="scopeOptions"- :override-route-query="false"+ :cache-query="false"/></div><divdiff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vueindex ea6d15f8da..f1211e91ee 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue@@ -40,7 +40,7 @@@click.stop="showDetail"><template #icon>- <heroicons:arrows-pointing-out class="w-3 h-3" />+ <ExpandIcon class="w-3 h-3" /></template></NButton></div>@@ -48,28 +48,26 @@</template><script setup lang="ts">-import { type Table } from "@tanstack/vue-table";import { useResizeObserver } from "@vueuse/core";import { escape } from "lodash-es";+import { ExpandIcon } from "lucide-vue-next";import { NButton } from "naive-ui";import { twMerge } from "tailwind-merge";import { computed, ref } from "vue";import { type ComposedDatabase } from "@/types";import { Engine } from "@/types/proto-es/v1/common_pb";-import type { QueryRow, RowValue } from "@/types/proto-es/v1/sql_service_pb";-import { extractSQLRowValuePlain, getHighlightHTMLByRegExp } from "@/utils";+import type { RowValue } from "@/types/proto-es/v1/sql_service_pb";+import { getHighlightHTMLByRegExp, type SearchScope } from "@/utils";import { useSQLResultViewContext } from "../context";+import BinaryFormatButton from "./common/BinaryFormatButton.vue";import {type BinaryFormat,- detectBinaryFormat,- formatBinaryValue,useBinaryFormatContext,-} from "./binary-format-store";-import BinaryFormatButton from "./common/BinaryFormatButton.vue";+} from "./common/binary-format-store";import { useSelectionContext } from "./common/selection-logic";+import { getPlainValue } from "./common/utils";const props = defineProps<{- table: Table<QueryRow>;value: RowValue;setIndex: number;rowIndex: number;@@ -77,9 +75,11 @@ const props = defineProps<{allowSelect?: boolean;columnType: string; // Column type from QueryResultdatabase: ComposedDatabase;+ scope?: SearchScope;+ keyword: string;}>();-const { detail, keyword } = useSQLResultViewContext();+const { detail } = useSQLResultViewContext();const { getBinaryFormat, setBinaryFormat } = useBinaryFormatContext();const {@@ -109,17 +109,22 @@ const binaryFormat = computed(() => {});});-useResizeObserver(wrapperRef, (entries) => {- const div = entries[0].target as HTMLDivElement;- const contentHeight = div.scrollHeight;- const visibleHeight = div.offsetHeight;+useResizeObserver(cellRef, () => {+ const cell = cellRef.value;+ const wrapper = wrapperRef.value;+ if (!cell || !wrapper) return;+// Check if content is truncated vertically (due to line-clamp)- if (contentHeight > visibleHeight + 2) {- // +2 for minor pixel differences- truncated.value = true;- } else {- truncated.value = false;- }+ const contentHeight = wrapper.scrollHeight;+ const visibleHeight = wrapper.offsetHeight;+ const verticalTruncated = contentHeight > visibleHeight + 2; // +2 for minor pixel differences++ // Check if content is truncated horizontally+ const contentWidth = wrapper.scrollWidth;+ const visibleWidth = cell.offsetWidth;+ const horizontalTruncated = contentWidth > visibleWidth + 2;++ truncated.value = verticalTruncated || horizontalTruncated;});const clickable = computed(() => {@@ -135,30 +140,36 @@ const clickable = computed(() => {return false;});+const selected = computed(() => {+ if (!allowSelect.value) {+ return false;+ }+ if (+ selectionState.value.columns.length === 1 &&+ selectionState.value.rows.length === 1+ ) {+ if (+ selectionState.value.columns[0] === props.colIndex &&+ selectionState.value.rows[0] === props.rowIndex+ ) {+ return true;+ }+ } else if (+ selectionState.value.columns.includes(props.colIndex) ||+ selectionState.value.rows.includes(props.rowIndex)+ ) {+ return true;+ }+ return false;+});+const classes = computed(() => {const classes: string[] = [];if (allowSelect.value) {classes.push("cursor-pointer");- classes.push("hover:bg-white/20 dark:hover:bg-black/5");- if (props.colIndex === 0) {- classes.push("pl-3");- }- if (- selectionState.value.columns.length === 1 &&- selectionState.value.rows.length === 1- ) {- if (- selectionState.value.columns[0] === props.colIndex &&- selectionState.value.rows[0] === props.rowIndex- ) {- classes.push("bg-accent/10! dark:bg-accent/40!");- }- } else if (- selectionState.value.columns.includes(props.colIndex) ||- selectionState.value.rows.includes(props.rowIndex)- ) {- classes.push("bg-accent/10! dark:bg-accent/40!");- } else {+ classes.push("hover:bg-accent/10 dark:hover:bg-accent/20");+ if (selected.value) {+ classes.push("bg-accent/20! dark:bg-accent/40!");}} else {classes.push("select-none");@@ -166,48 +177,8 @@ const classes = computed(() => {return twMerge(classes);});-// Format the binary value based on selected format (proto-es oneof pattern)-const formattedValue = computed(() => {- const bytesValue =- props.value.kind?.case === "bytesValue"- ? props.value.kind.value- : undefined;- if (!bytesValue) {- return props.value;- }-- // Determine the format to use - column override, cell override, or auto-detected format- let actualFormat = binaryFormat.value ?? "DEFAULT";-- // If format is DEFAULT or undefined, auto-detect based on column type and content- if (actualFormat === "DEFAULT") {- actualFormat = detectBinaryFormat({- bytesValue,- columnType: props.columnType,- });- }-- const stringValue = formatBinaryValue({- bytesValue,- format: actualFormat,- });-- // Return proto-es oneof structure with stringValue- return {- ...props.value,- kind: {- case: "stringValue" as const,- value: stringValue,- },- };-});-const plainValue = computed(() => {- const value = extractSQLRowValuePlain(formattedValue.value);- if (value === undefined || value === null) {- return value;- }- return String(value);+ return getPlainValue(props.value, props.columnType, binaryFormat.value);});const html = computed(() => {@@ -224,13 +195,16 @@ const html = computed(() => {return `<br style="min-width: 1rem; display: inline-flex;" />`;}- const kw = keyword.value.trim();+ let kw = props.scope?.value.trim();+ if (!kw) {+ kw = props.keyword.trim();+ }if (!kw) {return escape(value);}return getHighlightHTMLByRegExp(- escape(value),+ value,escape(kw),false /* !caseSensitive */);@@ -258,11 +232,6 @@ const showDetail = () => {set: props.setIndex,row: props.rowIndex,col: props.colIndex,- table: props.table,};};--defineExpose({- plainValue,-});</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/VirtualDataTable.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/VirtualDataTable.vueindex 9d21e73c52..e20a6e3a75 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/VirtualDataTable.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/VirtualDataTable.vue@@ -2,74 +2,87 @@<divref="containerRef"class="relative w-full flex-1 overflow-auto flex flex-col rounded-sm border dark:border-zinc-500"- :style="{- maxHeight: maxHeight ? `${maxHeight}px` : undefined,- }"><tableref="tableRef"class="relative border-collapse w-full -mx-px table-fixed"- v-bind="tableResize.getTableProps()"+ v-bind="tableResize.tableProps"><theadclass="bg-gray-50 dark:bg-gray-700 sticky top-0 z-1 drop-shadow-xs"><tr>+ <!-- header for the index --><th- v-for="header of columns"- :key="`${setIndex}-${header.id}`"+ :key="`${setIndex}-0-index`"+ class="`group relative px-1 py-2 tracking-wider border-x border-block-border dark:border-zinc-500"+ v-bind="tableResize.getColumnProps(0)"+ >+ <!-- Use the max index to calculate the cell width -->+ <div+ :class="[+ 'textinfolabel opacity-0',+ ]"+ >{{ rows.length }}</div>+ <div+ class="absolute w-2 right-0 top-0 bottom-0 cursor-col-resize"+ @pointerdown="tableResize.startResizing(0)"+ @click.stop.prevent+ />+ </th>+ <!-- header for columns -->+ <th+ v-for="(header, columnIndex) of columns"+ :key="`${setIndex}-${columnIndex + 1}-${header.id}`"class="group relative px-2 py-2 min-w-8 text-left text-xs font-medium text-gray-500 dark:text-gray-300 tracking-wider border-x border-block-border dark:border-zinc-500":class="{'cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800':!selectionDisabled,'bg-accent/10! dark:bg-accent/40!':selectionState.rows.length === 0 &&- selectionState.columns.includes(header.index),- 'pl-6': header.index === 0 && !selectionDisabled,+ selectionState.columns.includes(columnIndex),}"- v-bind="tableResize.getColumnProps(header.index)"- @click.stop="selectColumn(header.index)"+ v-bind="tableResize.getColumnProps(columnIndex + 1)"+ @click.stop="selectColumn(columnIndex)"><div class="flex items-center overflow-hidden"><span class="flex flex-row items-center select-none"><template- v-if="String(header.column.columnDef.header).length > 0"+ v-if="String(header.name).length > 0">- {{ header.column.columnDef.header }}+ {{ header.name }}</template><br v-else class="min-h-4 inline-flex" /></span><MaskingReasonPopover- v-if="getMaskingReason && getMaskingReason(header.index)"- :reason="getMaskingReason(header.index)"+ v-if="getMaskingReason && getMaskingReason(columnIndex)"+ :reason="getMaskingReason(columnIndex)"class="ml-0.5 shrink-0"/><SensitiveDataIcon- v-else-if="isSensitiveColumn(header.index)"+ v-else-if="isSensitiveColumn(columnIndex)"class="ml-0.5 shrink-0"/><ColumnSortedIcon- :is-sorted="header.column.getIsSorted()"- @click.stop.prevent="- header.column.getToggleSortingHandler()?.($event)- "+ :is-sorted="getColumnSortDirection(columnIndex)"+ @click.stop.prevent="handleHeaderClick(columnIndex)"/><!-- Add binary format button if this column has binary data --><BinaryFormatButton- v-if="existBinaryValue(header.index)"+ v-if="existBinaryValue(columnIndex)":format="getBinaryFormat({- colIndex: header.index,+ colIndex: columnIndex,setIndex,})"@update:format="(format: BinaryFormat) =>setBinaryFormat({- colIndex: header.index,+ colIndex: columnIndex,setIndex,format,})@@ -81,154 +94,168 @@<!-- The drag-to-resize handler --><divclass="absolute w-2 right-0 top-0 bottom-0 cursor-col-resize"- @pointerdown="tableResize.startResizing(header.index)"+ @pointerdown="tableResize.startResizing(columnIndex + 1)"@click.stop.prevent/></th></tr></thead>- <tbody>- <!-- Virtual scrolling container -->- <tr>- <td :colspan="columns.length" class="p-0! border-0!">+ </table>+ <NVirtualList+ ref="virtualListRef"+ :items="rows"+ :item-size="ROW_HEIGHT"+ :style="{ width: `${tableResize.totalWidth.value}px` }"+ >+ <template #default="{ item: row, index: rowIndex }: { item: { item: QueryRow; }; index: number; }">+ <div+ :key="`${setIndex}-${rowIndex}`"+ class="flex group"+ :data-row-index="rowIndex"+ :style="{+ height: `${ROW_HEIGHT}px`,+ }"+ >+ <!-- the index cell -->+ <div+ :key="`${setIndex}-${rowIndex}-0`"+ class="relative flex items-center pl-3 shrink-0 text-sm dark:text-gray-100 leading-5 whitespace-nowrap break-all border-block-border dark:border-zinc-500 group-even:bg-gray-100/50 dark:group-even:bg-gray-700/50"+ :class="{+ 'border-r': true,+ 'border-b': rowIndex < (rows.length - 1),+ 'bg-accent/10! dark:bg-accent/40!': activeRowIndex === rowIndex,+ 'bg-accent/20! dark:bg-accent/40!': selectionState.rows.includes(rowIndex)+ }"+ :data-col-index="0"+ :style="{+ height: `${ROW_HEIGHT}px`,+ width: `${tableResize.getColumnWidth(0)}px`,+ }"+ >+ <NPerformantEllipsis+ :class="[+ 'overflow-hidden textinfolabel',+ selectionDisabled+ ? ''+ : 'ml-2',+ ]"+ >+ {{ rowIndex + 1 }}+ </NPerformantEllipsis>+<div- ref="scrollerRef"- class="relative w-full"- :style="{- height: `${virtualizer.getTotalSize()}px`,+ v-if="!selectionDisabled"+ class="absolute inset-y-0 left-0 w-3 cursor-pointer bg-accent/5 dark:bg-white/10 hover:bg-accent/10 dark:hover:bg-accent/40"+ :class="{+ 'bg-accent/20! dark:bg-accent/40!':+ selectionState.columns.length === 0 &&+ selectionState.rows.includes(+ rowIndex+ ),}"+ @click.prevent.stop="+ selectRow(rowIndex)+ "+ ></div>+ </div>++ <!-- other cells -->+ <div+ v-for="(cell, columnIndex) of row.item.values"+ :key="`${setIndex}-${rowIndex}-${columnIndex + 1}`"+ class="relative shrink-0 text-sm dark:text-gray-100 leading-5 whitespace-nowrap break-all border-block-border dark:border-zinc-500 group-even:bg-gray-100/50 dark:group-even:bg-gray-700/50"+ :class="{+ 'border-r': columnIndex < (row.item.values.length - 1),+ 'border-b': rowIndex < (rows.length - 1),+ }"+ :data-col-index="columnIndex + 1"+ :style="{+ height: `${ROW_HEIGHT}px`,+ width: `${tableResize.getColumnWidth(columnIndex + 1)}px`,+ }"+ >+ <div+ class="h-full flex items-center overflow-hidden">- <div- class="absolute top-0 left-0 w-full"- :style="{- transform: `translateY(${virtualItems[0]?.start ?? 0}px)`,+ <TableCell+ :value="cell"+ :keyword="search.query"+ :scope="search.scopes.find(scope => scope.id === columns[columnIndex]?.id)"+ :set-index="setIndex"+ :row-index="rowIndex"+ :col-index="columnIndex"+ :allow-select="true"+ :column-type="getColumnTypeByIndex(columnIndex)"+ class="h-full w-full truncate"+ :database="database"+ :class="{+ 'bg-accent/10! dark:bg-accent/40!': activeRowIndex === rowIndex}"- >- <table- class="w-full border-collapse table-fixed"- :style="{ tableLayout: 'fixed' }"- >- <colgroup>- <col- v-for="(_, index) in columns"- :key="`col-${index}`"- v-bind="tableResize.getColumnProps(index)"- />- </colgroup>- <tbody>- <tr- v-for="virtualRow in virtualItems"- :key="`${setIndex}-${virtualRow.index}`"- class="group"- :data-row-index="offset + virtualRow.index"- :style="{- height: `${virtualRow.size}px`,- }"- >- <td- v-for="(cell, columnIndex) of rows[- virtualRow.index- ].getVisibleCells()"- :key="`${setIndex}-${virtualRow.index}-${columnIndex}`"- class="relative max-w-[50vw] p-0! text-sm dark:text-gray-100 leading-5 whitespace-nowrap break-all border-x border-b border-block-border dark:border-zinc-500 group-even:bg-gray-100/50 dark:group-even:bg-gray-700/50"- :data-col-index="columnIndex"- :style="{- height: `${virtualRow.size}px`,- }"- >- <div- :class="[- 'h-full flex items-center',- columnIndex === 0 && !selectionDisabled- ? 'ml-3'- : '',- ]"- >- <TableCell- :table="table"- :value="cell.getValue<RowValue>()"- :keyword="keyword"- :set-index="setIndex"- :row-index="offset + virtualRow.index"- :col-index="columnIndex"- :allow-select="true"- :column-type="getColumnTypeByIndex(columnIndex)"- :class="{- // 'ml-3': columnIndex === 0 && !selectionDisabled,- 'h-full': true,- 'w-full': true,- }"- :database="database"- />- </div>- <div- v-if="columnIndex === 0 && !selectionDisabled"- class="absolute inset-y-0 left-0 w-3 cursor-pointer bg-accent/5 dark:bg-white/10 hover:bg-accent/10 dark:hover:bg-accent/40"- :class="{- 'bg-accent/10! dark:bg-accent/40!':- selectionState.columns.length === 0 &&- selectionState.rows.includes(- offset + virtualRow.index- ),- }"- @click.prevent.stop="- selectRow(offset + virtualRow.index)- "- ></div>- </td>- </tr>- </tbody>- </table>- </div>+ /></div>- </td>- </tr>- </tbody>- </table>- <div- class="w-full sticky left-0 flex justify-center items-center py-12"- v-if="rows.length === 0"- >- <NEmpty />- </div>+ </div>+ </div>+ </template>+ </NVirtualList></div></template><script lang="ts" setup>-import type { Table } from "@tanstack/vue-table";-import { useVirtualizer } from "@tanstack/vue-virtual";-import { NEmpty } from "naive-ui";-import { computed, nextTick, onMounted, ref, watch } from "vue";-import { type ComposedDatabase } from "@/types";-import {- type QueryRow,- type RowValue,-} from "@/types/proto-es/v1/sql_service_pb";-import { useSQLResultViewContext } from "../context";+import { useWindowSize, watchDebounced } from "@vueuse/core";+import { NPerformantEllipsis, NVirtualList } from "naive-ui";+import { nextTick, ref } from "vue";+import { type ComposedDatabase, DEBOUNCE_SEARCH_DELAY } from "@/types";+import { type QueryRow } from "@/types/proto-es/v1/sql_service_pb";+import { type SearchParams } from "@/utils";+import BinaryFormatButton from "./common/BinaryFormatButton.vue";import {type BinaryFormat,getBinaryFormatByColumnType,useBinaryFormatContext,-} from "./binary-format-store";-import BinaryFormatButton from "./common/BinaryFormatButton.vue";+} from "./common/binary-format-store";import ColumnSortedIcon from "./common/ColumnSortedIcon.vue";import MaskingReasonPopover from "./common/MaskingReasonPopover.vue";import SensitiveDataIcon from "./common/SensitiveDataIcon.vue";import { useSelectionContext } from "./common/selection-logic";-import { getColumnType } from "./common/utils";+import type {+ ResultTableColumn,+ ResultTableRow,+ SortDirection,+ SortState,+} from "./common/types";import TableCell from "./TableCell.vue";import useTableColumnWidthLogic from "./useTableResize";const props = defineProps<{- table: Table<QueryRow>;+ rows: ResultTableRow[];+ columns: ResultTableColumn[];setIndex: number;- offset: number;+ activeRowIndex: number;isSensitiveColumn: (index: number) => boolean;getMaskingReason?: (index: number) => any;- maxHeight?: number;database: ComposedDatabase;+ sortState?: SortState;+ search: SearchParams;}>();+const emit = defineEmits<{+ (event: "toggle-sort", columnIndex: number): void;+}>();++const ROW_HEIGHT = 35; // 35px height for every row+const { width: windowWidth } = useWindowSize();++const getColumnSortDirection = (columnIndex: number): SortDirection => {+ if (!props.sortState || props.sortState.columnIndex !== columnIndex) {+ return false;+ }+ return props.sortState.direction;+};++const handleHeaderClick = (columnIndex: number) => {+ emit("toggle-sort", columnIndex);+};+const {state: selectionState,disabled: selectionDisabled,@@ -237,7 +264,7 @@ const {} = useSelectionContext();const containerRef = ref<HTMLDivElement>();const tableRef = ref<HTMLTableElement>();-const scrollerRef = ref<HTMLDivElement>();+const virtualListRef = ref<InstanceType<typeof NVirtualList>>();const tableResize = useTableColumnWidthLogic({tableRef,@@ -248,13 +275,8 @@ const tableResize = useTableColumnWidthLogic({const { getBinaryFormat, setBinaryFormat } = useBinaryFormatContext();-const { keyword } = useSQLResultViewContext();--const rows = computed(() => props.table.getRowModel().rows);-const columns = computed(() => props.table.getFlatHeaders());-const getColumnTypeByIndex = (columnIndex: number) => {- return getColumnType(columns.value[columnIndex]);+ return props.columns[columnIndex].columnType;};const existBinaryValue = (columnIndex: number) => {@@ -263,12 +285,11 @@ const existBinaryValue = (columnIndex: number) => {}// Check each row in the column for binary data (proto-es oneof pattern)- for (const row of rows.value) {- const cell = row.getVisibleCells()[columnIndex];+ for (const row of props.rows) {+ const cell = row.item.values[columnIndex];if (!cell) continue;- const value = cell.getValue<RowValue>();- if (value?.kind?.case === "bytesValue") {+ if (cell.kind?.case === "bytesValue") {return true;}}@@ -276,44 +297,33 @@ const existBinaryValue = (columnIndex: number) => {return false;};-// Virtual scrolling setup-const virtualizer = useVirtualizer(- computed(() => ({- count: rows.value.length,- getScrollElement: () => containerRef.value ?? null,- estimateSize: () => 35, // Estimated row height- overscan: 10, // Number of items to render outside visible area- }))-);--const virtualItems = computed(() => virtualizer.value.getVirtualItems());--onMounted(() => {- nextTick(() => {- tableResize.reset();- });-});-// Re-initialize column widths when data changes-watch(- () => [rows.value.length, columns.value.length],+watchDebounced(+ () => props.columns,() => {nextTick(() => {tableResize.reset();});- }+ },+ { immediate: true, deep: true, debounce: DEBOUNCE_SEARCH_DELAY });-const scrollTo = (x: number, y: number) => {- containerRef.value?.scroll(x, y);-};--watch(- () => props.offset,+watchDebounced(+ () => windowWidth.value,() => {- // When the offset changed, we need to reset the scroll position.- scrollTo(0, 0);- virtualizer.value.scrollToOffset(0);- }+ nextTick(() => {+ tableResize.reset();+ });+ },+ { debounce: DEBOUNCE_SEARCH_DELAY });++defineExpose({+ scrollTo: (index: number) =>+ virtualListRef.value?.scrollTo({+ top: Math.max(0, (index - 1) * ROW_HEIGHT),+ debounce: true,+ behavior: "smooth",+ }),+});</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/BinaryFormatButton.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/BinaryFormatButton.vueindex 42e09a444c..a0a11b10e7 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/BinaryFormatButton.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/BinaryFormatButton.vue@@ -52,7 +52,7 @@import { CodeIcon } from "lucide-vue-next";import { NButton, NPopover, NRadio, NRadioGroup } from "naive-ui";import { computed } from "vue";-import { type BinaryFormat } from "../binary-format-store";+import { type BinaryFormat } from "../common/binary-format-store";const emit = defineEmits<{(e: "update:format", format: BinaryFormat): void;diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/ColumnSortedIcon.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/ColumnSortedIcon.vueindex c0b121cc55..131fba0181 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/ColumnSortedIcon.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/ColumnSortedIcon.vue@@ -10,10 +10,10 @@</template><script lang="ts" setup>-import type { SortDirection } from "@tanstack/vue-table";import { ArrowDownWideNarrow, ArrowUpWideNarrow } from "lucide-vue-next";+import type { SortDirection } from "../common/types";defineProps<{- isSorted: false | SortDirection;+ isSorted: SortDirection;}>();</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/binary-format-store.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/binary-format-store.tssimilarity index 99%rename from frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/binary-format-store.tsrename to frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/binary-format-store.tsindex 812f835170..1ca1ef40a2 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/binary-format-store.ts+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/binary-format-store.ts@@ -2,6 +2,7 @@ import type { InjectionKey, Ref } from "vue";import { inject, provide, ref } from "vue";export type BinaryFormat = "DEFAULT" | "BINARY" | "HEX" | "TEXT" | "BOOLEAN";+interface ColumnKeyParams {colIndex: number;setIndex?: number;diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/selection-logic.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/selection-logic.tsindex dce1a3074f..0b1e3303e0 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/selection-logic.ts+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/selection-logic.ts@@ -1,7 +1,7 @@-import type { Cell, Row, Table } from "@tanstack/vue-table";-import { useEventListener } from "@vueuse/core";+import { useClipboard, useEventListener } from "@vueuse/core";import { sortBy } from "lodash-es";import {+ type ComputedRef,computed,type InjectionKey,inject,@@ -9,19 +9,18 @@ import {provide,type Ref,ref,- watch,} from "vue";import { useI18n } from "vue-i18n";import { pushNotification } from "@/store";import type { QueryRow, RowValue } from "@/types/proto-es/v1/sql_service_pb";-import { extractSQLRowValuePlain, isDescendantOf, toClipboard } from "@/utils";+import { extractSQLRowValuePlain, isDescendantOf } from "@/utils";import { useSQLResultViewContext } from "../../context";import {detectBinaryFormat,formatBinaryValue,useBinaryFormatContext,-} from "../binary-format-store";-import { getColumnType } from "./utils";+} from "./binary-format-store";+import type { ResultTableColumn, ResultTableRow } from "./types";const PREVENT_DISMISS_SELECTION = "bb-prevent-dismiss-selection";@@ -44,10 +43,20 @@ export const KEY = Symbol("bb.sql-editor.result-view.selection") as InjectionKey<SelectionContext>;-export const provideSelectionContext = (table: Ref<Table<QueryRow>>) => {+export const provideSelectionContext = ({+ rows,+ columns,+}: {+ rows: ComputedRef<ResultTableRow[]>;+ columns: ComputedRef<ResultTableColumn[]>;+}) => {const { t } = useI18n();const { getBinaryFormat } = useBinaryFormatContext();+ const { copy: copyTextToClipboard, isSupported } = useClipboard({+ legacy: true,+ });+const copying = ref(false);const state = ref<SelectionState>({rows: [],@@ -125,11 +134,6 @@ export const provideSelectionContext = (table: Ref<Table<QueryRow>>) => {deselect();});- watch(table, deselect, {- immediate: true,- deep: false,- });-const getFormattedValue = ({value,colIndex,@@ -158,10 +162,9 @@ export const provideSelectionContext = (table: Ref<Table<QueryRow>>) => {});}- const header = table.value.getFlatHeaders()[colIndex];const detectedFormat = detectBinaryFormat({bytesValue: value.kind.value,- columnType: getColumnType(header),+ columnType: columns.value[colIndex].columnType,});return formatBinaryValue({bytesValue: value.kind.value,@@ -175,41 +178,39 @@ export const provideSelectionContext = (table: Ref<Table<QueryRow>>) => {const getValues = () => {if (state.value.rows.length === 1 && state.value.columns.length === 1) {- const row =- table.value.getPrePaginationRowModel().rows[state.value.rows[0]];+ const row = rows.value[state.value.rows[0]];if (!row) {return "";}- const cell = row.getVisibleCells()[state.value.columns[0]];+ const cell = row.item.values[state.value.columns[0]];if (!cell) {return "";}// Get the cell valuereturn getFormattedValue({- value: cell.getValue<RowValue>(),+ value: cell,colIndex: state.value.columns[0],rowIndex: state.value.rows[0],});} else if (state.value.rows.length > 0) {- const rows: Row<QueryRow>[] = [];- for (const row of state.value.rows) {- const d = table.value.getPrePaginationRowModel().rows[row];+ const data: QueryRow[] = [];+ for (const rowIndex of state.value.rows) {+ const d = rows.value[rowIndex].item;if (!d) {continue;}- rows.push(d);+ data.push(d);}- if (rows.length === 0) {+ if (data.length === 0) {return "";}- return rows+ return data.map((row, rowIdx) => {- const cells = row.getVisibleCells();- return cells+ return row.values.map((cell, colIdx) => {return getFormattedValue({- value: cell.getValue<RowValue>(),+ value: cell,colIndex: colIdx,rowIndex: state.value.rows[rowIdx],});@@ -218,12 +219,11 @@ export const provideSelectionContext = (table: Ref<Table<QueryRow>>) => {}).join("\n");} else if (state.value.columns.length > 0) {- const rows = table.value.getRowModel().rows;- const values: Cell<QueryRow, unknown>[][] = [];- for (const row of rows) {- const cells: Cell<QueryRow, unknown>[] = [];+ const values: RowValue[][] = [];+ for (const row of rows.value) {+ const cells: RowValue[] = [];for (const column of state.value.columns) {- const cell = row.getVisibleCells()[column];+ const cell = row.item.values[column];if (!cell) continue;cells.push(cell);}@@ -237,7 +237,7 @@ export const provideSelectionContext = (table: Ref<Table<QueryRow>>) => {cells.map((cell, colIdx) => {return getFormattedValue({- value: cell.getValue<RowValue>(),+ value: cell,rowIndex: rowIdx,colIndex: state.value.columns[colIdx],});@@ -251,7 +251,7 @@ export const provideSelectionContext = (table: Ref<Table<QueryRow>>) => {};const copy = () => {- if (disabled.value) {+ if (disabled.value || !isSupported.value) {return false;}const values = getValues();@@ -259,7 +259,7 @@ export const provideSelectionContext = (table: Ref<Table<QueryRow>>) => {return false;}copying.value = true;- toClipboard(values)+ copyTextToClipboard(values).catch((err: any) => {const errors = [t("common.failed")];if (err && err instanceof Error) {diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/types.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/types.tsnew file mode 100644index 0000000000..74f700d404--- /dev/null+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/types.ts@@ -0,0 +1,19 @@+import type { QueryRow } from "@/types/proto-es/v1/sql_service_pb";++export interface ResultTableColumn {+ id: string;+ name: string;+ columnType: string;+}++export interface ResultTableRow {+ key: number;+ item: QueryRow;+}++export type SortDirection = "asc" | "desc" | false;++export interface SortState {+ columnIndex: number;+ direction: SortDirection;+}diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/utils.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/utils.tsindex ca76824076..694184bd43 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/utils.ts+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/common/utils.ts@@ -1,14 +1,60 @@-import type { Header } from "@tanstack/vue-table";-import type { QueryRow } from "@/types/proto-es/v1/sql_service_pb";+import type { RowValue } from "@/types/proto-es/v1/sql_service_pb";+import { extractSQLRowValuePlain } from "@/utils";+import {+ type BinaryFormat,+ detectBinaryFormat,+ formatBinaryValue,+} from "./binary-format-store";-interface ColumnMeta {- columnType: string;-}+const getFormattedValue = (+ rowValue: RowValue,+ columnType: string,+ binaryFormat: BinaryFormat | undefined+) => {+ const bytesValue =+ rowValue.kind?.case === "bytesValue" ? rowValue.kind.value : undefined;+ if (!bytesValue) {+ return rowValue;+ }++ // Determine the format to use - column override, cell override, or auto-detected format+ let actualFormat = binaryFormat ?? "DEFAULT";++ // If format is DEFAULT or undefined, auto-detect based on column type and content+ if (actualFormat === "DEFAULT") {+ actualFormat = detectBinaryFormat({+ bytesValue,+ columnType: columnType,+ });+ }++ const stringValue = formatBinaryValue({+ bytesValue,+ format: actualFormat,+ });++ // Return proto-es oneof structure with stringValue+ return {+ ...rowValue,+ kind: {+ case: "stringValue" as const,+ value: stringValue,+ },+ };+};-export const getColumnType = (- column: Header<QueryRow, unknown> | undefined+export const getPlainValue = (+ rowValue: RowValue | undefined,+ columnType: string,+ binaryFormat: BinaryFormat | undefined) => {- return (- (column?.column.columnDef.meta as ColumnMeta | undefined)?.columnType ?? ""- );+ if (!rowValue) {+ return undefined;+ }+ const formattedValue = getFormattedValue(rowValue, columnType, binaryFormat);+ const value = extractSQLRowValuePlain(formattedValue);+ if (value === undefined || value === null) {+ return value;+ }+ return String(value);};diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/useTableResize.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/useTableResize.tsindex 1e438f3dc0..f16254b32f 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/useTableResize.ts+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/useTableResize.ts@@ -1,7 +1,7 @@import { useEventListener, usePointer } from "@vueuse/core";import { sumBy } from "lodash-es";import type { Ref } from "vue";-import { computed, onBeforeUnmount, reactive, watch } from "vue";+import { computed, nextTick, onBeforeUnmount, reactive, watch } from "vue";export type TableResizeOptions = {tableRef: Ref<HTMLTableElement | undefined>;@@ -34,7 +34,7 @@ const useTableResize = (options: TableResizeOptions) => {});const pointer = usePointer();- const table = computed(() => options.tableRef.value!);+ const table = computed(() => options.tableRef.value);const containerWidth = computed(() => {return options.containerRef?.value?.scrollWidth || 0;@@ -71,7 +71,12 @@ const useTableResize = (options: TableResizeOptions) => {).map((width) => ({ width }));// After calculating the width, use fixed layout to keep the width stable.- table.value.style.tableLayout = "fixed";+ nextTick(() => {+ if (!table.value) {+ return;+ }+ table.value.style.tableLayout = "fixed";+ });};// Record the initial state of dragging.@@ -120,14 +125,22 @@ const useTableResize = (options: TableResizeOptions) => {};};- const getTableProps = () => {- const totalWidth = sumBy(state.columns, (col) => col.width);+ const getColumnWidth = (index: number): number => {+ const column = state.columns[index];+ return column?.width ?? 0;+ };++ const totalWidth = computed(() => {+ return sumBy(state.columns, (col) => col.width);+ });++ const tableProps = computed(() => {return {style: {- width: state.isAutoAdjusting ? "auto" : `${totalWidth}px`,+ width: state.isAutoAdjusting ? "auto" : `${totalWidth.value}px`,},};- };+ });onBeforeUnmount(() => {toggleDragStyle(table, false);@@ -136,7 +149,9 @@ const useTableResize = (options: TableResizeOptions) => {return {reset,getColumnProps,- getTableProps,+ getColumnWidth,+ tableProps,+ totalWidth,startResizing,};};diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DetailPanel/DetailPanel.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DetailPanel/DetailPanel.vueindex 2cf5f5ba50..f048d164de 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DetailPanel/DetailPanel.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DetailPanel/DetailPanel.vue@@ -154,17 +154,20 @@ import {import { NButton, NPopover, NScrollbar, NTooltip } from "naive-ui";import { computed } from "vue";import { CopyButton, DrawerContent } from "@/components/v2";-import type { RowValue } from "@/types/proto-es/v1/sql_service_pb";-import { extractSQLRowValuePlain } from "@/utils";+import type { QueryResult } from "@/types/proto-es/v1/sql_service_pb";import { useSQLResultViewContext } from "../context";+import BinaryFormatButton from "../DataTable/common/BinaryFormatButton.vue";import {type BinaryFormat,- formatBinaryValue,useBinaryFormatContext,-} from "../DataTable/binary-format-store";-import BinaryFormatButton from "../DataTable/common/BinaryFormatButton.vue";+} from "../DataTable/common/binary-format-store";+import { getPlainValue } from "../DataTable/common/utils";import PrettyJSON from "./PrettyJSON.vue";+const props = defineProps<{+ result: QueryResult;+}>();+const { dark, detail, disallowCopyingData } = useSQLResultViewContext();const { getBinaryFormat, setBinaryFormat } = useBinaryFormatContext();@@ -183,11 +186,15 @@ const rawValue = computed(() => {return;}- const { row, col, table } = detail.value;- return table- .getPrePaginationRowModel()- .rows[row]?.getVisibleCells()- [col]?.getValue<RowValue>();+ const { row, col } = detail.value;+ return props.result.rows[row].values[col];+});++const columnType = computed(() => {+ if (!detail.value) {+ return "";+ }+ return props.result.columnTypeNames[detail.value.col];});const binaryFormat = computed(() => {@@ -207,37 +214,8 @@ const isBinaryData = computed(() => {return rawValue.value.kind?.case === "bytesValue";});-// Format the binary value based on selected format-const formattedValue = computed(() => {- if (rawValue.value?.kind?.case !== "bytesValue") {- return rawValue.value;- }-- // Determine the format to use - column override, cell override, or auto-detected format- const actualFormat = binaryFormat.value ?? "DEFAULT";-- // Skip formatting for DEFAULT (auto) format- if (actualFormat === "DEFAULT") {- return rawValue.value;- }-- const stringValue = formatBinaryValue({- bytesValue: rawValue.value.kind.value,- format: actualFormat,- });- return {- ...rawValue.value,- stringValue,- };-});-const content = computed(() => {- if (!rawValue.value) {- return;- }-- // Otherwise use the raw value- return String(extractSQLRowValuePlain(formattedValue.value));+ return getPlainValue(rawValue.value, columnType.value, binaryFormat.value);});const guessedIsJSON = computed(() => {@@ -250,7 +228,7 @@ const guessedIsJSON = computed(() => {});const totalCount = computed(() => {- return detail.value?.table.getPrePaginationRowModel().rows.length ?? 0;+ return props.result.rows.length;});const contentClass = computed(() => {diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vueindex 5e10b9e2e5..1d67a99499 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue@@ -155,8 +155,8 @@</template></div>- <Drawer :show="!!detail" @close="detail = undefined">- <DetailPanel />+ <Drawer v-if="detail" :show="!!detail" @close="detail = undefined">+ <DetailPanel :result="viewMode === 'SINGLE-RESULT' ? resultSet.results[0] : filteredResults[detail.set]" /></Drawer></NConfigProvider></template>@@ -204,7 +204,7 @@ import { ExportRequestSchema } from "@/types/proto-es/v1/sql_service_pb";import type { SQLResultViewContext } from "./context";import { provideSQLResultViewContext } from "./context";-import { provideBinaryFormatContext } from "./DataTable/binary-format-store";+import { provideBinaryFormatContext } from "./DataTable/common/binary-format-store";import DetailPanel from "./DetailPanel";import EmptyView from "./EmptyView.vue";import ErrorView from "./ErrorView";@@ -243,7 +243,6 @@ const effectiveQueryDataPolicy = computed(() => {return policyStore.getEffectiveQueryDataPolicyForProject(project.value);});-const keyword = ref("");const detail: SQLResultViewContext["detail"] = ref(undefined);provideBinaryFormatContext(computed(() => props.contextId));@@ -339,7 +338,6 @@ const filteredResults = computed(() => {provideSQLResultViewContext({dark: toRef(props, "dark"),disallowCopyingData,- keyword,detail,});diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SelectionCopyTooltips.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SelectionCopyTooltips.vueindex bff2a4d8dc..e9f8efa968 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SelectionCopyTooltips.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SelectionCopyTooltips.vue@@ -11,18 +11,18 @@class="text-sm flex flex-row justify-start items-center gap-1"><template #action>- <kbd- class="w-auto h-5 flex items-center justify-center bg-black dark:bg-zinc-700 dark:text-zinc-300 bg-opacity-10 rounded-sm px-1.5 text-control overflow-y-hidden"- >- <span v-if="isMac" class="text-base leading-none">⌘</span>- <span- v-else- class="tracking-tighter text-xs transform scale-x-90 leading-none"- >- Ctrl- </span>- <span class="pl-1 text-xs leading-none">C</span>- </kbd>+ <NButton size="tiny" type="primary" secondary>+ <template #icon>+ <span v-if="isMac" class="text-base leading-none">⌘</span>+ <span+ v-else+ class="tracking-tighter text-xs transform scale-x-90 leading-none"+ >+ Ctrl+ </span>+ </template>+ C+ </NButton></template><template #button><NButton size="tiny" @click="copySelection" type="primary" secondary>@@ -34,7 +34,7 @@</template></i18n-t><div class="ml-1">- <NButton size="tiny" secondary @click="deselect">+ <NButton size="tiny" quaternary @click="deselect">{{ $t("sql-editor.cancel-selection") }}</NButton></div>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vueindex 1cfeaf57a2..0f8e67fe19 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue@@ -13,29 +13,23 @@<ErrorView :error="result.error" /></BBAttention><div- class="relative w-full shrink-0 flex flex-row justify-between items-center mb-2 overflow-x-auto hide-scrollbar"+ class="result-toolbar relative w-full shrink-0 flex flex-row gap-x-4 justify-between items-center mb-2 hide-scrollbar">- <div class="flex flex-row justify-start items-center mr-2 shrink-0">- <NInput- v-if="showSearchFeature"- :value="state.search"- class="max-w-40!"- size="small"- type="text"- :placeholder="t('sql-editor.search-results')"- @update:value="updateKeyword"- >- <template #prefix>- <heroicons-outline:search class="h-5 w-5 text-gray-300" />- </template>- </NInput>+ <div class="flex flex-row justify-start items-center mr-2 flex-1">+ <AdvancedSearch+ v-model:params="state.searchParams"+ placeholder=""+ :scope-options="searchScopeOptions"+ :cache-query="false"+ @keyup:enter="scrollToNextCandidate"+ /><span class="ml-2 whitespace-nowrap text-sm text-gray-500">{{resultRowsText}}</span><spanv-if="currentTab?.mode !== 'ADMIN' &&- dataLength === editorStore.resultRowsLimit+ rows.length === editorStore.resultRowsLimit"class="ml-2 whitespace-nowrap text-sm text-gray-500">@@ -50,27 +44,6 @@{{ $t("sql-editor.vertical-display") }}</span></div>- <NPagination- :simple="true"- :item-count="table.getCoreRowModel().rows.length"- :page="pageIndex + 1"- :page-size="pageSize"- class="pagination whitespace-nowrap"- style="--n-input-width: 2.5rem"- @update-page="handleChangePage"- >- <template #suffix>- <NSelect- v-model:value="pageSize"- :options="pageSizeOptions"- :consistent-menu-width="false"- :show-arrow="false"- class="pagesize-select"- placement="bottom-end"- size="small"- />- </template>- </NPagination><NTooltip v-if="DISMISS_PLACEHOLDER"><template #trigger><NButton@@ -119,25 +92,68 @@<SelectionCopyTooltips /></div>- <div class="flex-1 w-full flex flex-col overflow-y-auto">+ <div class="flex-1 w-full flex flex-col overflow-y-auto relative"><VirtualDataBlockv-if="state.vertical"- :table="table"+ ref="dataTableRef"+ :rows="rows"+ :columns="columns":set-index="setIndex"- :offset="pageIndex * pageSize":is-sensitive-column="isSensitiveColumn":get-masking-reason="getMaskingReason":database="database"+ :active-row-index="activeRowIndex"+ :search="state.searchParams"/><VirtualDataTablev-else- :table="table"+ ref="dataTableRef"+ :rows="rows"+ :columns="columns":set-index="setIndex"- :offset="pageIndex * pageSize":is-sensitive-column="isSensitiveColumn":get-masking-reason="getMaskingReason":database="database"+ :sort-state="state.sortState"+ :active-row-index="activeRowIndex"+ :search="state.searchParams"+ @toggle-sort="toggleSort"/>+ <NEmpty v-if="rows.length === 0">+ <template #extra>+ {{ $t("sql-editor.no-data-available") }}+ </template>+ </NEmpty>++ <div v-if="state.searchCandidateRowIndexs.length > 0" class="flex flex-row gap-x-2 absolute bottom-2 right-2 border shadow rounded bg-white py-1 px-2">+ <NButton+ quaternary+ size="small"+ :disabled="state.searchCandidateActiveIndex <= 0"+ @click="scrollToPreviousCandidate"+ >+ <template #icon>+ <ArrowUpIcon class="x-4" />+ </template>+ {{ $t("sql-editor.previous-row") }}+ </NButton>+ <NButton+ quaternary+ size="small"+ :disabled="state.searchCandidateActiveIndex >= (state.searchCandidateRowIndexs.length - 1)"+ @click="scrollToNextCandidate"+ >+ <template #icon>+ <ArrowDownIcon class="x-4" />+ </template>+ {{ $t("sql-editor.next-row") }}+ </NButton>+ <NButton quaternary size="small" style="--n-padding: 2px" @click="clearSearchCandidate">+ <template #icon>+ <XIcon class="x-4" />+ </template>+ </NButton>+ </div></div><div@@ -187,29 +203,16 @@<script lang="ts" setup>import { create } from "@bufbuild/protobuf";-import type { ColumnDef } from "@tanstack/vue-table";-import {- getCoreRowModel,- getPaginationRowModel,- getSortedRowModel,- useVueTable,-} from "@tanstack/vue-table";-import { useClipboard, useDebounceFn, useLocalStorage } from "@vueuse/core";+import { useClipboard } from "@vueuse/core";import { isEmpty } from "lodash-es";-import {- NButton,- NFormItem,- NInput,- NPagination,- NSelect,- NSwitch,- NTooltip,- type SelectOption,-} from "naive-ui";+import { ArrowDownIcon, ArrowUpIcon, XIcon } from "lucide-vue-next";+import { NButton, NEmpty, NFormItem, NSwitch, NTooltip } from "naive-ui";import { v4 as uuidv4 } from "uuid";-import { computed, reactive } from "vue";+import { computed, nextTick, reactive, ref, watch } from "vue";import { useI18n } from "vue-i18n";import { BBAttention } from "@/bbkit";+import AdvancedSearch from "@/components/AdvancedSearch";+import type { ScopeOption } from "@/components/AdvancedSearch/types";import DatabaseInfo from "@/components/DatabaseInfo.vue";import type {DownloadContent,@@ -229,24 +232,27 @@ import type {SQLEditorDatabaseQueryContext,SQLEditorQueryParams,} from "@/types";-import { DEBOUNCE_SEARCH_DELAY, isValidInstanceName } from "@/types";import { Engine, ExportFormat } from "@/types/proto-es/v1/common_pb";import {QueryOption_MSSQLExplainFormat,QueryOptionSchema,type QueryResult,- type QueryRow,type RowValue,} from "@/types/proto-es/v1/sql_service_pb";import {compareQueryRowValues,createExplainToken,extractSQLRowValuePlain,- instanceV1HasStructuredQueryResult,isNullOrUndefined,+ type SearchParams,} from "@/utils";import { useSQLResultViewContext } from "./context";import { provideSelectionContext } from "./DataTable/common/selection-logic";+import type {+ ResultTableColumn,+ ResultTableRow,+ SortState,+} from "./DataTable/common/types";import VirtualDataTable from "./DataTable/VirtualDataTable.vue";import EmptyView from "./EmptyView.vue";import ErrorView from "./ErrorView";@@ -254,16 +260,14 @@ import SelectionCopyTooltips from "./SelectionCopyTooltips.vue";import VirtualDataBlock from "./VirtualDataBlock.vue";type LocalState = {- search: string;vertical: boolean;+ sortState: SortState | undefined;+ searchParams: SearchParams;+ searchCandidateActiveIndex: number;+ searchCandidateRowIndexs: number[];};-type ViewMode = "RESULT" | "EMPTY" | "AFFECTED-ROWS" | "ERROR";-const DEFAULT_PAGE_SIZE = 50;-const storedPageSize = useLocalStorage<number>(- "bb.sql-editor.result-page-size",- DEFAULT_PAGE_SIZE-);+type ViewMode = "RESULT" | "EMPTY" | "AFFECTED-ROWS" | "ERROR";const props = defineProps<{params: SQLEditorQueryParams;@@ -287,10 +291,19 @@ defineEmits<{}>();const state = reactive<LocalState>({- search: "",vertical: false,+ sortState: undefined,+ searchParams: {+ query: "",+ scopes: [],+ },+ searchCandidateActiveIndex: -1,+ searchCandidateRowIndexs: [],});+const dataTableRef =+ ref<InstanceType<typeof VirtualDataTable | typeof VirtualDataBlock>>();+const { copy: copyTextToClipboard, isSupported } = useClipboard({legacy: true,});@@ -309,7 +322,7 @@ const copyStatement = () => {};const { t } = useI18n();-const { dark, keyword } = useSQLResultViewContext();+const { dark } = useSQLResultViewContext();const tabStore = useSQLEditorTabStore();const editorStore = useSQLEditorStore();const currentTab = computed(() => tabStore.currentTab);@@ -317,7 +330,7 @@ const { runQuery } = useExecuteSQL();const viewMode = computed((): ViewMode => {const { result } = props;- if (result.error && dataLength.value === 0) {+ if (result.error && rows.value.length === 0) {return "ERROR";}const columnNames = result.columnNames;@@ -330,75 +343,205 @@ const viewMode = computed((): ViewMode => {return "RESULT";});-const showSearchFeature = computed(() => {- if (!isValidInstanceName(props.database.instance)) {- return false;- }- return instanceV1HasStructuredQueryResult(props.database.instanceResource);-});--// use a debounced value to improve performance when typing rapidly-const debouncedUpdateKeyword = useDebounceFn((value: string) => {- keyword.value = value;-}, DEBOUNCE_SEARCH_DELAY);--const updateKeyword = (value: string) => {- state.search = value;- debouncedUpdateKeyword(value);-};--const columns = computed(() => {- return props.result.columnNames.map<ColumnDef<QueryRow, RowValue>>(+const columns = computed((): ResultTableColumn[] => {+ return props.result.columnNames.map<ResultTableColumn>((columnName, index) => {const columnType = props.result.columnTypeNames[index];-return {- id: `${columnName}@${index}`,- accessorFn: (item) => item.values[index],- header: columnName,- meta: {- // Store column type in meta for easy access by other components- columnType,- },- sortingFn: (rowA, rowB) => {- return compareQueryRowValues(- columnType,- rowA.original.values[index],- rowB.original.values[index]- );- },+ id: columnName,+ name: columnName,+ columnType,};});});-// Memoize the filtered data to avoid filtering on every render-const data = computed(() => {- const search = keyword.value.trim().toLowerCase();+const searchScopeOptions = computed((): ScopeOption[] => {+ return columns.value.map((column) => {+ return {+ id: column.id,+ title: column.name,+ description: t("sql-editor.search-scope-column-description", {+ type: column.columnType,+ }),+ };+ });+});++const activeRowIndex = computed(() => {+ return state.searchCandidateRowIndexs[state.searchCandidateActiveIndex] ?? -1;+});++watch(+ () => state.searchParams,+ (params) => {+ const next = getNextCandidateRowIndex(0, params);+ const indexs = [];+ if (next >= 0) {+ indexs.push(next);+ const another = getNextCandidateRowIndex(next + 1, params);+ if (another >= 0) {+ indexs.push(another);+ }+ }+ state.searchCandidateRowIndexs = indexs;+ state.searchCandidateActiveIndex = 0;+ },+ { deep: true }+);++watch(+ () => activeRowIndex.value,+ () => {+ scrollToCurrentCandidate();+ }+);++watch(+ () => state.vertical,+ () => {+ scrollToCurrentCandidate();+ }+);++const scrollToNextCandidate = () => {+ state.searchCandidateActiveIndex++;+ // Append next candidate if reaches the last+ if (+ state.searchCandidateActiveIndex ===+ state.searchCandidateRowIndexs.length - 1+ ) {+ const currentRowIndex =+ state.searchCandidateRowIndexs[state.searchCandidateActiveIndex];+ const next = getNextCandidateRowIndex(+ currentRowIndex + 1,+ state.searchParams+ );+ if (next >= 0) {+ state.searchCandidateRowIndexs.push(next);+ }+ }+};++const scrollToPreviousCandidate = () => {+ state.searchCandidateActiveIndex--;+};++const scrollToCurrentCandidate = () => {+ scrollToSearchCandidate(activeRowIndex.value);+};- // Return original rows if no search- if (!search) {- return props.result.rows;+const scrollToSearchCandidate = (index: number | undefined) => {+ if (index === undefined || index < 0) {+ return;}+ nextTick(() => {+ if (index >= 0) {+ dataTableRef.value?.scrollTo(index);+ }+ });+};- // Only filter when there's a search term- return props.result.rows.filter((item) => {- return item.values.some((col) => {- const value = extractSQLRowValuePlain(col);- if (isNullOrUndefined(value)) {+const clearSearchCandidate = () => {+ state.searchParams = {+ query: "",+ scopes: [],+ };+};++const cellValueMatches = (cell: RowValue, query: string) => {+ const value = extractSQLRowValuePlain(cell);+ if (isNullOrUndefined(value)) {+ return false;+ }+ return String(value).toLowerCase().includes(query.toLowerCase());+};++const getNextCandidateRowIndex = (from: number, params: SearchParams) => {+ if (params.scopes.length === 0 && !params.query) {+ return -1;+ }++ for (let i = from; i < rows.value.length; i++) {+ const row = rows.value[i];++ let checked = params.scopes.every((scope) => {+ if (!scope.value) {+ return false;+ }+ const columnIndex = columns.value.findIndex(+ (column) => column.name === scope.id+ );+ if (columnIndex < 0) {return false;}- return String(value).toLowerCase().includes(search);+ const cell = row.item.values[columnIndex];+ return cellValueMatches(cell, scope.value);});- });-});+ if (!checked) {+ continue;+ }++ if (params.query) {+ checked = row.item.values.some((cell) => {+ return cellValueMatches(cell, params.query);+ });+ }+ if (checked) {+ return i;+ }+ }++ return -1;+};++const toggleSort = (columnIndex: number) => {+ const currentSort = state.sortState;++ if (!currentSort || currentSort.columnIndex !== columnIndex) {+ // New column or no current sort - start with descending+ state.sortState = { columnIndex, direction: "desc" };+ } else if (currentSort.direction === "desc") {+ // Currently descending - switch to ascending+ state.sortState = { columnIndex, direction: "asc" };+ } else {+ // Currently ascending - clear sort+ state.sortState = undefined;+ }+};++// Apply sorting to filtered rows+const rows = computed((): ResultTableRow[] => {+ const sortState = state.sortState;++ if (!sortState || !sortState.direction) {+ return props.result.rows.map((item, index) => ({+ key: index,+ item,+ }));+ }-// Cache data length to avoid multiple accesses-const dataLength = computed(() => data.value.length);+ const { columnIndex, direction } = sortState;+ const columnType = columns.value[columnIndex]?.columnType ?? "";++ return props.result.rows+ .map((item, index) => ({+ key: index,+ item,+ }))+ .sort((a, b) => {+ const result = compareQueryRowValues(+ columnType,+ a.item.values[columnIndex],+ b.item.values[columnIndex]+ );+ return direction === "asc" ? result : -result;+ });+});// Computed property for result rows text to avoid accessing data.length twiceconst resultRowsText = computed(() => {- const length = dataLength.value;+ const length = rows.value.length;return `${length} ${t("sql-editor.rows", length)}`;});@@ -425,39 +568,9 @@ const getMaskingReason = (columnIndex: number) => {return reason;};-const table = useVueTable<QueryRow>({- get data() {- return data.value;- },- get columns() {- return columns.value;- },- getCoreRowModel: getCoreRowModel(),- getSortedRowModel: getSortedRowModel(),- getPaginationRowModel: getPaginationRowModel(),-});--table.setPageSize(storedPageSize.value);--provideSelectionContext(computed(() => table));--const pageIndex = computed(() => {- return table.getState().pagination.pageIndex;-});-const pageSize = computed({- get() {- return table.getState().pagination.pageSize;- },- set(ps) {- table.setPageSize(ps);- storedPageSize.value = ps;- },-});-const pageSizeOptions = computed(() => {- return [20, 50, 100, 200].map<SelectOption>((n) => ({- label: t("sql-editor.n-per-page", { n }),- value: n,- }));+provideSelectionContext({+ columns: columns,+ rows: rows,});const engine = computed(() => props.database.instanceResource.engine);@@ -523,10 +636,6 @@ const getExplainTokenForMSSQL = async () => {return getExplainToken(result);};-const handleChangePage = (page: number) => {- table.setPageIndex(page - 1);-};-const queryTime = computed(() => {const { latency } = props.result;if (!latency) return "-";@@ -554,4 +663,26 @@ const queryTime = computed(() => {--n-padding-single-left: 8px !important;--n-padding-single-right: 8px !important;}++.result-toolbar {+ scrollbar-width: thin;+ scrollbar-color: rgba(0, 0, 0, 0.2) transparent;+}++.result-toolbar::-webkit-scrollbar {+ width: 6px;+}++.result-toolbar::-webkit-scrollbar-track {+ background: transparent;+}++.result-toolbar::-webkit-scrollbar-thumb {+ background-color: rgba(0, 0, 0, 0.2);+ border-radius: 3px;+}++.result-toolbar::-webkit-scrollbar-thumb:hover {+ background-color: rgba(0, 0, 0, 0.3);+}</style>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/VirtualDataBlock.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/VirtualDataBlock.vueindex 6f9a98a29e..be51d0bb83 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/VirtualDataBlock.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/VirtualDataBlock.vue@@ -1,158 +1,129 @@<template>- <div ref="containerRef" class="h-full overflow-auto">- <div- class="relative"- :style="{- height: `${virtualizer.getTotalSize()}px`,- }"- >+ <NVirtualList+ ref="virtualListRef"+ item-resizable+ :items="rows"+ :item-size="estimateRowHeight"+ >+ <template #default="{ item: row, index: rowIndex }: { item: { item: QueryRow; }; index: number; }"><div- class="absolute top-0 left-0 w-full"+ :key="`row-${rowIndex}`"+ class="font-mono mb-2 mx-2":style="{- transform: `translateY(${virtualItems[0]?.start ?? 0}px)`,+ height: `${estimateRowHeight}px`,}">+ <p+ class="font-bold text-gray-500 dark:text-gray-300 overflow-hidden whitespace-nowrap mb-1"+ >+ ********************************+ {{ rowIndex + 1 }}. row+ ********************************+ </p><div- v-for="(virtualRow, i) in virtualItems"- :key="`row-${offset + virtualRow.index}`"- class="font-mono mb-5 mx-2"- :style="{- height: `${virtualRow.size}px`,+ class="py-2 px-3 bg-gray-50 dark:bg-gray-700 rounded relative"+ :class="{+ 'border-2 border-accent/20 bg-accent/10!': activeRowIndex === rowIndex}">- <p- class="font-medium text-gray-500 dark:text-gray-300 overflow-hidden whitespace-nowrap"+ <div+ class="absolute right-2 top-2 z-50 opacity-70 hover:opacity-100">- ********************************- {{ offset + virtualRow.index + 1 }}. row- ********************************- </p>+ <CopyButton size="small" :content="() => getContent(rowIndex)" />+ </div><div- class="py-2 px-3 bg-gray-50 dark:bg-gray-700 rounded-xs relative"+ v-for="(column, columnIndex) in columns"+ :key="column.id"+ class="flex items-start text-gray-500 dark:text-gray-300 text-sm">- <div- class="absolute right-2 top-2 z-50 opacity-70 hover:opacity-100"- >- <CopyButton size="small" :content="() => getContent(i)" />+ <div class="min-w-28 text-left flex items-start font-medium pt-1">+ {{ column.name }}+ <MaskingReasonPopover+ v-if="getMaskingReason && getMaskingReason(columnIndex)"+ :reason="getMaskingReason(columnIndex)"+ class="ml-0.5 shrink-0"+ />+ <SensitiveDataIcon+ v-else-if="isSensitiveColumn(columnIndex)"+ class="ml-0.5 shrink-0"+ />+ :</div>- <div- v-for="header in columnHeaders"- :key="`${virtualRow.index}-${header.index}`"- class="flex items-start text-gray-500 dark:text-gray-300 text-sm"- >- <div class="min-w-28 text-left flex items-start font-medium pt-1">- {{ header.column.columnDef.header }}- <MaskingReasonPopover- v-if="getMaskingReason && getMaskingReason(header.index)"- :reason="getMaskingReason(header.index)"- class="ml-0.5 shrink-0"- />- <SensitiveDataIcon- v-else-if="isSensitiveColumn(header.index)"- class="ml-0.5 shrink-0"- />- :- </div>- <div class="flex-1">- <TableCell- ref="cellRefs"- :table="table"- :value="- rows[virtualRow.index]- .getVisibleCells()- [header.index].getValue() as RowValue- "- :keyword="keyword"- :set-index="setIndex"- :row-index="offset + virtualRow.index"- :col-index="header.index"- :column-type="getColumnType(header)"- :allow-select="true"- :database="database"- />- </div>+ <div class="flex-1">+ <TableCell+ :value="row.item.values[columnIndex]"+ :keyword="search.query"+ :scope="search.scopes.find(scope => scope.id === columns[columnIndex]?.id)"+ :set-index="setIndex"+ :row-index="rowIndex"+ :col-index="columnIndex"+ :column-type="column.columnType"+ :allow-select="true"+ :database="database"+ /></div></div></div></div>- </div>- <div- v-if="rows.length === 0"- class="text-center w-full my-12 textinfolabel"- >- {{ $t("sql-editor.no-data-available") }}- </div>- </div>+ </template>+ </NVirtualList></template><script setup lang="ts">-import type { Table } from "@tanstack/vue-table";-import { useVirtualizer } from "@tanstack/vue-virtual";-import { computed, ref, watch } from "vue";+import { NVirtualList } from "naive-ui";+import { computed, ref } from "vue";import { CopyButton } from "@/components/v2";import { type ComposedDatabase } from "@/types";-import type { QueryRow, RowValue } from "@/types/proto-es/v1/sql_service_pb";-import { useSQLResultViewContext } from "./context";+import type { QueryRow } from "@/types/proto-es/v1/sql_service_pb";+import { type SearchParams } from "@/utils";+import { useBinaryFormatContext } from "./DataTable/common/binary-format-store";import MaskingReasonPopover from "./DataTable/common/MaskingReasonPopover.vue";import SensitiveDataIcon from "./DataTable/common/SensitiveDataIcon.vue";-import { getColumnType } from "./DataTable/common/utils";+import type {+ ResultTableColumn,+ ResultTableRow,+} from "./DataTable/common/types";+import { getPlainValue } from "./DataTable/common/utils";import TableCell from "./DataTable/TableCell.vue";const props = defineProps<{- table: Table<QueryRow>;+ rows: ResultTableRow[];+ columns: ResultTableColumn[];setIndex: number;- offset: number;+ activeRowIndex: number;isSensitiveColumn: (index: number) => boolean;getMaskingReason?: (index: number) => any;database: ComposedDatabase;+ search: SearchParams;}>();-const { keyword } = useSQLResultViewContext();-const containerRef = ref<HTMLDivElement>();-const cellRefs = ref<InstanceType<typeof TableCell>[]>([]);--const rows = computed(() => props.table.getRowModel().rows);--// Cache column headers to avoid recalculation-const columnHeaders = computed(() => props.table.getFlatHeaders());+const { getBinaryFormat } = useBinaryFormatContext();+const virtualListRef = ref<InstanceType<typeof NVirtualList>>();// Calculate the height of each row block-const estimateRowHeight = () => {+const estimateRowHeight = computed(() => {// Estimate based on number of columns// Each column is roughly 28px, plus padding and header- const columnCount = columnHeaders.value.length;+ const columnCount = props.columns.length;return 60 + columnCount * 28; // Header + columns-};--// Virtual scrolling setup-const virtualizer = useVirtualizer(- computed(() => ({- count: rows.value.length,- getScrollElement: () => containerRef.value ?? null,- estimateSize: estimateRowHeight,- overscan: 3, // Fewer items in overscan since each item is larger- }))-);--const virtualItems = computed(() => virtualizer.value.getVirtualItems());+});-// Reset scroll position when offset changes-watch(- () => props.offset,- () => {- containerRef.value?.scrollTo({ top: 0 });- virtualizer.value.scrollToOffset(0);- }-);--const getContent = (index: number): string => {- const object = columnHeaders.value.reduce(- (obj, header, j) => {- if (!header.column.columnDef.header) {+const getContent = (rowIndex: number): string => {+ const object = props.columns.reduce(+ (obj, column, columnIndex) => {+ if (!column.name) {return obj;}- obj[`${header.column.columnDef.header}`] =- cellRefs.value[index * columnHeaders.value.length + j]?.plainValue;+ const binaryFormat = getBinaryFormat({+ rowIndex: rowIndex,+ colIndex: columnIndex,+ setIndex: props.setIndex,+ });+ obj[`${column.name}`] = getPlainValue(+ props.rows[rowIndex].item.values[columnIndex],+ column.columnType,+ binaryFormat+ );return obj;},{} as Record<string, any>@@ -160,4 +131,13 @@ const getContent = (index: number): string => {return JSON.stringify(object, null, 4);};++defineExpose({+ scrollTo: (index: number) =>+ virtualListRef.value?.scrollTo({+ top: index * estimateRowHeight.value,+ debounce: true,+ behavior: "smooth",+ }),+});</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/context.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/context.tsindex 9baff97af9..840742a06b 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/context.ts+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/context.ts@@ -1,17 +1,13 @@-import { type Table } from "@tanstack/vue-table";import { type InjectionKey, inject, provide, type Ref } from "vue";-import type { QueryRow } from "@/types/proto-es/v1/sql_service_pb";export type SQLResultViewContext = {dark: Ref<boolean>;disallowCopyingData: Ref<boolean>;- keyword: Ref<string>;detail: Ref<| {set: number; // The index of selected result set.row: number; // The row index of selected record.col: number; // The column index of selected cell.- table: Table<QueryRow>;}| undefined>;diff --git a/frontend/src/views/sql-editor/EditorCommon/SharePopover.vue b/frontend/src/views/sql-editor/EditorCommon/SharePopover.vueindex ec725bf0c3..680d5dcb61 100644--- a/frontend/src/views/sql-editor/EditorCommon/SharePopover.vue+++ b/frontend/src/views/sql-editor/EditorCommon/SharePopover.vue@@ -84,6 +84,7 @@</template><script lang="ts" setup>+import { useClipboard } from "@vueuse/core";import { LockKeyholeIcon, UsersIcon } from "lucide-vue-next";import { NInput, NInputGroup, NInputGroupLabel, NPopover } from "naive-ui";import { computed, h, onMounted, ref } from "vue";@@ -103,11 +104,7 @@ import {type Worksheet,Worksheet_Visibility,} from "@/types/proto-es/v1/worksheet_service_pb";-import {- extractProjectResourceName,- extractWorksheetUID,- toClipboard,-} from "@/utils";+import { extractProjectResourceName, extractWorksheetUID } from "@/utils";const props = defineProps<{worksheet?: Worksheet;@@ -125,6 +122,10 @@ const worksheetV1Store = useWorkSheetStore();const settingStore = useSettingV1Store();const me = useCurrentUserV1();+const { copy: copyTextToClipboard, isSupported } = useClipboard({+ legacy: true,+});+const workspaceExternalURL = computed(() => settingStore.workspaceProfileSetting?.externalUrl);@@ -171,8 +172,8 @@ const handleChangeAccess = async (option: AccessOption) => {["visibility"]);- if (sharedTabLink.value) {- await toClipboard(sharedTabLink.value);+ if (sharedTabLink.value && isSupported.value) {+ await copyTextToClipboard(sharedTabLink.value);pushNotification({module: "bytebase",style: "SUCCESS",