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: unify DataTable and DataTableLite style (#14256)
Liu Jiebf9ed7a74b0
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vueindex abcc7c4206..a3e746c7bb 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue@@ -1,9 +1,11 @@<template><div+ ref="containerRef"class="bb-data-table relative w-full flex-1 overflow-hidden flex flex-col":style="{maxHeight: maxHeight ? `${maxHeight}px` : undefined,}"+ :data-container-height="containerHeight"><div class="w-full flex-1 flex flex-col overflow-hidden"><div@@ -13,7 +15,7 @@<divref="scrollerRef"class="inner-wrapper max-h-full w-full overflow-auto border-y border-r border-block-border fix-scrollbar-z-index"- :class="rows.length === 0 && 'border-b-0 border-r-0'"+ :class="rows.length === 0 && 'border-r-0 hide-scrollbar'"><tableref="tableRef"@@ -81,7 +83,7 @@<tdv-for="(cell, cellIndex) of row.getVisibleCells()":key="cellIndex"- class="p-0 text-sm dark:text-gray-100 leading-5 whitespace-nowrap break-all border border-block-border group-last:border-b-0 group-even:bg-gray-50/50 dark:group-even:bg-gray-700/50"+ class="p-0 text-sm dark:text-gray-100 leading-5 whitespace-nowrap break-all border border-block-border border-y-0 group-even:bg-gray-100/50 dark:group-even:bg-gray-700/50":data-col-index="cellIndex"><TableCell@@ -96,11 +98,21 @@</tr></tbody></table>+ </div>++ <div+ v-if="rows.length === 0"+ class="w-full border border-block-border absolute pointer-events-none"+ style="padding-top: 33px"+ ><div- v-if="rows.length === 0"- class="text-center w-full my-12 textinfolabel"+ class="w-full flex items-center justify-center border-t border-block-border"+ style="padding-top: 48px; padding-bottom: 48px"+ :style="{+ maxHeight: `${Math.max(0, containerHeight - 34)}px`,+ }">- {{ $t("sql-editor.no-data-available") }}+ <NEmpty /></div></div></div>@@ -109,6 +121,8 @@<script lang="ts" setup>import type { Table } from "@tanstack/vue-table";+import { useElementSize } from "@vueuse/core";+import { NEmpty } from "naive-ui";import { computed, nextTick, ref, watch } from "vue";import {FeatureBadge,@@ -137,10 +151,11 @@ const props = defineProps<{maxHeight?: number;}>();+const containerRef = ref<HTMLDivElement>();const scrollerRef = ref<HTMLDivElement>();const tableRef = ref<HTMLTableElement>();const subscriptionStore = useSubscriptionV1Store();-+const { height: containerHeight } = useElementSize(containerRef);usePreventBackAndForward(scrollerRef);const tableResize = useTableColumnWidthLogic({diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/ColumnHeader.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/ColumnHeader.vueindex 026db9c854..54aa1608da 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/ColumnHeader.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/ColumnHeader.vue@@ -1,9 +1,9 @@<template><div- class="relative px-2 py-2 min-w-[2rem] whitespace-nowrap text-left bg-gray-50 dark:bg-gray-700 text-xs font-medium text-gray-500 dark:text-gray-300 tracking-wider"+ class="relative px-2 h-[32px] min-w-[2rem] whitespace-nowrap text-left bg-gray-50 dark:bg-gray-700 text-xs font-medium text-gray-500 dark:text-gray-300 tracking-wider"><div- class="flex items-center overflow-hidden cursor-pointer"+ class="h-full flex items-center overflow-hidden cursor-pointer"@click="header.column.getToggleSortingHandler()?.($event)"><span class="flex flex-row items-center select-none">diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/DataTableLite.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/DataTableLite.vueindex eccdf5ec7f..e040a8e2dd 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/DataTableLite.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/DataTableLite.vue@@ -6,8 +6,15 @@:data-height="containerHeight"><div- tag="div"- class="header-track absolute z-0 left-0 top-0 right-0 h-[34px] border border-block-border rounded-t-sm bg-gray-50 dark:bg-gray-700"+ class="header-track absolute z-[1] left-0 top-0 right-0 h-[34px] border border-block-border bg-gray-50 dark:bg-gray-700"+ />+ <div+ class="absolute z-[0] left-0 right-0 border-b border-r border-block-border"+ :style="padStyle"+ :data-container-width="containerWidth"+ :data-container-height="containerHeight"+ :data-table-body-height="tableBodyHeight"+ :data-rendered-table-body-height="renderedTableBodyHeight"/><NDataTable@@ -25,11 +32,11 @@:scroll-x="tableResize.getTableScrollWidth()"table-layout="fixed"size="small"- class="relative z-[1]"+ class="relative z-[1] -mr-px"style="--n-th-padding: 0;--n-td-padding: 0;- --n-border-radius: 2px;+ --n-border-radius: 0;--n-border-color: rgb(var(--color-block-border));":style="{@@ -43,7 +50,7 @@import type { Header, Row, Table } from "@tanstack/vue-table";import { pausableWatch, useElementSize } from "@vueuse/core";import { type DataTableColumn, type DataTableInst, NDataTable } from "naive-ui";-import { computed, h, nextTick, ref, toRef, watch } from "vue";+import { computed, h, nextTick, ref, toRef, watch, type StyleValue } from "vue";import { QueryRow, type RowValue } from "@/types/proto/v1/sql_service";import { nextAnimationFrame, usePreventBackAndForward } from "@/utils";import { useSQLResultViewContext } from "../context";@@ -139,6 +146,19 @@ const tableResize = useTableColumnWidthLogic({maxWidth: COLUMN_WIDTH.MAX,});+const tableBodyElemRef = computed(() => {+ return queryTableBodyElement();+});+const { height: renderedTableBodyHeight } = useElementSize(tableBodyElemRef);+const padStyle = computed(() => {+ const style: StyleValue = {+ top: `${HEADER_HEIGHT}px`,+ };+ const height = Math.min(renderedTableBodyHeight.value, tableBodyHeight.value);+ style.height = `${height + GAP_AND_BORDER_HEIGHT}px`;+ return style;+});+const columns = computed(() => {return headers.value.map<DataTableColumn<Row<QueryRow>>>((header, colIndex) => {@@ -175,7 +195,7 @@ const columns = computed(() => {setIndex: props.setIndex,rowIndex: props.offset + row.index,colIndex,- class: row.index % 2 === 0 && "bg-gray-100/50 dark:bg-gray-700/50",+ class: row.index % 2 === 1 && "bg-gray-100/50 dark:bg-gray-700/50",});},width: tableResize.state.autoAdjusting.has(colIndex)diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/useTableResize.ts b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/useTableResize.tsindex 83385991ee..e845fdceb1 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/useTableResize.ts+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTableLite/useTableResize.ts@@ -55,8 +55,8 @@ const useTableResize = (options: TableResizeOptions) => {const normalizeWidth = (width: number) => {if (state.columns.length === 1) {// When there is only one column, display it with full width.- // minus 1px to avoid unexpected horizontal scrollbar.- return options.containerWidth.value - 1;+ // minus 2px to avoid unexpected horizontal scrollbar.+ return options.containerWidth.value - 2;}return minmax(width, options.minWidth, options.maxWidth);};