Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: truncate long data and display full detail in popup (#6616)
Liu Ji8104b8e430b6
diff --git a/frontend/src/components/ProvideSQLEditorContext.vue b/frontend/src/components/ProvideSQLEditorContext.vueindex ca25d6bfde..3709c8ac9f 100644--- a/frontend/src/components/ProvideSQLEditorContext.vue+++ b/frontend/src/components/ProvideSQLEditorContext.vue@@ -190,6 +190,9 @@ const prepareConnectionTree = async () => {const prepareSheet = async () => {const sheetSlug = (route.params.sheetSlug as string) || "";+ if (!sheetSlug) {+ return false;+ }const sheetName = sheetNameFromSlug(sheetSlug);const openingSheetTab = tabStore.tabList.find(@@ -224,34 +227,32 @@ const prepareSheet = async () => {} else {// Open the sheet in a "temp" tab otherwise.tabStore.selectOrAddTempTab();+ }- let insId = String(UNKNOWN_ID);- let dbId = String(UNKNOWN_ID);- if (sheet.database) {- const [instanceName, databaseId] = getInstanceAndDatabaseId(- sheet.database- );- const ins = await useInstanceV1Store().getOrFetchInstanceByName(- `instances/${instanceName}`- );- insId = ins.uid;- dbId = databaseId;- }-- tabStore.updateCurrentTab({- sheetName,- name: sheet.title,- statement: new TextDecoder().decode(sheet.content),- isSaved: true,- connection: {- ...emptyConnection(),- // TODO: legacy instance id.- instanceId: insId,- databaseId: dbId,- },- });+ let insId = String(UNKNOWN_ID);+ let dbId = String(UNKNOWN_ID);+ if (sheet.database) {+ const [instanceName, databaseId] = getInstanceAndDatabaseId(sheet.database);+ const ins = await useInstanceV1Store().getOrFetchInstanceByName(+ `instances/${instanceName}`+ );+ insId = ins.uid;+ dbId = databaseId;}+ tabStore.updateCurrentTab({+ sheetName,+ name: sheet.title,+ statement: new TextDecoder().decode(sheet.content),+ isSaved: true,+ connection: {+ ...emptyConnection(),+ // TODO: legacy instance id.+ instanceId: insId,+ databaseId: dbId,+ },+ });+return true;};diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vueindex 33baa1f01b..27336f87d0 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue@@ -56,13 +56,13 @@:key="rowIndex"class="group">- <!-- eslint-disable vue/no-v-html --><tdv-for="(cell, cellIndex) of row.getVisibleCells()":key="cellIndex"- class="px-2 py-1 text-sm dark:text-gray-100 leading-5 whitespace-pre-wrap break-all border border-block-border group-last:border-b-0 group-even:bg-gray-50/50 dark:group-even:bg-gray-700/50"- v-html="renderCellValue(cell.getValue())"- ></td>+ class="px-2 py-1 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"+ >+ <TableCell :html="renderCellValue(cell.getValue())" />+ </td></tr></tbody></table>@@ -84,6 +84,7 @@ import { escape } from "lodash-es";import useTableColumnWidthLogic from "./useTableResize";import SensitiveDataIcon from "./SensitiveDataIcon.vue";+import TableCell from "./TableCell.vue";import { getHighlightHTMLByRegExp } from "@/utils";export type DataTableColumn = {diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vuenew file mode 100644index 0000000000..77d7785ef3--- /dev/null+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue@@ -0,0 +1,52 @@+<template>+ <div class="relative">+ <!-- eslint-disable-next-line vue/no-v-html -->+ <div ref="wrapperRef" class="overflow-hidden" v-html="html"></div>+ <div v-if="truncated" class="absolute right-0 top-1/2 translate-y-[-50%]">+ <NButton size="tiny" circle class="!bg-white" @click="showModal = true">+ <template #icon>+ <heroicons:arrows-pointing-out class="w-4 h-4" />+ </template>+ </NButton>+ </div>++ <BBModal+ v-if="showModal"+ :title="$t('common.detail')"+ @close="showModal = false"+ >+ <!-- eslint-disable vue/no-v-html -->+ <div+ class="w-[100vw-8rem] min-w-[20rem] md:max-w-[40rem] max-h-[100vh-12rem] overflow-auto whitespace-pre-wrap text-sm"+ v-html="html"+ ></div>+ </BBModal>+ </div>+</template>++<script setup lang="ts">+import { ref } from "vue";+import { NButton } from "naive-ui";+import { useResizeObserver } from "@vueuse/core";++import { BBModal } from "@/bbkit";++defineProps<{+ html?: string;+}>();++const wrapperRef = ref<HTMLDivElement>();+const truncated = ref(false);+const showModal = ref(false);++useResizeObserver(wrapperRef, (entries) => {+ const div = entries[0].target as HTMLDivElement;+ const contentWidth = div.scrollWidth;+ const visibleWidth = div.offsetWidth;+ if (contentWidth > visibleWidth) {+ truncated.value = true;+ } else {+ truncated.value = false;+ }+});+</script>