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: move search field to the tab bar (#8734)
zll600c8fb7a32da28
diff --git a/frontend/src/components/SchemaEditorV1/Editor.vue b/frontend/src/components/SchemaEditorV1/Editor.vueindex 06dba0cda6..ad09937075 100644--- a/frontend/src/components/SchemaEditorV1/Editor.vue+++ b/frontend/src/components/SchemaEditorV1/Editor.vue@@ -1,13 +1,18 @@<template><main class="px-2 pt-2 w-full h-full flex flex-col overflow-y-auto"><template v-if="currentTab">- <TabsContainer />+ <TabsContainer+ @on-table-search-pattern="handleTableSearchPattern"+ @on-column-search-pattern="handleColumnSearchPattern"+ /><div :key="currentTab.id" class="w-full h-full relative overflow-y-auto"><DatabaseEditorv-if="currentTab.type === SchemaEditorTabType.TabForDatabase"+ :search-pattern="state.tableSearchPattern"/><TableEditorv-else-if="currentTab.type === SchemaEditorTabType.TabForTable"+ :search-pattern="state.columnSearchPattern"/></div></template>@@ -16,7 +21,7 @@</template><script lang="ts" setup>-import { computed } from "vue";+import { computed, reactive, watch } from "vue";import { useSchemaEditorV1Store } from "@/store/modules/v1/schemaEditor";import { SchemaEditorTabType } from "@/types/v1/schemaEditor";import DatabaseEditor from "./Panels/DatabaseEditor.vue";@@ -25,4 +30,27 @@ import TabsContainer from "./TabsContainer.vue";const schemaEditorV1Store = useSchemaEditorV1Store();const currentTab = computed(() => schemaEditorV1Store.currentTab);++interface LocalState {+ tableSearchPattern: string;+ columnSearchPattern: string;+}++const state = reactive<LocalState>({+ tableSearchPattern: "",+ columnSearchPattern: "",+});++const handleTableSearchPattern = (tableSearchPattern: string) => {+ state.tableSearchPattern = tableSearchPattern;+};++const handleColumnSearchPattern = (columnSearchPattern: string) => {+ state.columnSearchPattern = columnSearchPattern;+};++watch([() => state.tableSearchPattern, () => currentTab.value], () => {+ // state.tableSearchPattern = "";+ state.columnSearchPattern = "";+});</script>diff --git a/frontend/src/components/SchemaEditorV1/Panels/DatabaseEditor.vue b/frontend/src/components/SchemaEditorV1/Panels/DatabaseEditor.vueindex 2244a043c1..12519d7844 100644--- a/frontend/src/components/SchemaEditorV1/Panels/DatabaseEditor.vue+++ b/frontend/src/components/SchemaEditorV1/Panels/DatabaseEditor.vue@@ -39,16 +39,6 @@</div></div><div class="flex justify-end items-center">- <NInput- v-if="state.selectedSubtab === 'table-list'"- v-model:value="searchPattern"- class="!w-48 mr-3"- :placeholder="$t('schema-editor.search-table')"- >- <template #prefix>- <heroicons-outline:search class="w-4 h-auto text-gray-300" />- </template>- </NInput><divclass="flex flex-row justify-end items-center bg-gray-100 p-1 rounded">@@ -254,7 +244,7 @@import { head } from "lodash-es";import { NEllipsis, NTooltip } from "naive-ui";import scrollIntoView from "scroll-into-view-if-needed";-import { computed, nextTick, reactive, ref, watch } from "vue";+import { computed, nextTick, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import { SchemaDiagram, SchemaDiagramIcon } from "@/components/SchemaDiagram";import { Drawer, DrawerContent } from "@/components/v2";@@ -285,6 +275,15 @@ import TableNameModal from "../Modals/TableNameModal.vue";import { isTableChanged } from "../utils";import { useMetadataForDiagram } from "../utils/useMetadataForDiagram";+const props = withDefaults(+ defineProps<{+ searchPattern: string;+ }>(),+ {+ searchPattern: "",+ }+);+type SubtabType = "table-list" | "schema-diagram";interface LocalState {@@ -306,7 +305,6 @@ interface LocalState {const { t } = useI18n();const editorStore = useSchemaEditorV1Store();const settingStore = useSettingV1Store();-const searchPattern = ref("");const currentTab = computed(() => editorStore.currentTab as DatabaseTabContext);const state = reactive<LocalState>({selectedSubtab: "table-list",@@ -340,7 +338,7 @@ const tableList = computed(() => {});const shownTableList = computed(() => {return tableList.value.filter((table) =>- table.name.includes(searchPattern.value.trim())+ table.name.includes(props.searchPattern.trim()));});const classificationConfig = computed(() => {diff --git a/frontend/src/components/SchemaEditorV1/Panels/TableEditor.vue b/frontend/src/components/SchemaEditorV1/Panels/TableEditor.vueindex 892e6a40c2..8bb186c6ed 100644--- a/frontend/src/components/SchemaEditorV1/Panels/TableEditor.vue+++ b/frontend/src/components/SchemaEditorV1/Panels/TableEditor.vue@@ -25,18 +25,6 @@</NButton></div></div>- <div class="flex justify-end items-center">- <NInput- v-model:value="searchPattern"- class="!w-48"- size="small"- :placeholder="$t('schema-editor.search-column')"- >- <template #prefix>- <heroicons-outline:search class="w-4 h-auto text-gray-300" />- </template>- </NInput>- </div></div><TableColumnEditor@@ -47,7 +35,7 @@:foreign-key-list="foreignKeyList":classification-config-id="project.dataClassificationConfigId":disable-change-table="disableChangeTable"- :filter-column="(column: Column) => column.name.includes(searchPattern.trim())"+ :filter-column="(column: Column) => column.name.includes(props.searchPattern.trim())":disable-alter-column="disableAlterColumn":get-referenced-foreign-key-name="getReferencedForeignKeyName":get-column-item-computed-class-list="getColumnItemComputedClassList"@@ -116,6 +104,15 @@ import EditColumnForeignKeyModal from "../Modals/EditColumnForeignKeyModal.vue";import { isColumnChanged } from "../utils";import TableColumnEditor from "./TableColumnEditor.vue";+const props = withDefaults(+ defineProps<{+ searchPattern: string;+ }>(),+ {+ searchPattern: "",+ }+);+interface LocalState {showEditColumnForeignKeyModal: boolean;showSchemaTemplateDrawer: boolean;@@ -161,7 +158,6 @@ const foreignKeyList = computed(() => {) as ForeignKey[];});-const searchPattern = ref("");const editForeignKeyColumn = ref<Column>();const isDroppedSchema = computed(() => {diff --git a/frontend/src/components/SchemaEditorV1/TabsContainer.vue b/frontend/src/components/SchemaEditorV1/TabsContainer.vueindex c3bbe36b6e..34ca1b24e2 100644--- a/frontend/src/components/SchemaEditorV1/TabsContainer.vue+++ b/frontend/src/components/SchemaEditorV1/TabsContainer.vue@@ -1,40 +1,69 @@<template>- <div- ref="tabsContainerRef"- class="w-full max-w-full overflow-x-auto bg-gray-100 select-none shrink-0 p-1 rounded"- >- <div class="w-fit flex flex-nowrap">+ <div class="flex justify-between items-center">+ <div+ class="relative flex flex-1 flex-nowrap overflow-hidden overflow bg-gray-100 select-none shrink-0 p-1 rounded"+ ><div- v-for="tab in tabList"- :key="tab.id"- class="relative px-1 pl-2 py-1 rounded w-40 flex flex-row justify-between items-center shrink-0 border border-transparent cursor-pointer"- :class="[- `tab-${tab.id}`,- tab.id === currentTab?.id && 'bg-white border-gray-200 shadow',- ]"- @click="handleSelectTab(tab)"+ ref="tabsContainerRef"+ class="flex flex-nowrap overflow-x-auto max-x-full hide-scrollbar overscroll-none">- <div class="flex flex-row justify-start items-center mr-1">- <span class="mr-1">- <heroicons-outline:table-cells- v-if="tab.type === SchemaEditorTabType.TabForTable"- class="rounded w-4 h-auto text-gray-400"+ <div+ v-for="tab in tabList"+ ref="tabsContainerRef"+ :key="tab.id"+ class="relative px-1 pl-2 py-1 rounded w-40 flex flex-row justify-between items-center shrink-0 border border-transparent cursor-pointer"+ :class="[+ `tab-${tab.id}`,+ tab.id === currentTab?.id && 'bg-white border-gray-200 shadow',+ ]"+ @click="handleSelectTab(tab)"+ >+ <div class="flex flex-row justify-start items-center mr-1">+ <span class="mr-1">+ <heroicons-outline:table-cells+ v-if="tab.type === SchemaEditorTabType.TabForTable"+ class="rounded w-4 h-auto text-gray-400"+ />+ </span>+ <NEllipsis+ class="text-sm w-24"+ :class="getTabComputedClassList(tab)"+ >{{ getTabName(tab) }}</NEllipsis+ >+ </div>+ <span class="tab-close-button shrink-0 flex">+ <heroicons-outline:x+ class="rounded w-4 h-auto text-gray-400 hover:text-gray-600"+ @click.stop.prevent="handleCloseTab(tab)"/></span>- <NEllipsis- class="text-sm w-24"- :class="getTabComputedClassList(tab)"- >{{ getTabName(tab) }}</NEllipsis- ></div>- <span class="tab-close-button shrink-0 flex">- <heroicons-outline:x- class="rounded w-4 h-auto text-gray-400 hover:text-gray-600"- @click.stop.prevent="handleCloseTab(tab)"- />- </span></div></div>+ <div v-if="currentTab" class="hidden lg:block p-1">+ <NInput+ v-if="currentTab.type === SchemaEditorTabType.TabForDatabase"+ v-model:value="searchPattern"+ class="!w-48"+ :placeholder="$t('schema-editor.search-table')"+ @input="$emit('onTableSearchPattern', $event)"+ >+ <template #prefix>+ <heroicons-outline:search class="w-4 h-auto text-gray-300" />+ </template>+ </NInput>+ <NInput+ v-if="currentTab.type === SchemaEditorTabType.TabForTable"+ v-model:value="searchPattern"+ class="!w-48"+ :placeholder="$t('schema-editor.search-column')"+ @input="$emit('onColumnSearchPattern', $event)"+ >+ <template #prefix>+ <heroicons-outline:search class="w-4 h-auto text-gray-300" />+ </template>+ </NInput>+ </div></div></template>@@ -46,6 +75,15 @@ import { useSchemaEditorV1Store } from "@/store";import { SchemaEditorTabType, TabContext } from "@/types/v1/schemaEditor";import { isTableChanged } from "./utils";+defineEmits<{+ (event: "onTableSearchPattern", tableSearchPattern: string): void;+ (event: "onColumnSearchPattern", columnSearchPattern: string): void;+}>();++const searchPattern = ref("");++const originalTabContext = ref<TabContext | undefined>(undefined);+const schemaEditorV1Store = useSchemaEditorV1Store();const tabsContainerRef = ref();const tabList = computed(() => {@@ -58,6 +96,11 @@ const currentTab = computed(() => {watch(() => currentTab.value,() => {+ if (currentTab.value !== originalTabContext.value) {+ searchPattern.value = "";+ originalTabContext.value = currentTab.value;+ }+nextTick(() => {const element = tabsContainerRef.value?.querySelector(`.tab-${currentTab.value?.id}`