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: retire data table lite (#15007)
boojack370d58a41360
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vueindex edd5059f91..2d2607bd71 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue@@ -1,14 +1,14 @@<template><divref="containerRef"- class="relative w-full flex-1 overflow-auto flex flex-col border rounded"+ class="relative w-full flex-1 overflow-auto flex flex-col rounded border dark:border-zinc-500":style="{maxHeight: maxHeight ? `${maxHeight}px` : undefined,}"><tableref="tableRef"- class="relative border-collapse table-fixed z-[1]"+ class="relative border-collapse w-full table-auto -mx-px"v-bind="tableResize.getTableProps()"><thead@@ -18,9 +18,9 @@<thv-for="header of table.getFlatHeaders()":key="header.index"- class="group relative px-2 py-2 min-w-[2rem] text-left text-xs font-medium text-gray-500 dark:text-gray-300 tracking-wider border-l first:border-l-0 border-block-border"+ class="group relative px-2 py-2 min-w-[2rem] 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="{- '!bg-accent/10':+ '!bg-accent/10 dark:!bg-accent/40':selectionState.rows.length === 0 &&selectionState.columns.includes(header.index),}"@@ -30,7 +30,8 @@<spanclass="flex flex-row items-center select-none":class="{- 'cursor-pointer hover:text-accent': !selectionDisabled,+ 'cursor-pointer hover:text-accent dark:hover:text-gray-500':+ !selectionDisabled,}"@click.stop="selectColumn(header.index)">@@ -71,7 +72,6 @@<!-- The drag-to-resize handler --><divclass="absolute w-[8px] right-0 top-0 bottom-0 cursor-col-resize"- @dblclick="tableResize.autoAdjustColumnWidth([header.index])"@pointerdown="tableResize.startResizing(header.index)"@click.stop.prevent/>@@ -88,7 +88,7 @@<tdv-for="(cell, cellIndex) of row.getVisibleCells()":key="cellIndex"- class="relative p-0 text-sm dark:text-gray-100 leading-5 whitespace-nowrap break-all border-l first:border-l-0 border-block-border group-even:bg-gray-100/50 dark:group-even:bg-gray-700/50"+ class="relative 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="cellIndex"><TableCell@@ -104,8 +104,9 @@v-if="cellIndex === 0"class="absolute inset-y-0 left-0 w-2":class="{- 'cursor-pointer hover:bg-accent/10': !selectionDisabled,- 'bg-accent/10':+ 'cursor-pointer hover:bg-accent/10 dark:hover:bg-accent/40':+ !selectionDisabled,+ 'bg-accent/10 dark:bg-accent/40':selectionState.columns.length === 0 &&selectionState.rows.includes(offset + rowIndex),}"@@ -127,7 +128,7 @@<script lang="ts" setup>import type { Table } from "@tanstack/vue-table";import { NEmpty } from "naive-ui";-import { computed, nextTick, ref, watch } from "vue";+import { computed, nextTick, onMounted, ref, watch } from "vue";import {FeatureBadge,FeatureBadgeForInstanceLicense,@@ -173,28 +174,18 @@ const hasSensitiveFeature = computed(() => {return subscriptionStore.hasFeature("bb.feature.sensitive-data");});+const rows = computed(() => props.table.getRowModel().rows);++onMounted(() => {+ nextTick(() => {+ tableResize.reset();+ });+});+const scrollTo = (x: number, y: number) => {containerRef.value?.scroll(x, y);};-const rows = computed(() => props.table.getRowModel().rows);--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,() => {diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTableLite.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTableLite.vuedeleted file mode 100644index 416f9930d4..0000000000--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTableLite.vue+++ /dev/null@@ -1,187 +0,0 @@-<template>- <div- ref="containerRef"- class="relative w-full flex-1 overflow-auto flex flex-col border dark:border-zinc-500"- :style="{- maxHeight: maxHeight ? `${maxHeight}px` : undefined,- }"- >- <table class="relative border-collapse table-auto">- <thead- class="sticky top-0 z-[1] drop-shadow-sm bg-gray-50 dark:bg-gray-700"- >- <tr>- <th- v-for="header of table.getFlatHeaders()"- :key="header.index"- class="relative min-w-[2rem] max-w-[50vw] text-left text-xs font-medium text-gray-500 dark:text-gray-300 tracking-wider border-l first:border-l-0 border-block-border dark:border-zinc-500"- :class="- twMerge(- selectionState.rows.length === 0 &&- selectionState.columns.includes(header.index) &&- '!bg-accent/10 dark:!bg-accent/40'- )- "- >- <div class="px-2 py-2 flex items-center overflow-hidden">- <span- class="flex flex-row items-center select-none"- :class="{- 'cursor-pointer hover:text-accent dark:hover:text-gray-500':- !selectionDisabled,- }"- @click.stop="selectColumn(header.index)"- >- <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()"- @click.stop.prevent="- header.column.getToggleSortingHandler()?.($event)- "- />- </div>- </th>- </tr>- </thead>- <tbody>- <tr- v-for="(row, rowIndex) of rows"- :key="rowIndex"- class="group"- :data-row-index="offset + rowIndex"- >- <td- v-for="(cell, cellIndex) of row.getVisibleCells()"- :key="cellIndex"- class="relative min-w-8 max-w-[50vw] p-0 text-sm dark:text-gray-100 leading-5 whitespace-nowrap break-all border-l first:border-l-0 border-block-border dark:border-zinc-500 group-even:bg-gray-100/50 dark:group-even:bg-gray-700/50"- :data-col-index="cellIndex"- >- <TableCell- :table="table"- :value="cell.getValue<RowValue>()"- :keyword="keyword"- :set-index="setIndex"- :row-index="offset + rowIndex"- :col-index="cellIndex"- :allow-select="true"- />- <div- v-if="cellIndex === 0"- class="absolute inset-y-0 left-0 w-2"- :class="{- 'cursor-pointer hover:bg-accent/10 dark:hover:bg-accent/40':- !selectionDisabled,- 'bg-accent/10 dark:bg-accent/40':- selectionState.columns.length === 0 &&- selectionState.rows.includes(offset + rowIndex),- }"- @click.prevent.stop="selectRow(offset + rowIndex)"- ></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>-</template>--<script lang="ts" setup>-import type { Table } from "@tanstack/vue-table";-import { NEmpty } from "naive-ui";-import { twMerge } from "tailwind-merge";-import { computed, nextTick, ref, watch } from "vue";-import {- FeatureBadge,- FeatureBadgeForInstanceLicense,-} from "@/components/FeatureGuard";-import { useSubscriptionV1Store } from "@/store";-import type { QueryRow, RowValue } from "@/types/proto/v1/sql_service";-import ColumnSortedIcon from "../DataTable/common/ColumnSortedIcon.vue";-import SensitiveDataIcon from "../DataTable/common/SensitiveDataIcon.vue";-import { useSQLResultViewContext } from "../context";-import TableCell from "./TableCell.vue";-import { useSelectionContext } from "./common/selection-logic";--const props = defineProps<{- table: Table<QueryRow>;- setIndex: number;- offset: number;- isSensitiveColumn: (index: number) => boolean;- isColumnMissingSensitive: (index: number) => boolean;- maxHeight?: number;-}>();--const {- state: selectionState,- disabled: selectionDisabled,- selectColumn,- selectRow,-} = useSelectionContext();-const containerRef = ref<HTMLDivElement>();-const subscriptionStore = useSubscriptionV1Store();--const { keyword } = useSQLResultViewContext();--const hasSensitiveFeature = computed(() => {- return subscriptionStore.hasFeature("bb.feature.sensitive-data");-});--const scrollTo = (x: number, y: number) => {- containerRef.value?.scroll(x, y);-};--const rows = computed(() => props.table.getRowModel().rows);--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);- });- },- { immediate: true }-);--watch(- () => props.offset,- () => {- // When the offset changed, we need to reset the scroll position.- scrollTo(0, 0);- }-);-</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/index.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/index.tsindex 94a54fa8eb..5e544303ab 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/index.ts+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/index.ts@@ -1,4 +1,3 @@import DataTable from "./DataTable.vue";-import DataTableLite from "./DataTableLite.vue";-export { DataTable, DataTableLite };+export default DataTable;diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/useTableResize.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/useTableResize.tsindex 495496126b..a688a2816a 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/useTableResize.ts+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/useTableResize.ts@@ -58,90 +58,22 @@ const useTableResize = (options: TableResizeOptions) => {state.drag = undefined;state.isAutoAdjusting = false;+ // Use auto layout to calculate the width of each column.+ table.value.style.tableLayout = "auto";const thList = Array.from(table.value.querySelectorAll("th"));const columnCount = thList.length;- state.columns = new Array(columnCount);-- const indexList: number[] = [];- for (let i = 0; i < columnCount; i++) {- indexList.push(i);- state.columns[i] = {- width: 0, // For auto adjust below- };+ if (columnCount === 1) {+ state.columns = [+ {+ width: containerWidth.value - 1,+ },+ ];+ } else {+ const columnWidths = thList.map((th) => th.getBoundingClientRect().width);+ state.columns = columnWidths.map((width) => ({ width }));}-- // Calculate a friendly width for every column when the first render happened.- requestAnimationFrame(() => {- autoAdjustColumnWidth(indexList);- });- };-- // Automatically estimate the width of a column.- // Like double-clicking a cell border of Excel.- // Able to estimate multiple columns in a time.- const autoAdjustColumnWidth = (indexList: number[]): Promise<number[]> => {- return new Promise((resolve) => {- const cellListOfEachColumn = indexList.map((index) => {- const pseudo = `:nth-child(${index + 1})`;- // Find all cells in this column- const cellList = Array.from(- table.value.querySelectorAll(`th${pseudo}, td${pseudo}`)- ) as HTMLElement[];- return cellList;- });-- // Update the cells' and table's style to estimate the width.- state.isAutoAdjusting = true;- cellListOfEachColumn.forEach((cellList) => {- cellList.forEach((cell) => {- cell.style.whiteSpace = "nowrap";- cell.style.overflow = "visible";- cell.style.width = "auto";- cell.style.maxWidth = `${options.maxWidth}px`;- cell.style.minWidth = `${options.minWidth}px`;- });- });- const tableWidthBackup = table.value.style.width;- table.value.style.width = "auto";-- // Wait for the next render frame.- requestAnimationFrame(() => {- // Read the rendered widths.-- const widthList = indexList.map((index, i) => {- const cellList = cellListOfEachColumn[i];- const th = cellList[0];- const stretchedWidth = getElementWidth(th);- const finalWidth = normalizeWidth(stretchedWidth);-- const column = state.columns[index];- if (column) {- // Sometimes the `columns` is out-of-sync with the `indexList`- // so we need to detect and suppress errors here.- // Only occurs in dev hot reload mode.- column.width = finalWidth;- }-- return finalWidth;- });-- // Reset the cells' and table's style.- cellListOfEachColumn.forEach((cellList) => {- cellList.forEach((cell) => {- cell.style.whiteSpace = "";- cell.style.overflow = "";- cell.style.width = "";- cell.style.maxWidth = "";- cell.style.minWidth = "";- });- });- table.value.style.width = tableWidthBackup;- state.isAutoAdjusting = false;-- resolve(widthList);- // Style bindings will be automatically updated next frame.- });- });+ // After calculating the width, use fixed layout to keep the width stable.+ table.value.style.tableLayout = "fixed";};// Record the initial state of dragging.@@ -207,19 +139,12 @@ const useTableResize = (options: TableResizeOptions) => {reset,getColumnProps,getTableProps,- autoAdjustColumnWidth,startResizing,};};export default useTableResize;-const getElementWidth = (elem: HTMLElement) => {- if (!elem) return 0;- const rect = elem.getBoundingClientRect();- return rect.width;-};-const scrollMaxX = (elem: HTMLElement | null | undefined) => {if (!elem) return;const max = elem.scrollWidth;diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vueindex 6528f6e0a4..97768b984b 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue@@ -115,24 +115,14 @@:is-sensitive-column="isSensitiveColumn":is-column-missing-sensitive="isColumnMissingSensitive"/>- <template v-else>- <DataTableLite- v-if="useDataTableLite"- :table="table"- :set-index="setIndex"- :offset="pageIndex * pageSize"- :is-sensitive-column="isSensitiveColumn"- :is-column-missing-sensitive="isColumnMissingSensitive"- />- <DataTable- v-else- :table="table"- :set-index="setIndex"- :offset="pageIndex * pageSize"- :is-sensitive-column="isSensitiveColumn"- :is-column-missing-sensitive="isColumnMissingSensitive"- />- </template>+ <DataTable+ v-else+ :table="table"+ :set-index="setIndex"+ :offset="pageIndex * pageSize"+ :is-sensitive-column="isSensitiveColumn"+ :is-column-missing-sensitive="isColumnMissingSensitive"+ /></div><div@@ -244,7 +234,7 @@ import {isNullOrUndefined,} from "@/utils";import DataBlock from "./DataBlock.vue";-import { DataTable, DataTableLite } from "./DataTable";+import DataTable from "./DataTable";import { provideSelectionContext } from "./DataTable/common/selection-logic";import EmptyView from "./EmptyView.vue";import ErrorView from "./ErrorView";@@ -400,15 +390,6 @@ const data = computed(() => {return temp;});-const useDataTableLite = computed(() => {- // In admin mode, always use DataTableLite to keep consistent- if (currentTab.value?.mode === "ADMIN") return true;-- // Otherwise, use DataTableLite if the result set has too many columns in a page.- const colCount = table.getFlatHeaders().length;- return colCount >= 50;-});-const isSensitiveColumn = (columnIndex: number): boolean => {return props.result.masked[columnIndex] ?? false;};