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(react): cut SchemaEditorLite over to React, wire into Plan editing (#20154)
boojackb1aad0cd87ab
diff --git a/frontend/src/components/SchemaEditorLite/Aside/Aside.vue b/frontend/src/components/SchemaEditorLite/Aside/Aside.vuedeleted file mode 100644index 0c4839c930..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/Aside.vue+++ /dev/null@@ -1,9 +0,0 @@-<template>- <Tree @update-is-editing="$emit('update-is-editing', $event)" />-</template>--<script lang="ts" setup>-import Tree from "./Tree.vue";--defineEmits(["update-is-editing"]);-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ColumnNodeCheckbox.vue b/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ColumnNodeCheckbox.vuedeleted file mode 100644index a12d0b6912..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ColumnNodeCheckbox.vue+++ /dev/null@@ -1,31 +0,0 @@-<template>- <NCheckbox- :checked="state.checked"- :indeterminate="state.indeterminate"- size="small"- @update:checked="update"- @click.prevent.stop- />-</template>--<script setup lang="ts">-import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useSchemaEditorContext } from "../../context";-import type { TreeNodeForColumn } from "../common";--const props = defineProps<{- node: TreeNodeForColumn;-}>();--const { getColumnSelectionState, updateColumnSelection } =- useSchemaEditorContext();--const state = computed(() => {- return getColumnSelectionState(props.node.db, props.node.metadata);-});--const update = (on: boolean) => {- updateColumnSelection(props.node.db, props.node.metadata, on);-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/FunctionGroupNodeCheckbox.vue b/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/FunctionGroupNodeCheckbox.vuedeleted file mode 100644index d70d7e179b..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/FunctionGroupNodeCheckbox.vue+++ /dev/null@@ -1,40 +0,0 @@-<template>- <NCheckbox- :checked="state.checked"- :indeterminate="state.indeterminate"- size="small"- @update:checked="update"- @click.prevent.stop- />-</template>--<script setup lang="ts">-import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useSchemaEditorContext } from "../../context";-import type { TreeNodeForGroup } from "../common";--const props = defineProps<{- node: TreeNodeForGroup<"function">;-}>();--const { getAllFunctionsSelectionState, updateAllFunctionsSelection } =- useSchemaEditorContext();--const state = computed(() => {- return getAllFunctionsSelectionState(- props.node.db,- props.node.metadata,- props.node.metadata.schema.functions- );-});--const update = (on: boolean) => {- updateAllFunctionsSelection(- props.node.db,- props.node.metadata,- props.node.metadata.schema.functions,- on- );-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/FunctionNodeCheckbox.vue b/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/FunctionNodeCheckbox.vuedeleted file mode 100644index 054d50fe4d..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/FunctionNodeCheckbox.vue+++ /dev/null@@ -1,30 +0,0 @@-<template>- <NCheckbox- :checked="state.checked"- :indeterminate="state.indeterminate"- size="small"- @update:checked="update"- @click.prevent.stop- />-</template>--<script setup lang="ts">-import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useSchemaEditorContext } from "../../context";-import type { TreeNodeForFunction } from "../common";--const props = defineProps<{- node: TreeNodeForFunction;-}>();--const { getFunctionSelectionState, updateFunctionSelection } =- useSchemaEditorContext();--const state = computed(() => {- return getFunctionSelectionState(props.node.db, props.node.metadata);-});-const update = (on: boolean) => {- updateFunctionSelection(props.node.db, props.node.metadata, on);-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/NodeCheckbox.vue b/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/NodeCheckbox.vuedeleted file mode 100644index 70343d4901..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/NodeCheckbox.vue+++ /dev/null@@ -1,40 +0,0 @@-<template>- <TableGroupNodeCheckbox- v-if="node.type === 'group' && node.group === 'table'"- :node="node as TreeNodeForGroup<'table'>"- />- <ViewGroupNodeCheckbox- v-if="node.type === 'group' && node.group === 'view'"- :node="node as TreeNodeForGroup<'view'>"- />- <ProcedureGroupNodeCheckbox- v-if="node.type === 'group' && node.group === 'procedure'"- :node="node as TreeNodeForGroup<'procedure'>"- />- <FunctionGroupNodeCheckbox- v-if="node.type === 'group' && node.group === 'function'"- :node="node as TreeNodeForGroup<'function'>"- />- <TableNodeCheckbox v-if="node.type === 'table'" :node="node" />- <ColumnNodeCheckbox v-if="node.type === 'column'" :node="node" />- <ViewNodeCheckbox v-if="node.type === 'view'" :node="node" />- <ProcedureNodeCheckbox v-if="node.type === 'procedure'" :node="node" />- <FunctionNodeCheckbox v-if="node.type === 'function'" :node="node" />-</template>--<script setup lang="ts">-import type { TreeNode, TreeNodeForGroup } from "../common";-import ColumnNodeCheckbox from "./ColumnNodeCheckbox.vue";-import FunctionGroupNodeCheckbox from "./FunctionGroupNodeCheckbox.vue";-import FunctionNodeCheckbox from "./FunctionNodeCheckbox.vue";-import ProcedureGroupNodeCheckbox from "./ProcedureGroupNodeCheckbox.vue";-import ProcedureNodeCheckbox from "./ProcedureNodeCheckbox.vue";-import TableGroupNodeCheckbox from "./TableGroupNodeCheckbox.vue";-import TableNodeCheckbox from "./TableNodeCheckbox.vue";-import ViewGroupNodeCheckbox from "./ViewGroupNodeCheckbox.vue";-import ViewNodeCheckbox from "./ViewNodeCheckbox.vue";--defineProps<{- node: TreeNode;-}>();-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ProcedureGroupNodeCheckbox.vue b/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ProcedureGroupNodeCheckbox.vuedeleted file mode 100644index 5e22b52fc5..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ProcedureGroupNodeCheckbox.vue+++ /dev/null@@ -1,40 +0,0 @@-<template>- <NCheckbox- :checked="state.checked"- :indeterminate="state.indeterminate"- size="small"- @update:checked="update"- @click.prevent.stop- />-</template>--<script setup lang="ts">-import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useSchemaEditorContext } from "../../context";-import type { TreeNodeForGroup } from "../common";--const props = defineProps<{- node: TreeNodeForGroup<"procedure">;-}>();--const { getAllProceduresSelectionState, updateAllProceduresSelection } =- useSchemaEditorContext();--const state = computed(() => {- return getAllProceduresSelectionState(- props.node.db,- props.node.metadata,- props.node.metadata.schema.procedures- );-});--const update = (on: boolean) => {- updateAllProceduresSelection(- props.node.db,- props.node.metadata,- props.node.metadata.schema.procedures,- on- );-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ProcedureNodeCheckbox.vue b/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ProcedureNodeCheckbox.vuedeleted file mode 100644index 5af6b00f88..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ProcedureNodeCheckbox.vue+++ /dev/null@@ -1,30 +0,0 @@-<template>- <NCheckbox- :checked="state.checked"- :indeterminate="state.indeterminate"- size="small"- @update:checked="update"- @click.prevent.stop- />-</template>--<script setup lang="ts">-import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useSchemaEditorContext } from "../../context";-import type { TreeNodeForProcedure } from "../common";--const props = defineProps<{- node: TreeNodeForProcedure;-}>();--const { getProcedureSelectionState, updateProcedureSelection } =- useSchemaEditorContext();--const state = computed(() => {- return getProcedureSelectionState(props.node.db, props.node.metadata);-});-const update = (on: boolean) => {- updateProcedureSelection(props.node.db, props.node.metadata, on);-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/TableGroupNodeCheckbox.vue b/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/TableGroupNodeCheckbox.vuedeleted file mode 100644index 3de3e87aaf..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/TableGroupNodeCheckbox.vue+++ /dev/null@@ -1,40 +0,0 @@-<template>- <NCheckbox- :checked="state.checked"- :indeterminate="state.indeterminate"- size="small"- @update:checked="update"- @click.prevent.stop- />-</template>--<script setup lang="ts">-import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useSchemaEditorContext } from "../../context";-import type { TreeNodeForGroup } from "../common";--const props = defineProps<{- node: TreeNodeForGroup<"table">;-}>();--const { getAllTablesSelectionState, updateAllTablesSelection } =- useSchemaEditorContext();--const state = computed(() => {- return getAllTablesSelectionState(- props.node.db,- props.node.metadata,- props.node.metadata.schema.tables- );-});--const update = (on: boolean) => {- updateAllTablesSelection(- props.node.db,- props.node.metadata,- props.node.metadata.schema.tables,- on- );-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/TableNodeCheckbox.vue b/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/TableNodeCheckbox.vuedeleted file mode 100644index 30ddcdd9e3..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/TableNodeCheckbox.vue+++ /dev/null@@ -1,30 +0,0 @@-<template>- <NCheckbox- :checked="state.checked"- :indeterminate="state.indeterminate"- size="small"- @update:checked="update"- @click.prevent.stop- />-</template>--<script setup lang="ts">-import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useSchemaEditorContext } from "../../context";-import type { TreeNodeForTable } from "../common";--const props = defineProps<{- node: TreeNodeForTable;-}>();--const { getTableSelectionState, updateTableSelection } =- useSchemaEditorContext();--const state = computed(() => {- return getTableSelectionState(props.node.db, props.node.metadata);-});-const update = (on: boolean) => {- updateTableSelection(props.node.db, props.node.metadata, on);-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ViewGroupNodeCheckbox.vue b/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ViewGroupNodeCheckbox.vuedeleted file mode 100644index 743785f815..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ViewGroupNodeCheckbox.vue+++ /dev/null@@ -1,40 +0,0 @@-<template>- <NCheckbox- :checked="state.checked"- :indeterminate="state.indeterminate"- size="small"- @update:checked="update"- @click.prevent.stop- />-</template>--<script setup lang="ts">-import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useSchemaEditorContext } from "../../context";-import type { TreeNodeForGroup } from "../common";--const props = defineProps<{- node: TreeNodeForGroup<"view">;-}>();--const { getAllViewsSelectionState, updateAllViewsSelection } =- useSchemaEditorContext();--const state = computed(() => {- return getAllViewsSelectionState(- props.node.db,- props.node.metadata,- props.node.metadata.schema.views- );-});--const update = (on: boolean) => {- updateAllViewsSelection(- props.node.db,- props.node.metadata,- props.node.metadata.schema.views,- on- );-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ViewNodeCheckbox.vue b/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ViewNodeCheckbox.vuedeleted file mode 100644index 2e695eed12..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/ViewNodeCheckbox.vue+++ /dev/null@@ -1,29 +0,0 @@-<template>- <NCheckbox- :checked="state.checked"- :indeterminate="state.indeterminate"- size="small"- @update:checked="update"- @click.prevent.stop- />-</template>--<script setup lang="ts">-import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useSchemaEditorContext } from "../../context";-import type { TreeNodeForView } from "../common";--const props = defineProps<{- node: TreeNodeForView;-}>();--const { getViewSelectionState, updateViewSelection } = useSchemaEditorContext();--const state = computed(() => {- return getViewSelectionState(props.node.db, props.node.metadata);-});-const update = (on: boolean) => {- updateViewSelection(props.node.db, props.node.metadata, on);-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/index.ts b/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/index.tsdeleted file mode 100644index 194c7073dd..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodeCheckbox/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import NodeCheckbox from "./NodeCheckbox.vue";--export default NodeCheckbox;diff --git a/frontend/src/components/SchemaEditorLite/Aside/NodePrefix.vue b/frontend/src/components/SchemaEditorLite/Aside/NodePrefix.vuedeleted file mode 100644index 9f74911f1c..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/NodePrefix.vue+++ /dev/null@@ -1,107 +0,0 @@-<template>- <div class="flex flex-row items-center gap-x-1 text-sm">- <NodeCheckbox v-if="selectionEnabled" :node="node" />-- <template v-if="node.type === 'instance'">- <InstanceV1EngineIcon :instance="node.instance" />- <span class="text-gray-500">- {{ environmentForInstanceNode(node).title }}- </span>- </template>- <template v-if="node.type === 'database'">- <DatabaseIcon class="w-4 h-auto text-gray-400" />- <span class="text-gray-500">- {{ getDatabaseEnvironment(node.db).title }}- </span>- </template>-- <template v-if="node.type === 'group'">- <SchemaIcon- v-if="node.group === 'table'"- class="w-4 h-auto text-gray-400"- />- <ViewIcon v-if="node.group === 'view'" class="w-4 h-auto text-gray-400" />- <ProcedureIcon- v-if="node.group === 'procedure'"- class="w-4 h-auto text-gray-400"- />- <FunctionIcon- v-if="node.group === 'function'"- class="w-4 h-auto text-gray-400"- />- </template>-- <div- v-if="node.type === 'column'"- class="w-4 h-4 inline-flex items-center justify-center"- >- <PrimaryKeyIcon v-if="isPrimaryKeyColumn" class="w-4 h-4" />- <IndexIcon v-if="isIndexColumn" class="w-4! h-4! text-gray-500" />- </div>-- <SchemaIcon- v-if="node.type === 'schema'"- class="w-4 h-auto text-gray-400"- />- <TableIcon v-if="node.type === 'table'" class="w-4 h-auto text-gray-400" />- <ViewIcon v-if="node.type === 'view'" class="w-4 h-auto text-gray-400" />- <ProcedureIcon- v-if="node.type === 'procedure'"- class="w-4 h-auto text-gray-400"- />- <FunctionIcon- v-if="node.type === 'function'"- class="w-4 h-auto text-gray-400"- />- </div>-</template>--<script setup lang="ts">-import { computed } from "vue";-import {- DatabaseIcon,- FunctionIcon,- IndexIcon,- PrimaryKeyIcon,- ProcedureIcon,- SchemaIcon,- TableIcon,- ViewIcon,-} from "@/components/Icon";-import { InstanceV1EngineIcon } from "@/components/v2";-import { useEnvironmentV1Store } from "@/store";-import { getDatabaseEnvironment } from "@/utils";-import { useSchemaEditorContext } from "../context";-import type { TreeNode, TreeNodeForInstance } from "./common";-import NodeCheckbox from "./NodeCheckbox";--const props = defineProps<{- node: TreeNode;-}>();--const { selectionEnabled } = useSchemaEditorContext();--const isPrimaryKeyColumn = computed(() => {- const { node } = props;- if (node.type !== "column") return false;-- const { table, column } = node.metadata;- const pk = table.indexes.find((idx) => idx.primary);- if (!pk) return false;- return pk.expressions.includes(column.name);-});-const isIndexColumn = computed(() => {- if (isPrimaryKeyColumn.value) return false;-- const { node } = props;- if (node.type !== "column") return false;- const { table, column } = node.metadata;- return table.indexes.some((idx) => idx.expressions.includes(column.name));-});--const environmentForInstanceNode = (node: TreeNodeForInstance) => {- return useEnvironmentV1Store().getEnvironmentByName(- node.instance.environment ?? ""- );-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Aside/Tree.vue b/frontend/src/components/SchemaEditorLite/Aside/Tree.vuedeleted file mode 100644index 37571fb6db..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/Tree.vue+++ /dev/null@@ -1,930 +0,0 @@-<template>- <div- class="w-full h-full pl-1 pr-2 flex flex-col gap-y-2 relative overflow-y-hidden"- >- <div class="w-full sticky top-0 pt-2">- <SearchBox- :size="'small'"- v-model:value="searchPattern"- style="max-width: 100%"- :placeholder="$t('schema-editor.search-database-and-table')"- />- </div>- <div- ref="treeContainerElRef"- class="schema-editor-tree flex-1 pb-1 text-sm overflow-hidden select-none"- :data-height="treeContainerHeight"- >- <NTree- v-if="treeContainerHeight > 0"- ref="treeRef"- block-line- virtual-scroll- :style="{- height: `${treeContainerHeight}px`,- }"- :data="treeDataRef"- :pattern="loading ? undefined : debouncedSearchPattern"- :render-prefix="renderPrefix"- :render-label="renderLabel"- :render-suffix="renderSuffix"- :node-props="nodeProps"- :expanded-keys="expandedKeysRef"- :selected-keys="selectedKeysRef"- :show-irrelevant-nodes="false"- :theme-overrides="{ nodeHeight: '28px' }"- @update:expanded-keys="handleExpandedKeysChange"- />- <NDropdown- trigger="manual"- placement="bottom-start"- :show="contextMenu.show"- :options="contextMenuOptions"- :x="contextMenu.clientX"- :y="contextMenu.clientY"- to="body"- @select="handleContextMenuSelect"- @clickoutside="handleContextMenuClickoutside"- />- </div>- </div>-- <SchemaNameModal- v-if="state.schemaNameModalContext !== undefined"- :database="state.schemaNameModalContext.db"- :metadata="state.schemaNameModalContext.database"- @close="state.schemaNameModalContext = undefined"- />-- <TableNameModal- v-if="state.tableNameModalContext !== undefined"- :database="state.tableNameModalContext.db"- :metadata="state.tableNameModalContext.database"- :schema="state.tableNameModalContext.schema"- :table="state.tableNameModalContext.table"- @close="state.tableNameModalContext = undefined"- />-- <ProcedureNameModal- v-if="state.procedureNameModalContext !== undefined"- :database="state.procedureNameModalContext.db"- :metadata="state.procedureNameModalContext.database"- :schema="state.procedureNameModalContext.schema"- :procedure="state.procedureNameModalContext.procedure"- @close="state.procedureNameModalContext = undefined"- />-- <ViewNameModal- v-if="state.viewNameModalContext !== undefined"- :database="state.viewNameModalContext.db"- :metadata="state.viewNameModalContext.database"- :schema="state.viewNameModalContext.schema"- :view="state.viewNameModalContext.view"- @close="state.viewNameModalContext = undefined"- />-- <FunctionNameModal- v-if="state.functionNameModalContext !== undefined"- :database="state.functionNameModalContext.db"- :metadata="state.functionNameModalContext.database"- :schema="state.functionNameModalContext.schema"- :func="state.functionNameModalContext.function"- @close="state.functionNameModalContext = undefined"- />-</template>--<script lang="ts" setup>-import { refDebounced, useElementSize } from "@vueuse/core";-import { MD5 } from "crypto-js";-import { cloneDeep, debounce, head } from "lodash-es";-import { CopyIcon, MoreHorizontalIcon } from "lucide-vue-next";-import type { TreeOption } from "naive-ui";-import { NDropdown, NPerformantEllipsis, NTree } from "naive-ui";-import {- computed,- h,- nextTick,- onMounted,- reactive,- ref,- type VNode,- watch,-} from "vue";-import { useI18n } from "vue-i18n";-import { SearchBox } from "@/components/v2";-import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener";-import { useDBSchemaV1Store } from "@/store";-import type {- Database,- DatabaseMetadata,- FunctionMetadata,- ProcedureMetadata,- SchemaMetadata,- TableMetadata,- ViewMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import {- getDatabaseEngine,- getFixedPrimaryKey,- getHighlightHTMLByKeyWords,- isDescendantOf,-} from "@/utils";-import { useSchemaEditorContext } from "../context";-import { keyForResource, keyForResourceName } from "../context/common";-import FunctionNameModal from "../Modals/FunctionNameModal.vue";-import ProcedureNameModal from "../Modals/ProcedureNameModal.vue";-import SchemaNameModal from "../Modals/SchemaNameModal.vue";-import TableNameModal from "../Modals/TableNameModal.vue";-import ViewNameModal from "../Modals/ViewNameModal.vue";-import { engineSupportsMultiSchema } from "../spec";-import type {- TreeNode,- TreeNodeForGroup,- TreeNodeForInstance,- TreeNodeForSchema,- TreeNodeForTable,-} from "./common";-import { useBuildTree } from "./common";-import { useContextMenu } from "./context-menu";-import NodePrefix from "./NodePrefix.vue";--interface LocalState {- shouldRelocateTreeNode: boolean;- schemaNameModalContext?: {- db: Database;- database: DatabaseMetadata;- schema?: SchemaMetadata;- };- tableNameModalContext?: {- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- table?: TableMetadata;- };- procedureNameModalContext?: {- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- procedure?: ProcedureMetadata;- };- viewNameModalContext?: {- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- view?: ViewMetadata;- };- functionNameModalContext?: {- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- function?: FunctionMetadata;- };-}--const { t } = useI18n();-const {- events,- targets,- readonly,- currentTab,- addTab,- markEditStatus,- removeEditStatus,- getSchemaStatus,- getTableStatus,- getColumnStatus,- getViewStatus,- getProcedureStatus,- getFunctionStatus,- queuePendingScrollToTable,- queuePendingScrollToColumn,-} = useSchemaEditorContext();-const buildTree = useBuildTree();-const state = reactive<LocalState>({- shouldRelocateTreeNode: false,-});--const dbSchemaStore = useDBSchemaV1Store();-const treeContainerElRef = ref<HTMLElement>();-const { height: treeContainerHeight } = useElementSize(- treeContainerElRef,- undefined,- {- box: "content-box",- }-);-const treeRef = ref<InstanceType<typeof NTree>>();-const searchPattern = ref("");-const debouncedSearchPattern = refDebounced(searchPattern, 200);-const loading = ref(false);-const expandedKeysRef = ref<string[]>([]);-const selectedKeysRef = ref<string[]>([]);-const treeDataRef = ref<TreeNode[]>([]);-const treeNodeMap = new Map<string, TreeNode>();--const handleSearch = debounce(- async (search: string) => {- if (loading.value) return;- loading.value = true;-- if (search.trim() !== "") {- const responses = await Promise.all(- targets.value.map(async (target) => {- const metadata = await dbSchemaStore.getOrFetchDatabaseMetadata({- database: target.database.name,- skipCache: false,- limit: 100,- filter: `table.contains("${search.trim()}")`,- });- return metadata;- })- );- await events.emit("merge-metadata", responses);- buildDatabaseTreeData(false);- }-- loading.value = false;- },- 500,- { trailing: true }-);--watch(- () => searchPattern.value,- (search) => handleSearch(search)-);--const {- menu: contextMenu,- options: contextMenuOptions,- events: contextMenuEvents,- handleShow: handleContextMenuShow,- handleSelect: handleContextMenuSelect,- handleClickOutside: handleContextMenuClickoutside,-} = useContextMenu();--const upsertExpandedKeys = (key: string) => {- if (expandedKeysRef.value.includes(key)) return;- expandedKeysRef.value.push(key);-};-const expandNodeRecursively = (node: TreeNode | undefined) => {- if (!node) return;- if (node.type === "column") {- // column nodes are not expandable- expandNodeRecursively(node.parent);- }- if (node.type === "group") {- upsertExpandedKeys(node.key);- expandNodeRecursively(node.parent);- }- if (node.type === "table") {- upsertExpandedKeys(node.key);- expandNodeRecursively(node.parent);- }- if (node.type === "schema") {- upsertExpandedKeys(node.key);- expandNodeRecursively(node.parent);- }- if (node.type === "database") {- upsertExpandedKeys(node.key);- expandNodeRecursively(node.parent);- }- if (node.type === "instance") {- upsertExpandedKeys(node.key);- }-};-const findFirstTableGroupNode = (- nodeList: TreeNodeForSchema[] | TreeNodeForInstance[] | TreeNodeForGroup[]-): TreeNodeForGroup<"table"> | undefined => {- const first = nodeList[0];- if (!first) {- return undefined;- }- if (first.type === "group" && first.group === "table") {- return first as TreeNodeForGroup<"table">;- }- if (first.type === "instance") {- const firstDatabaseNode = head(first.children);- return findFirstTableGroupNode(firstDatabaseNode?.children ?? []);- }- if (first.type === "schema") {- return findFirstTableGroupNode(first.children);- }- return undefined;-};--const buildDatabaseTreeData = (openFirstChild: boolean) => {- const treeNodeList = buildTree(targets.value, treeNodeMap, {- byInstance: true,- });- treeDataRef.value = treeNodeList;-- if (openFirstChild) {- const firstTableGroupNode = findFirstTableGroupNode(treeNodeList);- if (firstTableGroupNode) {- nextTick(() => {- // Auto expand the first tree node.- openTabForTreeNode(firstTableGroupNode);- });- }- }-};-const debouncedBuildDatabaseTreeData = debounce(buildDatabaseTreeData, 100);-useEmitteryEventListener(events, "rebuild-tree", (params) => {- debouncedBuildDatabaseTreeData(params.openFirstChild);-});--const tabWatchKey = computed(() => {- const tab = currentTab.value;- if (!tab) return undefined;- if (tab.type === "database") {- return keyForResourceName(- {- database: tab.database.name,- schema: tab.selectedSchema,- },- "table-group"- );- }- return keyForResource(tab.database, tab.metadata);-});-// Sync tree expandedKeys and selectedKeys with tabs-watch(tabWatchKey, () => {- requestAnimationFrame(() => {- const tab = currentTab.value;- if (!tab) {- selectedKeysRef.value = [];- return;- }-- if (tab.type === "database") {- const { database, selectedSchema: schema } = tab;- if (schema !== undefined) {- const key = keyForResourceName(- { database: database.name, schema },- "table-group"- );- const node = treeNodeMap.get(key);- if (node) {- expandNodeRecursively(node);- }- selectedKeysRef.value = [key];- }- } else if (tab.type === "table") {- const {- database,- metadata: { schema, table },- } = tab;- const schemaKey = keyForResource(database, { schema });- const schemaNode = treeNodeMap.get(schemaKey);- if (schemaNode) {- expandNodeRecursively(schemaNode);- }- const tableKey = keyForResource(database, { schema, table });- selectedKeysRef.value = [tableKey];- } else if (tab.type === "procedure") {- const {- database,- metadata: { schema, procedure },- } = tab;- const schemaKey = keyForResource(database, { schema });- const schemaNode = treeNodeMap.get(schemaKey);- if (schemaNode) {- expandNodeRecursively(schemaNode);- }- const procedureKey = keyForResource(database, { schema, procedure });- selectedKeysRef.value = [procedureKey];- } else if (tab.type === "function") {- const {- database,- metadata: { schema, function: func },- } = tab;- const schemaKey = keyForResource(database, { schema });- const schemaNode = treeNodeMap.get(schemaKey);- if (schemaNode) {- expandNodeRecursively(schemaNode);- }- const procedureKey = keyForResource(database, { schema, function: func });- selectedKeysRef.value = [procedureKey];- }-- if (state.shouldRelocateTreeNode) {- nextTick(() => {- treeRef.value?.scrollTo({- key: selectedKeysRef.value[0],- });- });- }- });-});--const openTabForTreeNode = (node: TreeNode) => {- state.shouldRelocateTreeNode = false;-- if (node.type === "column") {- openTabForTreeNode(node.parent);- queuePendingScrollToColumn({- db: node.db,- metadata: node.metadata,- });- return;- }- if (node.type === "table") {- expandNodeRecursively(node);- addTab({- type: "table",- database: node.db,- metadata: node.metadata,- });- }- if (- node.type === "schema" ||- (node.type === "group" && node.group === "table")- ) {- expandNodeRecursively(node);- addTab({- type: "database",- database: node.db,- metadata: node.metadata,- selectedSchema: node.metadata.schema.name,- });- }- if (node.type === "view") {- expandNodeRecursively(node);- addTab({- type: "view",- database: node.db,- metadata: node.metadata,- });- }- if (node.type === "procedure") {- expandNodeRecursively(node);- addTab({- type: "procedure",- database: node.db,- metadata: node.metadata,- });- }- if (node.type === "function") {- expandNodeRecursively(node);- addTab({- type: "function",- database: node.db,- metadata: node.metadata,- });- }-- state.shouldRelocateTreeNode = true;-};--onMounted(() => {- buildDatabaseTreeData(/* openFirstChild */ true);-});--// Render prefix icons before label text.-const renderPrefix = ({ option }: { option: TreeOption }) => {- const node = option as TreeNode;- return h(NodePrefix, { node });-};--// Render label text.-const renderLabel = ({ option }: { option: TreeOption }) => {- const node = option as TreeNode;- const additionalClassList: string[] = ["select-none"];- let label = node.label;-- if (node.type === "placeholder") {- return h(- "span",- { class: "text-control-placeholder italic" },- `<${t("common.empty")}>`- );- }-- if (node.type === "schema") {- const { db, metadata } = node;- additionalClassList.push(getSchemaStatus(db, metadata));- label = metadata.schema.name;- }- if (node.type === "group") {- label = `(${node.group} - group)`;- if (node.group === "table") {- return t("schema-editor.tables");- }- if (node.group === "view") {- return t("schema-editor.views");- }- if (node.group === "procedure") {- return t("schema-editor.procedures");- }- if (node.group === "function") {- return t("schema-editor.functions");- }- }- if (node.type === "table") {- const { db, metadata } = node;- additionalClassList.push(getTableStatus(db, metadata));- label = metadata.table.name;- }- if (node.type === "column") {- const { db, metadata } = node;- additionalClassList.push(getColumnStatus(db, metadata));- const { name } = metadata.column;- if (name) {- label = name;- } else {- label = `<${t("common.untitled")}>`;- additionalClassList.push("text-control-placeholder italic");- }- }- if (node.type === "view") {- const { db, metadata } = node;- additionalClassList.push(getViewStatus(db, metadata));- label = metadata.view.name;- }- if (node.type === "procedure") {- const { db, metadata } = node;- additionalClassList.push(getProcedureStatus(db, metadata));- label = metadata.procedure.name;- }- if (node.type === "function") {- const { db, metadata } = node;- additionalClassList.push(getFunctionStatus(db, metadata));- label = metadata.function.name;- }- return h(- NPerformantEllipsis,- {- class: additionalClassList.join(" "),- },- () => [- h("span", {- innerHTML: getHighlightHTMLByKeyWords(label, searchPattern.value),- }),- ]- );-};--// Render a 'menu' icon in the right of the node-const renderSuffix = ({ option }: { option: TreeOption }) => {- const node = option as TreeNode;- const icons: VNode[] = [];-- const renderIcons = () => {- if (icons.length === 0) return null;- return h("div", { class: "inline-flex gap-1" }, icons);- };-- if (readonly.value) {- return renderIcons();- }-- const menuIcon = h(MoreHorizontalIcon, {- class: "w-4 h-auto text-gray-600",- onClick: (e) => {- handleContextMenuShow(e, node);- },- });- if (node.type === "database") {- const engine = getDatabaseEngine(node.db);- if (engineSupportsMultiSchema(engine)) {- icons.push(menuIcon);- }- }- if (node.type === "schema") {- icons.push(menuIcon);- }- if (node.type === "group") {- icons.push(menuIcon);- }- if (node.type === "table") {- const duplicateIcon = h(CopyIcon, {- class: "w-4 h-auto text-gray-600",- onClick: (e) => {- e.preventDefault();- e.stopPropagation();- e.stopImmediatePropagation();-- handleDuplicateTable(node);- },- });- icons.push(duplicateIcon);- icons.push(menuIcon);- }- if (node.type === "procedure") {- icons.push(menuIcon);- }- if (node.type === "function") {- icons.push(menuIcon);- }-- return renderIcons();-};--const handleDuplicateTable = (treeNode: TreeNodeForTable) => {- const { db } = treeNode;- const engine = getDatabaseEngine(db);- const { schema, table } = treeNode.metadata;- const flattenTableList = treeNode.metadata.database.schemas.flatMap(- (schema) => schema.tables- );- const getOriginalName = (name: string): string => {- return name.replace(/_copy[0-9]{0,}$/, "");- };-- const extractDuplicateNumber = (name: string): number => {- const match = /_copy[0-9]{0,}$/.exec(name);- if (!match) {- return -1;- }-- const num = Number(match[0].replace("_copy", "0"));- if (Number.isNaN(num)) {- return -1;- }- return num;- };-- const getDuplicateName = (name: string): string => {- const num = extractDuplicateNumber(name);- if (num < 0) {- return `${name}_copy`;- }- return `${getOriginalName(name)}_copy${num + 1}`;- };-- const matchPattern = new RegExp(- `^${getOriginalName(table.name)}` + "(_copy[0-9]{0,}){0,1}$"- );- const copiedTableNames = flattenTableList- .filter((table) => {- return matchPattern.test(table.name);- })- .sort((t1, t2) => {- return extractDuplicateNumber(t1.name) - extractDuplicateNumber(t2.name);- });- const targetName = copiedTableNames.slice(-1)[0]?.name ?? table.name;-- const newTable = cloneDeep(table);- newTable.name = getDuplicateName(targetName);- // As index names should be unique, we need to generate new names for them.- for (const index of newTable.indexes) {- let name = `${index.name}_${MD5(`${newTable.name}_${Date.now()}`).toString().slice(0, 6)}`;- if (index.primary) {- const fixedName = getFixedPrimaryKey(engine);- // If the primary key name is fixed, use it instead.- if (fixedName) {- name = fixedName;- }- }- index.name = name;- }- schema.tables.push(newTable);- markEditStatus(- db,- {- ...treeNode.metadata,- table: newTable,- },- "created"- );- newTable.columns.forEach((newColumn) => {- markEditStatus(- db,- {- ...treeNode.metadata,- table: newTable,- column: newColumn,- },- "created"- );- });-- addTab({- type: "table",- database: db,- metadata: {- ...treeNode.metadata,- table: newTable,- },- });- queuePendingScrollToTable({- db,- metadata: {- ...treeNode.metadata,- table: newTable,- },- });- events.emit("rebuild-tree", {- openFirstChild: false,- });-};--// Set event handler to tree nodes.-const nodeProps = ({ option }: { option: TreeOption }) => {- const node = option as TreeNode;- return {- async onClick(e: MouseEvent) {- // Check if clicked on the content part.- // And ignore the fold/unfold arrow.- if (isDescendantOf(e.target as Element, ".n-tree-node-content")) {- state.shouldRelocateTreeNode = false;- if (node.type === "group") {- expandNodeRecursively(node);- if (node.group === "table") {- openTabForTreeNode(node);- }- } else if (node.type === "instance") {- expandNodeRecursively(node);- } else if (node.type === "database") {- expandNodeRecursively(node);- addTab({- type: "database",- database: node.db,- metadata: node.metadata,- selectedSchema: head(node.metadata.database.schemas)?.name,- });- } else {- openTabForTreeNode(node);- }- } else {- nextTick(() => {- selectedKeysRef.value = [];- });- }- },- oncontextmenu(e: MouseEvent) {- handleContextMenuShow(e, node);- },- };-};--const emit = defineEmits(["update-is-editing"]);--// Handle context menu actions-useEmitteryEventListener(contextMenuEvents, "show", ({ node }) => {- selectedKeysRef.value = [node.key];-});-useEmitteryEventListener(contextMenuEvents, "hide", () => {- selectedKeysRef.value = [];-});--useEmitteryEventListener(contextMenuEvents, "create-schema", (node) => {- state.schemaNameModalContext = {- db: node.db,- database: node.metadata.database,- schema: undefined,- };- emit("update-is-editing", true);-});-useEmitteryEventListener(contextMenuEvents, "drop-schema", (node) => {- markEditStatus(node.db, node.metadata, "dropped");- emit("update-is-editing", true);-});-useEmitteryEventListener(contextMenuEvents, "restore-schema", (node) => {- removeEditStatus(node.db, node.metadata, /* recursive */ false);- emit("update-is-editing", true);-});--useEmitteryEventListener(contextMenuEvents, "create-table", (node) => {- state.tableNameModalContext = {- db: node.db,- database: node.metadata.database,- schema: node.metadata.schema,- table: undefined,- };- emit("update-is-editing", true);-});-useEmitteryEventListener(contextMenuEvents, "drop-table", (node) => {- markEditStatus(node.db, node.metadata, "dropped");- emit("update-is-editing", true);-});-useEmitteryEventListener(contextMenuEvents, "restore-table", (node) => {- removeEditStatus(node.db, node.metadata, /* recursive */ false);- emit("update-is-editing", true);-});-useEmitteryEventListener(contextMenuEvents, "rename-table", (node) => {- state.tableNameModalContext = {- db: node.db,- database: node.metadata.database,- schema: node.metadata.schema,- table: node.metadata.table,- };- emit("update-is-editing", true);-});--useEmitteryEventListener(contextMenuEvents, "create-view", (node) => {- state.viewNameModalContext = {- db: node.db,- database: node.metadata.database,- schema: node.metadata.schema,- view: undefined,- };- expandNodeRecursively(node);- emit("update-is-editing", true);-});-useEmitteryEventListener(contextMenuEvents, "drop-view", (node) => {- markEditStatus(node.db, node.metadata, "dropped");- emit("update-is-editing", true);-});-useEmitteryEventListener(contextMenuEvents, "restore-view", (node) => {- removeEditStatus(node.db, node.metadata, /* recursive */ false);- emit("update-is-editing", true);-});--useEmitteryEventListener(contextMenuEvents, "create-procedure", (node) => {- state.procedureNameModalContext = {- db: node.db,- database: node.metadata.database,- schema: node.metadata.schema,- procedure: undefined,- };- expandNodeRecursively(node);- emit("update-is-editing", true);-});-useEmitteryEventListener(contextMenuEvents, "drop-procedure", (node) => {- markEditStatus(node.db, node.metadata, "dropped");- emit("update-is-editing", true);-});-useEmitteryEventListener(contextMenuEvents, "restore-procedure", (node) => {- removeEditStatus(node.db, node.metadata, /* recursive */ false);- emit("update-is-editing", true);-});--useEmitteryEventListener(contextMenuEvents, "create-function", (node) => {- state.functionNameModalContext = {- db: node.db,- database: node.metadata.database,- schema: node.metadata.schema,- function: undefined,- };- expandNodeRecursively(node);- emit("update-is-editing", true);-});-useEmitteryEventListener(contextMenuEvents, "drop-function", (node) => {- markEditStatus(node.db, node.metadata, "dropped");- emit("update-is-editing", true);-});-useEmitteryEventListener(contextMenuEvents, "restore-function", (node) => {- removeEditStatus(node.db, node.metadata, /* recursive */ false);- emit("update-is-editing", true);-});--const handleExpandedKeysChange = (expandedKeys: string[]) => {- expandedKeysRef.value = expandedKeys;-};-</script>--<style lang="postcss" scoped>-.schema-editor-tree :deep(.n-tree-node-wrapper) {- padding: 0 !important;-}-.schema-editor-tree :deep(.n-tree-node-content) {- padding-left: 0.5rem !important;- font-size: 0.875rem;- line-height: 1.25rem;-}-.schema-editor-tree :deep(.n-tree-node-indent) {- width: 0.25rem;-}-.schema-editor-tree :deep(.n-tree-node-content__prefix) {- flex-shrink: 0;- margin-right: 0.25rem !important;-}-.schema-editor-tree- :deep(.n-tree-node-wrapper:hover .n-tree-node-content__suffix) {- display: flex !important;-}-.schema-editor-tree- :deep(- .n-tree-node-wrapper .n-tree-node--selected .n-tree-node-content__suffix- ) {- display: flex !important;-}--.schema-editor-tree :deep(.n-tree-node-content__text) {- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- margin-right: 0.25rem;-}-.schema-editor-tree :deep(.n-tree-node-switcher) {- padding-left: 0;- padding-right: 0;- width: 1rem !important;- height: 1.75rem !important;-}-.schema-editor-tree:not(.disable-diff-coloring)- :deep(.n-tree-node-content .created) {- color: var(--color-green-700);-}-.schema-editor-tree:not(.disable-diff-coloring)- :deep(.n-tree-node-content .dropped) {- color: var(--color-red-700);- text-decoration-line: line-through;-}-.schema-editor-tree:not(.disable-diff-coloring)- :deep(.n-tree-node-content .updated) {- color: var(--color-yellow-700);-}-</style>diff --git a/frontend/src/components/SchemaEditorLite/Aside/common.ts b/frontend/src/components/SchemaEditorLite/Aside/common.tsdeleted file mode 100644index f4a92ef44d..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/common.ts+++ /dev/null@@ -1,560 +0,0 @@-import type { TreeOption } from "naive-ui";-import type {- ColumnMetadata,- Database,- DatabaseMetadata,- FunctionMetadata,- ProcedureMetadata,- SchemaMetadata,- TableMetadata,- ViewMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import type { InstanceResource } from "@/types/proto-es/v1/instance_service_pb";-import {- extractDatabaseResourceName,- getDatabaseEngine,- getInstanceResource,- groupBy,-} from "@/utils";-import { keyForResource } from "../context/common";-import {- engineSupportsEditFunctions,- engineSupportsEditProcedures,- engineSupportsEditViews,-} from "../spec";-import type { EditTarget } from "../types";--export interface BaseTreeNode extends TreeOption {- key: string;- label: string;- isLeaf: boolean;- children?: TreeNode[];-}--export interface TreeNodeForInstance extends BaseTreeNode {- type: "instance";- instance: InstanceResource;- children: TreeNodeForDatabase[];-}--export interface TreeNodeForDatabase extends BaseTreeNode {- type: "database";- db: Database;- parent?: TreeNodeForInstance;- metadata: {- database: DatabaseMetadata;- };- children:- | TreeNodeForSchema[] // for multi-schema engines- | TreeNodeForGroup[]; // for single-schema engines-}--export interface TreeNodeForSchema extends BaseTreeNode {- type: "schema";- db: Database;- parent?: TreeNodeForDatabase;- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- };- children: TreeNodeForGroup[];-}--export interface TreeNodeForTable extends BaseTreeNode {- type: "table";- db: Database;- parent: TreeNodeForGroup<"table">;- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- };- children: TreeNodeForColumn[] | TreeNodeForPlaceholder<"column">[];-}--export interface TreeNodeForColumn extends BaseTreeNode {- type: "column";- db: Database;- parent: TreeNodeForTable;- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- column: ColumnMetadata;- };- children: undefined;- isLeaf: true;-}--export interface TreeNodeForView extends BaseTreeNode {- type: "view";- db: Database;- parent: TreeNodeForGroup<"view">;- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- view: ViewMetadata;- };- children: undefined;- isLeaf: true;-}--export interface TreeNodeForProcedure extends BaseTreeNode {- type: "procedure";- db: Database;- parent: TreeNodeForGroup<"procedure">;- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- procedure: ProcedureMetadata;- };- children: undefined;- isLeaf: true;-}--export interface TreeNodeForFunction extends BaseTreeNode {- type: "function";- db: Database;- parent: TreeNodeForGroup<"function">;- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- function: FunctionMetadata;- };- children: undefined;- isLeaf: true;-}--export type GroupNodeType = "table" | "view" | "procedure" | "function";-export interface TreeNodeForGroup<T extends GroupNodeType = GroupNodeType>- extends BaseTreeNode {- type: "group";- group: T;- db: Database;- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- };- parent: TreeNodeForSchema | TreeNodeForDatabase | undefined;- isLeaf: false;- children: T extends "table"- ? TreeNodeForTable[] | TreeNodeForPlaceholder<"table">[]- : T extends "view"- ? TreeNodeForView[] | TreeNodeForPlaceholder<"view">[]- : T extends "procedure"- ? TreeNodeForProcedure[] | TreeNodeForPlaceholder<"procedure">[]- : T extends "function"- ? TreeNodeForFunction[] | TreeNodeForPlaceholder<"function">[]- : undefined;-}--export type PlaceholderNodeType =- | "table"- | "column"- | "view"- | "procedure"- | "function";-export interface TreeNodeForPlaceholder<- T extends PlaceholderNodeType = PlaceholderNodeType,-> extends BaseTreeNode {- type: "placeholder";- placeholder: T;- parent: TreeNode;- isLeaf: true;- children: undefined;-}--export type TreeNode =- | TreeNodeForInstance- | TreeNodeForDatabase- | TreeNodeForSchema- | TreeNodeForTable- | TreeNodeForColumn- | TreeNodeForView- | TreeNodeForProcedure- | TreeNodeForFunction- | TreeNodeForGroup- | TreeNodeForPlaceholder;--export type BuildTreeOptions = {- byInstance: boolean;-};--export const useBuildTree = () => {- const buildTree = (- targets: EditTarget[],- map: Map<string, TreeNode>,- options: BuildTreeOptions- ) => {- map.clear();- if (options.byInstance) {- return buildInstanceNodeList(targets, map);- } else {- const target = targets[0];- return buildSchemaNodeList(- target.metadata.schemas,- map,- target.database,- target.metadata,- undefined- );- }- };-- const buildInstanceNodeList = (- targets: EditTarget[],- map: Map<string, TreeNode>- ) => {- const groupedByInstance = groupBy(- targets,- (target) => extractDatabaseResourceName(target.database.name).instance- );- return Array.from(groupedByInstance).map(([key, targets]) => {- const instance = getInstanceResource(targets[0].database);- const instanceNode: TreeNodeForInstance = {- type: "instance",- key: key,- label: instance.title,- isLeaf: false,- instance,- children: [],- };- map.set(instanceNode.key, instanceNode);- instanceNode.children = buildDatabaseNodeList(targets, map, instanceNode);- return instanceNode;- });- };-- const buildDatabaseNodeList = (- targets: EditTarget[],- map: Map<string, TreeNode>,- parent: TreeNodeForInstance | undefined- ) => {- return targets.map((target) => {- const db = target.database;- const databaseNode: TreeNodeForDatabase = {- type: "database",- key: db.name,- parent,- label: extractDatabaseResourceName(db.name).databaseName,- isLeaf: false,- db,- metadata: {- database: target.metadata,- },- children: [],- };- map.set(databaseNode.key, databaseNode);- databaseNode.children = buildSchemaNodeList(- target.metadata.schemas,- map,- db,- target.metadata,- databaseNode- );- return databaseNode;- });- };- const buildSchemaNodeList = (- schemas: SchemaMetadata[],- map: Map<string, TreeNode>,- db: Database,- database: DatabaseMetadata,- parent: TreeNodeForDatabase | undefined- ) => {- const mapSchemaChildrenNodes = (- schema: SchemaMetadata,- parent: TreeNodeForSchema | TreeNodeForDatabase | undefined- ) => {- const groups: TreeNodeForGroup[] = [];- const metadata = {- database,- schema,- };- // Tables- const tableGroupNode: TreeNodeForGroup<"table"> = {- type: "group",- group: "table",- key: keyForResource(db, metadata, "table-group"),- parent,- db,- metadata,- label: "Tables",- children: [],- isLeaf: false,- };- tableGroupNode.children = buildTableNodeList(- schema.tables,- map,- tableGroupNode- );- if (tableGroupNode.children.length === 0) {- tableGroupNode.children = [- buildPlaceholderNode("table", tableGroupNode, map),- ];- }- groups.push(tableGroupNode);- map.set(tableGroupNode.key, tableGroupNode);-- // Views- if (engineSupportsEditViews(getDatabaseEngine(db))) {- const viewGroupNode: TreeNodeForGroup<"view"> = {- type: "group",- group: "view",- key: keyForResource(db, metadata, "view-group"),- parent,- db,- metadata,- label: "Views",- children: [],- isLeaf: false,- };- viewGroupNode.children = buildViewNodeList(- schema.views,- map,- viewGroupNode- );- if (viewGroupNode.children.length === 0) {- viewGroupNode.children = [- buildPlaceholderNode("view", viewGroupNode, map),- ];- }- groups.push(viewGroupNode);- map.set(viewGroupNode.key, viewGroupNode);- }- // Procedures- if (engineSupportsEditProcedures(getDatabaseEngine(db))) {- const procedureGroupNode: TreeNodeForGroup<"procedure"> = {- type: "group",- group: "procedure",- key: keyForResource(db, metadata, "procedure-group"),- parent,- db,- metadata,- label: "Procedures",- children: [],- isLeaf: false,- };- procedureGroupNode.children = buildProcedureNodeList(- schema.procedures,- map,- procedureGroupNode- );- if (procedureGroupNode.children.length === 0) {- procedureGroupNode.children = [- buildPlaceholderNode("procedure", procedureGroupNode, map),- ];- }- groups.push(procedureGroupNode);- map.set(procedureGroupNode.key, procedureGroupNode);- }- // Functions- if (engineSupportsEditFunctions(getDatabaseEngine(db))) {- const functionGroupNode: TreeNodeForGroup<"function"> = {- type: "group",- group: "function",- key: keyForResource(db, metadata, "function-group"),- parent,- db,- metadata,- label: "functions",- children: [],- isLeaf: false,- };- functionGroupNode.children = buildFunctionNodeList(- schema.functions,- map,- functionGroupNode- );- if (functionGroupNode.children.length === 0) {- functionGroupNode.children = [- buildPlaceholderNode("function", functionGroupNode, map),- ];- }- groups.push(functionGroupNode);- map.set(functionGroupNode.key, functionGroupNode);- }- return groups;- };-- // MySQL, TiDB has only one "schema" with empty name- if (schemas.length === 1 && schemas[0].name === "") {- return mapSchemaChildrenNodes(schemas[0], parent);- }-- return schemas.map((schema) => {- const metadata = {- database,- schema,- };- const schemaNode: TreeNodeForSchema = {- type: "schema",- parent: parent,- key: keyForResource(db, metadata),- label: schema.name,- isLeaf: false,- db,- metadata,- children: [],- };- schemaNode.children = mapSchemaChildrenNodes(schema, schemaNode);- map.set(schemaNode.key, schemaNode);- return schemaNode;- });- };-- const buildTableNodeList = (- tables: TableMetadata[],- map: Map<string, TreeNode>,- parent: TreeNodeForGroup<"table">- ) => {- return tables.map((table) => {- const { db } = parent;- const metadata = {- ...parent.metadata,- table,- };- const tableNode: TreeNodeForTable = {- type: "table",- parent,- key: keyForResource(db, metadata),- label: table.name,- isLeaf: false,- db,- metadata,- children: [],- };- map.set(tableNode.key, tableNode);- tableNode.children = buildColumnNodeList(table.columns, map, tableNode);-- if (tableNode.children.length === 0) {- tableNode.children = [buildPlaceholderNode("column", tableNode, map)];- }- return tableNode;- });- };-- const buildViewNodeList = (- views: ViewMetadata[],- map: Map<string, TreeNode>,- parent: TreeNodeForGroup<"view">- ) => {- return views.map((view) => {- const { db } = parent;- const metadata = {- ...parent.metadata,- view,- };- const viewNode: TreeNodeForView = {- type: "view",- parent,- key: keyForResource(db, metadata),- label: view.name,- isLeaf: true,- db,- metadata,- children: undefined,- };- map.set(viewNode.key, viewNode);- return viewNode;- });- };-- const buildProcedureNodeList = (- procedures: ProcedureMetadata[],- map: Map<string, TreeNode>,- parent: TreeNodeForGroup<"procedure">- ) => {- return procedures.map((procedure) => {- const { db } = parent;- const metadata = {- ...parent.metadata,- procedure,- };- const procedureNode: TreeNodeForProcedure = {- type: "procedure",- parent,- key: keyForResource(db, metadata),- label: procedure.signature || procedure.name,- isLeaf: true,- db,- metadata,- children: undefined,- };- map.set(procedureNode.key, procedureNode);- return procedureNode;- });- };-- const buildFunctionNodeList = (- functions: FunctionMetadata[],- map: Map<string, TreeNode>,- parent: TreeNodeForGroup<"function">- ) => {- return functions.map((func) => {- const { db } = parent;- const metadata = {- ...parent.metadata,- function: func,- };- const functionNode: TreeNodeForFunction = {- type: "function",- parent,- key: keyForResource(db, metadata),- label: func.signature || func.name,- isLeaf: true,- db,- metadata,- children: undefined,- };- map.set(functionNode.key, functionNode);- return functionNode;- });- };-- const buildColumnNodeList = (- columns: ColumnMetadata[],- map: Map<string, TreeNode>,- parent: TreeNodeForTable- ) => {- return columns.map((column) => {- const { db } = parent;- const metadata = {- ...parent.metadata,- column,- };- const columnNode: TreeNodeForColumn = {- type: "column",- key: keyForResource(db, metadata),- parent,- label: column.name,- db,- metadata,- isLeaf: true,- children: undefined,- };- map.set(columnNode.key, columnNode);- return columnNode;- });- };-- const buildPlaceholderNode = <T extends PlaceholderNodeType>(- placeholder: T,- parent: TreeNode,- map: Map<string, TreeNode>- ) => {- const node: TreeNodeForPlaceholder<T> = {- type: "placeholder",- key: `${parent.key}/placeholder`,- placeholder,- parent,- label: "",- children: undefined,- isLeaf: true,- };- map.set(node.key, node);- return node;- };-- return buildTree;-};diff --git a/frontend/src/components/SchemaEditorLite/Aside/context-menu.ts b/frontend/src/components/SchemaEditorLite/Aside/context-menu.tsdeleted file mode 100644index 6707dd7798..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/context-menu.ts+++ /dev/null@@ -1,260 +0,0 @@-import Emittery from "emittery";-import type { DropdownOption } from "naive-ui";-import { computed, type Ref, reactive } from "vue";-import { useI18n } from "vue-i18n";-import { Engine } from "@/types/proto-es/v1/common_pb";-import type { Database } from "@/types/proto-es/v1/database_service_pb";-import { getDatabaseEngine, isDescendantOf } from "@/utils";-import { useSchemaEditorContext } from "../context";-import { engineSupportsMultiSchema } from "../spec";-import type {- TreeNode,- TreeNodeForDatabase,- TreeNodeForFunction,- TreeNodeForGroup,- TreeNodeForProcedure,- TreeNodeForSchema,- TreeNodeForTable,- TreeNodeForView,-} from "./common";--interface TreeContextMenu {- show: boolean;- clientX: number;- clientY: number;- node?: TreeNode;-}--type TreeContextMenuEvents = Emittery<{- "create-schema": TreeNodeForDatabase;- "restore-schema": TreeNodeForSchema;- "drop-schema": TreeNodeForSchema;- "create-table": TreeNodeForGroup<"table">;- "rename-table": TreeNodeForTable;- "restore-table": TreeNodeForTable;- "drop-table": TreeNodeForTable;- "create-procedure": TreeNodeForGroup<"procedure">;- "restore-procedure": TreeNodeForProcedure;- "drop-procedure": TreeNodeForProcedure;- "create-view": TreeNodeForGroup<"view">;- "restore-view": TreeNodeForView;- "drop-view": TreeNodeForView;- "create-function": TreeNodeForGroup<"function">;- "restore-function": TreeNodeForFunction;- "drop-function": TreeNodeForFunction;- show: {- e: MouseEvent;- node: TreeNode;- };- hide: undefined;-}>;--export type ContextMenuContext = {- menu: Ref<TreeContextMenu>;- options: Ref<DropdownOption[]>;- events: TreeContextMenuEvents;- handleShow: (e: MouseEvent, node: TreeNode) => void;- handleSelect: (key: string) => void;- handleClickOutside: (e: MouseEvent) => void;-};--export const useContextMenu = (): ContextMenuContext => {- const menu = reactive<TreeContextMenu>({- show: false,- clientX: 0,- clientY: 0,- node: undefined,- });- const events: TreeContextMenuEvents = new Emittery();- const { t } = useI18n();- const {- getSchemaStatus,- getTableStatus,- getViewStatus,- getProcedureStatus,- getFunctionStatus,- } = useSchemaEditorContext();-- const options = computed((): DropdownOption[] => {- const { node } = menu;- if (!node) return [];- if (typeof node.db === "undefined") return [];-- const engine = getDatabaseEngine(node.db as Database);- if (node.type === "database") {- if (engineSupportsMultiSchema(engine)) {- return [- {- key: "create-schema",- label: t("schema-editor.actions.create-schema"),- },- ];- }- return [];- }- if (node.type === "schema") {- const options: DropdownOption[] = [];- if (engine === Engine.POSTGRES) {- const status = getSchemaStatus(node.db, node.metadata);- if (status === "dropped") {- options.push({- key: "restore-schema",- label: t("schema-editor.actions.restore"),- });- } else {- options.push({- key: "drop-schema",- label: t("schema-editor.actions.drop-schema"),- });- }- }- return options;- }- if (node.type === "group") {- if (node.group === "table") {- return [- {- key: "create-table",- label: t("schema-editor.actions.create-table"),- },- ];- }- if (node.group === "view") {- return [- {- key: "create-view",- label: t("schema-editor.actions.create-view"),- },- ];- }- if (node.group === "procedure") {- return [- {- key: "create-procedure",- label: t("schema-editor.actions.create-procedure"),- },- ];- }- if (node.group === "function") {- return [- {- key: "create-function",- label: t("schema-editor.actions.create-function"),- },- ];- }- }- if (node.type === "table") {- const options: DropdownOption[] = [];- const status = getTableStatus(node.db, node.metadata);- if (status === "dropped") {- options.push({- key: "restore-table",- label: t("schema-editor.actions.restore"),- });- } else {- if (status !== "normal") {- options.push({- key: "rename-table",- label: t("schema-editor.actions.rename"),- });- }- options.push({- key: "drop-table",- label: t("schema-editor.actions.drop-table"),- });- }- return options;- }- if (node.type === "view") {- const options: DropdownOption[] = [];- const status = getViewStatus(node.db, node.metadata);- if (status === "dropped") {- options.push({- key: "restore-view",- label: t("schema-editor.actions.restore"),- });- } else {- options.push({- key: "drop-view",- label: t("schema-editor.actions.drop"),- });- }- return options;- }- if (node.type === "procedure") {- const options: DropdownOption[] = [];- const status = getProcedureStatus(node.db, node.metadata);- if (status === "dropped") {- options.push({- key: "restore-procedure",- label: t("schema-editor.actions.restore"),- });- } else {- options.push({- key: "drop-procedure",- label: t("schema-editor.actions.drop"),- });- }- return options;- }- if (node.type === "function") {- const options: DropdownOption[] = [];- const status = getFunctionStatus(node.db, node.metadata);- if (status === "dropped") {- options.push({- key: "restore-function",- label: t("schema-editor.actions.restore"),- });- } else {- options.push({- key: "drop-function",- label: t("schema-editor.actions.drop"),- });- }- return options;- }-- return [];- });-- const handleShow = (e: MouseEvent, node: TreeNode) => {- e.preventDefault();- e.stopPropagation();- menu.node = node;- menu.show = true;- menu.clientX = e.clientX;- menu.clientY = e.clientY;- events.emit("show", { e, node });- };-- const handleSelect = async (key: string) => {- const node = menu.node;- if (!node) return;- const emit = events.emit.bind(events) as (- event: string,- data: TreeNode- ) => Promise<void>;- emit(key, node);- menu.show = false;- };-- const handleClickOutside = (e: MouseEvent) => {- if (- !isDescendantOf(e.target as Element, ".n-tree-node-wrapper") ||- e.button !== 2- ) {- events.emit("hide");- menu.show = false;- }- };-- return {- menu: computed(() => menu),- options,- events,- handleShow,- handleSelect,- handleClickOutside,- };-};diff --git a/frontend/src/components/SchemaEditorLite/Aside/index.ts b/frontend/src/components/SchemaEditorLite/Aside/index.tsdeleted file mode 100644index 9791604e76..0000000000--- a/frontend/src/components/SchemaEditorLite/Aside/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import Aside from "./Aside.vue";--export default Aside;diff --git a/frontend/src/components/SchemaEditorLite/Editor.vue b/frontend/src/components/SchemaEditorLite/Editor.vuedeleted file mode 100644index eb64ab2be8..0000000000--- a/frontend/src/components/SchemaEditorLite/Editor.vue+++ /dev/null@@ -1,68 +0,0 @@-<template>- <main class="w-full h-full flex flex-col overflow-y-hidden">- <template v-if="currentTab">- <TabsContainer class="px-2 pt-2" />- <div- class="w-full flex-1 relative overflow-y-hidden"- :data-key="currentTab.id"- >- <DatabaseEditor- v-if="currentTab.type === 'database'"- :key="currentTab.id"- v-model:selected-schema-name="currentTab.selectedSchema"- :db="currentTab.database"- :database="currentTab.metadata.database"- class="px-2 pb-2"- />- <TableEditor- v-if="currentTab.type === 'table'"- :key="currentTab.id"- :db="currentTab.database"- :database="currentTab.metadata.database"- :schema="currentTab.metadata.schema"- :table="currentTab.metadata.table"- />- <ProcedureEditor- v-if="currentTab.type === 'procedure'"- :key="currentTab.id"- :db="currentTab.database"- :database="currentTab.metadata.database"- :schema="currentTab.metadata.schema"- :procedure="currentTab.metadata.procedure"- class="pb-2"- />- <FunctionEditor- v-if="currentTab.type === 'function'"- :key="currentTab.id"- :db="currentTab.database"- :database="currentTab.metadata.database"- :schema="currentTab.metadata.schema"- :func="currentTab.metadata.function"- class="pb-2"- />- <ViewEditor- v-if="currentTab.type === 'view'"- :key="currentTab.id"- :db="currentTab.database"- :database="currentTab.metadata.database"- :schema="currentTab.metadata.schema"- :view="currentTab.metadata.view"- />- </div>- </template>- <EmptyTips v-else />- </main>-</template>--<script lang="ts" setup>-import { useSchemaEditorContext } from "./context";-import EmptyTips from "./EmptyTips.vue";-import DatabaseEditor from "./Panels/DatabaseEditor.vue";-import FunctionEditor from "./Panels/FunctionEditor.vue";-import ProcedureEditor from "./Panels/ProcedureEditor.vue";-import TableEditor from "./Panels/TableEditor.vue";-import ViewEditor from "./Panels/ViewEditor.vue";-import TabsContainer from "./TabsContainer.vue";--const { currentTab } = useSchemaEditorContext();-</script>diff --git a/frontend/src/components/SchemaEditorLite/EmptyTips.vue b/frontend/src/components/SchemaEditorLite/EmptyTips.vuedeleted file mode 100644index afb65dbbfd..0000000000--- a/frontend/src/components/SchemaEditorLite/EmptyTips.vue+++ /dev/null@@ -1,12 +0,0 @@-<template>- <div- class="w-full h-full flex flex-row justify-center items-center text-gray-600 font-medium"- >- <SquarePen class="w-4 h-auto mr-2" />- {{ $t("schema-designer.use-tips") }}- </div>-</template>--<script lang="ts" setup>-import { SquarePen } from "lucide-vue-next";-</script>diff --git a/frontend/src/components/SchemaEditorLite/Modals/ActionConfirmModal.vue b/frontend/src/components/SchemaEditorLite/Modals/ActionConfirmModal.vuedeleted file mode 100644index 11f20935b8..0000000000--- a/frontend/src/components/SchemaEditorLite/Modals/ActionConfirmModal.vue+++ /dev/null@@ -1,59 +0,0 @@-<template>- <BBModal- :title="props.title"- :show="show"- class="shadow-inner outline-solid outline-gray-200"- @close="dismissModal"- >- <div class="w-80 mb-6">- <p>{{ props.description }}</p>- </div>- <div class="w-full flex items-center justify-end mt-2 gap-x-2">- <NButton v-bind="negativeButtonProps" @click="dismissModal">- {{ $t("common.cancel") }}- </NButton>- <NButton v-bind="positiveButtonProps" @click="handleConfirmButtonClick">- {{ $t("common.confirm") }}- </NButton>- </div>- </BBModal>-</template>--<script lang="ts" setup>-import type { ButtonProps } from "naive-ui";-import { NButton } from "naive-ui";-import { BBModal } from "@/bbkit";--const props = withDefaults(- defineProps<{- show: boolean;- title: string;- description: string;- negativeButtonProps?: ButtonProps;- positiveButtonProps?: ButtonProps;- }>(),- {- show: true,- title: "",- description: "",- negativeButtonProps: () => ({ quaternary: true }),- positiveButtonProps: () => ({ type: "primary" }),- }-);--const emit = defineEmits<{- (event: "close"): void;- (event: "confirm"): void;- (event: "update:show", show: boolean): void;-}>();--const handleConfirmButtonClick = async () => {- emit("confirm");- emit("update:show", false);-};--const dismissModal = () => {- emit("close");- emit("update:show", false);-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Modals/EditColumnForeignKeyModal.vue b/frontend/src/components/SchemaEditorLite/Modals/EditColumnForeignKeyModal.vuedeleted file mode 100644index 2867b4e557..0000000000--- a/frontend/src/components/SchemaEditorLite/Modals/EditColumnForeignKeyModal.vue+++ /dev/null@@ -1,287 +0,0 @@-<template>- <BBModal- :title="$t('schema-editor.foreign-key.edit')"- class="shadow-inner outline-solid outline-gray-200"- @close="dismissModal"- >- <div>- <p class="textlabel mb-2">- {{ $t("database.foreign-key.reference") }}- <span class="textinfolabel"> ({{ referenceTips }}) </span>- </p>- <NInputGroup>- <NSelect- v-if="shouldShowSchemaSelector"- v-model:value="state.referencedSchemaName"- :options="referenceSelectOptions"- :placeholder="$t('schema-editor.schema.select')"- :filterable="true"- @update:value="- () => {- state.referencedTableName = null;- state.referencedColumnName = null;- }- "- />- <NSelect- v-model:value="state.referencedTableName"- :options="referencedTableOptions"- :placeholder="$t('schema-editor.table.select')"- :filterable="true"- @update:value="state.referencedColumnName = null"- />- <NSelect- v-model:value="state.referencedColumnName"- :options="referencedColumnOptions"- :placeholder="$t('schema-editor.column.select')"- :filterable="true"- />- </NInputGroup>- </div>- <div class="mt-4">- <p class="textlabel mb-2">{{ $t("common.name") }}</p>- <NInput- v-model:value="state.foreignKeyName"- :placeholder="$t('schema-editor.foreign-key.name-description')"- />- </div>-- <div class="w-full flex items-center justify-between mt-4">- <div class="flex flex-row items-center justify-start">- <NButton- v-if="foreignKey !== undefined"- type="error"- text- @click="handleRemove"- >- <template #icon>- <TrashIcon class="w-4 h-auto" />- </template>- {{ $t("common.delete") }}- </NButton>- </div>- <div class="flex flex-row items-center justify-end gap-x-2">- <NButton @click="dismissModal">- {{ $t("common.cancel") }}- </NButton>- <NButton- type="primary"- :disabled="!allowConfirm"- @click="handleConfirm"- >- {{ $t("common.save") }}- </NButton>- </div>- </div>- </BBModal>-</template>--<script lang="ts" setup>-import { create } from "@bufbuild/protobuf";-import { TrashIcon } from "lucide-vue-next";-import type { SelectOption } from "naive-ui";-import { NButton, NInput, NInputGroup, NSelect } from "naive-ui";-import { computed, onMounted, reactive } from "vue";-import { BBModal } from "@/bbkit";-import type {- ColumnMetadata,- Database,- DatabaseMetadata,- ForeignKeyMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { ForeignKeyMetadataSchema } from "@/types/proto-es/v1/database_service_pb";-import { getDatabaseEngine, hasSchemaProperty } from "@/utils";-import { useSchemaEditorContext } from "../context";-import {- removeColumnFromForeignKey,- upsertColumnFromForeignKey,-} from "../edit";--interface LocalState {- referencedSchemaName: string;- referencedTableName: string | null;- referencedColumnName: string | null;- foreignKeyName: string;-}--type SchemaSelectOption = SelectOption & {- label: string;- value: string;- schema: SchemaMetadata;-};-type TableSelectOption = SchemaSelectOption & {- table: TableMetadata;-};-type ColumnSelectOption = TableSelectOption & {- column: ColumnMetadata;-};--const props = defineProps<{- database: Database;- metadata: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- column: ColumnMetadata;- foreignKey?: ForeignKeyMetadata;-}>();--const emit = defineEmits<{- (event: "close"): void;-}>();--const { markEditStatus, getColumnStatus } = useSchemaEditorContext();-const state = reactive<LocalState>({- referencedSchemaName: props.schema.name,- referencedTableName: null,- referencedColumnName: null,- foreignKeyName: "",-});-const engine = computed(() => {- return getDatabaseEngine(props.database);-});--const referencedSchema = computed(() => {- return props.metadata.schemas.find(- (s) => s.name === state.referencedSchemaName- );-});-const referencedTable = computed(() => {- const schema = referencedSchema.value;- if (!schema) return undefined;- if (!state.referencedTableName) return undefined;- const table = schema.tables.find((t) => t.name === state.referencedTableName);- if (!table) return undefined;- return { schema, table };-});-const referencedColumn = computed(() => {- if (!referencedTable.value) return undefined;- const { schema, table } = referencedTable.value;- if (!state.referencedColumnName) return undefined;- const column = table?.columns.find(- (c) => c.name === state.referencedColumnName- );- if (!column) return undefined;- return { schema, table, column };-});-const referenceSelectOptions = computed(() => {- return props.metadata.schemas.map<SchemaSelectOption>((schema) => ({- label: schema.name,- value: schema.name,- schema,- }));-});-const referencedTableOptions = computed(() => {- const schema = referencedSchema.value;- if (!schema) return [];- return schema.tables.map<TableSelectOption>((table) => ({- label: table.name,- value: table.name,- schema,- table,- }));-});-const referencedColumnOptions = computed(() => {- if (!referencedTable.value) return [];- const { schema, table } = referencedTable.value;- return table.columns.map<ColumnSelectOption>((column) => ({- label: column.name,- value: column.name,- schema,- table,- column,- }));-});-const allowConfirm = computed(() => {- return state.foreignKeyName !== "" && referencedColumn.value !== undefined;-});-const shouldShowSchemaSelector = computed(() => {- return hasSchemaProperty(engine.value);-});-const referenceTips = computed(() => {- return shouldShowSchemaSelector.value- ? "Schema.Table.Column"- : "Table.Column";-});--onMounted(() => {- const { foreignKey } = props;- if (!foreignKey) return;- const position = foreignKey.columns.indexOf(props.column.name);- if (position < 0) return;- state.referencedSchemaName = foreignKey.referencedSchema;- state.referencedTableName = foreignKey.referencedTable;- state.referencedColumnName = foreignKey.referencedColumns[position];- state.foreignKeyName = foreignKey.name;-});--const metadataForColumn = () => {- return {- database: props.metadata,- schema: props.schema,- table: props.table,- column: props.column,- };-};-const statusForColumn = () => {- return getColumnStatus(props.database, metadataForColumn());-};-const markColumnUpdatedIfNeeded = () => {- if (statusForColumn() !== "created") {- markEditStatus(props.database, metadataForColumn(), "updated");- }-};--const handleRemove = async () => {- const { foreignKey } = props;- if (!foreignKey) return;-- removeColumnFromForeignKey(props.table, foreignKey, props.column.name);-- markColumnUpdatedIfNeeded();- dismissModal();-};--const handleConfirm = async () => {- if (state.foreignKeyName === "") {- return;- }- if (!referencedColumn.value) {- return;- }-- const { foreignKey, table, column } = props;- const refed = referencedColumn.value;- if (foreignKey) {- // upsert column in existed foreignKey- if (- foreignKey.referencedSchema !== refed.schema.name ||- foreignKey.referencedTable !== refed.table.name- ) {- // refed schema/table changed, clear the ref column list- foreignKey.referencedSchema = refed.schema.name;- foreignKey.referencedTable = refed.table.name;- foreignKey.columns = [];- foreignKey.referencedColumns = [];- }- foreignKey.name = state.foreignKeyName;- upsertColumnFromForeignKey(foreignKey, column.name, refed.column.name);- } else {- const fk = create(ForeignKeyMetadataSchema, {- name: state.foreignKeyName,- columns: [props.column.name],- referencedSchema: refed.schema.name,- referencedTable: refed.table.name,- referencedColumns: [refed.column.name],- });- table.foreignKeys.push(fk);- }- markColumnUpdatedIfNeeded();- dismissModal();-};--const dismissModal = () => {- emit("close");-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Modals/FunctionNameModal.vue b/frontend/src/components/SchemaEditorLite/Modals/FunctionNameModal.vuedeleted file mode 100644index b720524bdf..0000000000--- a/frontend/src/components/SchemaEditorLite/Modals/FunctionNameModal.vue+++ /dev/null@@ -1,150 +0,0 @@-<template>- <BBModal- :title="- mode === 'create'- ? $t('schema-editor.actions.create-function')- : $t('schema-editor.actions.rename')- "- class="shadow-inner outline-solid outline-gray-200"- @close="dismissModal"- >- <div class="w-72">- <p>{{ $t("common.name") }}</p>- <NInput- ref="inputRef"- v-model:value="state.functionName"- class="my-2"- :autofocus="true"- />- </div>- <div class="w-full flex items-center justify-end mt-2 gap-x-2">- <NButton @click="dismissModal">- {{ $t("common.cancel") }}- </NButton>- <NButton type="primary" @click="handleConfirmButtonClick">- {{ mode === "create" ? $t("common.create") : $t("common.save") }}- </NButton>- </div>- </BBModal>-</template>--<script lang="ts" setup>-import { create } from "@bufbuild/protobuf";-import type { InputInst } from "naive-ui";-import { NButton, NInput } from "naive-ui";-import { computed, onMounted, reactive, ref } from "vue";-import { useI18n } from "vue-i18n";-import { BBModal } from "@/bbkit";-import { useNotificationStore } from "@/store";-import type {- Database,- DatabaseMetadata,- FunctionMetadata,- SchemaMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { FunctionMetadataSchema } from "@/types/proto-es/v1/database_service_pb";-import { useSchemaEditorContext } from "../context";--// Function name must start with a non-space character, end with a non-space character.-const functionNameFieldRegexp = /^\S\S*\S?$/;--interface LocalState {- functionName: string;-}--const props = defineProps<{- database: Database;- metadata: DatabaseMetadata;- schema: SchemaMetadata;- func?: FunctionMetadata;-}>();--const emit = defineEmits<{- (event: "close"): void;-}>();--const { t } = useI18n();-const { events, addTab, markEditStatus } = useSchemaEditorContext();-const inputRef = ref<InputInst>();-const notificationStore = useNotificationStore();-const mode = computed(() => {- return props.func ? "edit" : "create";-});-const state = reactive<LocalState>({- functionName: props.func?.name ?? "",-});--const handleConfirmButtonClick = async () => {- if (!functionNameFieldRegexp.test(state.functionName)) {- notificationStore.pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("schema-editor.message.invalid-function-name"),- });- return;- }- const { schema } = props;- const existed = schema.functions.find(- (func) => func.name === state.functionName- );- if (existed) {- notificationStore.pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("schema-editor.message.duplicated-function-name"),- });- return;- }-- if (!props.func) {- const func = create(FunctionMetadataSchema, {- name: state.functionName,- definition: [- "CREATE FUNCTION `" + state.functionName + "`(...) RETURNS ...",- " DETERMINISTIC",- "BEGIN",- " ...",- "END",- ].join("\n"),- });- schema.functions.push(func);- markEditStatus(- props.database,- {- schema,- function: func,- },- "created"- );-- addTab({- type: "function",- database: props.database,- metadata: {- database: props.metadata,- schema: props.schema,- function: func,- },- });-- events.emit("rebuild-tree", {- openFirstChild: false,- });- } else {- const { func } = props;- func.name = state.functionName;- events.emit("rebuild-edit-status", {- resets: ["tree"],- });- }- dismissModal();-};--const dismissModal = () => {- emit("close");-};--onMounted(() => {- inputRef.value?.focus();-});-</script>diff --git a/frontend/src/components/SchemaEditorLite/Modals/ProcedureNameModal.vue b/frontend/src/components/SchemaEditorLite/Modals/ProcedureNameModal.vuedeleted file mode 100644index 8aa009a454..0000000000--- a/frontend/src/components/SchemaEditorLite/Modals/ProcedureNameModal.vue+++ /dev/null@@ -1,149 +0,0 @@-<template>- <BBModal- :title="- mode === 'create'- ? $t('schema-editor.actions.create-procedure')- : $t('schema-editor.actions.rename')- "- class="shadow-inner outline-solid outline-gray-200"- @close="dismissModal"- >- <div class="w-72">- <p>{{ $t("common.name") }}</p>- <NInput- ref="inputRef"- v-model:value="state.procedureName"- class="my-2"- :autofocus="true"- />- </div>- <div class="w-full flex items-center justify-end mt-2 gap-x-2">- <NButton @click="dismissModal">- {{ $t("common.cancel") }}- </NButton>- <NButton type="primary" @click="handleConfirmButtonClick">- {{ mode === "create" ? $t("common.create") : $t("common.save") }}- </NButton>- </div>- </BBModal>-</template>--<script lang="ts" setup>-import { create } from "@bufbuild/protobuf";-import type { InputInst } from "naive-ui";-import { NButton, NInput } from "naive-ui";-import { computed, onMounted, reactive, ref } from "vue";-import { useI18n } from "vue-i18n";-import { BBModal } from "@/bbkit";-import { useNotificationStore } from "@/store";-import type {- Database,- DatabaseMetadata,- ProcedureMetadata,- SchemaMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { ProcedureMetadataSchema } from "@/types/proto-es/v1/database_service_pb";-import { useSchemaEditorContext } from "../context";--// Procedure name must start with a non-space character, end with a non-space character.-const procedureNameFieldRegexp = /^\S\S*\S?$/;--interface LocalState {- procedureName: string;-}--const props = defineProps<{- database: Database;- metadata: DatabaseMetadata;- schema: SchemaMetadata;- procedure?: ProcedureMetadata;-}>();--const emit = defineEmits<{- (event: "close"): void;-}>();--const { t } = useI18n();-const { events, addTab, markEditStatus } = useSchemaEditorContext();-const inputRef = ref<InputInst>();-const notificationStore = useNotificationStore();-const mode = computed(() => {- return props.procedure ? "edit" : "create";-});-const state = reactive<LocalState>({- procedureName: props.procedure?.name ?? "",-});--const handleConfirmButtonClick = async () => {- if (!procedureNameFieldRegexp.test(state.procedureName)) {- notificationStore.pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("schema-editor.message.invalid-procedure-name"),- });- return;- }- const { schema } = props;- const existed = schema.procedures.find(- (procedure) => procedure.name === state.procedureName- );- if (existed) {- notificationStore.pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("schema-editor.message.duplicated-procedure-name"),- });- return;- }-- if (!props.procedure) {- const procedure = create(ProcedureMetadataSchema, {- name: state.procedureName,- definition: [- "CREATE PROCEDURE `" + state.procedureName + "`(...)",- "BEGIN",- " ...",- "END",- ].join("\n"),- });- schema.procedures.push(procedure);- markEditStatus(- props.database,- {- schema,- procedure,- },- "created"- );-- addTab({- type: "procedure",- database: props.database,- metadata: {- database: props.metadata,- schema: props.schema,- procedure,- },- });-- events.emit("rebuild-tree", {- openFirstChild: false,- });- } else {- const { procedure } = props;- procedure.name = state.procedureName;- events.emit("rebuild-edit-status", {- resets: ["tree"],- });- }- dismissModal();-};--const dismissModal = () => {- emit("close");-};--onMounted(() => {- inputRef.value?.focus();-});-</script>diff --git a/frontend/src/components/SchemaEditorLite/Modals/SchemaNameModal.vue b/frontend/src/components/SchemaEditorLite/Modals/SchemaNameModal.vuedeleted file mode 100644index 19d4a927ed..0000000000--- a/frontend/src/components/SchemaEditorLite/Modals/SchemaNameModal.vue+++ /dev/null@@ -1,105 +0,0 @@-<template>- <BBModal- :title="$t('schema-editor.actions.create-schema')"- class="shadow-inner outline-solid outline-gray-200"- @close="dismissModal"- >- <div class="w-72">- <p>{{ $t("schema-editor.schema.name") }}</p>- <NInput- ref="inputRef"- v-model:value="state.schemaName"- class="my-2"- :autofocus="true"- />- </div>- <div class="w-full flex items-center justify-end mt-2 gap-x-2">- <NButton @click="dismissModal">- {{ $t("common.cancel") }}- </NButton>- <NButton type="primary" @click="handleConfirmButtonClick">- {{ $t("common.create") }}- </NButton>- </div>- </BBModal>-</template>--<script lang="ts" setup>-import { create } from "@bufbuild/protobuf";-import { NButton, NInput } from "naive-ui";-import { reactive } from "vue";-import { useI18n } from "vue-i18n";-import { BBModal } from "@/bbkit";-import { useNotificationStore } from "@/store";-import type {- Database,- DatabaseMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { SchemaMetadataSchema } from "@/types/proto-es/v1/database_service_pb";-import { useSchemaEditorContext } from "../context";--const schemaNameFieldRegexp = /^\S+$/;--interface LocalState {- schemaName: string;-}--const props = defineProps<{- database: Database;- metadata: DatabaseMetadata;-}>();--const emit = defineEmits<{- (event: "close"): void;-}>();--const { t } = useI18n();-const { events, addTab, markEditStatus } = useSchemaEditorContext();-const notificationStore = useNotificationStore();-const state = reactive<LocalState>({- schemaName: "",-});--const handleConfirmButtonClick = async () => {- if (!schemaNameFieldRegexp.test(state.schemaName)) {- notificationStore.pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("schema-editor.message.invalid-schema-name"),- });- return;- }-- const schema = create(SchemaMetadataSchema, {- name: state.schemaName,- });- /* eslint-disable-next-line vue/no-mutating-props */- props.metadata.schemas.push(schema);- markEditStatus(- props.database,- {- schema,- },- "created"- );- requestAnimationFrame(() => {- addTab({- type: "database",- database: props.database,- metadata: {- database: props.metadata,- },- selectedSchema: schema.name,- });- events.emit("rebuild-tree", {- openFirstChild: false,- });- });-- dismissModal();-};--const dismissModal = () => {- emit("close");-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Modals/TableNameModal.vue b/frontend/src/components/SchemaEditorLite/Modals/TableNameModal.vuedeleted file mode 100644index c7fd724c2a..0000000000--- a/frontend/src/components/SchemaEditorLite/Modals/TableNameModal.vue+++ /dev/null@@ -1,177 +0,0 @@-<template>- <BBModal- :title="- mode === 'create'- ? $t('schema-editor.actions.create-table')- : $t('schema-editor.actions.rename')- "- class="shadow-inner outline-solid outline-gray-200"- @close="dismissModal"- >- <div class="w-72">- <p>{{ $t("schema-editor.table.name") }}</p>- <NInput- ref="inputRef"- v-model:value="state.tableName"- class="my-2"- :autofocus="true"- />- </div>- <div class="w-full flex items-center justify-end mt-2 gap-x-2">- <NButton @click="dismissModal">- {{ $t("common.cancel") }}- </NButton>- <NButton type="primary" @click="handleConfirmButtonClick">- {{ mode === "create" ? $t("common.create") : $t("common.save") }}- </NButton>- </div>- </BBModal>-</template>--<script lang="ts" setup>-import { create } from "@bufbuild/protobuf";-import type { InputInst } from "naive-ui";-import { NButton, NInput } from "naive-ui";-import { computed, onMounted, reactive, ref } from "vue";-import { useI18n } from "vue-i18n";-import { BBModal } from "@/bbkit";-import { useNotificationStore } from "@/store";-import { Engine } from "@/types/proto-es/v1/common_pb";-import type {- Database,- DatabaseMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import {- ColumnMetadataSchema,- TableMetadataSchema,-} from "@/types/proto-es/v1/database_service_pb";-import { getDatabaseEngine } from "@/utils";-import { useSchemaEditorContext } from "../context";-import { upsertColumnPrimaryKey } from "../edit";--// Table name must start with a non-space character, end with a non-space character, and can contain space in between.-const tableNameFieldRegexp = /^\S[\S ]*\S?$/;--interface LocalState {- tableName: string;-}--const props = defineProps<{- database: Database;- metadata: DatabaseMetadata;- schema: SchemaMetadata;- table?: TableMetadata;-}>();--const emit = defineEmits<{- (event: "close"): void;-}>();--const { t } = useI18n();-const { events, addTab, markEditStatus, queuePendingScrollToTable } =- useSchemaEditorContext();-const inputRef = ref<InputInst>();-const notificationStore = useNotificationStore();-const mode = computed(() => {- return props.table ? "edit" : "create";-});-const state = reactive<LocalState>({- tableName: props.table?.name ?? "",-});--const handleConfirmButtonClick = async () => {- if (!tableNameFieldRegexp.test(state.tableName)) {- notificationStore.pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("schema-editor.message.invalid-table-name"),- });- return;- }- const { schema } = props;- const existedTable = schema.tables.find(- (table) => table.name === state.tableName- );- if (existedTable) {- notificationStore.pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("schema-editor.message.duplicated-table-name"),- });- return;- }-- if (!props.table) {- const table = create(TableMetadataSchema, {- name: state.tableName,- columns: [],- });- schema.tables.push(table);- markEditStatus(- props.database,- {- schema,- table,- },- "created"- );-- const column = create(ColumnMetadataSchema, {});- column.name = "id";- const engine = getDatabaseEngine(props.database);- column.type = engine === Engine.POSTGRES ? "integer" : "int";- column.comment = "";- table.columns.push(column);- upsertColumnPrimaryKey(engine, table, column.name);- markEditStatus(- props.database,- {- schema,- table,- column,- },- "created"- );-- addTab({- type: "table",- database: props.database,- metadata: {- database: props.metadata,- schema: props.schema,- table,- },- });-- queuePendingScrollToTable({- db: props.database,- metadata: {- database: props.metadata,- schema: props.schema,- table,- },- });- events.emit("rebuild-tree", {- openFirstChild: false,- });- } else {- const { table } = props;-- table.name = state.tableName;- events.emit("rebuild-edit-status", {- resets: ["tree"],- });- }- dismissModal();-};--const dismissModal = () => {- emit("close");-};--onMounted(() => {- inputRef.value?.focus();-});-</script>diff --git a/frontend/src/components/SchemaEditorLite/Modals/ViewNameModal.vue b/frontend/src/components/SchemaEditorLite/Modals/ViewNameModal.vuedeleted file mode 100644index 3803755f12..0000000000--- a/frontend/src/components/SchemaEditorLite/Modals/ViewNameModal.vue+++ /dev/null@@ -1,142 +0,0 @@-<template>- <BBModal- :title="- mode === 'create'- ? $t('schema-editor.actions.create-view')- : $t('schema-editor.actions.rename')- "- class="shadow-inner outline-solid outline-gray-200"- @close="dismissModal"- >- <div class="w-72">- <p>{{ $t("common.name") }}</p>- <NInput- ref="inputRef"- v-model:value="state.viewName"- class="my-2"- :autofocus="true"- />- </div>- <div class="w-full flex items-center justify-end mt-2 gap-x-2">- <NButton @click="dismissModal">- {{ $t("common.cancel") }}- </NButton>- <NButton type="primary" @click="handleConfirmButtonClick">- {{ mode === "create" ? $t("common.create") : $t("common.save") }}- </NButton>- </div>- </BBModal>-</template>--<script lang="ts" setup>-import { create } from "@bufbuild/protobuf";-import type { InputInst } from "naive-ui";-import { NButton, NInput } from "naive-ui";-import { computed, onMounted, reactive, ref } from "vue";-import { useI18n } from "vue-i18n";-import { BBModal } from "@/bbkit";-import { useNotificationStore } from "@/store";-import type {- Database,- DatabaseMetadata,- SchemaMetadata,- ViewMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { ViewMetadataSchema } from "@/types/proto-es/v1/database_service_pb";-import { useSchemaEditorContext } from "../context";--// View name must start with a non-space character, end with a non-space character.-const viewNameFieldRegexp = /^\S\S*\S?$/;--interface LocalState {- viewName: string;-}--const props = defineProps<{- database: Database;- metadata: DatabaseMetadata;- schema: SchemaMetadata;- view?: ViewMetadata;-}>();--const emit = defineEmits<{- (event: "close"): void;-}>();--const { t } = useI18n();-const { events, addTab, markEditStatus } = useSchemaEditorContext();-const inputRef = ref<InputInst>();-const notificationStore = useNotificationStore();-const mode = computed(() => {- return props.view ? "edit" : "create";-});-const state = reactive<LocalState>({- viewName: props.view?.name ?? "",-});--const handleConfirmButtonClick = async () => {- if (!viewNameFieldRegexp.test(state.viewName)) {- notificationStore.pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("schema-editor.message.invalid-view-name"),- });- return;- }- const { schema } = props;- const existed = schema.views.find((view) => view.name === state.viewName);- if (existed) {- notificationStore.pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("schema-editor.message.duplicated-view-name"),- });- return;- }-- if (!props.view) {- const view = create(ViewMetadataSchema, {- name: state.viewName,- definition: "",- });- schema.views.push(view);- markEditStatus(- props.database,- {- schema,- view,- },- "created"- );-- addTab({- type: "view",- database: props.database,- metadata: {- database: props.metadata,- schema: props.schema,- view,- },- });-- events.emit("rebuild-tree", {- openFirstChild: false,- });- } else {- const { view } = props;- view.name = state.viewName;- events.emit("rebuild-edit-status", {- resets: ["tree"],- });- }- dismissModal();-};--const dismissModal = () => {- emit("close");-};--onMounted(() => {- inputRef.value?.focus();-});-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/ColumnSelectionSummary.vue b/frontend/src/components/SchemaEditorLite/Panels/ColumnSelectionSummary.vuedeleted file mode 100644index 21e44f1aeb..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/ColumnSelectionSummary.vue+++ /dev/null@@ -1,42 +0,0 @@-<template>- <span class="text-control-placeholder">- ({{ summary.selected }} / {{ summary.total }})- </span>-</template>--<script setup lang="ts">-import { computed } from "vue";-import { useSchemaEditorContext } from "@/components/SchemaEditorLite/context";-import type {- Database,- DatabaseMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";--const props = defineProps<{- db: Database;- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- };-}>();--const { getColumnSelectionState } = useSchemaEditorContext();--const summary = computed(() => {- const { columns } = props.metadata.table;- const selectedColumns = columns.filter((column) => {- const state = getColumnSelectionState(props.db, {- ...props.metadata,- column,- });- return state.checked || state.indeterminate;- });- return {- selected: selectedColumns.length,- total: columns.length,- };-});-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/CommonCodeEditor.vue b/frontend/src/components/SchemaEditorLite/Panels/CommonCodeEditor.vuedeleted file mode 100644index 58d789eaac..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/CommonCodeEditor.vue+++ /dev/null@@ -1,67 +0,0 @@-<template>- <div class="h-full flex flex-col gap-1 overflow-y-hidden pt-1">- <div class="flex justify-between items-center text-sm">- <slot name="header-suffix" />- </div>- <div class="flex-1 relative px-2 overflow-y-hidden">- <MonacoEditor- :content="state.code"- :readonly="!editable"- :auto-complete-context="{- instance: extractDatabaseResourceName(db.name).instance,- database: db.name,- scene: 'all',- }"- class="border w-full h-full rounded-sm"- @update:content="handleUpdateCode"- />- </div>- <slot name="preview" />- </div>-</template>--<script setup lang="ts">-import { computed, reactive, watch } from "vue";-import { MonacoEditor } from "@/components/MonacoEditor";-import type { Database } from "@/types/proto-es/v1/database_service_pb";-import { extractDatabaseResourceName } from "@/utils";-import type { EditStatus } from "..";--type LocalState = {- code: string;-};--const props = defineProps<{- db: Database;- code: string;- readonly: boolean;- status: EditStatus;-}>();--const emit = defineEmits<{- (e: "update:code", code: string): void;-}>();--const state = reactive<LocalState>({- code: props.code,-});--const editable = computed(() => {- if (props.readonly) {- return false;- }- return true;-});--const handleUpdateCode = (code: string) => {- state.code = code;- emit("update:code", code);-};--watch(- () => props.code,- (code) => {- state.code = code;- }-);-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/DatabaseEditor.vue b/frontend/src/components/SchemaEditorLite/Panels/DatabaseEditor.vuedeleted file mode 100644index 1f45ffb06f..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/DatabaseEditor.vue+++ /dev/null@@ -1,284 +0,0 @@-<template>- <div class="flex flex-col w-full h-full overflow-y-hidden" v-bind="$attrs">- <div class="py-2 w-full flex flex-row justify-between items-center">- <div>- <div- v-if="state.selectedSubTab === 'table-list'"- class="w-full flex justify-between items-center gap-x-2"- >- <div class="flex flex-row justify-start items-center gap-x-2">- <div- v-if="shouldShowSchemaSelector"- class="pl-1 flex-row justify-start items-center text-sm gap-x-2 overflow-auto hidden xl:flex"- >- <span class="shrink-0">Schema:</span>- <NSelect- :value="selectedSchemaName"- :options="schemaSelectorOptionList"- class="min-w-32"- @update:value="$emit('update:selected-schema-name', $event)"- />- </div>- <NButton- v-if="!readonly"- :disabled="!allowCreateTable"- @click="handleCreateNewTable"- >- <template #icon>- <PlusIcon class="w-4 h-4" />- </template>- {{ $t("schema-editor.actions.create-table") }}- </NButton>- <div- v-if="selectionEnabled"- class="text-sm flex flex-row items-center gap-x-2"- >- <span class="text-main">- {{ $t("branch.select-tables-to-rollout") }}- </span>- <TableSelectionSummary- v-if="selectedSchema"- :db="db"- :metadata="{- database,- schema: selectedSchema,- }"- />- </div>- </div>- </div>- </div>- <div class="flex justify-end items-center">- <div- class="flex flex-row justify-end items-center bg-gray-100 p-1 rounded-sm whitespace-nowrap"- >- <NButton- size="small"- :secondary="state.selectedSubTab === 'table-list'"- :quaternary="state.selectedSubTab !== 'table-list'"- @click="handleChangeTab('table-list')"- >- <List class="inline w-4 h-auto mr-1" />- {{ $t("schema-editor.tables") }}- </NButton>- <NTooltip :disabled="!schemaDiagramDisabled">- <template #trigger>- <NButton- tag="div"- size="small"- :disabled="schemaDiagramDisabled"- :secondary="state.selectedSubTab === 'schema-diagram'"- :quaternary="state.selectedSubTab !== 'schema-diagram'"- @click="handleChangeTab('schema-diagram')"- >- <SchemaDiagramIcon class="mr-1" />- {{ $t("schema-diagram.self") }}- </NButton>- </template>- <div class="whitespace-nowrap">Too many tables</div>- </NTooltip>- </div>- </div>- </div>-- <div class="flex-1 overflow-y-hidden">- <!-- List view -->- <template v-if="state.selectedSubTab === 'table-list'">- <TableList- v-if="selectedSchema"- :db="db"- :database="database"- :schema="selectedSchema"- :tables="selectedSchema.tables"- :search-pattern="searchPattern"- />- </template>- <template v-else-if="state.selectedSubTab === 'schema-diagram'">- <!-- TODO: bring status coloring back -->- <SchemaDiagram- :database="db"- :database-metadata="database"- :editable="true"- @edit-table="tryEditTable"- @edit-column="tryEditColumn"- />- </template>- </div>- </div>-- <TableNameModal- v-if="state.tableNameModalContext !== undefined"- :database="db"- :metadata="database"- :schema="state.tableNameModalContext.schema"- mode="create"- @close="state.tableNameModalContext = undefined"- />-</template>--<script lang="ts" setup>-import { head, sumBy } from "lodash-es";-import { List, PlusIcon } from "lucide-vue-next";-import { NButton, NSelect, NTooltip } from "naive-ui";-import { computed, nextTick, reactive, watch } from "vue";-import SchemaDiagram, { SchemaDiagramIcon } from "@/components/SchemaDiagram";-import { Engine } from "@/types/proto-es/v1/common_pb";-import type {- ColumnMetadata,- Database,- DatabaseMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { getDatabaseEngine } from "@/utils";-import { useSchemaEditorContext } from "../context";-import TableNameModal from "../Modals/TableNameModal.vue";-import TableList from "./TableList";-import TableSelectionSummary from "./TableSelectionSummary.vue";--defineOptions({- inheritAttrs: false,-});--const props = withDefaults(- defineProps<{- db: Database;- database: DatabaseMetadata;- selectedSchemaName: string | undefined;- searchPattern?: string;- }>(),- {- searchPattern: "",- }-);-const emit = defineEmits<{- (event: "update:selected-schema-name", schema: string | undefined): void;-}>();--type SubTabType = "table-list" | "schema-diagram";--interface LocalState {- selectedSubTab: SubTabType;- showFeatureModal: boolean;- tableNameModalContext?: {- schema: SchemaMetadata;- };- activeTableId?: string;-}--const context = useSchemaEditorContext();-const { readonly, selectionEnabled, addTab, getSchemaStatus } = context;-const state = reactive<LocalState>({- selectedSubTab: "table-list",- showFeatureModal: false,-});-const engine = computed(() => {- return getDatabaseEngine(props.db);-});-const selectedSchema = computed(() => {- return props.database.schemas.find(- (schema) => schema.name === props.selectedSchemaName- );-});-const shouldShowSchemaSelector = computed(() => {- return engine.value === Engine.POSTGRES;-});--const allowCreateTable = computed(() => {- const schema = selectedSchema.value;- if (!schema) return false;- if (engine.value === Engine.POSTGRES) {- const status = getSchemaStatus(props.db, {- schema,- });-- return (- props.database.schemas.length > 0 &&- selectedSchema.value &&- status !== "dropped"- );- }- return true;-});--const schemaSelectorOptionList = computed(() => {- const optionList = [];- for (const schema of props.database.schemas) {- optionList.push({- label: schema.name,- value: schema.name,- });- }-- return optionList;-});--watch(- schemaSelectorOptionList,- (options) => {- if (!options.find((opt) => opt.value === props.selectedSchemaName)) {- emit("update:selected-schema-name", head(options)?.value);- }- },- {- immediate: true,- }-);--const handleChangeTab = (tab: SubTabType) => {- state.selectedSubTab = tab;-};-const schemaDiagramDisabled = computed(() => {- return sumBy(props.database.schemas, (schema) => schema.tables.length) >= 200;-});-watch(- schemaDiagramDisabled,- (disabled) => {- if (disabled) handleChangeTab("table-list");- },- { immediate: true }-);--const handleCreateNewTable = () => {- if (selectedSchema.value) {- state.tableNameModalContext = {- schema: selectedSchema.value,- };- }-};--const tryEditTable = async (schema: SchemaMetadata, table: TableMetadata) => {- emit("update:selected-schema-name", schema.name);- await nextTick();- addTab({- type: "table",- database: props.db,- metadata: {- database: props.database,- schema,- table,- },- });-};--const tryEditColumn = async (- schema: SchemaMetadata,- table: TableMetadata,- column: ColumnMetadata-) => {- if (schema && table && column) {- await tryEditTable(schema, table);-- // TODO: scroll column into view and focus the input box- // await nextTick();- // const container = document.querySelector("#table-editor-container");- // const input = container?.querySelector(- // `.column-${column.id} .column-${target}-input`- // ) as HTMLInputElement | undefined;- // if (input) {- // input.focus();- // scrollIntoView(input);- // }- }-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/FunctionEditor.vue b/frontend/src/components/SchemaEditorLite/Panels/FunctionEditor.vuedeleted file mode 100644index 186d4c9da0..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/FunctionEditor.vue+++ /dev/null@@ -1,70 +0,0 @@-<template>- <CommonCodeEditor- :db="db"- :code="func.definition"- :readonly="disallowChangeFunction"- :status="status"- @update:code="handleUpdateDefinition"- />-</template>--<script setup lang="ts">-import { computed } from "vue";-import type {- Database,- DatabaseMetadata,- FunctionMetadata,- SchemaMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { useSchemaEditorContext } from "../context";-import type { EditStatus } from "../types";-import CommonCodeEditor from "./CommonCodeEditor.vue";--const props = defineProps<{- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- func: FunctionMetadata;-}>();--const { readonly, markEditStatus, getSchemaStatus, getFunctionStatus } =- useSchemaEditorContext();--const statusForSchema = () => {- return getSchemaStatus(props.db, {- schema: props.schema,- });-};-const status = computed(() => {- return getFunctionStatus(props.db, {- schema: props.schema,- function: props.func,- });-});-const markStatus = (status: EditStatus) => {- markEditStatus(- props.db,- {- schema: props.schema,- function: props.func,- },- status- );-};--const disallowChangeFunction = computed(() => {- if (readonly.value) {- return true;- }- return statusForSchema() === "dropped" || status.value === "dropped";-});--const handleUpdateDefinition = (code: string) => {- // eslint-disable-next-line vue/no-mutating-props- props.func.definition = code;-- if (status.value === "normal") {- markStatus("updated");- }-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/IndexesEditor.vue b/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/IndexesEditor.vuedeleted file mode 100644index a87aea5d00..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/IndexesEditor.vue+++ /dev/null@@ -1,284 +0,0 @@-<template>- <div- v-show="show"- ref="containerElRef"- class="w-full h-full overflow-x-auto"- :data-height="containerHeight"- :data-table-header-height="tableHeaderHeight"- :data-table-body-height="tableBodyHeight"- >- <NDataTable- v-bind="$attrs"- ref="dataTableRef"- size="small"- :row-key="getIndexKey"- :columns="columns"- :data="layoutReady ? indexList : []"- :max-height="tableBodyHeight"- :virtual-scroll="true"- :striped="true"- :bordered="true"- :bottom-bordered="true"- class="schema-editor-table-indexes-editor"- />- </div>-</template>--<script lang="ts" setup>-import { useElementSize } from "@vueuse/core";-import { pull } from "lodash-es";-import type { DataTableColumn, DataTableInst } from "naive-ui";-import { NCheckbox, NDataTable } from "naive-ui";-import { computed, h, ref } from "vue";-import { useI18n } from "vue-i18n";-import { InlineInput } from "@/components/v2";-import { Engine } from "@/types/proto-es/v1/common_pb";-import type {- Database,- DatabaseMetadata,- IndexMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { getDatabaseEngine } from "@/utils";-import { markUUID } from "../common";-import { ColumnsCell, OperationCell } from "./components";--const props = withDefaults(- defineProps<{- show?: boolean;- readonly?: boolean;- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- maxBodyHeight?: number;- }>(),- {- show: true,- readonly: false,- maxBodyHeight: undefined,- }-);-const emit = defineEmits<{- (event: "update"): void;-}>();--const dataTableRef = ref<DataTableInst>();-const containerElRef = ref<HTMLElement>();-const tableHeaderElRef = computed(- () =>- containerElRef.value?.querySelector("thead.n-data-table-thead") as- | HTMLElement- | undefined-);-const { height: containerHeight } = useElementSize(containerElRef);-const { height: tableHeaderHeight } = useElementSize(tableHeaderElRef);-const tableBodyHeight = computed(() => {- const bodyHeight = containerHeight.value - tableHeaderHeight.value - 2;- const { maxBodyHeight = 0 } = props;- if (maxBodyHeight > 0) {- return Math.min(maxBodyHeight, bodyHeight);- }- return bodyHeight;-});-// Use this to avoid unnecessary initial rendering-const layoutReady = computed(() => tableHeaderHeight.value > 0);-const { t } = useI18n();--const indexList = computed(() => {- return props.table.indexes;-});--const getIndexKey = (index: IndexMetadata) => {- return markUUID(index);-};--const columns = computed(() => {- const columns: (DataTableColumn<IndexMetadata> & { hide?: boolean })[] = [- {- key: "name",- title: t("schema-editor.column.name"),- resizable: true,- minWidth: 140,- className: "input-cell",- render: (index) => {- return h(InlineInput, {- value: index.name,- disabled: props.readonly,- placeholder: t("common.name"),- style: {- "--n-padding-left": "6px",- "--n-padding-right": "4px",- "--n-text-color-disabled": "rgb(var(--color-main))",- },- "onUpdate:value": (value: string) => {- index.name = value;- emit("update");- },- });- },- },- {- key: "columns",- title: t("schema-editor.columns"),- resizable: true,- minWidth: 400,- maxWidth: 480,- className: "input-cell",- render: (index) => {- return h(ColumnsCell, {- readonly: props.readonly,- db: props.db,- database: props.database,- schema: props.schema,- table: props.table,- index,- "onUpdate:expressions": (expressions) => {- index.expressions = expressions;- emit("update");- },- });- },- },- {- key: "comment",- title: t("schema-editor.column.comment"),- resizable: true,- minWidth: 140,- maxWidth: 320,- className: "input-cell",- render: (index) => {- return h(InlineInput, {- value: index.comment,- disabled: props.readonly,- placeholder: "comment",- style: {- "--n-padding-left": "6px",- "--n-padding-right": "4px",- "--n-text-color-disabled": "rgb(var(--color-main))",- },- "onUpdate:value": (value) => {- index.comment = value;- emit("update");- },- });- },- },- {- key: "primary",- title: t("schema-editor.column.primary"),- resizable: false,- width: 80,- className: "checkbox-cell",- render: (index) => {- const allowTurnOnOrOffPrimary = () => {- // Do not allow to edit primary key for TiDB.- if (getDatabaseEngine(props.db) === Engine.TIDB) {- return false;- }-- if (index.primary) return true;- return !props.table.indexes.some((idx) => idx.primary);- };- return h(NCheckbox, {- checked: index.primary,- disabled: props.readonly || !allowTurnOnOrOffPrimary(),- "onUpdate:checked": (checked: boolean) => {- index.primary = checked;- if (checked) {- index.unique = false;- }- emit("update");- },- });- },- },- {- key: "unique",- title: t("schema-editor.index.unique"),- resizable: false,- width: 80,- className: "checkbox-cell",- render: (index) => {- return h(NCheckbox, {- checked: index.unique,- disabled: props.readonly,- "onUpdate:checked": (checked: boolean) => {- index.unique = checked;- if (checked) {- index.primary = false;- }- emit("update");- },- });- },- },- {- key: "operations",- title: "",- resizable: false,- width: 30,- hide: props.readonly,- className: "px-0!",- render: (index) => {- return h(OperationCell, {- index,- onDrop: () => {- pull(props.table.indexes, index);- emit("update");- },- });- },- },- ];- return columns.filter((header) => !header.hide);-});-</script>--<style lang="postcss" scoped>-.schema-editor-table-indexes-editor- :deep(.n-data-table-th .n-data-table-resize-button::after) {- background-color: var(--color-control-bg);- height: 66.666667%;-}-.schema-editor-table-indexes-editor :deep(.n-data-table-td.input-cell) {- padding-left: 0.125rem;- padding-right: 0.25rem;- padding-top: 0;- padding-bottom: 0;-}-.schema-editor-table-indexes-editor- :deep(.n-data-table-td.input-cell .n-input__placeholder),-.schema-editor-table-indexes-editor- :deep(.n-data-table-td.input-cell .n-base-selection-placeholder) {- font-style: italic;-}-.schema-editor-table-indexes-editor :deep(.n-data-table-td.checkbox-cell) {- padding-right: 0.25rem;- padding-top: 0;- padding-bottom: 0;-}-.schema-editor-table-indexes-editor :deep(.n-data-table-td.text-cell) {- padding-right: 0.25rem;- padding-top: 0;- padding-bottom: 0;-}-.schema-editor-table-indexes-editor- :deep(.n-data-table-tr.created .n-data-table-td) {- color: var(--color-green-700);- background-color: var(--color-green-50) !important;-}-.schema-editor-table-indexes-editor- :deep(.n-data-table-tr.dropped .n-data-table-td) {- color: var(--color-red-700);- cursor: not-allowed;- background-color: var(--color-red-50) !important;- opacity: 0.7;-}-.schema-editor-table-indexes-editor- :deep(.n-data-table-tr.updated .n-data-table-td) {- color: var(--color-yellow-700);- background-color: var(--color-yellow-50) !important;-}-</style>diff --git a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/ColumnsCell.vue b/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/ColumnsCell.vuedeleted file mode 100644index 02c7224187..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/ColumnsCell.vue+++ /dev/null@@ -1,106 +0,0 @@-<template>- <NSelect- :value="index.expressions"- :options="columnOptions"- :disabled="readonly"- :consistent-menu-width="true"- :style="style"- :multiple="true"- :max-tag-count="'responsive'"- :placeholder="$t('schema-editor.columns')"- :filterable="true"- :render-tag="renderTag"- :show-arrow="!readonly"- suffix-style="right: 3px"- class="bb-schema-editor--index-columns-select"- @focus="focused = true"- @blur="focused = false"- @update:value="$emit('update:expressions', $event as string[])"- />-</template>--<script lang="ts" setup>-import type { SelectOption } from "naive-ui";-import { NSelect, NTag } from "naive-ui";-import type { CSSProperties } from "vue";-import { computed, h, ref } from "vue";-import type {- ColumnMetadata,- Database,- DatabaseMetadata,- IndexMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";--type ColumnOption = SelectOption & {- label: string;- value: string;- column: ColumnMetadata;-};--const props = defineProps<{- readonly?: boolean;- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- index: IndexMetadata;-}>();-defineEmits<{- (event: "update:expressions", expressions: string[]): void;-}>();--const focused = ref(false);--const columnOptions = computed(() => {- return props.table.columns.map<ColumnOption>((column) => ({- label: column.name,- value: column.name,- column,- }));-});--const style = computed(() => {- const style: CSSProperties = {- "--n-color": "transparent",- "--n-color-disabled": "transparent",- "--n-text-color-disabled": "rgb(var(--color-main))",- cursor: "default",- };- const border = focused.value- ? "1px solid rgb(var(--color-control-border))"- : "none";- style["--n-border"] = border;- style["--n-border-disabled"] = border;-- return style;-});--const renderTag = (item: { option: SelectOption; handleClose: () => void }) => {- const { option, handleClose } = item;- const { column } = option as ColumnOption;- return h(- NTag,- {- closable: !props.readonly,- onClose: handleClose,- },- { default: () => column.name }- );-};-</script>--<style lang="postcss" scoped>-.bb-schema-editor--index-columns-select :deep(.n-base-selection) {- --n-padding-multiple: 2px 16px 0px 2px !important;- --n-color: transparent !important;- --n-color-disabled: transparent !important;- --n-border: none !important;- --n-text-color-disabled: rgb(var(--color-main)) !important;-}-.bb-schema-editor--index-columns-select- :deep(.n-base-selection .n-base-suffix) {- right: 4px;-}-</style>diff --git a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/OperationCell.vue b/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/OperationCell.vuedeleted file mode 100644index 9bc7d91d4a..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/OperationCell.vue+++ /dev/null@@ -1,27 +0,0 @@-<template>- <div class="flex justify-start items-center">- <NPopconfirm @positive-click="$emit('drop')">- <template #trigger>- <MiniActionButton tag="div">- <TrashIcon class="w-4 h-4" />- </MiniActionButton>- </template>- <template #default>- {{ $t("branch.index.drop-index-confirm") }}- </template>- </NPopconfirm>- </div>-</template>-<script lang="ts" setup>-import { TrashIcon } from "lucide-vue-next";-import { NPopconfirm } from "naive-ui";-import { MiniActionButton } from "@/components/v2";-import type { IndexMetadata } from "@/types/proto-es/v1/database_service_pb";--defineProps<{- index: IndexMetadata;-}>();-defineEmits<{- (event: "drop"): void;-}>();-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/index.ts b/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/index.tsdeleted file mode 100644index 4bf7658e0c..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/index.ts+++ /dev/null@@ -1,4 +0,0 @@-import ColumnsCell from "./ColumnsCell.vue";-import OperationCell from "./OperationCell.vue";--export { ColumnsCell, OperationCell };diff --git a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/index.ts b/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/index.tsdeleted file mode 100644index 7cbc05f093..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import IndexesEditor from "./IndexesEditor.vue";--export default IndexesEditor;diff --git a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/PartitionsEditor.vue b/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/PartitionsEditor.vuedeleted file mode 100644index 087db82313..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/PartitionsEditor.vue+++ /dev/null@@ -1,464 +0,0 @@-<template>- <div- v-show="show"- ref="containerElRef"- class="w-full h-full overflow-x-auto"- :data-height="containerHeight"- :data-table-header-height="tableHeaderHeight"- :data-table-body-height="tableBodyHeight"- >- <NDataTable- v-bind="$attrs"- ref="dataTableRef"- size="small"- :row-key="getItemKey"- :columns="columns"- :data="layoutReady ? flattenItemList : []"- :row-class-name="classesForRow"- :max-height="tableBodyHeight"- :virtual-scroll="true"- :striped="true"- :bordered="true"- :bottom-bordered="true"- class="schema-editor-table-partitions-editor"- />- </div>-</template>--<script setup lang="tsx">-import { create } from "@bufbuild/protobuf";-import { useElementSize } from "@vueuse/core";-import { head, pull } from "lodash-es";-import { ChevronDownIcon } from "lucide-vue-next";-import { type DataTableColumn, NDataTable } from "naive-ui";-import { computed, ref } from "vue";-import { useI18n } from "vue-i18n";-import type {- Database,- DatabaseMetadata,- SchemaMetadata,- TableMetadata,- TablePartitionMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import {- TablePartitionMetadata_Type,- TablePartitionMetadataSchema,-} from "@/types/proto-es/v1/database_service_pb";-import type { EditStatus } from "../..";-import { useSchemaEditorContext } from "../../context";-import { markUUID } from "../common";-import {- ExpressionCell,- NameCell,- OperationCell,- TypeCell,- ValueCell,-} from "./components";--type FlattenTablePartitionMetadata = {- partition: TablePartitionMetadata;- parent?: TablePartitionMetadata;-};--const props = withDefaults(- defineProps<{- show?: boolean;- readonly?: boolean;- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- maxBodyHeight?: number;- }>(),- {- show: true,- readonly: false,- maxBodyHeight: undefined,- }-);-const emit = defineEmits<{- (event: "update"): void;-}>();--const { t } = useI18n();-const containerElRef = ref<HTMLElement>();-const tableHeaderElRef = computed(- () =>- containerElRef.value?.querySelector("thead.n-data-table-thead") as- | HTMLElement- | undefined-);-const { height: containerHeight } = useElementSize(containerElRef);-const { height: tableHeaderHeight } = useElementSize(tableHeaderElRef);-const tableBodyHeight = computed(() => {- const bodyHeight = containerHeight.value - tableHeaderHeight.value - 2;- const { maxBodyHeight = 0 } = props;- if (maxBodyHeight > 0) {- return Math.min(maxBodyHeight, bodyHeight);- }- return bodyHeight;-});-// Use this to avoid unnecessary initial rendering-const layoutReady = computed(() => tableHeaderHeight.value > 0);-const { markEditStatus, getPartitionStatus, getTableStatus, removeEditStatus } =- useSchemaEditorContext();--const tableStatus = computed(() => {- return getTableStatus(props.db, {- schema: props.schema,- table: props.table,- });-});--const metadataForPartition = (partition: TablePartitionMetadata) => {- return {- database: props.database,- schema: props.schema,- table: props.table,- partition,- };-};-const statusForPartition = (partition: TablePartitionMetadata) => {- return getPartitionStatus(props.db, metadataForPartition(partition));-};-const markStatus = (- partition: TablePartitionMetadata,- status: EditStatus,- oldStatus: EditStatus | undefined = undefined-) => {- if (!oldStatus) {- oldStatus = statusForPartition(partition);- }- if (- (oldStatus === "created" || oldStatus === "dropped") &&- status === "updated"- ) {- markEditStatus(props.db, metadataForPartition(partition), oldStatus);- return;- }- markEditStatus(props.db, metadataForPartition(partition), status);-};--const allowEditPartition = (partition: TablePartitionMetadata) => {- if (props.readonly) {- return false;- }- if (tableStatus.value === "created") {- return true;- }-- const status = statusForPartition(partition);- return status === "created";-};--const classesForRow = (item: FlattenTablePartitionMetadata) => {- return statusForPartition(item.partition);-};--const flattenItemList = computed(() => {- const list: FlattenTablePartitionMetadata[] = [];- const dfsWalk = (- partition: TablePartitionMetadata,- parent?: TablePartitionMetadata- ) => {- list.push({- partition,- parent,- });- partition.subpartitions?.forEach((child) => {- dfsWalk(child, partition);- });- };- props.table.partitions.forEach((partition) => dfsWalk(partition, undefined));- return list;-});--const firstPartition = computed(() => {- return head(- flattenItemList.value.filter((item) => item.parent === undefined)- );-});-const firstSubPartition = computed(() => {- return head(- flattenItemList.value.filter((item) => item.parent !== undefined)- );-});--const getItemKey = (item: FlattenTablePartitionMetadata) => {- return markUUID(item.partition);-};--const allowEditTypeAndExprForItem = (item: FlattenTablePartitionMetadata) => {- if (- item.parent === undefined &&- firstPartition.value &&- item !== firstPartition.value- ) {- return false;- } else if (- item.parent !== undefined &&- firstSubPartition.value &&- item !== firstSubPartition.value- ) {- return false;- }- return true;-};--const columns = computed(() => {- const columns: (DataTableColumn<FlattenTablePartitionMetadata> & {- hide?: boolean;- })[] = [- {- key: "parent",- resizable: false,- width: 24,- render: (item) => {- if (item.partition.subpartitions?.length > 0) {- return <ChevronDownIcon class="w-4 h-4" />;- }- },- },- {- key: "name",- title: t("common.name"),- resizable: true,- minWidth: 140,- maxWidth: 320,- className: "input-cell",- render: (item) => {- return (- <NameCell- readonly={!allowEditPartition(item.partition)}- partition={item.partition}- onUpdate:name={(name) => {- const oldStatus = statusForPartition(item.partition);- item.partition.name = name;- markStatus(item.partition, "updated", oldStatus);- }}- />- );- },- },- {- key: "type",- title: t("common.type"),- resizable: true,- minWidth: 140,- className: "input-cell",- render: (item) => {- if (!allowEditTypeAndExprForItem(item)) {- return (- <div- class="flex items-center text-control-placeholder italic cursor-disallowed px-1.5"- style="height: 34px"- >- {item.partition.type}- </div>- );- }- return (- <TypeCell- readonly={!allowEditPartition(item.partition)}- partition={item.partition}- parent={item.parent}- onUpdate:type={(type) => {- flattenItemList.value- .filter((it) => {- if (item.parent === undefined) return it.parent === undefined;- return it.parent !== undefined;- })- .forEach((it) => {- it.partition.type = type;- });- emit("update");- }}- />- );- },- },- {- key: "expression",- title: t("schema-editor.table-partition.expression"),- resizable: true,- minWidth: 140,- className: "input-cell",- render: (item) => {- if (!allowEditTypeAndExprForItem(item)) {- return (- <div- class="flex items-center text-control-placeholder italic cursor-disallowed px-1.5"- style="height: 34px"- >- {item.partition.expression}- </div>- );- }- return (- <ExpressionCell- readonly={!allowEditPartition(item.partition)}- partition={item.partition}- onUpdate:expression={(expression) => {- flattenItemList.value- .filter((it) => {- if (item.parent === undefined) return it.parent === undefined;- return it.parent !== undefined;- })- .forEach((it) => {- it.partition.expression = expression;- });- emit("update");- }}- />- );- },- },- {- key: "value",- title: t("schema-editor.table-partition.value"),- resizable: true,- minWidth: 140,- className: "input-cell",- render: (item) => {- return (- <ValueCell- readonly={!allowEditPartition(item.partition)}- partition={item.partition}- onUpdate:value={(value) => {- item.partition.value = value;- emit("update");- }}- />- );- },- },- {- key: "operations",- title: "",- resizable: false,- width: 60,- hide: props.readonly,- className: "px-0!",- render: (item) => {- return (- <OperationCell- partition={item.partition}- parent={item.parent}- tableStatus={tableStatus.value}- status={statusForPartition(item.partition)}- onDrop={() => {- const status = statusForPartition(item.partition);- if (tableStatus.value === "created" || status === "created") {- // For newly created partitions, or partitions in newly created- // tables, we remove them directly.- if (item.parent) {- // Removing a subpartition from its parent- pull(item.parent.subpartitions, item.partition);- } else {- // Removing a partition will also remove all its subpartitions- pull(props.table.partitions, item.partition);- }- } else {- // For existed partitions, don't actually drop it, but keep- // a snapshot so that we could restore it later.- // This feature actually doesn't work by now, since we don't- // allow to drop existed partitions yet.- markStatus(item.partition, "dropped");- item.partition.subpartitions?.forEach((subpartition) => {- markStatus(subpartition, "dropped");- });- }- emit("update");- }}- onRestore={() => {- removeEditStatus(- props.db,- metadataForPartition(item.partition),- /* !recursive */ false- );- if (item.parent) {- removeEditStatus(- props.db,- metadataForPartition(item.parent),- /* !recursive */ false- );- }- }}- onAdd-sub={() => {- const first = firstSubPartition.value;- const sub = create(TablePartitionMetadataSchema, {- type: first?.partition.type ?? TablePartitionMetadata_Type.HASH,- expression: first?.partition.expression ?? "",- });- markStatus(sub, "created");- if (item.partition.subpartitions) {- item.partition.subpartitions.push(sub);- } else {- item.partition.subpartitions = [sub];- }- emit("update");- }}- />- );- },- },- ];- return columns.filter((header) => !header.hide);-});-</script>--<style lang="postcss" scoped>-.schema-editor-table-partitions-editor- :deep(.n-data-table-th .n-data-table-resize-button::after) {- background-color: var(--color-control-bg);- height: 66.666667%;-}-.schema-editor-table-partitions-editor :deep(.n-data-table-td.input-cell) {- padding-left: 0.125rem;- padding-right: 0.25rem;- padding-top: 0;- padding-bottom: 0;-}-.schema-editor-table-partitions-editor- :deep(.n-data-table-td .n-data-table-expand-placeholder) {- display: none;-}-.schema-editor-table-partitions-editor- :deep(.n-data-table-td .n-data-table-expand-trigger) {- margin-left: 0.5rem;- margin-right: 0;-}-.schema-editor-table-partitions-editor- :deep(.n-data-table-td.input-cell .n-input__placeholder),-.schema-editor-table-partitions-editor- :deep(.n-data-table-td.input-cell .n-base-selection-placeholder) {- font-style: italic;-}-.schema-editor-table-partitions-editor :deep(.n-data-table-td.checkbox-cell) {- padding-right: 0.25rem;- padding-top: 0;- padding-bottom: 0;-}-.schema-editor-table-partitions-editor :deep(.n-data-table-td.text-cell) {- padding-right: 0.25rem;- padding-top: 0;- padding-bottom: 0;-}-.schema-editor-table-partitions-editor- :deep(.n-data-table-tr.created .n-data-table-td) {- color: var(--color-green-700);- background-color: var(--color-green-50) !important;-}-.schema-editor-table-partitions-editor- :deep(.n-data-table-tr.dropped .n-data-table-td) {- color: var(--color-red-700);- cursor: not-allowed;- background-color: var(--color-red-50) !important;- opacity: 0.7;-}-.schema-editor-table-partitions-editor- :deep(.n-data-table-tr.updated .n-data-table-td) {- color: var(--color-yellow-700);- background-color: var(--color-yellow-50) !important;-}-</style>diff --git a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/common.ts b/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/common.tsdeleted file mode 100644index 97ec809056..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/common.ts+++ /dev/null@@ -1,9 +0,0 @@-import { TablePartitionMetadata_Type } from "@/types/proto-es/v1/database_service_pb";--export const PartitionTypesSupportSubPartition: readonly TablePartitionMetadata_Type[] =- [- TablePartitionMetadata_Type.RANGE,- TablePartitionMetadata_Type.RANGE_COLUMNS,- TablePartitionMetadata_Type.LIST,- TablePartitionMetadata_Type.LIST_COLUMNS,- ] as const;diff --git a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/ExpressionCell.vue b/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/ExpressionCell.vuedeleted file mode 100644index 8e15b8c8e9..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/ExpressionCell.vue+++ /dev/null@@ -1,26 +0,0 @@-<template>- <InlineInput- :value="partition.expression"- :disabled="readonly"- :placeholder="$t('schema-editor.table-partition.expression')"- style="- --n-padding-left: 6px;- --n-padding-right: 4px;- --n-text-color-disabled: rgb(var(--color-main));- "- @update:value="$emit('update:expression', $event)"- />-</template>--<script lang="ts" setup>-import { InlineInput } from "@/components/v2";-import { type TablePartitionMetadata } from "@/types/proto-es/v1/database_service_pb";--defineProps<{- readonly?: boolean;- partition: TablePartitionMetadata;-}>();-defineEmits<{- (event: "update:expression", expression: string): void;-}>();-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/NameCell.vue b/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/NameCell.vuedeleted file mode 100644index 0236904af3..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/NameCell.vue+++ /dev/null@@ -1,27 +0,0 @@-<template>- <InlineInput- :value="partition.name"- :disabled="readonly"- :placeholder="$t('common.name')"- style="- --n-padding-left: 6px;- --n-padding-right: 4px;- --n-text-color-disabled: rgb(var(--color-main));- width: inherit;- "- @update:value="$emit('update:name', $event)"- />-</template>--<script lang="ts" setup>-import { InlineInput } from "@/components/v2";-import { type TablePartitionMetadata } from "@/types/proto-es/v1/database_service_pb";--defineProps<{- readonly?: boolean;- partition: TablePartitionMetadata;-}>();-defineEmits<{- (event: "update:name", name: string): void;-}>();-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/OperationCell.vue b/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/OperationCell.vuedeleted file mode 100644index 7dd0fe57c6..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/OperationCell.vue+++ /dev/null@@ -1,75 +0,0 @@-<template>- <div class="flex justify-start items-center">- <NPopconfirm v-if="allowDrop" @positive-click="$emit('drop')">- <template #trigger>- <MiniActionButton tag="div">- <TrashIcon class="w-4 h-4" />- </MiniActionButton>- </template>- <template #default>- <div class="flex flex-col">- <p>- {{ $t("branch.table-partition.drop-partition-confirm") }}- </p>- <p v-if="partition.subpartitions?.length > 0">- {{- $t(- "branch.table-partition.drop-partition-with-subpartitions-confirm"- )- }}- </p>- </div>- </template>- </NPopconfirm>- <NTooltip v-if="status === 'dropped'" trigger="hover" to="body">- <template #trigger>- <MiniActionButton tag="div" @click="$emit('restore')">- <Undo2Icon class="w-4 h-4" />- </MiniActionButton>- </template>- <span>{{ $t("schema-editor.actions.restore") }}</span>- </NTooltip>- <NTooltip v-if="allowAddSub" trigger="hover" to="body">- <template #trigger>- <MiniActionButton tag="div" @click="$emit('add-sub')">- <CirclePlusIcon class="w-4 h-4" />- </MiniActionButton>- </template>- <span>{{ $t("schema-editor.table-partition.add-sub-partition") }}</span>- </NTooltip>- </div>-</template>-<script lang="ts" setup>-import { CirclePlusIcon, TrashIcon, Undo2Icon } from "lucide-vue-next";-import { NPopconfirm, NTooltip } from "naive-ui";-import { computed } from "vue";-import type { EditStatus } from "@/components/SchemaEditorLite";-import { MiniActionButton } from "@/components/v2";-import type { TablePartitionMetadata } from "@/types/proto-es/v1/database_service_pb";-import { PartitionTypesSupportSubPartition } from "../common";--const props = defineProps<{- partition: TablePartitionMetadata;- parent?: TablePartitionMetadata;- tableStatus: EditStatus;- status: EditStatus;-}>();-defineEmits<{- (event: "drop"): void;- (event: "restore"): void;- (event: "add-sub"): void;-}>();--const allowDrop = computed(() => {- return props.tableStatus === "created" || props.status === "created";-});--const allowAddSub = computed(() => {- const { partition, parent } = props;- if (parent) {- // partitions cannot nest (only 1-level parent-sub relationships)- return false;- }- return PartitionTypesSupportSubPartition.includes(partition.type);-});-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/TypeCell.vue b/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/TypeCell.vuedeleted file mode 100644index 2574c6bfc6..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/TypeCell.vue+++ /dev/null@@ -1,94 +0,0 @@-<template>- <NSelect- :value="partition.type || null"- :options="typeOptions"- :style="style"- :disabled="readonly"- :show-arrow="!readonly"- :placeholder="$t('schema-editor.table-partition.type')"- suffix-style="right: 3px"- class="bb-schema-editor--table-partition-type-select"- @focus="focused = true"- @blur="focused = false"- @update:value="$emit('update:type', $event)"- />-</template>--<script lang="ts" setup>-import { NSelect, type SelectOption } from "naive-ui";-import type { CSSProperties } from "vue";-import { computed, ref } from "vue";-import type { TablePartitionMetadata } from "@/types/proto-es/v1/database_service_pb";-import { TablePartitionMetadata_Type } from "@/types/proto-es/v1/database_service_pb";--const props = defineProps<{- readonly?: boolean;- partition: TablePartitionMetadata;- parent?: TablePartitionMetadata;-}>();-defineEmits<{- (event: "update:type", type: TablePartitionMetadata_Type): void;-}>();--const focused = ref(false);--const typeOptions = computed(() => {- const values: TablePartitionMetadata_Type[] = props.parent- ? [- TablePartitionMetadata_Type.HASH,- TablePartitionMetadata_Type.LINEAR_HASH,- TablePartitionMetadata_Type.KEY,- TablePartitionMetadata_Type.LINEAR_KEY,- ]- : [- TablePartitionMetadata_Type.RANGE,- TablePartitionMetadata_Type.RANGE_COLUMNS,- TablePartitionMetadata_Type.LIST,- TablePartitionMetadata_Type.LIST_COLUMNS,- TablePartitionMetadata_Type.HASH,- TablePartitionMetadata_Type.LINEAR_HASH,- TablePartitionMetadata_Type.KEY,- TablePartitionMetadata_Type.LINEAR_KEY,- ];- return values.map<SelectOption>((type) => {- // Convert enum number to string label- const label = TablePartitionMetadata_Type[type] || `UNKNOWN_${type}`;- return {- value: type,- label,- };- });-});--const style = computed(() => {- const style: CSSProperties = {- "--n-padding-left": "6px",- "--n-padding-right": "16px",- "--n-color": "transparent",- "--n-color-disabled": "transparent",- "--n-text-color-disabled": "rgb(var(--color-main))",- cursor: "default",- };- const border = focused.value- ? "1px solid rgb(var(--color-control-border))"- : "none";- style["--n-border"] = border;- style["--n-border-disabled"] = border;-- return style;-});-</script>--<style lang="postcss" scoped>-.bb-schema-editor--table-partition-type-select :deep(.n-base-selection) {- --n-padding-single: 0 16px 0 6px !important;- --n-color: transparent !important;- --n-color-disabled: transparent !important;- --n-border: none !important;- --n-text-color-disabled: rgb(var(--color-main)) !important;-}-.bb-schema-editor--table-partition-type-select- :deep(.n-base-selection .n-base-suffix) {- right: 4px;-}-</style>diff --git a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/ValueCell.vue b/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/ValueCell.vuedeleted file mode 100644index 83ac76cded..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/ValueCell.vue+++ /dev/null@@ -1,26 +0,0 @@-<template>- <InlineInput- :value="partition.value"- :disabled="readonly"- :placeholder="$t('schema-editor.table-partition.value')"- style="- --n-padding-left: 6px;- --n-padding-right: 4px;- --n-text-color-disabled: rgb(var(--color-main));- "- @update:value="$emit('update:value', $event)"- />-</template>--<script lang="ts" setup>-import { InlineInput } from "@/components/v2";-import { type TablePartitionMetadata } from "@/types/proto-es/v1/database_service_pb";--defineProps<{- readonly?: boolean;- partition: TablePartitionMetadata;-}>();-defineEmits<{- (event: "update:value", value: string): void;-}>();-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/index.ts b/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/index.tsdeleted file mode 100644index 112fe478c6..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/components/index.ts+++ /dev/null@@ -1,7 +0,0 @@-import ExpressionCell from "./ExpressionCell.vue";-import NameCell from "./NameCell.vue";-import OperationCell from "./OperationCell.vue";-import TypeCell from "./TypeCell.vue";-import ValueCell from "./ValueCell.vue";--export { NameCell, TypeCell, ExpressionCell, ValueCell, OperationCell };diff --git a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/index.ts b/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/index.tsdeleted file mode 100644index f6ef90ee4a..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/PartitionsEditor/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import PartitionsEditor from "./PartitionsEditor.vue";--export default PartitionsEditor;diff --git a/frontend/src/components/SchemaEditorLite/Panels/PreviewPane.vue b/frontend/src/components/SchemaEditorLite/Panels/PreviewPane.vuedeleted file mode 100644index 77c5f610d5..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/PreviewPane.vue+++ /dev/null@@ -1,144 +0,0 @@-<template>- <div- v-if="!hidePreview"- v-show="layoutReady"- class="overflow-hidden flex flex-col items-stretch shrink-0 transition-all"- :style="{- height: expanded ? `${panelHeight}px` : '1rem',- }"- :data-parent-height="parentHeight"- >- <div- class="cursor-pointer flex items-center justify-start px-2 gap-1 overflow-y-visible bg-control-bg hover:bg-control-bg-hover"- :style="{- height: '1rem',- }"- @click="expanded = !expanded"- >- <ChevronDownIcon- class="w-4 h-4 transition-transform"- :class="expanded ? '' : 'rotate-180'"- />- <span v-if="true || expanded" class="text-xs origin-left">- {{ title }}- </span>- </div>- <div class="relative flex-1 overflow-hidden">- <MonacoEditor- v-if="status === 'pending' || status === 'success'"- :readonly="true"- :content="data?.trim() ?? ''"- :options="{- fontSize: '12px',- lineHeight: '18px',- }"- class="w-full h-full"- />- <pre v-if="expanded && status === 'error'" class="text-sm text-error">{{- error?.message ?? "Unknown error"- }}</pre>- <MaskSpinner v-if="status === 'pending'" />- </div>- </div>-</template>--<script setup lang="ts">-import { create } from "@bufbuild/protobuf";-import {- useDebounceFn,- useElementSize,- useLocalStorage,- useParentElement,-} from "@vueuse/core";-import { ChevronDownIcon } from "lucide-vue-next";-import { computed, ref, toRef, watch } from "vue";-import { MonacoEditor } from "@/components/MonacoEditor";-import MaskSpinner from "@/components/misc/MaskSpinner.vue";-import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener";-import { databaseServiceClientConnect } from "@/connect";-import type {- Database,- DatabaseMetadata,- SchemaMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { GetSchemaStringRequestSchema } from "@/types/proto-es/v1/database_service_pb";-import { minmax, STORAGE_KEY_SCHEMA_EDITOR_PREVIEW } from "@/utils";-import { extractGrpcErrorMessage } from "@/utils/connect";-import { useSchemaEditorContext } from "../context";--const props = defineProps<{- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- title: string;- mocked: { metadata: DatabaseMetadata } | undefined;-}>();--const { hidePreview, events } = useSchemaEditorContext();-const expanded = useLocalStorage(STORAGE_KEY_SCHEMA_EDITOR_PREVIEW, true);-const parentElement = useParentElement();-const { height: parentHeight } = useElementSize(parentElement);-const layoutReady = computed(() => parentHeight.value > 0);-const panelHeight = computed(() => {- const min = 8 * 16; // 8rem ~= 6 lines- const max = 16 * 16; // 16rem ~= 13 lines- const flexible = parentHeight.value * 0.4;- return minmax(flexible, min, max);-});--const mocked = toRef(props, "mocked");--const status = ref<"pending" | "success" | "error">("success");-const data = ref<string>("");-const error = ref<Error | null>(null);--const fetchSchemaString = useDebounceFn(async () => {- if (!expanded.value) {- data.value = "";- status.value = "success";- return;- }-- if (!mocked.value) {- data.value = "";- status.value = "success";- return;- }-- status.value = "pending";- error.value = null;-- try {- const { metadata } = mocked.value;- const request = create(GetSchemaStringRequestSchema, {- name: `${props.db.name}/schemaString`,- metadata: metadata,- });- const response =- await databaseServiceClientConnect.getSchemaString(request);-- data.value = response.schemaString;- status.value = "success";- } catch (err) {- error.value = new Error(extractGrpcErrorMessage(err));- status.value = "error";- }-});--watch(- () => mocked.value,- () => {- if (expanded.value) {- fetchSchemaString();- }- },- { deep: true, immediate: true }-);--// Listen for refresh-preview events-useEmitteryEventListener(events, "refresh-preview", () => {- if (expanded.value && mocked.value) {- fetchSchemaString();- }-});-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/ProcedureEditor.vue b/frontend/src/components/SchemaEditorLite/Panels/ProcedureEditor.vuedeleted file mode 100644index 702de8bca3..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/ProcedureEditor.vue+++ /dev/null@@ -1,70 +0,0 @@-<template>- <CommonCodeEditor- :db="db"- :code="procedure.definition"- :readonly="disallowChangeProcedure"- :status="status"- @update:code="handleUpdateDefinition"- />-</template>--<script setup lang="ts">-import { computed } from "vue";-import type {- Database,- DatabaseMetadata,- ProcedureMetadata,- SchemaMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { useSchemaEditorContext } from "../context";-import type { EditStatus } from "../types";-import CommonCodeEditor from "./CommonCodeEditor.vue";--const props = defineProps<{- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- procedure: ProcedureMetadata;-}>();--const { readonly, markEditStatus, getSchemaStatus, getProcedureStatus } =- useSchemaEditorContext();--const statusForSchema = () => {- return getSchemaStatus(props.db, {- schema: props.schema,- });-};-const status = computed(() => {- return getProcedureStatus(props.db, {- schema: props.schema,- procedure: props.procedure,- });-});-const markStatus = (status: EditStatus) => {- markEditStatus(- props.db,- {- schema: props.schema,- procedure: props.procedure,- },- status- );-};--const disallowChangeProcedure = computed(() => {- if (readonly.value) {- return true;- }- return statusForSchema() === "dropped" || status.value === "dropped";-});--const handleUpdateDefinition = (code: string) => {- // eslint-disable-next-line vue/no-mutating-props- props.procedure.definition = code;-- if (status.value === "normal") {- markStatus("updated");- }-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/TableColumnEditor.vue b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/TableColumnEditor.vuedeleted file mode 100644index fd937b711c..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/TableColumnEditor.vue+++ /dev/null@@ -1,586 +0,0 @@-<template>- <div- v-show="show"- ref="containerElRef"- class="w-full h-full overflow-x-auto"- :data-height="containerHeight"- :data-table-header-height="tableHeaderHeight"- :data-table-body-height="tableBodyHeight"- >- <NDataTable- v-bind="$attrs"- ref="dataTableRef"- size="small"- :row-key="getColumnKey"- :columns="columns"- :data="layoutReady ? shownColumnList : []"- :row-class-name="classesForRow"- :max-height="tableBodyHeight"- :virtual-scroll="true"- :striped="true"- :bordered="true"- :bottom-bordered="true"- class="schema-editor-table-column-editor"- />- </div>-</template>--<script lang="ts" setup>-import { useElementSize } from "@vueuse/core";-import { pick, pull } from "lodash-es";-import type { DataTableColumn, DataTableInst } from "naive-ui";-import { NCheckbox, NDataTable } from "naive-ui";-import { computed, h, ref } from "vue";-import { useI18n } from "vue-i18n";-import {- changeColumnNameInPrimaryKey,- removeColumnFromAllForeignKeys,- removeColumnPrimaryKey,- upsertColumnPrimaryKey,-} from "@/components/SchemaEditorLite";-import { InlineInput } from "@/components/v2";-import { pushNotification } from "@/store";-import { Engine } from "@/types/proto-es/v1/common_pb";-import type {- ColumnMetadata,- Database,- DatabaseMetadata,- ForeignKeyMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { arraySwap } from "@/utils";-import { useSchemaEditorContext } from "../../context";-import type { EditStatus } from "../../types";-import type { DefaultValue } from "../../utils";-import { markUUID } from "../common";-import {- DataTypeCell,- DefaultValueCell,- ForeignKeyCell,- OperationCell,- ReorderCell,- SelectionCell,-} from "./components";--const props = withDefaults(- defineProps<{- show?: boolean;- readonly: boolean;- showForeignKey?: boolean;- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- engine: Engine;- disableChangeTable?: boolean;- allowChangePrimaryKeys?: boolean;- allowReorderColumns?: boolean;- maxBodyHeight?: number;- filterColumn?: (column: ColumnMetadata) => boolean;- disableAlterColumn?: (column: ColumnMetadata) => boolean;- }>(),- {- show: true,- showForeignKey: true,- disableChangeTable: false,- allowChangePrimaryKeys: false,- allowReorderColumns: false,- maxBodyHeight: undefined,- filterColumn: (_: ColumnMetadata) => true,- disableAlterColumn: (_: ColumnMetadata) => false,- }-);--const emit = defineEmits<{- (- event: "foreign-key-edit",- column: ColumnMetadata,- fk: ForeignKeyMetadata | undefined- ): void;- (- event: "foreign-key-click",- column: ColumnMetadata,- fk: ForeignKeyMetadata- ): void;-}>();--const {- selectionEnabled,- markEditStatus,- removeEditStatus,- getColumnStatus,- useConsumePendingScrollToColumn,- getAllColumnsSelectionState,- updateAllColumnsSelection,-} = useSchemaEditorContext();-const dataTableRef = ref<DataTableInst>();-const containerElRef = ref<HTMLElement>();-const tableHeaderElRef = computed(- () =>- containerElRef.value?.querySelector("thead.n-data-table-thead") as- | HTMLElement- | undefined-);-const { height: containerHeight } = useElementSize(containerElRef);-const { height: tableHeaderHeight } = useElementSize(tableHeaderElRef);-const tableBodyHeight = computed(() => {- const bodyHeight = containerHeight.value - tableHeaderHeight.value - 2;- const { maxBodyHeight = 0 } = props;- if (maxBodyHeight > 0) {- return Math.min(maxBodyHeight, bodyHeight);- }- return bodyHeight;-});-// Use this to avoid unnecessary initial rendering-const layoutReady = computed(() => tableHeaderHeight.value > 0);-const { t } = useI18n();--const metadataForColumn = (column: ColumnMetadata) => {- return {- database: props.database,- schema: props.schema,- table: props.table,- column,- };-};--const statusForColumn = (column: ColumnMetadata) => {- return getColumnStatus(props.db, metadataForColumn(column));-};--const markColumnStatus = (- column: ColumnMetadata,- status: EditStatus,- oldStatus: EditStatus | undefined = undefined-) => {- if (!oldStatus) {- oldStatus = statusForColumn(column);- }- if (- (oldStatus === "created" || oldStatus === "dropped") &&- status === "updated"- ) {- markEditStatus(props.db, metadataForColumn(column), oldStatus);- return;- }- markEditStatus(props.db, metadataForColumn(column), status);-};--const primaryKey = computed(() => {- return props.table.indexes.find((idx) => idx.primary);-});--const setColumnPrimaryKey = (column: ColumnMetadata, isPrimaryKey: boolean) => {- if (isPrimaryKey) {- column.nullable = false;- upsertColumnPrimaryKey(props.engine, props.table, column.name);- } else {- removeColumnPrimaryKey(props.table, column.name);- }- markColumnStatus(column, "updated");-};--const handleReorderColumn = (index: number, delta: -1 | 1) => {- const target = index + delta;- const { columns } = props.table;- if (target < 0) return;- if (target >= columns.length) return;- arraySwap(columns, index, target);-};--const handleDropColumn = (column: ColumnMetadata) => {- const { table } = props;- // Disallow to drop the last column.- const nonDroppedColumns = table.columns.filter((column) => {- return statusForColumn(column) !== "dropped";- });- if (nonDroppedColumns.length === 1) {- pushNotification({- module: "bytebase",- style: "CRITICAL",- title: t("schema-editor.message.cannot-drop-the-last-column"),- });- return;- }- const status = statusForColumn(column);- if (status === "created") {- pull(table.columns, column);- table.columns = table.columns.filter((col) => col !== column);-- removeColumnPrimaryKey(table, column.name);- removeColumnFromAllForeignKeys(table, column.name);- } else {- markColumnStatus(column, "dropped");- }-};--const handleRestoreColumn = (column: ColumnMetadata) => {- if (statusForColumn(column) === "created") {- return;- }- removeEditStatus(props.db, metadataForColumn(column), /* recursive */ false);-};--const columns = computed(() => {- const columns: (DataTableColumn<ColumnMetadata> & { hide?: boolean })[] = [- {- key: "__selected__",- width: 32,- hide: !selectionEnabled.value,- title: () => {- const state = getAllColumnsSelectionState(- props.db,- pick(props, "database", "schema", "table"),- shownColumnList.value- );- return h(NCheckbox, {- checked: state.checked,- indeterminate: state.indeterminate,- onUpdateChecked: (on: boolean) => {- updateAllColumnsSelection(- props.db,- pick(props, "database", "schema", "table"),- shownColumnList.value,- on- );- },- });- },- render: (column) => {- return h(SelectionCell, {- db: props.db,- metadata: {- ...pick(props, "database", "schema", "table"),- column,- },- });- },- },- {- key: "reorder",- title: "",- resizable: false,- width: 44,- hide: props.readonly || !props.allowReorderColumns,- className: "px-0!",- render: (column, index) => {- return h(ReorderCell, {- allowMoveUp: index > 0,- allowMoveDown: index < shownColumnList.value.length - 1,- disabled: props.disableChangeTable,- onReorder: (delta: -1 | 1) => handleReorderColumn(index, delta),- });- },- },- {- key: "name",- title: t("schema-editor.column.name"),- resizable: true,- minWidth: 140,- className: "input-cell",- render: (column) => {- const isPk = isColumnPrimaryKey(column);- return h(InlineInput, {- value: column.name,- disabled: props.readonly || props.disableAlterColumn(column),- placeholder: "column name",- style: {- "--n-padding-left": "6px",- "--n-padding-right": "4px",- "--n-text-color-disabled": "rgb(var(--color-main))",- },- "onUpdate:value": (value: string) => {- const oldStatus = statusForColumn(column);-- const oldName = column.name;- if (isPk) {- changeColumnNameInPrimaryKey(props.table, oldName, value);- }- column.name = value;- markColumnStatus(column, "updated", oldStatus);- },- });- },- },- {- key: "type",- title: t("schema-editor.column.type"),- resizable: true,- minWidth: 140,- maxWidth: 320,- className: "input-cell",- render: (column) => {- return h(DataTypeCell, {- column,- disabled: props.readonly || props.disableAlterColumn(column),- schemaTemplateColumnTypes: schemaTemplateColumnTypes.value,- engine: props.engine,- "onUpdate:value": (value: string) => {- column.type = value;- markColumnStatus(column, "updated");- },- });- },- },- {- key: "default-value",- title: t("schema-editor.column.default"),- resizable: true,- minWidth: 140,- maxWidth: 320,- className: "input-cell",- render: (column) => {- return h(DefaultValueCell, {- column,- disabled: props.readonly || props.disableAlterColumn(column),- onUpdate: (option) => handleColumnDefaultSelect(column, option),- });- },- },- {- key: "on-update",- title: t("schema-editor.column.on-update"),- resizable: true,- minWidth: 140,- maxWidth: 320,- hide: props.engine !== Engine.MYSQL && props.engine !== Engine.TIDB,- className: "input-cell",- render: (column) => {- return h(InlineInput, {- value: column.onUpdate,- disabled: props.readonly || props.disableAlterColumn(column),- placeholder: "",- style: {- "--n-padding-left": "6px",- "--n-padding-right": "4px",- "--n-text-color-disabled": "rgb(var(--color-main))",- },- "onUpdate:value": (value: string) => {- column.onUpdate = value;- markColumnStatus(column, "updated");- },- });- },- },- {- key: "comment",- title: t("schema-editor.column.comment"),- resizable: true,- minWidth: 140,- maxWidth: 320,- className: "input-cell",- render: (column) => {- return h(InlineInput, {- value: column.comment,- disabled: props.readonly || props.disableAlterColumn(column),- placeholder: "comment",- style: {- "--n-padding-left": "6px",- "--n-padding-right": "4px",- "--n-text-color-disabled": "rgb(var(--color-main))",- },- "onUpdate:value": (value: string) => {- column.comment = value;- markColumnStatus(column, "updated");- },- });- },- },- {- key: "not-null",- title: t("schema-editor.column.not-null"),- resizable: true,- minWidth: 80,- maxWidth: 160,- className: "checkbox-cell",- render: (column) => {- return h(NCheckbox, {- checked: !column.nullable,- disabled:- props.readonly ||- props.disableAlterColumn(column) ||- isColumnPrimaryKey(column),- "onUpdate:checked": (checked: boolean) => {- column.nullable = !checked;- markColumnStatus(column, "updated");- },- });- },- },- {- key: "primary",- title: t("schema-editor.column.primary"),- resizable: true,- minWidth: 80,- maxWidth: 160,- className: "checkbox-cell",- render: (column) => {- return h(NCheckbox, {- checked: isColumnPrimaryKey(column),- disabled:- props.readonly ||- !props.allowChangePrimaryKeys ||- props.disableAlterColumn(column),- "onUpdate:checked": (checked: boolean) =>- setColumnPrimaryKey(column, checked),- });- },- },- {- key: "foreign-key",- title: t("schema-editor.column.foreign-key"),- hide: !props.showForeignKey,- resizable: true,- minWidth: 140,- maxWidth: 320,- className: "text-cell",- render: (column) => {- return h(ForeignKeyCell, {- db: props.db,- database: props.database,- schema: props.schema,- table: props.table,- column: column,- readonly: props.readonly,- disabled: props.readonly || props.disableAlterColumn(column),- onClick: (fk: ForeignKeyMetadata) =>- emit("foreign-key-click", column, fk),- onEdit: (fk: ForeignKeyMetadata | undefined) =>- emit("foreign-key-edit", column, fk),- });- },- },- {- key: "operations",- title: "",- resizable: false,- width: 30,- hide: props.readonly,- className: "px-0!",- render: (column) => {- return h(OperationCell, {- dropped: isDroppedColumn(column),- disabled: props.disableChangeTable,- onDrop: () => handleDropColumn(column),- onRestore: () => handleRestoreColumn(column),- });- },- },- ];- return columns.filter((header) => !header.hide);-});--const shownColumnList = computed(() => {- return props.table.columns.filter(props.filterColumn);-});--const isColumnPrimaryKey = (column: ColumnMetadata): boolean => {- const pk = primaryKey.value;- if (!pk) return false;- return pk.expressions.includes(column.name);-};--const schemaTemplateColumnTypes = computed(() => {- // SchemaTemplate feature has been removed- return [];-});--const handleColumnDefaultSelect = (- column: ColumnMetadata,- defaultValue: DefaultValue-) => {- Object.assign(column, defaultValue);- markColumnStatus(column, "updated");-};--const classesForRow = (column: ColumnMetadata) => {- return statusForColumn(column);-};--const isDroppedColumn = (column: ColumnMetadata): boolean => {- return statusForColumn(column) === "dropped";-};--const getColumnKey = (column: ColumnMetadata) => {- return markUUID(column);-};--const vlRef = computed(() => {- // biome-ignore lint/suspicious/noExplicitAny: accessing internal naive-ui refs- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef // eslint-disable-line @typescript-eslint/no-explicit-any- ?.virtualListRef;-});--useConsumePendingScrollToColumn(- computed(() => ({- db: props.db,- metadata: {- database: props.database,- schema: props.schema,- table: props.table,- },- })),- vlRef,- (params, vl) => {- const key = getColumnKey(params.metadata.column);- if (!key) return;- requestAnimationFrame(() => {- try {- console.debug("scroll-to-column", vl, params, key);- vl.scrollTo({ key });- // TODO: focus name or type input element- } catch {- // Do nothing- }- });- }-);-</script>--<style lang="postcss" scoped>-.schema-editor-table-column-editor- :deep(.n-data-table-th .n-data-table-resize-button::after) {- background-color: var(--color-control-bg);- height: 66.666667%;-}-.schema-editor-table-column-editor :deep(.n-data-table-td.input-cell) {- padding-left: 0.125rem;- padding-right: 0.25rem;- padding-top: 0;- padding-bottom: 0;-}-.schema-editor-table-column-editor- :deep(.n-data-table-td.input-cell .n-input__placeholder),-.schema-editor-table-column-editor- :deep(.n-data-table-td.input-cell .n-base-selection-placeholder) {- font-style: italic;-}-.schema-editor-table-column-editor :deep(.n-data-table-td.checkbox-cell) {- padding-right: 0.25rem;- padding-top: 0;- padding-bottom: 0;-}-.schema-editor-table-column-editor :deep(.n-data-table-td.text-cell) {- padding-right: 0.25rem;- padding-top: 0;- padding-bottom: 0;-}-.schema-editor-table-column-editor:not(.disable-diff-coloring)- :deep(.n-data-table-tr.created .n-data-table-td) {- color: var(--color-green-700);- background-color: var(--color-green-50) !important;-}-.schema-editor-table-column-editor:not(.disable-diff-coloring)- :deep(.n-data-table-tr.dropped .n-data-table-td) {- color: var(--color-red-700);- cursor: not-allowed;- background-color: var(--color-red-50) !important;- opacity: 0.7;-}-.schema-editor-table-column-editor:not(.disable-diff-coloring)- :deep(.n-data-table-tr.updated .n-data-table-td) {- color: var(--color-yellow-700);- background-color: var(--color-yellow-50) !important;-}-</style>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/DataTypeCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/DataTypeCell.vuedeleted file mode 100644index 8cb93105b3..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/DataTypeCell.vue+++ /dev/null@@ -1,99 +0,0 @@-<template>- <DropdownInput- :value="column.type || null"- :allow-input-value="allowInputValue"- :options="columnTypeOptions"- :consistent-menu-width="true"- :allow-filter="allowFilter"- :style="style"- suffix-style="right: 3px"- placeholder="column type"- class="bb-schema-editor--column-data-type-select"- @focus="focused = true"- @blur="focused = false"- @update:value="$emit('update:value', $event)"- />-</template>--<script lang="ts" setup>-import type { SelectOption } from "naive-ui";-import type { CSSProperties } from "vue";-import { computed, onMounted, ref } from "vue";-import { DropdownInput } from "@/components/v2";-import type { Engine } from "@/types/proto-es/v1/common_pb";-import type { ColumnMetadata } from "@/types/proto-es/v1/database_service_pb";-import { getDataTypeSuggestionList } from "@/utils";--const props = defineProps<{- column: ColumnMetadata;- readonly?: boolean;- engine: Engine;- schemaTemplateColumnTypes: string[];-}>();-defineEmits<{- (event: "update:value", value: string): void;-}>();--const focused = ref(false);-const originalType = ref("");--onMounted(() => (originalType.value = props.column.type));--const allowFilter = computed(() => {- return !props.column.type || originalType.value !== props.column.type;-});--const allowInputValue = computed(() => {- return props.schemaTemplateColumnTypes.length === 0;-});--const columnTypeOptions = computed(() => {- const { schemaTemplateColumnTypes, engine } = props;- if (allowInputValue.value) {- return getDataTypeSuggestionList(engine).map<SelectOption>((dataType) => {- return {- value: dataType,- label: dataType,- };- });- }- return schemaTemplateColumnTypes.map<SelectOption>((columnType) => {- return {- value: columnType,- label: columnType,- };- });-});--const style = computed(() => {- const style: CSSProperties = {- "--n-padding-left": "6px",- "--n-padding-right": "16px",- "--n-color": "transparent",- "--n-color-disabled": "transparent",- "--n-text-color-disabled": "rgb(var(--color-main))",- cursor: "default",- };- const border = focused.value- ? "1px solid rgb(var(--color-control-border))"- : "none";- style["--n-border"] = border;- style["--n-border-disabled"] = border;-- return style;-});-</script>--<style lang="postcss" scoped>-.bb-schema-editor--column-data-type-select :deep(.n-base-selection) {- --n-padding-single: 0 16px 0 6px !important;- --n-color: transparent !important;- --n-color-disabled: transparent !important;- --n-border: none !important;- --n-text-color-disabled: rgb(var(--color-main)) !important;-}-.bb-schema-editor--column-data-type-select- :deep(.n-base-selection .n-base-suffix) {- right: 4px;-}-</style>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/DefaultValueCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/DefaultValueCell.vuedeleted file mode 100644index 2a2dc87fe6..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/DefaultValueCell.vue+++ /dev/null@@ -1,64 +0,0 @@-<template>- <NInput- ref="inputRef"- :value="column.default"- :placeholder="$t('schema-editor.default.placeholder')"- :disabled="disabled"- :style="simpleInputStyle"- @focus="focused = true"- @blur="focused = false"- @update:value="handleSimpleInput"- />-</template>--<script lang="ts" setup>-import { type InputInst, NInput } from "naive-ui";-import type { CSSProperties } from "vue";-import { computed, ref } from "vue";-import type { DefaultValue } from "@/components/SchemaEditorLite/utils";-import type { ColumnMetadata } from "@/types/proto-es/v1/database_service_pb";--const props = withDefaults(- defineProps<{- column: ColumnMetadata;- disabled?: boolean;- border?: string;- }>(),- {- border: "none",- }-);--const emit = defineEmits<{- (event: "update", option: DefaultValue): void;-}>();--const focused = ref(false);-const inputRef = ref<InputInst>();--const simpleInputStyle = computed(() => {- const style: CSSProperties = {- cursor: "default",- "--n-color": "transparent",- "--n-color-disabled": "transparent",- "--n-padding-left": "6px",- "--n-padding-right": "4px",- "--n-text-color-disabled": "rgb(var(--color-main))",- };- const border = focused.value- ? "1px solid rgb(var(--color-control-border))"- : props.border;- style["--n-border"] = border;- style["--n-border-disabled"] = border;-- return style;-});--const handleSimpleInput = (value: string) => {- const defaultValue = {- hasDefault: !!value.trim(),- default: value.trim(), // Both PostgreSQL and MySQL use default for now- };- emit("update", defaultValue);-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/ForeignKeyCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/ForeignKeyCell.vuedeleted file mode 100644index 24e0ff9cf3..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/ForeignKeyCell.vue+++ /dev/null@@ -1,100 +0,0 @@-<template>- <div- v-for="fk in foreignKeys"- :key="fk.name"- class="flex flex-row flex-wrap items-center break-all"- >- <span @click="$emit('click', fk)">- {{ referencedNameForFk(fk) }}- </span>-- <MiniActionButton- v-if="!readonly"- :disabled="disabled"- @click="$emit('edit', fk)"- >- <PenSquareIcon class="w-4 h-4" />- </MiniActionButton>- </div>-- <div- v-if="foreignKeys.length === 0"- class="flex flex-row flex-wrap items-center break-all"- >- <span class="italic text-control-placeholder">EMPTY</span>- <MiniActionButton- v-if="!readonly"- :disabled="disabled"- @click="$emit('edit', undefined)"- >- <PenSquareIcon class="w-4 h-4" />- </MiniActionButton>- </div>-</template>--<script lang="ts" setup>-import { PenSquareIcon } from "lucide-vue-next";-import { computed } from "vue";-import { MiniActionButton } from "@/components/v2";-import type {- ColumnMetadata,- Database,- DatabaseMetadata,- ForeignKeyMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { getDatabaseEngine } from "@/utils";-import { engineSupportsMultiSchema } from "../../../spec";--const props = defineProps<{- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- column: ColumnMetadata;- readonly?: boolean;- disabled: boolean;-}>();-defineEmits<{- (event: "click", fk: ForeignKeyMetadata): void;- (event: "edit", fk: ForeignKeyMetadata | undefined): void;-}>();--const foreignKeys = computed(() => {- return props.table.foreignKeys.filter((fk) =>- fk.columns.includes(props.column.name)- );-});--const referencedNameForFk = (fk: ForeignKeyMetadata) => {- const position = fk.columns.indexOf(props.column.name);- if (position < 0) {- return "";- }-- const referencedSchema = props.database.schemas.find(- (schema) => schema.name === fk.referencedSchema- );- if (!referencedSchema) {- return "";- }-- const referencedTable = referencedSchema.tables.find(- (table) => table.name === fk.referencedTable- );- if (!referencedTable) {- return "";- }-- const referencedColumn = referencedTable.columns.find(- (column) => column.name === fk.referencedColumns[position]- );-- if (engineSupportsMultiSchema(getDatabaseEngine(props.db))) {- return `${referencedSchema.name}.${referencedTable.name}(${referencedColumn?.name})`;- } else {- return `${referencedTable.name}(${referencedColumn?.name})`;- }-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/OperationCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/OperationCell.vuedeleted file mode 100644index effe6e41f9..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/OperationCell.vue+++ /dev/null@@ -1,39 +0,0 @@-<template>- <div class="flex justify-start items-center">- <NTooltip v-if="!dropped" trigger="hover" to="body">- <template #trigger>- <MiniActionButton tag="div" :disabled="disabled" @click="$emit('drop')">- <TrashIcon class="w-4 h-4" />- </MiniActionButton>- </template>- <span>{{ $t("schema-editor.actions.drop-column") }}</span>- </NTooltip>- <NTooltip v-else trigger="hover" to="body">- <template #trigger>- <MiniActionButton- tag="div"- :disabled="disabled"- @click="$emit('restore')"- >- <Undo2Icon class="w-4 h-4" />- </MiniActionButton>- </template>- <span>{{ $t("schema-editor.actions.restore") }}</span>- </NTooltip>- </div>-</template>--<script lang="ts" setup>-import { TrashIcon, Undo2Icon } from "lucide-vue-next";-import { NTooltip } from "naive-ui";-import { MiniActionButton } from "@/components/v2";--defineProps<{- dropped?: boolean;- disabled?: boolean;-}>();-defineEmits<{- (event: "drop"): void;- (event: "restore"): void;-}>();-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/ReorderCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/ReorderCell.vuedeleted file mode 100644index 9b238e942f..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/ReorderCell.vue+++ /dev/null@@ -1,29 +0,0 @@-<template>- <div class="flex justify-start items-center">- <MiniActionButton- :disabled="disabled || !allowMoveUp"- @click="$emit('reorder', -1)"- >- <ChevronUpIcon class="w-4 h-4" />- </MiniActionButton>- <MiniActionButton- :disabled="disabled || !allowMoveDown"- @click="$emit('reorder', 1)"- >- <ChevronDownIcon class="w-4 h-4" />- </MiniActionButton>- </div>-</template>-<script setup lang="ts">-import { ChevronDownIcon, ChevronUpIcon } from "lucide-vue-next";-import { MiniActionButton } from "@/components/v2";--defineProps<{- allowMoveUp?: boolean;- allowMoveDown?: boolean;- disabled?: boolean;-}>();-defineEmits<{- (event: "reorder", delta: -1 | 1): void;-}>();-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/SelectionCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/SelectionCell.vuedeleted file mode 100644index 3ca3603d6a..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/SelectionCell.vue+++ /dev/null@@ -1,39 +0,0 @@-<template>- <NCheckbox- :checked="state.checked"- :indeterminate="state.indeterminate"- @update:checked="update"- />-</template>--<script setup lang="ts">-import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useSchemaEditorContext } from "@/components/SchemaEditorLite/context";-import type {- ColumnMetadata,- Database,- DatabaseMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";--const props = defineProps<{- db: Database;- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- column: ColumnMetadata;- };-}>();-const { getColumnSelectionState, updateColumnSelection } =- useSchemaEditorContext();--const state = computed(() => {- return getColumnSelectionState(props.db, props.metadata);-});-const update = (on: boolean) => {- updateColumnSelection(props.db, props.metadata, on);-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/index.ts b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/index.tsdeleted file mode 100644index 4d405a90af..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/index.ts+++ /dev/null@@ -1,15 +0,0 @@-import DataTypeCell from "./DataTypeCell.vue";-import DefaultValueCell from "./DefaultValueCell.vue";-import ForeignKeyCell from "./ForeignKeyCell.vue";-import OperationCell from "./OperationCell.vue";-import ReorderCell from "./ReorderCell.vue";-import SelectionCell from "./SelectionCell.vue";--export {- ReorderCell,- SelectionCell,- DataTypeCell,- DefaultValueCell,- ForeignKeyCell,- OperationCell,-};diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/index.ts b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/index.tsdeleted file mode 100644index 17ba45a252..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import TableColumnEditor from "./TableColumnEditor.vue";--export default TableColumnEditor;diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableEditor.vue b/frontend/src/components/SchemaEditorLite/Panels/TableEditor.vuedeleted file mode 100644index 1d79913c0d..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableEditor.vue+++ /dev/null@@ -1,480 +0,0 @@-<template>- <div- class="flex flex-col pt-2 gap-y-2 w-full h-full overflow-y-hidden"- v-bind="$attrs"- >- <div class="w-full flex flex-row justify-between items-center px-2">- <div class="w-full flex justify-start items-center gap-x-2">- <slot v-if="state.mode === 'COLUMNS'" name="toolbar-prefix" />-- <template- v-if="state.mode === 'INDEXES' || state.mode === 'PARTITIONS'"- >- <NButton size="small" @click="state.mode = 'COLUMNS'">- <ArrowLeftIcon class="w-4 h-4" />- </NButton>- <template v-if="!readonly">- <NButton- v-if="state.mode === 'INDEXES'"- size="small"- @click="handleAddIndex"- >- <PlusIcon class="w-4 h-4 mr-1" />- {{ $t("common.add") }}- </NButton>- <NButton- v-if="state.mode === 'PARTITIONS'"- size="small"- @click="handleAddPartition"- >- <PlusIcon class="w-4 h-4 mr-1" />- {{ $t("common.add") }}- </NButton>- </template>- </template>- <template v-if="state.mode === 'COLUMNS'">- <template v-if="!readonly">- <NButton- size="small"- :disabled="disableChangeTable"- @click="handleAddColumn"- >- <PlusIcon class="w-4 h-auto mr-1 text-gray-400" />- {{ $t("schema-editor.actions.add-column") }}- </NButton>- </template>- <NButton- v-if="showIndexes"- size="small"- :disabled="disableChangeTable"- @click="state.mode = 'INDEXES'"- >- <IndexIcon class="mr-1" />- {{- readonly- ? $t("schema-editor.index.indexes")- : $t("schema-editor.index.edit-indexes")- }}- </NButton>- <NButton- v-if="showPartitions"- size="small"- :disabled="disableChangeTable"- @click="state.mode = 'PARTITIONS'"- >- <TablePartitionIcon class="w-3 h-3 mr-1" />- {{- readonly- ? $t("schema-editor.table-partition.partitions")- : $t("schema-editor.table-partition.edit-partitions")- }}- </NButton>- </template>- </div>- <div class="text-sm flex flex-row items-center justify-end gap-x-2">- <div- v-if="selectionEnabled"- class="text-sm flex flex-row items-center gap-x-2 h-[28px] whitespace-nowrap"- >- <span class="text-main">- {{ $t("branch.select-tables-to-rollout") }}- </span>- <ColumnSelectionSummary- :db="db"- :metadata="{- database,- schema,- table,- }"- />- </div>- </div>- </div>-- <div class="flex-1 overflow-y-hidden px-2">- <TableColumnEditor- :show="state.mode === 'COLUMNS'"- :readonly="readonly"- :show-foreign-key="true"- :db="db"- :database="database"- :schema="schema"- :table="table"- :engine="engine"- :disable-change-table="disableChangeTable"- :allow-change-primary-keys="allowChangePrimaryKeys"- :allow-reorder-columns="allowReorderColumns"- :filter-column="- (column: ColumnMetadata) =>- column.name.includes(props.searchPattern.trim())- "- :disable-alter-column="disableAlterColumn"- :show-database-catalog-column="false"- @foreign-key-edit="handleEditColumnForeignKey"- @foreign-key-click="gotoForeignKeyReferencedTable"- />- <IndexesEditor- :show="state.mode === 'INDEXES'"- :readonly="readonly"- :db="db"- :database="database"- :schema="schema"- :table="table"- @update="markTableStatus('updated')"- />- <PartitionsEditor- :show="state.mode === 'PARTITIONS'"- :readonly="readonly"- :db="db"- :database="database"- :schema="schema"- :table="table"- @update="markTableStatus('updated')"- />- </div>-- <PreviewPane- :db="db"- :database="database"- :schema="schema"- :title="$t('schema-editor.preview-schema-text')"- :mocked="mocked"- />- </div>-- <EditColumnForeignKeyModal- v-if="state.showEditColumnForeignKeyModal && editForeignKeyContext"- :database="db"- :metadata="database"- :schema="schema"- :table="table"- :column="editForeignKeyContext.column"- :foreign-key="editForeignKeyContext.foreignKey"- @close="state.showEditColumnForeignKeyModal = false"- />-</template>--<script lang="ts" setup>-import { create } from "@bufbuild/protobuf";-import { cloneDeep, head } from "lodash-es";-import { ArrowLeftIcon, PlusIcon } from "lucide-vue-next";-import { NButton } from "naive-ui";-import { computed, reactive, ref } from "vue";-import { IndexIcon, TablePartitionIcon } from "@/components/Icon";-import { Engine } from "@/types/proto-es/v1/common_pb";-import type {- ColumnMetadata,- Database,- DatabaseMetadata,- ForeignKeyMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import {- ColumnMetadataSchema,- DatabaseMetadataSchema,- IndexMetadataSchema,- TablePartitionMetadata_Type,- TablePartitionMetadataSchema,-} from "@/types/proto-es/v1/database_service_pb";-import {- getDatabaseEngine,- instanceV1AllowsReorderColumns,- randomString,-} from "@/utils";-import { useSchemaEditorContext } from "../context";-import EditColumnForeignKeyModal from "../Modals/EditColumnForeignKeyModal.vue";-import {- engineSupportsEditIndexes,- engineSupportsEditTablePartitions,-} from "../spec";-import type { EditStatus } from "../types";-import ColumnSelectionSummary from "./ColumnSelectionSummary.vue";-import IndexesEditor from "./IndexesEditor";-import PartitionsEditor from "./PartitionsEditor";-import PreviewPane from "./PreviewPane.vue";-import TableColumnEditor from "./TableColumnEditor";--type EditMode = "COLUMNS" | "INDEXES" | "PARTITIONS";--const props = withDefaults(- defineProps<{- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- searchPattern?: string;- }>(),- {- searchPattern: "",- }-);--interface LocalState {- mode: EditMode;- showEditColumnForeignKeyModal: boolean;- showFeatureModal: boolean;-}--const {- readonly,- events,- options,- addTab,- markEditStatus,- getSchemaStatus,- getTableStatus,- getColumnStatus,- queuePendingScrollToColumn,- selectionEnabled,-} = useSchemaEditorContext();--const engine = computed((): Engine => {- return getDatabaseEngine(props.db);-});-const state = reactive<LocalState>({- mode: "COLUMNS",- showEditColumnForeignKeyModal: false,- showFeatureModal: false,-});--const editForeignKeyContext = ref<{- column: ColumnMetadata;- foreignKey: ForeignKeyMetadata | undefined;-}>();--const metadataForColumn = (column: ColumnMetadata) => {- return {- database: props.database,- schema: props.schema,- table: props.table,- column,- };-};--const statusForSchema = () => {- return getSchemaStatus(props.db, {- schema: props.schema,- });-};--const statusForTable = () => {- return getTableStatus(props.db, {- schema: props.schema,- table: props.table,- });-};--const statusForColumn = (column: ColumnMetadata) => {- return getColumnStatus(props.db, metadataForColumn(column));-};--const markColumnStatus = (column: ColumnMetadata, status: EditStatus) => {- markEditStatus(props.db, metadataForColumn(column), status);-};--const isDroppedSchema = computed(() => {- return statusForSchema() === "dropped";-});--const isDroppedTable = computed(() => {- return statusForTable() === "dropped";-});--const isDroppedColumn = (column: ColumnMetadata): boolean => {- return statusForColumn(column) === "dropped";-};--const disableChangeTable = computed(() => {- return isDroppedSchema.value || isDroppedTable.value;-});--const allowChangePrimaryKeys = computed(() => {- return statusForTable() === "created";-});--const allowReorderColumns = computed(() => {- if (props.searchPattern.trim().length !== 0) {- // The column keyword filter will break the original indexes of columns- return false;- }-- const status = statusForTable();- return instanceV1AllowsReorderColumns(engine.value) && status === "created";-});--const showIndexes = computed(() => {- if (options?.value.forceShowIndexes) {- return props.table.indexes.length > 0;- }- return engineSupportsEditIndexes(engine.value);-});--const showPartitions = computed(() => {- if (options?.value.forceShowPartitions) {- return props.table.partitions.length > 0;- }- return engineSupportsEditTablePartitions(engine.value);-});--const disableAlterColumn = (column: ColumnMetadata): boolean => {- return (- isDroppedSchema.value || isDroppedTable.value || isDroppedColumn(column)- );-};--const handleAddColumn = () => {- const column = create(ColumnMetadataSchema, {});- /* eslint-disable-next-line vue/no-mutating-props */- props.table.columns.push(column);- markColumnStatus(column, "created");-- queuePendingScrollToColumn({- db: props.db,- metadata: {- database: props.database,- schema: props.schema,- table: props.table,- column,- },- });-- events.emit("rebuild-tree", {- openFirstChild: false,- });-};-const handleAddIndex = () => {- // eslint-disable-next-line vue/no-mutating-props- props.table.indexes.push(- create(IndexMetadataSchema, {- name: `${props.table.name}_index_${randomString(8).toLowerCase()}`,- })- );- markTableStatus("updated");-};-const handleAddPartition = () => {- const first = head(props.table.partitions);- const partition = create(TablePartitionMetadataSchema, {- type: first?.type ?? TablePartitionMetadata_Type.HASH,- expression: first?.expression ?? "",- });- // eslint-disable-next-line vue/no-mutating-props- props.table.partitions.push(partition);- markEditStatus(- props.db,- {- schema: props.schema,- table: props.table,- partition,- },- "created"- );- markTableStatus("updated");-};--const gotoForeignKeyReferencedTable = (- column: ColumnMetadata,- fk: ForeignKeyMetadata-) => {- const position = fk.columns.indexOf(column.name);- if (position < 0) {- return;- }- const referencedColumnName = fk.referencedColumns[position];- if (!referencedColumnName) {- return;- }- const referencedSchema = props.database.schemas.find(- (schema) => schema.name === fk.referencedSchema- );- if (!referencedSchema) {- return;- }- const referencedTable = referencedSchema.tables.find(- (table) => table.name === fk.referencedTable- );- if (!referencedTable) {- return;- }- const referencedColumn = referencedTable.columns.find(- (column) => column.name === referencedColumnName- );- if (!referencedColumn) {- return;- }-- addTab({- type: "table",- database: props.db,- metadata: {- database: props.database,- schema: referencedSchema,- table: referencedTable,- },- });-- queuePendingScrollToColumn({- db: props.db,- metadata: {- database: props.database,- schema: referencedSchema,- table: referencedTable,- column: referencedColumn,- },- });-};--const handleEditColumnForeignKey = (- column: ColumnMetadata,- foreignKey: ForeignKeyMetadata | undefined-) => {- editForeignKeyContext.value = {- column,- foreignKey,- };- state.showEditColumnForeignKeyModal = true;-};--const mocked = computed(() => {- const { db, database, schema, table } = props;-- const mockedTable = cloneDeep(table);- mockedTable.columns = mockedTable.columns.filter((column) => {- if (!column.name) {- return false;- }- const status = getColumnStatus(db, { schema, table, column });- return status !== "dropped";- });- const mockedDatabase = create(DatabaseMetadataSchema, {- name: database.name,- characterSet: database.characterSet,- collation: database.collation,- schemas: [- {- name: schema.name,- tables: [mockedTable],- },- ],- });- return { metadata: mockedDatabase };-});--const markTableStatus = (status: EditStatus) => {- const oldStatus = statusForTable();- if (- (oldStatus === "created" || oldStatus === "dropped") &&- status === "updated"- ) {- return;- }- markEditStatus(- props.db,- {- schema: props.schema,- table: props.table,- },- status- );-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableList/TableList.vue b/frontend/src/components/SchemaEditorLite/Panels/TableList/TableList.vuedeleted file mode 100644index 60ba6c2cac..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableList/TableList.vue+++ /dev/null@@ -1,327 +0,0 @@-<template>- <div- ref="containerElRef"- class="w-full h-full overflow-x-auto"- :data-height="containerHeight"- :data-table-header-height="tableHeaderHeight"- :data-table-body-height="tableBodyHeight"- >- <NDataTable- v-bind="$attrs"- ref="dataTableRef"- size="small"- :row-key="getTableKey"- :columns="columns"- :data="layoutReady ? filteredTables : []"- :row-class-name="classesForRow"- :max-height="tableBodyHeight"- :virtual-scroll="true"- :striped="true"- :bordered="true"- :bottom-bordered="true"- class="schema-editor-table-list"- />- </div>-</template>--<script lang="ts" setup>-import { useElementSize } from "@vueuse/core";-import { pick } from "lodash-es";-import type { DataTableColumn, DataTableInst } from "naive-ui";-import { NCheckbox, NDataTable } from "naive-ui";-import { computed, h, ref } from "vue";-import { useI18n } from "vue-i18n";-import { InlineInput } from "@/components/v2";-import type {- Database,- DatabaseMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { useSchemaEditorContext } from "../../context";-import { markUUID } from "../common";-import { NameCell, OperationCell, SelectionCell } from "./components";--const props = defineProps<{- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- tables: TableMetadata[];- searchPattern?: string;- customClick?: boolean;-}>();--const emit = defineEmits<{- (- event: "click",- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- }- ): void;-}>();--const { t } = useI18n();-const {- readonly,- selectionEnabled,- addTab,- markEditStatus,- removeEditStatus,- getSchemaStatus,- getTableStatus,- useConsumePendingScrollToTable,- getAllTablesSelectionState,- updateAllTablesSelection,-} = useSchemaEditorContext();--const dataTableRef = ref<DataTableInst>();-const containerElRef = ref<HTMLElement>();-const tableHeaderElRef = computed(- () =>- containerElRef.value?.querySelector("thead.n-data-table-thead") as- | HTMLElement- | undefined-);-const { height: containerHeight } = useElementSize(containerElRef);-const { height: tableHeaderHeight } = useElementSize(tableHeaderElRef);-const tableBodyHeight = computed(() => {- return containerHeight.value - tableHeaderHeight.value - 2;-});-// Use this to avoid unnecessary initial rendering-const layoutReady = computed(() => tableHeaderHeight.value > 0);-const filteredTables = computed(() => {- const keyword = props.searchPattern?.trim();- if (!keyword) {- return props.tables;- }- return props.tables.filter((table) => table.name.includes(keyword));-});--const metadataForTable = (table: TableMetadata) => {- return {- database: props.database,- schema: props.schema,- table,- };-};--const statusForTable = (table: TableMetadata) => {- return getTableStatus(props.db, metadataForTable(table));-};--const classesForRow = (table: TableMetadata) => {- return statusForTable(table);-};--const isDroppedSchema = computed(() => {- return (- getSchemaStatus(props.db, {- schema: props.schema,- }) === "dropped"- );-});--const columns = computed(() => {- const columns: (DataTableColumn<TableMetadata> & { hide?: boolean })[] = [- {- key: "__selected__",- width: 32,- hide: !selectionEnabled.value,- title: () => {- const state = getAllTablesSelectionState(- props.db,- pick(props, "database", "schema"),- filteredTables.value- );- return h(NCheckbox, {- checked: state.checked,- indeterminate: state.indeterminate,- onUpdateChecked: (on: boolean) => {- updateAllTablesSelection(- props.db,- pick(props, "database", "schema"),- filteredTables.value,- on- );- },- });- },- render: (table) => {- return h(SelectionCell, {- db: props.db,- metadata: {- ...pick(props, "database", "schema"),- table,- },- });- },- },- {- key: "name",- title: t("schema-editor.database.name"),- resizable: true,- minWidth: 140,- className: "truncate",- render: (table) => {- return h(NameCell, {- table,- onClick: () => handleTableItemClick(table),- });- },- },- {- key: "engine",- title: t("schema-editor.database.engine"),- resizable: true,- minWidth: 120,- maxWidth: 180,- render: (table) => {- return table.engine;- },- },- {- key: "collation",- title: t("schema-editor.database.collation"),- resizable: true,- minWidth: 120,- maxWidth: 180,- ellipsis: true,- ellipsisComponent: "performant-ellipsis",- },- {- key: "comment",- title: t("schema-editor.database.comment"),- resizable: true,- minWidth: 140,- maxWidth: 320,- className: "input-cell",- render: (table) => {- return h(InlineInput, {- value: table.comment,- disabled:- readonly.value || isDroppedSchema.value || isDroppedTable(table),- placeholder: "comment",- style: {- "--n-padding-left": "6px",- "--n-padding-right": "4px",- "--n-text-color-disabled": "rgb(var(--color-main))",- },- "onUpdate:value": (value) => {- table.comment = value;- markEditStatus(props.db, metadataForTable(table), "updated");- },- });- },- },- {- key: "operations",- title: "",- resizable: false,- width: 30,- hide: readonly.value,- className: "px-0!",- render: (table) => {- return h(OperationCell, {- table,- dropped: isDroppedTable(table),- disabled: isDroppedSchema.value,- onDrop: () => handleDropTable(table),- onRestore: () => handleRestoreTable(table),- });- },- },- ];- return columns.filter((header) => !header.hide);-});--const handleTableItemClick = (table: TableMetadata) => {- if (props.customClick) {- emit("click", metadataForTable(table));- return;- }- addTab({- type: "table",- database: props.db,- metadata: metadataForTable(table),- });-};--const handleDropTable = (table: TableMetadata) => {- // We don't physically remove it, mark it as 'dropped' instead- // If it a 'created' table, it will remains till the page is refreshed.- markEditStatus(props.db, metadataForTable(table), "dropped");-};--const handleRestoreTable = (table: TableMetadata) => {- removeEditStatus(props.db, metadataForTable(table), /* recursive */ false);-};--const isDroppedTable = (table: TableMetadata) => {- return statusForTable(table) === "dropped";-};--const getTableKey = (table: TableMetadata) => {- return markUUID(table);-};--const vlRef = computed(() => {- // biome-ignore lint/suspicious/noExplicitAny: accessing internal naive-ui refs- return (dataTableRef.value as any)?.$refs?.mainTableInstRef?.bodyInstRef // eslint-disable-line @typescript-eslint/no-explicit-any- ?.virtualListRef;-});-useConsumePendingScrollToTable(- computed(() => ({- db: props.db,- metadata: {- database: props.database,- schema: props.schema,- },- })),- vlRef,- (params, vl) => {- const key = getTableKey(params.metadata.table);- if (!key) return;- requestAnimationFrame(() => {- try {- console.debug("scroll-to-table", vl, params, key);- vl.scrollTo({ key });- } catch {- // Do nothing- }- });- }-);-</script>--<style lang="postcss" scoped>-.schema-editor-table-list- :deep(.n-data-table-th .n-data-table-resize-button::after) {- background-color: var(--color-control-bg);- height: 66.666667%;-}-.schema-editor-table-list :deep(.n-data-table-td.input-cell) {- padding-left: 0.125rem;- padding-right: 0.25rem;- padding-top: 0;- padding-bottom: 0;-}-.schema-editor-table-list:not(.disable-diff-coloring)- :deep(.n-data-table-tr.created .n-data-table-td) {- color: var(--color-green-700);- background-color: var(--color-green-50) !important;-}-.schema-editor-table-list:not(.disable-diff-coloring)- :deep(.n-data-table-tr.dropped .n-data-table-td) {- color: var(--color-red-700);- background-color: var(--color-red-50) !important;- opacity: 0.7;-}--.schema-editor-table-list:not(.disable-diff-coloring)- :deep(.n-data-table-tr.updated .n-data-table-td) {- color: var(--color-yellow-700);- background-color: var(--color-yellow-50) !important;-}-</style>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableList/components/NameCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableList/components/NameCell.vuedeleted file mode 100644index 07892751d7..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableList/components/NameCell.vue+++ /dev/null@@ -1,21 +0,0 @@-<template>- <NPerformantEllipsis- class="w-full cursor-pointer leading-6 hover:text-accent"- >- <span @click="$emit('click')">- {{ table.name }}- </span>- </NPerformantEllipsis>-</template>--<script lang="ts" setup>-import { NPerformantEllipsis } from "naive-ui";-import type { TableMetadata } from "@/types/proto-es/v1/database_service_pb";--defineProps<{- table: TableMetadata;-}>();-defineEmits<{- (event: "click"): void;-}>();-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableList/components/OperationCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableList/components/OperationCell.vuedeleted file mode 100644index 3ca6174e4c..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableList/components/OperationCell.vue+++ /dev/null@@ -1,40 +0,0 @@-<template>- <div class="flex justify-start items-center">- <NTooltip v-if="!dropped" trigger="hover" to="body">- <template #trigger>- <MiniActionButton tag="div" :disabled="disabled" @click="$emit('drop')">- <TrashIcon class="w-4 h-4" />- </MiniActionButton>- </template>- <span>{{ $t("schema-editor.actions.drop-table") }}</span>- </NTooltip>- <NTooltip v-else trigger="hover" to="body">- <template #trigger>- <MiniActionButton- tag="div"- :disabled="disabled"- @click="$emit('restore')"- >- <Undo2Icon class="w-4 h-4" />- </MiniActionButton>- </template>- <span>{{ $t("schema-editor.actions.restore") }}</span>- </NTooltip>- </div>-</template>-<script lang="ts" setup>-import { TrashIcon, Undo2Icon } from "lucide-vue-next";-import { NTooltip } from "naive-ui";-import { MiniActionButton } from "@/components/v2";-import type { TableMetadata } from "@/types/proto-es/v1/database_service_pb";--defineProps<{- table: TableMetadata;- dropped?: boolean;- disabled?: boolean;-}>();-defineEmits<{- (event: "drop"): void;- (event: "restore"): void;-}>();-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableList/components/SelectionCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableList/components/SelectionCell.vuedeleted file mode 100644index 0d088c1dc7..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableList/components/SelectionCell.vue+++ /dev/null@@ -1,37 +0,0 @@-<template>- <NCheckbox- :checked="state.checked"- :indeterminate="state.indeterminate"- @update:checked="update"- />-</template>--<script setup lang="ts">-import { NCheckbox } from "naive-ui";-import { computed } from "vue";-import { useSchemaEditorContext } from "@/components/SchemaEditorLite/context";-import type {- Database,- DatabaseMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";--const props = defineProps<{- db: Database;- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- };-}>();-const { getTableSelectionState, updateTableSelection } =- useSchemaEditorContext();--const state = computed(() => {- return getTableSelectionState(props.db, props.metadata);-});-const update = (on: boolean) => {- updateTableSelection(props.db, props.metadata, on);-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableList/components/index.ts b/frontend/src/components/SchemaEditorLite/Panels/TableList/components/index.tsdeleted file mode 100644index 5895fa2fd3..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableList/components/index.ts+++ /dev/null@@ -1,5 +0,0 @@-import NameCell from "./NameCell.vue";-import OperationCell from "./OperationCell.vue";-import SelectionCell from "./SelectionCell.vue";--export { SelectionCell, NameCell, OperationCell };diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableList/index.ts b/frontend/src/components/SchemaEditorLite/Panels/TableList/index.tsdeleted file mode 100644index 71642de4c4..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableList/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import TableList from "./TableList.vue";--export default TableList;diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableSelectionSummary.vue b/frontend/src/components/SchemaEditorLite/Panels/TableSelectionSummary.vuedeleted file mode 100644index 429faddd53..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/TableSelectionSummary.vue+++ /dev/null@@ -1,40 +0,0 @@-<template>- <span class="text-control-placeholder">- ({{ summary.selected }} / {{ summary.total }})- </span>-</template>--<script setup lang="ts">-import { computed } from "vue";-import type {- Database,- DatabaseMetadata,- SchemaMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { useSchemaEditorContext } from "../context";--const props = defineProps<{- db: Database;- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- };-}>();--const { getTableSelectionState } = useSchemaEditorContext();--const summary = computed(() => {- const { tables } = props.metadata.schema;- const selectedTables = tables.filter((table) => {- const state = getTableSelectionState(props.db, {- ...props.metadata,- table,- });- return state.checked || state.indeterminate;- });- return {- selected: selectedTables.length,- total: tables.length,- };-});-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/ViewEditor.vue b/frontend/src/components/SchemaEditorLite/Panels/ViewEditor.vuedeleted file mode 100644index f1930de67a..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/ViewEditor.vue+++ /dev/null@@ -1,103 +0,0 @@-<template>- <CommonCodeEditor- :db="db"- :code="view.definition"- :readonly="disallowChangeView"- :status="status"- @update:code="handleUpdateDefinition"- >- <template #preview>- <PreviewPane- :db="db"- :database="database"- :schema="schema"- :mocked="mocked"- :title="$t('schema-editor.preview-view-definition')"- />- </template>- </CommonCodeEditor>-</template>--<script setup lang="ts">-import { create } from "@bufbuild/protobuf";-import { cloneDeep } from "lodash-es";-import { computed } from "vue";-import type {- Database,- DatabaseMetadata,- SchemaMetadata,- ViewMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import { DatabaseMetadataSchema } from "@/types/proto-es/v1/database_service_pb";-import { useSchemaEditorContext } from "../context";-import type { EditStatus } from "../types";-import CommonCodeEditor from "./CommonCodeEditor.vue";-import PreviewPane from "./PreviewPane.vue";--const props = defineProps<{- db: Database;- database: DatabaseMetadata;- schema: SchemaMetadata;- view: ViewMetadata;-}>();--const { readonly, markEditStatus, getSchemaStatus, getViewStatus } =- useSchemaEditorContext();--const statusForSchema = () => {- return getSchemaStatus(props.db, {- schema: props.schema,- });-};-const status = computed(() => {- return getViewStatus(props.db, {- schema: props.schema,- view: props.view,- });-});-const markStatus = (status: EditStatus) => {- markEditStatus(- props.db,- {- schema: props.schema,- view: props.view,- },- status- );-};--const disallowChangeView = computed(() => {- if (readonly.value) {- return true;- }- return statusForSchema() === "dropped" || status.value === "dropped";-});--const mocked = computed(() => {- const { database, schema, view } = props;-- const mockedView = cloneDeep(view);- const mockedDatabase = create(DatabaseMetadataSchema, {- name: database.name,- characterSet: database.characterSet,- collation: database.collation,- schemas: [- {- name: schema.name,- views: [mockedView],- },- ],- });-- return { metadata: mockedDatabase };-});--const handleUpdateDefinition = (code: string) => {- // eslint-disable-next-line vue/no-mutating-props- props.view.definition = code;-- if (status.value === "normal") {- markStatus("updated");- }-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/Panels/common/common.ts b/frontend/src/components/SchemaEditorLite/Panels/common/common.tsdeleted file mode 100644index 9bfd0f75e3..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/common/common.ts+++ /dev/null@@ -1,41 +0,0 @@-import { v1 as uuidv1 } from "uuid";-import type { EditStatus } from "../../types";--// Hidden properties added to schema objects-interface HiddenProps {- __uuid?: string;- __status_before_drop?: EditStatus;-}--type ObjectWithHiddenProps = object & HiddenProps;--export const markUUID = (obj: object): string => {- // column.name is editable, so we need to insert another hidden field- // as a column's stable unique key.- const target = obj as ObjectWithHiddenProps;- if (!target.__uuid) {- // Make this field 'invisible' to avoid it breaks lodash's deep comparing- Object.defineProperty(obj, "__uuid", {- enumerable: false,- writable: false,- configurable: false,- value: uuidv1(),- });- }- return target.__uuid as string;-};--export const markEditStatusBeforeDrop = (obj: object, status: EditStatus) => {- Object.defineProperty(obj, "__status_before_drop", {- enumerable: false,- writable: true,- configurable: false,- value: status,- });-};--export const getEditStatusBeforeDrop = (- obj: object-): EditStatus | undefined => {- return (obj as ObjectWithHiddenProps).__status_before_drop;-};diff --git a/frontend/src/components/SchemaEditorLite/Panels/common/index.ts b/frontend/src/components/SchemaEditorLite/Panels/common/index.tsdeleted file mode 100644index 6b57160892..0000000000--- a/frontend/src/components/SchemaEditorLite/Panels/common/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./common";diff --git a/frontend/src/components/SchemaEditorLite/SchemaEditorLite.vue b/frontend/src/components/SchemaEditorLite/SchemaEditorLite.vuedeleted file mode 100644index b227931106..0000000000--- a/frontend/src/components/SchemaEditorLite/SchemaEditorLite.vue+++ /dev/null@@ -1,144 +0,0 @@-<template>- <div- class="bb-schema-editor w-full h-full flex flex-col border rounded-lg overflow-hidden relative"- v-bind="$attrs"- >- <MaskSpinner v-if="combinedLoading" />- <NSplit- :min="0.15"- :max="0.4"- :default-size="0.25"- :resize-trigger-size="3"- >- <template #1>- <Aside- v-if="ready"- @update-is-editing="$emit('update-is-editing', $event)"- />- </template>- <template #2>- <Editor v-if="ready" />- </template>- </NSplit>- </div>-</template>--<script lang="ts" setup>-import { cloneDeep } from "lodash-es";-import { NSplit } from "naive-ui";-import { computed, toRef } from "vue";-import MaskSpinner from "@/components/misc/MaskSpinner.vue";-import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener";-import type { DatabaseMetadata } from "@/types/proto-es/v1/database_service_pb";-import type { Project } from "@/types/proto-es/v1/project_service_pb";-import Aside from "./Aside";-import { useAlgorithm } from "./algorithm";-import { provideSchemaEditorContext } from "./context";-import Editor from "./Editor.vue";-import type { EditTarget, RolloutObject } from "./types";--const props = defineProps<{- project: Project;- readonly?: boolean;- selectedRolloutObjects?: RolloutObject[];- targets?: EditTarget[];- loading?: boolean;- hidePreview?: boolean;-}>();--const emit = defineEmits<{- (event: "update:selected-rollout-objects", objects: RolloutObject[]): void;- (event: "update-is-editing", objects: RolloutObject[]): void;-}>();--const targets = computed(() => {- return props.targets ?? [];-});--const ready = computed(() => {- return targets.value.length > 0;-});--const combinedLoading = computed(() => {- return props.loading || !ready.value;-});--const context = provideSchemaEditorContext({- targets,- project: toRef(props, "project"),- readonly: toRef(props, "readonly"),- selectedRolloutObjects: toRef(props, "selectedRolloutObjects"),- hidePreview: toRef(props, "hidePreview"),-});-const { rebuildMetadataEdit, applyMetadataEdit } = useAlgorithm(context);--useEmitteryEventListener(context.events, "rebuild-edit-status", (params) => {- if (ready.value) {- targets.value.forEach((target) => {- rebuildMetadataEdit(target, params.resets);- });- }-});--useEmitteryEventListener(- context.events,- "update:selected-rollout-objects",- (objects) => {- emit("update:selected-rollout-objects", objects);- }-);--useEmitteryEventListener(context.events, "merge-metadata", (metadatas) => {- for (const metadata of metadatas) {- const target = props.targets?.find(- (t) => t.metadata.name === metadata.name- );- if (!target) {- continue;- }-- mergeTableMetadataToTarge({- metadata,- mergeTo: target.metadata,- });- mergeTableMetadataToTarge({- metadata,- mergeTo: target.baselineMetadata,- });- }-});--const mergeTableMetadataToTarge = ({- metadata,- mergeTo,-}: {- metadata: DatabaseMetadata;- mergeTo: DatabaseMetadata;-}) => {- for (const schema of metadata.schemas) {- if (schema.tables.length === 0) {- continue;- }- const targetSchema = mergeTo.schemas.find((s) => s.name === schema.name);- if (!targetSchema) {- continue;- }-- for (const table of schema.tables) {- if (!targetSchema.tables.find((t) => t.name === table.name)) {- targetSchema.tables.push(cloneDeep(table));- }- }- }-};--const refreshPreview = () => {- context.events.emit("refresh-preview");-};--defineExpose({- applyMetadataEdit,- refreshPreview,- isDirty: context.isDirty,-});-</script>diff --git a/frontend/src/components/SchemaEditorLite/TabsContainer.vue b/frontend/src/components/SchemaEditorLite/TabsContainer.vuedeleted file mode 100644index 3d90990239..0000000000--- a/frontend/src/components/SchemaEditorLite/TabsContainer.vue+++ /dev/null@@ -1,179 +0,0 @@-<template>- <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 rounded-sm"- >- <div- ref="tabsContainerRef"- class="flex flex-nowrap overflow-x-auto max-x-full hide-scrollbar overscroll-none px-1 gap-x-1"- >- <div- v-for="tab in tabList"- ref="tabsContainerRef"- :key="tab.id"- :class="[- `relative px-1 py-1 my-1 rounded-sm w-40 flex flex-row justify-between items-center shrink-0 border border-transparent cursor-pointer`,- `tab-${tab.id}`,- tab.id === currentTab?.id && 'bg-white border-gray-200 shadow-sm',- ]"- @click="handleSelectTab(tab)"- >- <div class="flex flex-row justify-start items-center mr-1">- <span class="mr-1">- <DatabaseIcon- v-if="tab.type === 'database'"- class="w-4 h-4 text-gray-400"- />- <TableIcon- v-if="tab.type === 'table'"- class="w-4 h-4 text-gray-400"- />- <ViewIcon- v-if="tab.type === 'view'"- class="w-4 h-4 text-gray-400"- />- <ProcedureIcon- v-if="tab.type === 'procedure'"- class="w-4 h-4 text-gray-400"- />- <FunctionIcon- v-if="tab.type === 'function'"- class="w-4 h-4 text-gray-400"- />- </span>- <NEllipsis- class="text-sm w-20 leading-4"- :class="getTabComputedClassList(tab)"- >{{ getTabName(tab) }}</NEllipsis- >- </div>- <span class="tab-close-button shrink-0 flex">- <XIcon- class="rounded-sm w-4 h-auto text-gray-400 hover:text-gray-600"- @click.stop.prevent="handleCloseTab(tab)"- />- </span>- </div>- </div>- </div>- </div>-</template>--<script lang="ts" setup>-import { XIcon } from "lucide-vue-next";-import { NEllipsis } from "naive-ui";-import scrollIntoView from "scroll-into-view-if-needed";-import { nextTick, ref, watch } from "vue";-import { extractDatabaseResourceName } from "@/utils";-import {- DatabaseIcon,- FunctionIcon,- ProcedureIcon,- TableIcon,- ViewIcon,-} from "../Icon";-import { useSchemaEditorContext } from "./context";-import type { TabContext } from "./types";--const { tabList, currentTab, setCurrentTab, closeTab, getTableStatus } =- useSchemaEditorContext();-const tabsContainerRef = ref();-const searchPattern = ref("");-const originalTabContext = ref<TabContext | undefined>(undefined);--watch(- () => currentTab.value,- () => {- if (currentTab.value !== originalTabContext.value) {- searchPattern.value = "";- originalTabContext.value = currentTab.value;- }-- nextTick(() => {- const element = tabsContainerRef.value?.querySelector(- `.tab-${currentTab.value?.id}`- );- if (element) {- scrollIntoView(element, {- scrollMode: "if-needed",- });- }- });- }-);--const getTabComputedClassList = (tab: TabContext) => {- if (tab.type === "table") {- const { database, metadata } = tab;- const status = getTableStatus(database, metadata);-- if (status === "dropped") {- return ["text-red-700", "line-through"];- }- if (status === "created") {- return ["text-green-700"];- }- if (status === "updated") {- return ["text-yellow-700"];- }- }- return [];-};--const getTabName = (tab: TabContext) => {- if (tab.type === "database") {- const { database } = tab;- return extractDatabaseResourceName(database.name).databaseName;- }- if (tab.type === "table") {- const {- metadata: { schema, table },- } = tab;- const parts = [table.name];- if (schema.name) {- parts.unshift(schema.name);- }- return parts.join(".");- }- if (tab.type === "view") {- const {- metadata: { schema, view },- } = tab;- const parts = [view.name];- if (schema.name) {- parts.unshift(schema.name);- }- return parts.join(".");- }- if (tab.type === "procedure") {- const {- metadata: { schema, procedure },- } = tab;- const parts = [procedure.name];- if (schema.name) {- parts.unshift(schema.name);- }- return parts.join(".");- }- if (tab.type === "function") {- const {- metadata: { schema, function: func },- } = tab;- const parts = [func.name];- if (schema.name) {- parts.unshift(schema.name);- }- return parts.join(".");- }- // Should never reach here.- return "unknown tab";-};--const handleSelectTab = (tab: TabContext) => {- setCurrentTab(tab.id);-};--const handleCloseTab = (tab: TabContext) => {- closeTab(tab.id);-};-</script>diff --git a/frontend/src/components/SchemaEditorLite/algorithm/apply.ts b/frontend/src/components/SchemaEditorLite/algorithm/apply.tsdeleted file mode 100644index 6d674abd10..0000000000--- a/frontend/src/components/SchemaEditorLite/algorithm/apply.ts+++ /dev/null@@ -1,77 +0,0 @@-import { cloneDeep } from "lodash-es";-import type {- Database,- DatabaseMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import type { SchemaEditorContext } from "../context";--export const useApplyMetadataEdit = (context: SchemaEditorContext) => {- const {- getSchemaStatus,- getTableStatus,- getColumnStatus,- getViewStatus,- getProcedureStatus,- getFunctionStatus,- } = context;-- const applyMetadataEdit = (- database: Database,- metadata: DatabaseMetadata- ) => {- const response = cloneDeep(metadata);- // Drop schemas- response.schemas = response.schemas.filter((schema) => {- const status = getSchemaStatus(database, {- schema,- });- return status !== "dropped";- });- // Drop tables, views, procedures and functions- response.schemas.forEach((schema) => {- schema.tables = schema.tables.filter((table) => {- const status = getTableStatus(database, {- schema,- table,- });- return status !== "dropped";- });- // Drop columns- schema.tables.forEach((table) => {- table.columns = table.columns.filter((column) => {- const status = getColumnStatus(database, {- schema,- table,- column,- });- return status !== "dropped";- });- });- schema.views = schema.views.filter((view) => {- const status = getViewStatus(database, {- schema,- view,- });- return status !== "dropped";- });- schema.procedures = schema.procedures.filter((procedure) => {- const status = getProcedureStatus(database, {- schema,- procedure,- });- return status !== "dropped";- });- schema.functions = schema.functions.filter((func) => {- const status = getFunctionStatus(database, {- schema,- function: func,- });- return status !== "dropped";- });- });-- return { metadata: response };- };-- return { applyMetadataEdit };-};diff --git a/frontend/src/components/SchemaEditorLite/algorithm/index.ts b/frontend/src/components/SchemaEditorLite/algorithm/index.tsdeleted file mode 100644index 5f0a6f7a91..0000000000--- a/frontend/src/components/SchemaEditorLite/algorithm/index.ts+++ /dev/null@@ -1,10 +0,0 @@-import type { SchemaEditorContext } from "../context";-import { useApplyMetadataEdit } from "./apply";-import { useRebuildMetadataEdit } from "./rebuild";--export const useAlgorithm = (context: SchemaEditorContext) => {- return {- ...useRebuildMetadataEdit(context),- ...useApplyMetadataEdit(context),- };-};diff --git a/frontend/src/components/SchemaEditorLite/algorithm/rebuild.ts b/frontend/src/components/SchemaEditorLite/algorithm/rebuild.tsdeleted file mode 100644index b5acd0f673..0000000000--- a/frontend/src/components/SchemaEditorLite/algorithm/rebuild.ts+++ /dev/null@@ -1,39 +0,0 @@-import { nextTick } from "vue";-import type { SchemaEditorContext } from "../context";-import type { EditTarget } from "../types";-import { DiffMerge } from "./diff-merge";--export type RebuildMetadataEditReset = "tabs" | "tree";--export const useRebuildMetadataEdit = (context: SchemaEditorContext) => {- const { clearEditStatus, events } = context;-- const rebuildMetadataEdit = (- target: EditTarget,- resets: RebuildMetadataEditReset[] = ["tree"]- ) => {- clearEditStatus();-- const { database, metadata, baselineMetadata } = target;- const dm = new DiffMerge({- context,- database,- sourceMetadata: baselineMetadata,- targetMetadata: metadata,- });- dm.merge();- dm.timer.printAll();- nextTick(() => {- if (resets.includes("tabs")) {- events.emit("clear-tabs");- }- if (resets.includes("tree")) {- events.emit("rebuild-tree", {- openFirstChild: resets.includes("tabs"),- });- }- });- };-- return { rebuildMetadataEdit };-};diff --git a/frontend/src/components/SchemaEditorLite/context/edit.ts b/frontend/src/components/SchemaEditorLite/context/edit.tsdeleted file mode 100644index 5a8accff79..0000000000--- a/frontend/src/components/SchemaEditorLite/context/edit.ts+++ /dev/null@@ -1,237 +0,0 @@-import { computed, ref } from "vue";-import type {- ColumnMetadata,- Database,- FunctionMetadata,- ProcedureMetadata,- SchemaMetadata,- TableMetadata,- TablePartitionMetadata,- ViewMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import type { EditStatus } from "../types";-import { keyForResource } from "./common";--export const useEditStatus = () => {- const dirtyPaths = ref(new Map<string, EditStatus>());- const dirtyPathsArray = computed(() => {- return Array.from(dirtyPaths.value.keys());- });-- const markEditStatus = (- database: Database,- metadata: {- schema: SchemaMetadata;- table?: TableMetadata;- column?: ColumnMetadata;- partition?: TablePartitionMetadata;- procedure?: ProcedureMetadata;- function?: FunctionMetadata;- view?: ViewMetadata;- },- status: EditStatus- ) => {- const key = keyForResource(database, metadata);- dirtyPaths.value.set(key, status);- };-- const markEditStatusByKey = (key: string, status: EditStatus) => {- dirtyPaths.value.set(key, status);- };-- const getEditStatusByKey = (key: string) => {- return dirtyPaths.value.get(key);- };-- const removeEditStatus = (- database: Database,- metadata: {- schema: SchemaMetadata;- table?: TableMetadata;- column?: ColumnMetadata;- partition?: TablePartitionMetadata;- procedure?: ProcedureMetadata;- function?: FunctionMetadata;- view?: ViewMetadata;- },- recursive: boolean- ) => {- const key = keyForResource(database, metadata);- const keys = recursive- ? dirtyPathsArray.value.filter(- (path) => path === key || path.startsWith(`${key}/`)- )- : [key];-- keys.forEach((key) => dirtyPaths.value.delete(key));- };-- const getSchemaStatus = (- database: Database,- metadata: {- schema: SchemaMetadata;- }- ): EditStatus => {- const key = keyForResource(database, metadata);- if (dirtyPaths.value.has(key)) {- return dirtyPaths.value.get(key)!;- }- if (dirtyPathsArray.value.some((path) => path.startsWith(`${key}/`))) {- return "updated";- }- return "normal";- };-- const getTableStatus = (- database: Database,- metadata: {- schema: SchemaMetadata;- table: TableMetadata;- }- ): EditStatus => {- const key = keyForResource(database, metadata);- if (dirtyPaths.value.has(key)) {- return dirtyPaths.value.get(key)!;- }- if (dirtyPathsArray.value.some((path) => path.startsWith(`${key}/`))) {- return "updated";- }- return "normal";- };-- const replaceTableName = (- database: Database,- metadata: {- schema: SchemaMetadata;- table: TableMetadata;- },- newName: string- ) => {- const key = keyForResource(database, metadata);-- const sections = key.split("/");- sections.pop();- sections.push(newName);- const newKey = sections.join("/");- if (key === newKey) {- return;- }-- const pathMap = new Map<string /* old path */, string /* new path */>();- for (const path of dirtyPathsArray.value) {- if (!dirtyPaths.value.has(path)) {- continue;- }- if (path.startsWith(key)) {- pathMap.set(path, path.replace(key, newKey));- }- }-- for (const [oldPath, newPath] of pathMap.entries()) {- const status = dirtyPaths.value.get(oldPath)!;- dirtyPaths.value.delete(oldPath);- dirtyPaths.value.set(newPath, status);- }- };-- const getColumnStatus = (- database: Database,- metadata: {- schema: SchemaMetadata;- table: TableMetadata;- column: ColumnMetadata;- }- ): EditStatus => {- const key = keyForResource(database, metadata);- if (dirtyPaths.value.has(key)) {- return dirtyPaths.value.get(key)!;- }- if (dirtyPathsArray.value.some((path) => path.startsWith(`${key}/`))) {- return "updated";- }- return "normal";- };-- const getPartitionStatus = (- database: Database,- metadata: {- schema: SchemaMetadata;- table: TableMetadata;- partition: TablePartitionMetadata;- }- ): EditStatus => {- const key = keyForResource(database, metadata);- if (dirtyPaths.value.has(key)) {- return dirtyPaths.value.get(key)!;- }- if (dirtyPathsArray.value.some((path) => path.startsWith(`${key}/`))) {- return "updated";- }- return "normal";- };-- const getProcedureStatus = (- database: Database,- metadata: {- schema: SchemaMetadata;- procedure: ProcedureMetadata;- }- ): EditStatus => {- const key = keyForResource(database, metadata);- if (dirtyPaths.value.has(key)) {- return dirtyPaths.value.get(key)!;- }- return "normal";- };-- const getFunctionStatus = (- database: Database,- metadata: {- schema: SchemaMetadata;- function: FunctionMetadata;- }- ): EditStatus => {- const key = keyForResource(database, metadata);- if (dirtyPaths.value.has(key)) {- return dirtyPaths.value.get(key)!;- }- return "normal";- };-- const getViewStatus = (- database: Database,- metadata: {- schema: SchemaMetadata;- view: ViewMetadata;- }- ): EditStatus => {- const key = keyForResource(database, metadata);- if (dirtyPaths.value.has(key)) {- return dirtyPaths.value.get(key)!;- }- return "normal";- };-- const clearEditStatus = () => {- dirtyPaths.value.clear();- };-- const isDirty = computed(() => dirtyPaths.value.size > 0);-- return {- isDirty,- markEditStatus,- markEditStatusByKey,- getEditStatusByKey,- removeEditStatus,- clearEditStatus,- getSchemaStatus,- getTableStatus,- getColumnStatus,- getPartitionStatus,- getProcedureStatus,- getFunctionStatus,- getViewStatus,- replaceTableName,- };-};diff --git a/frontend/src/components/SchemaEditorLite/context/index.ts b/frontend/src/components/SchemaEditorLite/context/index.tsdeleted file mode 100644index 4f7e2c083f..0000000000--- a/frontend/src/components/SchemaEditorLite/context/index.ts+++ /dev/null@@ -1,59 +0,0 @@-import Emittery from "emittery";-import type { Ref } from "vue";-import { inject, provide } from "vue";-import type { DatabaseMetadata } from "@/types/proto-es/v1/database_service_pb";-import type { Project } from "@/types/proto-es/v1/project_service_pb";-import type { RebuildMetadataEditReset } from "../algorithm/rebuild";-import type { EditTarget, RolloutObject } from "../types";-import { useEditStatus } from "./edit";-import { useScrollStatus } from "./scroll";-import { useSelection } from "./selection";-import { useTabs } from "./tabs";--export const KEY = Symbol("bb.schema-editor");--export type SchemaEditorEvents = Emittery<{- ["update:selected-rollout-objects"]: RolloutObject[];- ["rebuild-tree"]: {- openFirstChild: boolean;- };- ["rebuild-edit-status"]: { resets: RebuildMetadataEditReset[] };- ["clear-tabs"]: undefined;- ["refresh-preview"]: undefined;- ["merge-metadata"]: DatabaseMetadata[];-}>;--export type SchemaEditorOptions = {- forceShowIndexes: boolean;- forceShowPartitions: boolean;-};--export const provideSchemaEditorContext = (params: {- readonly: Ref<boolean>;- project: Ref<Project>;- targets: Ref<EditTarget[]>;- selectedRolloutObjects: Ref<RolloutObject[] | undefined>;- hidePreview: Ref<boolean>;- options?: Ref<SchemaEditorOptions>;-}) => {- const events = new Emittery() as SchemaEditorEvents;-- const context = {- events,- ...params,- ...useTabs(events),- ...useEditStatus(),- ...useScrollStatus(),- ...useSelection(params.selectedRolloutObjects, events),- };-- provide(KEY, context);-- return context;-};--export type SchemaEditorContext = ReturnType<typeof provideSchemaEditorContext>;--export const useSchemaEditorContext = () => {- return inject(KEY) as SchemaEditorContext;-};diff --git a/frontend/src/components/SchemaEditorLite/context/scroll.ts b/frontend/src/components/SchemaEditorLite/context/scroll.tsdeleted file mode 100644index 6be23eaebb..0000000000--- a/frontend/src/components/SchemaEditorLite/context/scroll.ts+++ /dev/null@@ -1,113 +0,0 @@-import { useMounted } from "@vueuse/core";-import type { Ref } from "vue";-import { computed, ref, watch } from "vue";-import type {- ColumnMetadata,- Database,- DatabaseMetadata,- SchemaMetadata,- TableMetadata,-} from "@/types/proto-es/v1/database_service_pb";--type RichSchemaMetadata = {- database: DatabaseMetadata;- schema: SchemaMetadata;-};-type RichTableMetadata = RichSchemaMetadata & {- table: TableMetadata;-};-type RichColumnMetadata = RichTableMetadata & {- column: ColumnMetadata;- // field?: "name" | "type"; // TODO-};-type RichMetadataWithDB<T> = {- db: Database;- metadata: T;-};--export const useScrollStatus = () => {- const pendingScrollToTable = ref<RichMetadataWithDB<RichTableMetadata>>();- const pendingScrollToColumn = ref<RichMetadataWithDB<RichColumnMetadata>>();- const useConsumePendingScrollToTable = <TContext>(- condition: Ref<RichMetadataWithDB<RichSchemaMetadata>>,- context: Ref<TContext>,- fn: (- params: RichMetadataWithDB<RichTableMetadata>,- context: TContext- ) => void- ) => {- const mounted = useMounted();- const matched = computed(() => {- const pending = pendingScrollToTable.value;- if (!pending) return false;- return (- pending.db.name === condition.value.db.name &&- pending.metadata.schema.name === condition.value.metadata.schema.name- );- });- watch(- [mounted, matched, context, pendingScrollToTable],- ([mounted, matched, context, pending]) => {- if (!mounted) return;- if (!matched) return;- if (!context) return;- if (!pending) return;- fn(pending, context);- pendingScrollToTable.value = undefined;- },- { immediate: true }- );- };- const useConsumePendingScrollToColumn = <TContext>(- condition: Ref<RichMetadataWithDB<RichTableMetadata>>,- context: Ref<TContext>,- fn: (- params: RichMetadataWithDB<RichColumnMetadata>,- context: TContext- ) => void- ) => {- const mounted = useMounted();- const matched = computed(() => {- const pending = pendingScrollToColumn.value;- if (!pending) return false;- return (- pending.db.name === condition.value.db.name &&- pending.metadata.schema.name === condition.value.metadata.schema.name &&- pending.metadata.table.name === condition.value.metadata.table.name- );- });- watch(- [mounted, matched, context, pendingScrollToColumn],- ([mounted, matched, context, pending]) => {- if (!mounted) return;- if (!matched) return;- if (!context) return;- if (!pending) return;- fn(pending, context);- pendingScrollToColumn.value = undefined;- },- { immediate: true }- );- };- const queuePendingScrollToTable = (- params: RichMetadataWithDB<RichTableMetadata>- ) => {- requestAnimationFrame(() => {- pendingScrollToTable.value = params;- });- };- const queuePendingScrollToColumn = (- params: RichMetadataWithDB<RichColumnMetadata>- ) => {- requestAnimationFrame(() => {- pendingScrollToColumn.value = params;- });- };-- return {- queuePendingScrollToTable,- queuePendingScrollToColumn,- useConsumePendingScrollToTable,- useConsumePendingScrollToColumn,- };-};diff --git a/frontend/src/components/SchemaEditorLite/context/selection.ts b/frontend/src/components/SchemaEditorLite/context/selection.tsdeleted file mode 100644index 25e10bbe1b..0000000000--- a/frontend/src/components/SchemaEditorLite/context/selection.ts+++ /dev/null@@ -1,628 +0,0 @@-import { pick } from "lodash-es";-import type { Ref } from "vue";-import { computed } from "vue";-import type {- ColumnMetadata,- Database,- DatabaseMetadata,- FunctionMetadata,- ProcedureMetadata,- SchemaMetadata,- TableMetadata,- ViewMetadata,-} from "@/types/proto-es/v1/database_service_pb";-import type { RolloutObject } from "../types";-import type { SchemaEditorEvents } from ".";-import { keyForResource } from "./common";--export const useSelection = (- selectedRolloutObjects: Ref<RolloutObject[] | undefined>,- events: SchemaEditorEvents-) => {- const selectionEnabled = computed(() => {- return selectedRolloutObjects.value !== undefined;- });-- const selectedRolloutObjectMap = computed(() => {- return new Map(- selectedRolloutObjects.value?.map((ro) => {- const key = keyForResource(ro.db, ro.metadata);- return [key, ro];- })- );- });-- const updateTableSelectionImpl = (- map: Map<string, RolloutObject>,- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- },- on: boolean- ) => {- const { table } = metadata;- if (on) {- // select the table itself including all its columns- map.set(keyForResource(db, metadata), {- db,- metadata,- });- table.columns.forEach((column) => {- map.set(keyForResource(db, { ...metadata, column }), {- db,- metadata: { ...metadata, column },- });- });- } else {- // de-select the table it self including all its columns- map.delete(keyForResource(db, metadata));- table.columns.forEach((column) => {- map.delete(keyForResource(db, { ...metadata, column }));- });- }- };- const updateColumnSelectionImpl = (- map: Map<string, RolloutObject>,- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- column: ColumnMetadata;- },- on: boolean- ) => {- const tableMeta = pick(metadata, "database", "schema", "table");- if (on) {- // ensure the column's table is selected- map.set(keyForResource(db, tableMeta), {- db,- metadata: tableMeta,- });- // then select the column itself- map.set(keyForResource(db, metadata), {- db,- metadata,- });- } else {- // de-select the column- map.delete(keyForResource(db, metadata));- }- };- const updateViewSelectionImpl = (- map: Map<string, RolloutObject>,- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- view: ViewMetadata;- },- on: boolean- ) => {- const key = keyForResource(db, metadata);- if (on) {- // select the view- map.set(key, {- db,- metadata,- });- } else {- // de-select the view- map.delete(key);- }- };- const updateProcedureSelectionImpl = (- map: Map<string, RolloutObject>,- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- procedure: ProcedureMetadata;- },- on: boolean- ) => {- const key = keyForResource(db, metadata);- if (on) {- // select the procedure- map.set(key, {- db,- metadata,- });- } else {- // de-select the procedure- map.delete(key);- }- };- const updateFunctionSelectionImpl = (- map: Map<string, RolloutObject>,- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- function: FunctionMetadata;- },- on: boolean- ) => {- const key = keyForResource(db, metadata);- if (on) {- // select the function- map.set(key, {- db,- metadata,- });- } else {- // de-select the function- map.delete(key);- }- };- const emit = (map: Map<string, RolloutObject>) => {- events.emit("update:selected-rollout-objects", Array.from(map.values()));- };-- const getTableSelectionState = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- }- ) => {- if (!selectionEnabled.value) {- return { checked: false, indeterminate: false };- }-- const { table } = metadata;- const tableChecked = selectedRolloutObjectMap.value.has(- keyForResource(db, metadata)- );- if (table.columns.length === 0) {- return {- checked: tableChecked,- indeterminate: false,- };- }-- const checkedColumns = table.columns.filter((column) => {- const columnChecked = selectedRolloutObjectMap.value.has(- keyForResource(db, {- ...metadata,- column,- })- );- return !!columnChecked;- });-- const state = {- checked: checkedColumns.length === table.columns.length,- indeterminate: false,- };- if (!state.checked) {- if (tableChecked || checkedColumns.length > 0) {- state.indeterminate = true;- }- }- return state;- };- const updateTableSelection = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- },- on: boolean- ) => {- if (!selectionEnabled.value) return;- const updatedMap = new Map(selectedRolloutObjectMap.value.entries());- updateTableSelectionImpl(updatedMap, db, metadata, on);- emit(updatedMap);- };- const getAllTablesSelectionState = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- },- tables: TableMetadata[]- ) => {- if (!selectionEnabled.value || tables.length === 0) {- return { checked: false, indeterminate: false };- }- const selectedTables = tables.filter((table) => {- return selectedRolloutObjectMap.value.has(- keyForResource(db, {- ...metadata,- table,- })- );- });- return {- checked: selectedTables.length === tables.length,- indeterminate:- selectedTables.length > 0 && selectedTables.length < tables.length,- };- };- const updateAllTablesSelection = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- },- tables: TableMetadata[],- on: boolean- ) => {- const updatedMap = new Map(selectedRolloutObjectMap.value.entries());- tables.forEach((table) => {- updateTableSelectionImpl(- updatedMap,- db,- {- ...metadata,- table,- },- on- );- });-- emit(updatedMap);- };- const getColumnSelectionState = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- column: ColumnMetadata;- }- ) => {- if (!selectionEnabled.value) {- return { checked: false, indeterminate: false };- }-- const checked = selectedRolloutObjectMap.value.has(- keyForResource(db, metadata)- );- return { checked, indeterminate: false };- };- const updateColumnSelection = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- column: ColumnMetadata;- },- on: boolean- ) => {- if (!selectionEnabled.value) return;- const updatedMap = new Map(selectedRolloutObjectMap.value.entries());- updateColumnSelectionImpl(updatedMap, db, metadata, on);- emit(updatedMap);- };- const getAllColumnsSelectionState = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- },- columns: ColumnMetadata[]- ) => {- if (!selectionEnabled.value || columns.length === 0) {- return { checked: false, indeterminate: false };- }- const selectedColumns = columns.filter((column) => {- return selectedRolloutObjectMap.value.has(- keyForResource(db, {- ...metadata,- column,- })- );- });- return {- checked: selectedColumns.length === columns.length,- indeterminate:- selectedColumns.length > 0 && selectedColumns.length < columns.length,- };- };- const updateAllColumnsSelection = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- table: TableMetadata;- },- columns: ColumnMetadata[],- on: boolean- ) => {- const updatedMap = new Map(selectedRolloutObjectMap.value.entries());- columns.forEach((column) => {- updateColumnSelectionImpl(- updatedMap,- db,- {- ...metadata,- column,- },- on- );- });-- emit(updatedMap);- };-- const getViewSelectionState = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- view: ViewMetadata;- }- ) => {- if (!selectionEnabled.value) {- return { checked: false, indeterminate: false };- }-- const checked = selectedRolloutObjectMap.value.has(- keyForResource(db, metadata)- );- return {- checked,- indeterminate: false,- };- };- const updateViewSelection = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- view: ViewMetadata;- },- on: boolean- ) => {- if (!selectionEnabled.value) return;- const updatedMap = new Map(selectedRolloutObjectMap.value.entries());- updateViewSelectionImpl(updatedMap, db, metadata, on);- emit(updatedMap);- };- const getAllViewsSelectionState = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- },- views: ViewMetadata[]- ) => {- if (!selectionEnabled.value || views.length === 0) {- return { checked: false, indeterminate: false };- }- const selected = views.filter((view) => {- return selectedRolloutObjectMap.value.has(- keyForResource(db, {- ...metadata,- view,- })- );- });- return {- checked: selected.length === views.length,- indeterminate: selected.length > 0 && selected.length < views.length,- };- };- const updateAllViewsSelection = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- },- views: ViewMetadata[],- on: boolean- ) => {- const updatedMap = new Map(selectedRolloutObjectMap.value.entries());- views.forEach((view) => {- updateViewSelectionImpl(- updatedMap,- db,- {- ...metadata,- view,- },- on- );- });-- emit(updatedMap);- };-- const getProcedureSelectionState = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- procedure: ProcedureMetadata;- }- ) => {- if (!selectionEnabled.value) {- return { checked: false, indeterminate: false };- }-- const checked = selectedRolloutObjectMap.value.has(- keyForResource(db, metadata)- );- return {- checked,- indeterminate: false,- };- };- const updateProcedureSelection = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- procedure: ProcedureMetadata;- },- on: boolean- ) => {- if (!selectionEnabled.value) return;- const updatedMap = new Map(selectedRolloutObjectMap.value.entries());- updateProcedureSelectionImpl(updatedMap, db, metadata, on);- emit(updatedMap);- };- const getAllProceduresSelectionState = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- },- procedures: ProcedureMetadata[]- ) => {- if (!selectionEnabled.value || procedures.length === 0) {- return { checked: false, indeterminate: false };- }- const selected = procedures.filter((procedure) => {- return selectedRolloutObjectMap.value.has(- keyForResource(db, {- ...metadata,- procedure,- })- );- });- return {- checked: selected.length === procedures.length,- indeterminate: selected.length > 0 && selected.length < procedures.length,- };- };- const updateAllProceduresSelection = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- },- procedures: ProcedureMetadata[],- on: boolean- ) => {- const updatedMap = new Map(selectedRolloutObjectMap.value.entries());- procedures.forEach((procedure) => {- updateProcedureSelectionImpl(- updatedMap,- db,- {- ...metadata,- procedure,- },- on- );- });-- emit(updatedMap);- };-- const getFunctionSelectionState = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- function: FunctionMetadata;- }- ) => {- if (!selectionEnabled.value) {- return { checked: false, indeterminate: false };- }-- const checked = selectedRolloutObjectMap.value.has(- keyForResource(db, metadata)- );- return {- checked,- indeterminate: false,- };- };- const updateFunctionSelection = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- function: FunctionMetadata;- },- on: boolean- ) => {- if (!selectionEnabled.value) return;- const updatedMap = new Map(selectedRolloutObjectMap.value.entries());- updateFunctionSelectionImpl(updatedMap, db, metadata, on);- emit(updatedMap);- };- const getAllFunctionsSelectionState = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- },- functions: FunctionMetadata[]- ) => {- if (!selectionEnabled.value || functions.length === 0) {- return { checked: false, indeterminate: false };- }- const selected = functions.filter((func) => {- return selectedRolloutObjectMap.value.has(- keyForResource(db, {- ...metadata,- function: func,- })- );- });- return {- checked: selected.length === functions.length,- indeterminate: selected.length > 0 && selected.length < functions.length,- };- };- const updateAllFunctionsSelection = (- db: Database,- metadata: {- database: DatabaseMetadata;- schema: SchemaMetadata;- },- functions: FunctionMetadata[],- on: boolean- ) => {- const updatedMap = new Map(selectedRolloutObjectMap.value.entries());- functions.forEach((func) => {- updateFunctionSelectionImpl(- updatedMap,- db,- {- ...metadata,- function: func,- },- on- );- });-- emit(updatedMap);- };-- return {- selectionEnabled,- getTableSelectionState,- updateTableSelection,- getAllTablesSelectionState,- updateAllTablesSelection,- getColumnSelectionState,- updateColumnSelection,- getAllColumnsSelectionState,- updateAllColumnsSelection,- getViewSelectionState,- updateViewSelection,- getAllViewsSelectionState,- updateAllViewsSelection,- getProcedureSelectionState,- updateProcedureSelection,- getAllProceduresSelectionState,- updateAllProceduresSelection,- getFunctionSelectionState,- updateFunctionSelection,- getAllFunctionsSelectionState,- updateAllFunctionsSelection,- };-};diff --git a/frontend/src/components/SchemaEditorLite/context/tabs.ts b/frontend/src/components/SchemaEditorLite/context/tabs.tsdeleted file mode 100644index cfbe641dfd..0000000000--- a/frontend/src/components/SchemaEditorLite/context/tabs.ts+++ /dev/null@@ -1,131 +0,0 @@-import { v1 as uuidv1 } from "uuid";-import { computed, type Ref, ref } from "vue";-import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener";-import type { CoreTabContext, TabContext } from "../types";-import type { SchemaEditorEvents } from "./index";--export type TabsContext = {- tabMap: Ref<Map<string, TabContext>>;- tabList: Ref<TabContext[]>;- currentTabId: Ref<string>;- currentTab: Ref<TabContext | undefined>;- addTab: (coreTab: CoreTabContext, setAsCurrentTab?: boolean) => void;- setCurrentTab: (id: string) => void;- closeTab: (id: string) => void;- findTab: (target: CoreTabContext) => TabContext | undefined;-};--export const useTabs = (events: SchemaEditorEvents): TabsContext => {- const tabMap = ref(new Map<string, TabContext>());- const tabList = computed(() => {- return Array.from(tabMap.value.values());- });- const currentTabId = ref<string>("");- const currentTab = computed(() => {- if (!currentTabId.value) return undefined;- return tabMap.value.get(currentTabId.value);- });-- const addTab = (coreTab: CoreTabContext, setAsCurrentTab = true) => {- const existedTab = findTab(coreTab);- if (existedTab) {- Object.assign(existedTab, coreTab);- if (setAsCurrentTab) {- currentTabId.value = existedTab.id;- }- return;- }-- const id = uuidv1();- const tab: TabContext = {- id,- ...coreTab,- };-- tabMap.value.set(id, tab);- if (setAsCurrentTab) {- // It's weird that nextTick doesn't work here- // So we need to delay a little bit longer- requestAnimationFrame(() => {- currentTabId.value = id;- });- }- };-- const setCurrentTab = (id: string) => {- if (tabMap.value.has(id)) {- currentTabId.value = id;- } else {- currentTabId.value = "";- }- };-- const closeTab = (id: string) => {- const index = tabList.value.findIndex((tab) => tab.id === id);- if (currentTabId.value === id) {- // Find next tab for showing.- let nextIndex = -1;- if (index === 0) {- nextIndex = 1;- } else {- nextIndex = index - 1;- }- const nextTab = tabList.value[nextIndex];- if (nextTab) {- setCurrentTab(nextTab.id);- } else {- setCurrentTab("");- }- }- tabMap.value.delete(id);- };- const findTab = (target: CoreTabContext) => {- return tabList.value.find((tab) => {- if (tab.type !== target.type) return false;- if (tab.database.name !== target.database.name) return false;- if (tab.type === "database" && target.type === "database") {- return tab.metadata.database.name === target.metadata.database.name;- }- if (tab.type === "table" && target.type === "table") {- return (- tab.metadata.schema.name === target.metadata.schema.name &&- tab.metadata.table.name === target.metadata.table.name- );- }- if (tab.type === "view" && target.type === "view") {- return (- tab.metadata.schema.name === target.metadata.schema.name &&- tab.metadata.view.name === target.metadata.view.name- );- }- if (tab.type === "procedure" && target.type === "procedure") {- return (- tab.metadata.schema.name === target.metadata.schema.name &&- tab.metadata.procedure.name === target.metadata.procedure.name- );- }- if (tab.type === "function" && target.type === "function") {- return (- tab.metadata.schema.name === target.metadata.schema.name &&- tab.metadata.function.name === target.metadata.function.name- );- }- return false;- });- };- useEmitteryEventListener(events, "clear-tabs", () => {- tabMap.value.clear();- currentTabId.value = "";- });-- return {- tabMap,- tabList,- currentTabId,- currentTab,- addTab,- setCurrentTab,- closeTab,- findTab,- };-};diff --git a/frontend/src/components/SchemaEditorLite/index.ts b/frontend/src/components/SchemaEditorLite/index.tsdeleted file mode 100644index 492094686b..0000000000--- a/frontend/src/components/SchemaEditorLite/index.ts+++ /dev/null@@ -1,13 +0,0 @@-import ActionConfirmModal from "./Modals/ActionConfirmModal.vue";-import TableColumnEditor from "./Panels/TableColumnEditor";-import SchemaEditorLite from "./SchemaEditorLite.vue";--export * from "./types";-export * from "./common";-export * from "./spec";-export * from "./utils";-export * from "./context";-export * from "./edit";-export { ActionConfirmModal, TableColumnEditor };--export default SchemaEditorLite;diff --git a/frontend/src/components/SchemaEditorLite/utils/index.ts b/frontend/src/components/SchemaEditorLite/utils/index.tsdeleted file mode 100644index f6a135cbba..0000000000--- a/frontend/src/components/SchemaEditorLite/utils/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./metadata";-export * from "./columnDefaultValue";diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 8ae1754fe3..20719104e4 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -160,14 +160,8 @@}},"branch": {- "index": {- "drop-index-confirm": "Drop index?"- },- "select-tables-to-rollout": "Select tables to rollout",- "table-partition": {- "drop-partition-confirm": "Drop table partition?",- "drop-partition-with-subpartitions-confirm": "Will also drop all its subpartitions."- }+ "index": {},+ "table-partition": {}},"cel": {"condition": {@@ -1768,9 +1762,7 @@},"task-execution-errors": "Task execution errors"},- "schema-designer": {- "use-tips": "Click a table to start."- },+ "schema-designer": {},"schema-diagram": {"fit-content-with-view": "Fit content within view","self": "Schema Diagram"@@ -1784,7 +1776,6 @@"create-table": "New table","create-view": "Create view","drop": "Drop",- "drop-column": "Drop column","drop-schema": "Drop schema","drop-table": "Drop table","rename": "Rename",@@ -1798,7 +1789,6 @@"not-null": "Not Null","on-update": "On Update","primary": "Primary",- "select": "Select column","type": "Type"},"columns": "Columns",@@ -1811,53 +1801,26 @@"default": {"placeholder": "Enter default value or leave empty for no default"},- "foreign-key": {- "edit": "Edit foreign key",- "name-description": "The unique name of foreign key"- },- "functions": "Functions",+ "foreign-key": {},"index": {"dependency-columns": "Depenedent columns",- "edit-indexes": "Edit indexes","indexes": "Indexes","unique": "Unique"},- "message": {- "cannot-drop-the-last-column": "Cannot drop the last column",- "duplicated-function-name": "Duplicated function name",- "duplicated-procedure-name": "Duplicated procedure name",- "duplicated-table-name": "Duplicated table name",- "duplicated-view-name": "Duplicated view name",- "invalid-function-name": "Invalid function name",- "invalid-procedure-name": "Invalid procedure name",- "invalid-schema": "Invalid schema",- "invalid-schema-name": "Invalid schema name",- "invalid-table-name": "Invalid table name",- "invalid-view-name": "Invalid view name"- },- "preview-schema-text": "Preview schema text",- "preview-view-definition": "Preview view definition",- "procedures": "Procedures",+ "insert-sql": "Insert SQL","raw-sql": "Raw SQL","schema": {- "name": "Schema Name","select": "Select schema"},- "search-database-and-table": "Search database and table",- "table": {- "name": "Table Name",- "select": "Select table"- },+ "self": "Schema editor",+ "table": {},"table-partition": {- "add-sub-partition": "Add sub partition",- "edit-partitions": "Edit partitions","expression": "Expression","partitions": "Partitions","type": "Type","value": "Value"},- "tables": "Tables",- "views": "Views"+ "template-database": "Template database"},"schema-template": {"classification": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 306f024fb3..3251e87b07 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -160,14 +160,8 @@}},"branch": {- "index": {- "drop-index-confirm": "¿Eliminar índice?"- },- "select-tables-to-rollout": "Seleccionar tablas para implementar",- "table-partition": {- "drop-partition-confirm": "¿Eliminar partición de tabla?",- "drop-partition-with-subpartitions-confirm": "También eliminará todas sus subparticiones."- }+ "index": {},+ "table-partition": {}},"cel": {"condition": {@@ -1768,9 +1762,7 @@},"task-execution-errors": "Errores de ejecución de tareas"},- "schema-designer": {- "use-tips": "Selecciona las tablas a diseñar"- },+ "schema-designer": {},"schema-diagram": {"fit-content-with-view": "Ajustar contenido dentro de la vista","self": "Diagrama de Esquema"@@ -1784,7 +1776,6 @@"create-table": "Nueva tabla","create-view": "Crear vista","drop": "Eliminar",- "drop-column": "Eliminar columna","drop-schema": "Eliminar esquema","drop-table": "Eliminar tabla","rename": "Renombrar",@@ -1798,7 +1789,6 @@"not-null": "No nulo","on-update": "En actualización","primary": "Primaria",- "select": "Seleccionar columna","type": "Tipo"},"columns": "Columnas",@@ -1811,53 +1801,26 @@"default": {"placeholder": "Introduzca un valor predeterminado o déjelo vacío si no hay ningún valor predeterminado"},- "foreign-key": {- "edit": "Editar clave externa",- "name-description": "El nombre único de la clave externa"- },- "functions": "Funciones",+ "foreign-key": {},"index": {"dependency-columns": "Columnas dependientes",- "edit-indexes": "Editar índices","indexes": "Índices","unique": "Único"},- "message": {- "cannot-drop-the-last-column": "No se puede eliminar la última columna",- "duplicated-function-name": "Nombre de función duplicado",- "duplicated-procedure-name": "Nombre del procedimiento duplicado",- "duplicated-table-name": "Nombre de tabla duplicado",- "duplicated-view-name": "Nombre de vista duplicado",- "invalid-function-name": "Nombre de función no válido",- "invalid-procedure-name": "Nombre de procedimiento no válido",- "invalid-schema": "Esquema no válido",- "invalid-schema-name": "Nombre de esquema inválido",- "invalid-table-name": "Nombre de tabla inválido",- "invalid-view-name": "Nombre de vista no válido"- },- "preview-schema-text": "Vista previa del texto del esquema",- "preview-view-definition": "Definición de vista previa",- "procedures": "Procedimientos",+ "insert-sql": "Insertar SQL","raw-sql": "SQL sin procesar","schema": {- "name": "Nombre del Esquema","select": "Seleccionar esquema"},- "search-database-and-table": "Buscar base de datos y tabla",- "table": {- "name": "Nombre de la tabla",- "select": "Seleccionar tabla"- },+ "self": "Editor de esquema",+ "table": {},"table-partition": {- "add-sub-partition": "Agregar subpartición",- "edit-partitions": "Editar particiones","expression": "Expresión","partitions": "Particiones","type": "Tipo","value": "Valor"},- "tables": "Tablas",- "views": "Vistas"+ "template-database": "Base de datos plantilla"},"schema-template": {"classification": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 5fa8271d13..a3f7f78b83 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -160,14 +160,8 @@}},"branch": {- "index": {- "drop-index-confirm": "インデックスを削除しますか?"- },- "select-tables-to-rollout": "公開するテーブルを選択してください",- "table-partition": {- "drop-partition-confirm": "テーブルパーティションを削除しますか?",- "drop-partition-with-subpartitions-confirm": "すべてのサブパーティションが同時に削除されます。"- }+ "index": {},+ "table-partition": {}},"cel": {"condition": {@@ -1768,9 +1762,7 @@},"task-execution-errors": "タスク実行エラー"},- "schema-designer": {- "use-tips": "デザインするテーブルを選択してください"- },+ "schema-designer": {},"schema-diagram": {"fit-content-with-view": "ビューに自動的に適応します","self": "スキーマ図"@@ -1784,7 +1776,6 @@"create-table": "新しいテーブルを作成する","create-view": "ビューの作成","drop": "落とす",- "drop-column": "列の削除","drop-schema": "スキーマの削除","drop-table": "テーブルの削除","rename": "名前の変更",@@ -1798,7 +1789,6 @@"not-null": "空にすることはできません","on-update": "アップデート時","primary": "主キー",- "select": "列を選択","type": "タイプ"},"columns": "カラム",@@ -1811,53 +1801,26 @@"default": {"placeholder": "デフォルト値を入力するか、デフォルト値がない場合は空白のままにします"},- "foreign-key": {- "edit": "外部キーを編集",- "name-description": "外部キーの一意の名前"- },- "functions": "関数",+ "foreign-key": {},"index": {"dependency-columns": "従属列",- "edit-indexes": "インデックスの編集","indexes": "索引","unique": "唯一"},- "message": {- "cannot-drop-the-last-column": "最後の列は削除できません",- "duplicated-function-name": "関数名が重複しています",- "duplicated-procedure-name": "重複したプロシージャ名",- "duplicated-table-name": "テーブル名が重複しています",- "duplicated-view-name": "重複したビュー名",- "invalid-function-name": "無効な関数名です",- "invalid-procedure-name": "無効なプロシージャ名です",- "invalid-schema": "無効なスキーマ",- "invalid-schema-name": "無効なスキーマ名",- "invalid-table-name": "無効なテーブル名です",- "invalid-view-name": "無効なビュー名です"- },- "preview-schema-text": "スキーマテキストのプレビュー",- "preview-view-definition": "プレビュービューの定義",- "procedures": "手順",+ "insert-sql": "SQL を挿入","raw-sql": "SQL文","schema": {- "name": "スキーマ名","select": "スキーマの選択"},- "search-database-and-table": "データベースとテーブルを検索する",- "table": {- "name": "テーブル名",- "select": "テーブルの選択"- },+ "self": "スキーマエディタ",+ "table": {},"table-partition": {- "add-sub-partition": "サブパーティションの追加",- "edit-partitions": "パーティションの編集","expression": "表現","partitions": "パーティション","type": "タイプ","value": "値"},- "tables": "テーブル",- "views": "ビュー"+ "template-database": "テンプレートデータベース"},"schema-template": {"classification": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex ebdd34adbc..9c29f69a27 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -160,14 +160,8 @@}},"branch": {- "index": {- "drop-index-confirm": "Xóa chỉ mục?"- },- "select-tables-to-rollout": "Chọn bảng để triển khai",- "table-partition": {- "drop-partition-confirm": "Xóa phân vùng bảng?",- "drop-partition-with-subpartitions-confirm": "Cũng sẽ xóa tất cả các phân vùng con của nó."- }+ "index": {},+ "table-partition": {}},"cel": {"condition": {@@ -1768,9 +1762,7 @@},"task-execution-errors": "Lỗi thực hiện tác vụ"},- "schema-designer": {- "use-tips": "Nhấp vào một bảng để bắt đầu."- },+ "schema-designer": {},"schema-diagram": {"fit-content-with-view": "Điều chỉnh nội dung vừa với khung nhìn","self": "Sơ đồ Lược đồ"@@ -1784,7 +1776,6 @@"create-table": "Bảng mới","create-view": "Tạo khung nhìn","drop": "Xóa",- "drop-column": "Xóa cột","drop-schema": "Xóa lược đồ","drop-table": "Xóa bảng","rename": "Đổi tên",@@ -1798,7 +1789,6 @@"not-null": "Không Null","on-update": "Khi cập nhật","primary": "Chính",- "select": "Chọn cột","type": "Loại"},"columns": "Cột",@@ -1811,53 +1801,26 @@"default": {"placeholder": "Nhập giá trị mặc định hoặc để trống nếu không có giá trị mặc định"},- "foreign-key": {- "edit": "Chỉnh sửa khóa ngoại",- "name-description": "Tên duy nhất của khóa ngoại"- },- "functions": "Hàm",+ "foreign-key": {},"index": {"dependency-columns": "Cột phụ thuộc",- "edit-indexes": "Chỉnh sửa chỉ mục","indexes": "Chỉ mục","unique": "Duy nhất"},- "message": {- "cannot-drop-the-last-column": "Không thể xóa cột cuối cùng",- "duplicated-function-name": "Tên hàm trùng lặp",- "duplicated-procedure-name": "Tên thủ tục trùng lặp",- "duplicated-table-name": "Tên bảng trùng lặp",- "duplicated-view-name": "Tên khung nhìn trùng lặp",- "invalid-function-name": "Tên hàm không hợp lệ",- "invalid-procedure-name": "Tên thủ tục không hợp lệ",- "invalid-schema": "Lược đồ không hợp lệ",- "invalid-schema-name": "Tên lược đồ không hợp lệ",- "invalid-table-name": "Tên bảng không hợp lệ",- "invalid-view-name": "Tên khung nhìn không hợp lệ"- },- "preview-schema-text": "Xem trước văn bản lược đồ",- "preview-view-definition": "Xem trước định nghĩa khung nhìn",- "procedures": "Thủ tục",+ "insert-sql": "Chèn SQL","raw-sql": "SQL thô","schema": {- "name": "Tên lược đồ","select": "Chọn lược đồ"},- "search-database-and-table": "Tìm kiếm cơ sở dữ liệu và bảng",- "table": {- "name": "Tên bảng",- "select": "Chọn bảng"- },+ "self": "Trình chỉnh sửa lược đồ",+ "table": {},"table-partition": {- "add-sub-partition": "Thêm phân vùng con",- "edit-partitions": "Chỉnh sửa phân vùng","expression": "Biểu thức","partitions": "Phân vùng","type": "Loại","value": "Giá trị"},- "tables": "Bảng",- "views": "Khung nhìn"+ "template-database": "Cơ sở dữ liệu mẫu"},"schema-template": {"classification": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex f23e71a44b..60dca8b8cb 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -160,14 +160,8 @@}},"branch": {- "index": {- "drop-index-confirm": "删除索引?"- },- "select-tables-to-rollout": "选择要发布的表",- "table-partition": {- "drop-partition-confirm": "删除表分区?",- "drop-partition-with-subpartitions-confirm": "将会同时删除其所有子分区。"- }+ "index": {},+ "table-partition": {}},"cel": {"condition": {@@ -1768,9 +1762,7 @@},"task-execution-errors": "任务执行错误"},- "schema-designer": {- "use-tips": "选择需要设计的表"- },+ "schema-designer": {},"schema-diagram": {"fit-content-with-view": "自动适应视图","self": "Schema 关系图"@@ -1784,7 +1776,6 @@"create-table": "新建表","create-view": "创建视图","drop": "删除",- "drop-column": "删除列","drop-schema": "删除 Schema","drop-table": "删除表","rename": "重命名",@@ -1798,7 +1789,6 @@"not-null": "不可为空","on-update": "更新时","primary": "主键",- "select": "选择列","type": "类型"},"columns": "列",@@ -1811,53 +1801,26 @@"default": {"placeholder": "输入默认值或留空以不使用默认值"},- "foreign-key": {- "edit": "修改外键",- "name-description": "外键的名称应该是唯一的"- },- "functions": "函数",+ "foreign-key": {},"index": {"dependency-columns": "依赖列",- "edit-indexes": "编辑索引","indexes": "索引","unique": "唯一"},- "message": {- "cannot-drop-the-last-column": "不能删除最后一列",- "duplicated-function-name": "重复的函数名称",- "duplicated-procedure-name": "重复的存储过程名称",- "duplicated-table-name": "重复的表名",- "duplicated-view-name": "重复的视图名称",- "invalid-function-name": "无效的函数名称",- "invalid-procedure-name": "无效的存储过程名称",- "invalid-schema": "无效的 Schema",- "invalid-schema-name": "无效的 Schema 名称",- "invalid-table-name": "无效的表名",- "invalid-view-name": "无效的视图名称"- },- "preview-schema-text": "预览文本 schema",- "preview-view-definition": "预览视图定义",- "procedures": "存储过程",+ "insert-sql": "插入 SQL","raw-sql": "SQL 语句","schema": {- "name": "Schema 名称","select": "选择 schema"},- "search-database-and-table": "搜索数据库和表",- "table": {- "name": "表名",- "select": "选择表"- },+ "self": "Schema 编辑器",+ "table": {},"table-partition": {- "add-sub-partition": "添加子分区",- "edit-partitions": "编辑分区","expression": "表达式","partitions": "分区","type": "类型","value": "值"},- "tables": "表",- "views": "视图"+ "template-database": "模板数据库"},"schema-template": {"classification": {diff --git a/frontend/src/react/components/SchemaEditorLite/Aside/tree-builder.ts b/frontend/src/react/components/SchemaEditorLite/Aside/tree-builder.tsindex 55aebe706e..7a72a233d5 100644--- a/frontend/src/react/components/SchemaEditorLite/Aside/tree-builder.ts+++ b/frontend/src/react/components/SchemaEditorLite/Aside/tree-builder.ts@@ -1,9 +1,3 @@-import { keyForResource } from "@/components/SchemaEditorLite/context/common";-import {- engineSupportsEditFunctions,- engineSupportsEditProcedures,- engineSupportsEditViews,-} from "@/components/SchemaEditorLite/spec";import type {ColumnMetadata,Database,@@ -21,6 +15,12 @@ import {getInstanceResource,groupBy,} from "@/utils";+import { keyForResource } from "../core/keyForResource";+import {+ engineSupportsEditFunctions,+ engineSupportsEditProcedures,+ engineSupportsEditViews,+} from "../core/spec";import type { EditTarget } from "../types";// Tree node types — framework-agnostic (no naive-ui TreeOption dependency).diff --git a/frontend/src/react/components/SchemaEditorLite/Aside/useContextMenu.ts b/frontend/src/react/components/SchemaEditorLite/Aside/useContextMenu.tsindex 15d366ab7b..4528cc34a8 100644--- a/frontend/src/react/components/SchemaEditorLite/Aside/useContextMenu.ts+++ b/frontend/src/react/components/SchemaEditorLite/Aside/useContextMenu.ts@@ -1,9 +1,9 @@import { useCallback, useMemo, useState } from "react";import { useTranslation } from "react-i18next";-import { engineSupportsMultiSchema } from "@/components/SchemaEditorLite/spec";import { Engine } from "@/types/proto-es/v1/common_pb";import type { Database } from "@/types/proto-es/v1/database_service_pb";import { getDatabaseEngine } from "@/utils";+import { engineSupportsMultiSchema } from "../core/spec";import type { EditStatusContext } from "../types";import type { TreeNode } from "./tree-builder";diff --git a/frontend/src/react/components/SchemaEditorLite/Modals/EditColumnForeignKeySheet.tsx b/frontend/src/react/components/SchemaEditorLite/Modals/EditColumnForeignKeySheet.tsxindex 0b190ba002..c12d7c252f 100644--- a/frontend/src/react/components/SchemaEditorLite/Modals/EditColumnForeignKeySheet.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Modals/EditColumnForeignKeySheet.tsx@@ -1,9 +1,5 @@import { useCallback, useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";-import {- removeColumnFromForeignKey,- upsertColumnFromForeignKey,-} from "@/components/SchemaEditorLite/edit";import { Button } from "@/react/components/ui/button";import { Combobox } from "@/react/components/ui/combobox";import { Input } from "@/react/components/ui/input";@@ -24,6 +20,10 @@ import type {} from "@/types/proto-es/v1/database_service_pb";import { getDatabaseEngine, hasSchemaProperty } from "@/utils";import { useSchemaEditorContext } from "../context";+import {+ removeColumnFromForeignKey,+ upsertColumnFromForeignKey,+} from "../core/edit";interface Props {open: boolean;diff --git a/frontend/src/react/components/SchemaEditorLite/Modals/TableNameDialog.tsx b/frontend/src/react/components/SchemaEditorLite/Modals/TableNameDialog.tsxindex 4e7515a4dd..c51dc8b0cb 100644--- a/frontend/src/react/components/SchemaEditorLite/Modals/TableNameDialog.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Modals/TableNameDialog.tsx@@ -1,7 +1,6 @@import { create } from "@bufbuild/protobuf";import { useCallback, useState } from "react";import { useTranslation } from "react-i18next";-import { upsertColumnPrimaryKey } from "@/components/SchemaEditorLite/edit";import { Button } from "@/react/components/ui/button";import {Dialog,@@ -22,6 +21,7 @@ import {} from "@/types/proto-es/v1/database_service_pb";import { getDatabaseEngine } from "@/utils";import { useSchemaEditorContext } from "../context";+import { upsertColumnPrimaryKey } from "../core/edit";import { markUUID } from "../Panels/common";interface Props {diff --git a/frontend/src/react/components/SchemaEditorLite/Panels/PreviewPane.tsx b/frontend/src/react/components/SchemaEditorLite/Panels/PreviewPane.tsxindex c97e03079a..3d1d763c95 100644--- a/frontend/src/react/components/SchemaEditorLite/Panels/PreviewPane.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Panels/PreviewPane.tsx@@ -19,6 +19,7 @@ import { languageOfEngineV1 } from "@/types/sqlEditor/editor";import { getDatabaseEngine } from "@/utils";import { extractGrpcErrorMessage } from "@/utils/connect";import { useSchemaEditorContext } from "../context";+import { resizeHandleClass, usePersistedDragSize } from "../resize";interface Props {db: Database;@@ -27,7 +28,11 @@ interface Props {table: TableMetadata;}-const STORAGE_KEY = "bb.schema-editor.preview-expanded";+const EXPANDED_STORAGE_KEY = "bb.schema-editor.preview-expanded";+const HEIGHT_STORAGE_KEY = "bb.schema-editor.preview-height";+const PREVIEW_MIN_HEIGHT = 80;+const PREVIEW_MAX_HEIGHT = 600;+const PREVIEW_DEFAULT_HEIGHT = 160;export function PreviewPane({ db, database, schema, table }: Props) {const { t } = useTranslation();@@ -37,12 +42,23 @@ export function PreviewPane({ db, database, schema, table }: Props) {const [expanded, setExpanded] = useState(() => {try {- return localStorage.getItem(STORAGE_KEY) !== "false";+ return localStorage.getItem(EXPANDED_STORAGE_KEY) !== "false";} catch {return true;}});+ // Drag-to-resize for the preview height. Handle sits on the panel's top+ // edge, so dragging up (smaller Y) grows the panel.+ const { size: height, handleResizeStart } = usePersistedDragSize({+ storageKey: HEIGHT_STORAGE_KEY,+ axis: "y",+ growsToward: "before",+ defaultSize: PREVIEW_DEFAULT_HEIGHT,+ minSize: PREVIEW_MIN_HEIGHT,+ maxSize: PREVIEW_MAX_HEIGHT,+ });+const [pending, setPending] = useState(false);const [ddl, setDdl] = useState("");const [error, setError] = useState("");@@ -52,7 +68,7 @@ export function PreviewPane({ db, database, schema, table }: Props) {setExpanded((prev) => {const next = !prev;try {- localStorage.setItem(STORAGE_KEY, String(next));+ localStorage.setItem(EXPANDED_STORAGE_KEY, String(next));} catch {// ignore}@@ -60,16 +76,19 @@ export function PreviewPane({ db, database, schema, table }: Props) {});}, []);- // Build mocked metadata (filter dropped columns, wrap in single-table DatabaseMetadata)+ // Build mocked metadata (filter dropped columns, wrap in single-table+ // DatabaseMetadata). Depending on editStatus.version (a stable primitive+ // that bumps on any edit) instead of the editStatus object reference+ // prevents this memo from rebuilding on every parent re-render — which+ // would otherwise restart an in-flight getSchemaString fetch and leave+ // the preview perpetually empty.+ const editStatusVersion = editStatus.version;+ const getColumnStatus = editStatus.getColumnStatus;const mockedMetadata = useMemo(() => {const cloned = cloneDeep(table);cloned.columns = cloned.columns.filter((column) => {if (!column.name) return false;- const status = editStatus.getColumnStatus(db, {- schema,- table,- column,- });+ const status = getColumnStatus(db, { schema, table, column });return status !== "dropped";});return create(DatabaseMetadataSchema, {@@ -78,42 +97,46 @@ export function PreviewPane({ db, database, schema, table }: Props) {collation: database.collation,schemas: [{ name: schema.name, tables: [cloned] }],}) as DatabaseMetadata;- }, [table, editStatus, db, schema, database]);+ }, [table, db, schema, database, getColumnStatus, editStatusVersion]);- // Fetch schema string for the mocked metadata- const fetchSchemaString = useCallback(async () => {+ useEffect(() => {+ if (!expanded || hidePreview) return;const id = ++fetchIdRef.current;setPending(true);setError("");- try {- const request = create(GetSchemaStringRequestSchema, {- name: `${db.name}/schemaString`,- metadata: mockedMetadata,- });- const response =- await databaseServiceClientConnect.getSchemaString(request);- if (id !== fetchIdRef.current) return;- setDdl(response.schemaString);- } catch (err) {- if (id !== fetchIdRef.current) return;- setError(extractGrpcErrorMessage(err));- } finally {- if (id === fetchIdRef.current) {- setPending(false);+ (async () => {+ try {+ const request = create(GetSchemaStringRequestSchema, {+ name: `${db.name}/schemaString`,+ metadata: mockedMetadata,+ });+ const response =+ await databaseServiceClientConnect.getSchemaString(request);+ if (id !== fetchIdRef.current) return;+ setDdl(response.schemaString);+ } catch (err) {+ if (id !== fetchIdRef.current) return;+ setError(extractGrpcErrorMessage(err));+ } finally {+ if (id === fetchIdRef.current) {+ setPending(false);+ }}- }- }, [db, mockedMetadata]);-- useEffect(() => {- if (expanded && !hidePreview) {- fetchSchemaString();- }- }, [expanded, hidePreview, fetchSchemaString]);+ })();+ }, [expanded, hidePreview, db, mockedMetadata]);if (hidePreview) return null;return (- <div className="border-t border-control-border">+ <div className="flex flex-col border-t border-control-border">+ {expanded && (+ <div+ role="separator"+ aria-orientation="horizontal"+ className={resizeHandleClass("horizontal")}+ onMouseDown={handleResizeStart}+ />+ )}<buttontype="button"className="flex w-full items-center gap-x-1 px-4 py-1.5 text-xs font-medium text-control-light hover:text-control"@@ -127,7 +150,10 @@ export function PreviewPane({ db, database, schema, table }: Props) {{t("schema-editor.preview")}</button>{expanded && (- <div className="relative h-32 overflow-hidden">+ <div+ className="relative overflow-hidden"+ style={{ height: `${height}px` }}+ >{pending && (<div className="absolute inset-0 z-10 flex items-center justify-center bg-white/60"><Loader2 className="size-5 animate-spin text-accent" />diff --git a/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/DataTypeCell.tsx b/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/DataTypeCell.tsxindex 9505c19f3b..c1d5aba49e 100644--- a/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/DataTypeCell.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/DataTypeCell.tsx@@ -1,5 +1,5 @@import { useMemo } from "react";-import { Combobox } from "@/react/components/ui/combobox";+import { Input } from "@/react/components/ui/input";import type { Engine } from "@/types/proto-es/v1/common_pb";import type { ColumnMetadata } from "@/types/proto-es/v1/database_service_pb";import { getDataTypeSuggestionList } from "@/utils";@@ -9,29 +9,49 @@ interface Props {engine: Engine;readonly: boolean;onUpdateValue: (value: string) => void;+ /** Shared id for the host <datalist> element (one per engine). */+ datalistId: string;}export function DataTypeCell({column,- engine,readonly: isReadonly,onUpdateValue,+ datalistId,}: Props) {- const options = useMemo(() => {- return getDataTypeSuggestionList(engine).map((dataType) => ({- label: dataType,- value: dataType,- }));- }, [engine]);-return (- <Combobox- value={column.type || ""}- onChange={(val) => onUpdateValue(val as string)}- options={options}+ <Input+ list={datalistId}+ value={column.type ?? ""}disabled={isReadonly}placeholder="column type"- className="h-7"+ size="xs"+ className="border-none bg-transparent shadow-none focus-visible:ring-1"+ onChange={(e) => onUpdateValue(e.target.value)}/>);}++/**+ * Renders the suggestion datalist that DataTypeCell rows reference via+ * the `list` attribute. Mount once per table.+ */+export function DataTypeSuggestionsDatalist({+ id,+ engine,+}: {+ id: string;+ engine: Engine;+}) {+ const suggestions = useMemo(+ () => getDataTypeSuggestionList(engine),+ [engine]+ );+ return (+ <datalist id={id}>+ {suggestions.map((dataType) => (+ <option key={dataType} value={dataType} />+ ))}+ </datalist>+ );+}diff --git a/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/DefaultValueCell.tsx b/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/DefaultValueCell.tsxindex f3e0e10070..2a9052044e 100644--- a/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/DefaultValueCell.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/DefaultValueCell.tsx@@ -32,7 +32,8 @@ export function DefaultValueCell({ column, disabled, onUpdate }: Props) {value={column.default ?? ""}disabled={disabled}placeholder={t("schema-editor.default.placeholder")}- className="h-7 border-none bg-transparent shadow-none focus-visible:ring-1"+ size="xs"+ className="border-none bg-transparent shadow-none focus-visible:ring-1"onChange={(e) => handleChange(e.target.value)}/>);diff --git a/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/TableColumnEditor.tsx b/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/TableColumnEditor.tsxindex 5a11729a03..03721bb8a7 100644--- a/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/TableColumnEditor.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Panels/TableColumnEditor/TableColumnEditor.tsx@@ -1,10 +1,6 @@import { RotateCcw, Trash2 } from "lucide-react";import { useCallback, useMemo } from "react";import { useTranslation } from "react-i18next";-import {- removeColumnPrimaryKey,- upsertColumnPrimaryKey,-} from "@/components/SchemaEditorLite/edit";import { Button } from "@/react/components/ui/button";import { Input } from "@/react/components/ui/input";import {@@ -25,8 +21,12 @@ import type {TableMetadata,} from "@/types/proto-es/v1/database_service_pb";import { useSchemaEditorContext } from "../../context";+import {+ removeColumnPrimaryKey,+ upsertColumnPrimaryKey,+} from "../../core/edit";import { markUUID } from "../common";-import { DataTypeCell } from "./DataTypeCell";+import { DataTypeCell, DataTypeSuggestionsDatalist } from "./DataTypeCell";import { DefaultValueCell } from "./DefaultValueCell";interface Props {@@ -196,31 +196,38 @@ export function TableColumnEditor({[editStatus, db, schema, table]);+ const datalistId = `schema-editor-types-${engine}`;+ // Compact override for table cells: reduce default px-4 py-3 padding so each+ // row hugs the inline editor heights instead of doubling them.+ const cellClass = "px-2 py-1";+ const headClass = "h-8 px-2 py-1 whitespace-nowrap";+return (<div className="size-full overflow-auto">+ <DataTypeSuggestionsDatalist id={datalistId} engine={engine} /><Table><TableHeader><TableRow>- <TableHead className="w-[180px]">+ <TableHead className={cn(headClass, "w-[160px]")}>{t("schema-editor.column.name")}</TableHead>- <TableHead className="w-[160px]">+ <TableHead className={cn(headClass, "w-[180px]")}>{t("schema-editor.column.type")}</TableHead>- <TableHead className="w-[140px]">+ <TableHead className={cn(headClass, "w-[200px]")}>{t("schema-editor.column.default")}</TableHead>- <TableHead className="w-[160px]">+ <TableHead className={cn(headClass)}>{t("schema-editor.column.comment")}</TableHead>- <TableHead className="w-16 text-center">+ <TableHead className={cn(headClass, "w-[72px] text-center")}>{t("schema-editor.column.not-null")}</TableHead>- <TableHead className="w-16 text-center">+ <TableHead className={cn(headClass, "w-[72px] text-center")}>{t("schema-editor.column.primary")}</TableHead>{!isReadonly && (- <TableHead className="w-16 text-right">+ <TableHead className={cn(headClass, "w-[60px] text-right")}>{t("schema-editor.column.operations")}</TableHead>)}@@ -243,42 +250,45 @@ export function TableColumnEditor({status === "dropped" && "text-error line-through")}>- <TableCell>+ <TableCell className={cellClass}><Inputvalue={column.name}disabled={disabled}- className="h-7 border-none bg-transparent shadow-none focus-visible:ring-1"+ size="xs"+ className="border-none bg-transparent shadow-none focus-visible:ring-1"onChange={(e) =>handleColumnNameChange(column, e.target.value)}/></TableCell>- <TableCell>+ <TableCell className={cellClass}><DataTypeCellcolumn={column}engine={engine}readonly={disabled}+ datalistId={datalistId}onUpdateValue={(val) => handleColumnTypeChange(column, val)}/></TableCell>- <TableCell>+ <TableCell className={cellClass}><DefaultValueCellcolumn={column}disabled={disabled}onUpdate={(val) => handleDefaultChange(column, val)}/></TableCell>- <TableCell>+ <TableCell className={cellClass}><Inputvalue={column.comment}disabled={disabled}- className="h-7 border-none bg-transparent shadow-none focus-visible:ring-1"+ size="xs"+ className="border-none bg-transparent shadow-none focus-visible:ring-1"onChange={(e) =>handleCommentChange(column, e.target.value)}/></TableCell>- <TableCell className="text-center">+ <TableCell className={cn(cellClass, "text-center")}><inputtype="checkbox"checked={!column.nullable}@@ -288,7 +298,7 @@ export function TableColumnEditor({}/></TableCell>- <TableCell className="text-center">+ <TableCell className={cn(cellClass, "text-center")}><inputtype="checkbox"checked={isPK}@@ -299,7 +309,7 @@ export function TableColumnEditor({/></TableCell>{!isReadonly && (- <TableCell className="text-right">+ <TableCell className={cn(cellClass, "text-right")}>{status === "dropped" ? (<Buttonvariant="ghost"diff --git a/frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsx b/frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsxindex eccb91e225..c1007856fc 100644--- a/frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsx+++ b/frontend/src/react/components/SchemaEditorLite/Panels/TableEditor.tsx@@ -2,10 +2,6 @@ import { create } from "@bufbuild/protobuf";import { Plus } from "lucide-react";import { useCallback, useMemo, useState } from "react";import { useTranslation } from "react-i18next";-import {- engineSupportsEditIndexes,- engineSupportsEditTablePartitions,-} from "@/components/SchemaEditorLite/spec";import { Button } from "@/react/components/ui/button";import type {Database,@@ -16,6 +12,10 @@ import type {import { ColumnMetadataSchema } from "@/types/proto-es/v1/database_service_pb";import { getDatabaseEngine } from "@/utils";import { useSchemaEditorContext } from "../context";+import {+ engineSupportsEditIndexes,+ engineSupportsEditTablePartitions,+} from "../core/spec";import { markUUID } from "./common";import { IndexesEditor } from "./IndexesEditor";import { PartitionsEditor } from "./PartitionsEditor";diff --git a/frontend/src/react/components/SchemaEditorLite/SchemaEditorLite.tsx b/frontend/src/react/components/SchemaEditorLite/SchemaEditorLite.tsxindex 1e38d0a313..1aa22217bb 100644--- a/frontend/src/react/components/SchemaEditorLite/SchemaEditorLite.tsx+++ b/frontend/src/react/components/SchemaEditorLite/SchemaEditorLite.tsx@@ -17,6 +17,7 @@ import type { DatabaseMetadata } from "@/types/proto-es/v1/database_service_pb";import { AsideTree } from "./Aside/AsideTree";import { SchemaEditorProvider } from "./context";import { EditorPanel } from "./EditorPanel";+import { resizeHandleClass } from "./resize";import type {RebuildMetadataEditReset,SchemaEditorContextValue,@@ -180,13 +181,13 @@ export const SchemaEditorLite = forwardRef<)}{ready && (<PanelGroup id="schema-editor" orientation="horizontal">- <Panel defaultSize={25} minSize={15} maxSize={40}>+ <Panel defaultSize="25%" minSize="15%" maxSize="40%"><div className="size-full overflow-hidden"><AsideTree /></div></Panel>- <PanelResizeHandle className="w-[3px] bg-control-border transition-colors hover:bg-accent data-[resize-handle-active]:bg-accent" />- <Panel defaultSize={75}>+ <PanelResizeHandle className={resizeHandleClass("vertical")} />+ <Panel defaultSize="75%"><div className="size-full overflow-hidden"><EditorPanel /></div>diff --git a/frontend/src/components/SchemaEditorLite/algorithm/diff-merge.ts b/frontend/src/react/components/SchemaEditorLite/core/algorithm/diff-merge.tssimilarity index 97%rename from frontend/src/components/SchemaEditorLite/algorithm/diff-merge.tsrename to frontend/src/react/components/SchemaEditorLite/core/algorithm/diff-merge.tsindex 80b81ee9cc..e926005162 100644--- a/frontend/src/components/SchemaEditorLite/algorithm/diff-merge.ts+++ b/frontend/src/react/components/SchemaEditorLite/core/algorithm/diff-merge.ts@@ -21,8 +21,29 @@ import {keyBy,TinyTimer,} from "@/utils";-import type { SchemaEditorContext } from "../context";-import { keyForResourceName } from "../context/common";+import { keyForResourceName } from "../keyForResource";+import type { EditStatus } from "../types";++/**+ * Minimal context surface that DiffMerge depends on.+ * Both Vue and React adapters supply an object satisfying this shape.+ */+export interface DiffMergeContext {+ markEditStatusByKey: (key: string, status: EditStatus) => void;+ markEditStatus: (+ database: Database,+ metadata: {+ schema: SchemaMetadata;+ table?: TableMetadata;+ column?: ColumnMetadata;+ partition?: TablePartitionMetadata;+ procedure?: ProcedureMetadata;+ function?: FunctionMetadata;+ view?: ViewMetadata;+ },+ status: EditStatus+ ) => void;+}type RichSchemaMetadata = {database: DatabaseMetadata;@@ -36,7 +57,7 @@ type RichColumnMetadata = RichTableMetadata & {};export class DiffMerge {- context: SchemaEditorContext;+ context: DiffMergeContext;database: Database;sourceMetadata: DatabaseMetadata;targetMetadata: DatabaseMetadata;@@ -69,7 +90,7 @@ export class DiffMerge {sourceMetadata,targetMetadata,}: {- context: SchemaEditorContext;+ context: DiffMergeContext;database: Database;sourceMetadata: DatabaseMetadata;targetMetadata: DatabaseMetadata;diff --git a/frontend/src/react/components/SchemaEditorLite/core/algorithm/index.ts b/frontend/src/react/components/SchemaEditorLite/core/algorithm/index.tsnew file mode 100644index 0000000000..dd26e0ab09--- /dev/null+++ b/frontend/src/react/components/SchemaEditorLite/core/algorithm/index.ts@@ -0,0 +1,3 @@+export { DiffMerge, type DiffMergeContext } from "./diff-merge";++export type RebuildMetadataEditReset = "tabs" | "tree";diff --git a/frontend/src/components/SchemaEditorLite/utils/columnDefaultValue.ts b/frontend/src/react/components/SchemaEditorLite/core/columnDefaultValue.tssimilarity index 100%rename from frontend/src/components/SchemaEditorLite/utils/columnDefaultValue.tsrename to frontend/src/react/components/SchemaEditorLite/core/columnDefaultValue.tsdiff --git a/frontend/src/components/SchemaEditorLite/edit.ts b/frontend/src/react/components/SchemaEditorLite/core/edit.tssimilarity index 100%rename from frontend/src/components/SchemaEditorLite/edit.tsrename to frontend/src/react/components/SchemaEditorLite/core/edit.tsdiff --git a/frontend/src/components/SchemaEditorLite/common.ts b/frontend/src/react/components/SchemaEditorLite/core/generateDiffDDL.tssimilarity index 90%rename from frontend/src/components/SchemaEditorLite/common.tsrename to frontend/src/react/components/SchemaEditorLite/core/generateDiffDDL.tsindex 843920db5c..7e4b9eeda8 100644--- a/frontend/src/components/SchemaEditorLite/common.ts+++ b/frontend/src/react/components/SchemaEditorLite/core/generateDiffDDL.ts@@ -3,7 +3,6 @@ import { createContextValues } from "@connectrpc/connect";import { isEqual } from "lodash-es";import { sqlServiceClientConnect } from "@/connect";import { silentContextKey } from "@/connect/context-key";-import { t } from "@/plugins/i18n";import type {Database,DatabaseMetadata,@@ -11,7 +10,7 @@ import type {import { DiffMetadataRequestSchema } from "@/types/proto-es/v1/sql_service_pb";import { getDatabaseEngine } from "@/utils";import { extractGrpcErrorMessage } from "@/utils/connect";-import { validateDatabaseMetadata } from "./utils";+import { validateDatabaseMetadata } from "./metadata";export type GenerateDiffDDLResult = {statement: string;@@ -40,10 +39,7 @@ export const generateDiffDDL = async ({const validationMessages = validateDatabaseMetadata(targetMetadata);if (validationMessages.length > 0) {- return finish("", [- t("schema-editor.message.invalid-schema"),- ...validationMessages,- ]);+ return finish("", ["Invalid schema", ...validationMessages]);}try {const newRequest = create(DiffMetadataRequestSchema, {diff --git a/frontend/src/components/SchemaEditorLite/context/common.ts b/frontend/src/react/components/SchemaEditorLite/core/keyForResource.tssimilarity index 100%rename from frontend/src/components/SchemaEditorLite/context/common.tsrename to frontend/src/react/components/SchemaEditorLite/core/keyForResource.tsdiff --git a/frontend/src/components/SchemaEditorLite/utils/metadata.ts b/frontend/src/react/components/SchemaEditorLite/core/metadata.tssimilarity index 100%rename from frontend/src/components/SchemaEditorLite/utils/metadata.tsrename to frontend/src/react/components/SchemaEditorLite/core/metadata.tsdiff --git a/frontend/src/components/SchemaEditorLite/spec.ts b/frontend/src/react/components/SchemaEditorLite/core/spec.tssimilarity index 100%rename from frontend/src/components/SchemaEditorLite/spec.tsrename to frontend/src/react/components/SchemaEditorLite/core/spec.tsdiff --git a/frontend/src/components/SchemaEditorLite/types.ts b/frontend/src/react/components/SchemaEditorLite/core/types.tssimilarity index 100%rename from frontend/src/components/SchemaEditorLite/types.tsrename to frontend/src/react/components/SchemaEditorLite/core/types.tsdiff --git a/frontend/src/react/components/SchemaEditorLite/resize.ts b/frontend/src/react/components/SchemaEditorLite/resize.tsnew file mode 100644index 0000000000..92d93bd2f8--- /dev/null+++ b/frontend/src/react/components/SchemaEditorLite/resize.ts@@ -0,0 +1,157 @@+import { useCallback, useRef, useState } from "react";+import { cn } from "@/react/lib/utils";++/**+ * Shared visual styling for resize handles inside SchemaEditorLite.+ *+ * One source of truth for thickness + colors across:+ * - the horizontal Aside | Editor split (driven by `react-resizable-panels`)+ * - the vertical Editor / Preview split (driven by `usePersistedDragSize`)+ *+ * Both handles render as a 4px `bg-control-border` track that highlights to+ * `bg-accent` on hover or while being dragged. Pick the orientation that+ * matches the *split direction* you're separating, not the handle's own+ * shape:+ *+ * - `vertical` — vertical bar between two horizontally-stacked panels+ * - `horizontal` — horizontal bar between two vertically-stacked panels+ */+export type ResizeHandleOrientation = "vertical" | "horizontal";++const RESIZE_HANDLE_BASE_CLASS =+ "shrink-0 bg-control-border transition-colors hover:bg-accent data-[resize-handle-active]:bg-accent";++export function resizeHandleClass(+ orientation: ResizeHandleOrientation,+ className?: string+): string {+ return cn(+ RESIZE_HANDLE_BASE_CLASS,+ orientation === "vertical"+ ? "w-1 cursor-ew-resize"+ : "h-1 w-full cursor-ns-resize",+ className+ );+}++// ---- usePersistedDragSize -------------------------------------------------++/**+ * Which side of the resize handle is being sized. The handle separates two+ * panels; the consumer specifies which one this hook tracks.+ *+ * Examples:+ * - PreviewPane sits BELOW its top-edge handle and grows upward as the+ * handle is dragged up → `axis: "y"`, `growsToward: "before"`.+ * - A right-side details pane sits to the RIGHT of its left-edge handle+ * and grows rightward as the handle is dragged right → `axis: "x"`,+ * `growsToward: "after"`.+ */+export type ResizeAxis = "x" | "y";+export type SizeGrowth = "before" | "after";++export interface UsePersistedDragSizeOptions {+ /** localStorage key for persisting the chosen size between sessions. */+ storageKey: string;+ /** Which mouse coordinate drives the resize. */+ axis: ResizeAxis;+ /**+ * Direction the tracked panel grows in *handle coordinates*:+ * - `before` — dragging toward smaller coordinate values grows it+ * (e.g. dragging the top-edge handle UPWARD grows a panel below).+ * - `after` — dragging toward larger coordinate values grows it.+ */+ growsToward: SizeGrowth;+ defaultSize: number;+ minSize: number;+ maxSize: number;+}++export interface UsePersistedDragSizeResult {+ size: number;+ handleResizeStart: (event: React.MouseEvent) => void;+}++const isClient = typeof window !== "undefined";++function readPersistedSize(+ storageKey: string,+ fallback: number,+ minSize: number,+ maxSize: number+): number {+ if (!isClient) return fallback;+ try {+ const raw = window.localStorage.getItem(storageKey);+ if (raw === null) return fallback;+ const value = Number(raw);+ if (Number.isFinite(value) && value >= minSize && value <= maxSize) {+ return value;+ }+ } catch {+ // ignore – fallback to default+ }+ return fallback;+}++function writePersistedSize(storageKey: string, size: number): void {+ if (!isClient) return;+ try {+ window.localStorage.setItem(storageKey, String(size));+ } catch {+ // ignore – non-fatal, just won't persist+ }+}++/**+ * Hook that pairs a draggable resize handle with localStorage persistence.+ *+ * Returns the current `size` (clamped to [minSize, maxSize]) and a+ * `handleResizeStart` to wire up to a handle's `onMouseDown`. While the user+ * drags, the document cursor is locked to the appropriate resize cursor and+ * text selection is suppressed; both are cleaned up on release.+ */+export function usePersistedDragSize(+ options: UsePersistedDragSizeOptions+): UsePersistedDragSizeResult {+ const { storageKey, axis, growsToward, defaultSize, minSize, maxSize } =+ options;++ const [size, setSize] = useState(() =>+ readPersistedSize(storageKey, defaultSize, minSize, maxSize)+ );+ // Track latest size in a ref so the mouseup persistence sees the final+ // value (the closure captured by addEventListener freezes initial state).+ const sizeRef = useRef(size);+ sizeRef.current = size;++ const handleResizeStart = useCallback(+ (event: React.MouseEvent) => {+ event.preventDefault();+ const startCoord = axis === "y" ? event.clientY : event.clientX;+ const startSize = sizeRef.current;+ const sign = growsToward === "before" ? -1 : 1;++ const onMove = (ev: MouseEvent) => {+ const current = axis === "y" ? ev.clientY : ev.clientX;+ const delta = (current - startCoord) * sign;+ const next = Math.max(minSize, Math.min(maxSize, startSize + delta));+ setSize(next);+ };+ const onUp = () => {+ document.removeEventListener("mousemove", onMove);+ document.removeEventListener("mouseup", onUp);+ writePersistedSize(storageKey, sizeRef.current);+ document.body.style.cursor = "";+ document.body.style.userSelect = "";+ };+ document.addEventListener("mousemove", onMove);+ document.addEventListener("mouseup", onUp);+ document.body.style.cursor = axis === "y" ? "ns-resize" : "ew-resize";+ document.body.style.userSelect = "none";+ },+ [axis, growsToward, storageKey, minSize, maxSize]+ );++ return { size, handleResizeStart };+}diff --git a/frontend/src/react/components/SchemaEditorLite/types.ts b/frontend/src/react/components/SchemaEditorLite/types.tsindex 565feca958..794bab3565 100644--- a/frontend/src/react/components/SchemaEditorLite/types.ts+++ b/frontend/src/react/components/SchemaEditorLite/types.ts@@ -1,3 +1,4 @@+export type { RebuildMetadataEditReset } from "./core/algorithm";export type {CommonTabContext,CoreTabContext,@@ -6,19 +7,8 @@ export type {RolloutObject,TabContext,TabType,-} from "@/components/SchemaEditorLite/types";+} from "./core/types";-import type { CoreTabContext } from "@/components/SchemaEditorLite/types";--export type { RebuildMetadataEditReset } from "@/components/SchemaEditorLite/algorithm/rebuild";--import type { RebuildMetadataEditReset } from "@/components/SchemaEditorLite/algorithm/rebuild";-import type {- EditStatus,- EditTarget,- RolloutObject,- TabContext,-} from "@/components/SchemaEditorLite/types";import type {ColumnMetadata,Database,@@ -31,6 +21,14 @@ import type {ViewMetadata,} from "@/types/proto-es/v1/database_service_pb";import type { Project } from "@/types/proto-es/v1/project_service_pb";+import type { RebuildMetadataEditReset } from "./core/algorithm";+import type {+ CoreTabContext,+ EditStatus,+ EditTarget,+ RolloutObject,+ TabContext,+} from "./core/types";export type SchemaEditorOptions = {forceShowIndexes: boolean;@@ -97,6 +95,12 @@ export type TabsContext = {// Edit status contextexport type EditStatusContext = {isDirty: boolean;+ /**+ * Monotonic counter that bumps on any mutation (mark / remove / clear).+ * Use as a memo / effect dependency to react to in-place metadata edits+ * that React cannot otherwise observe.+ */+ version: number;markEditStatus: (database: Database,metadata: SchemaResourceMetadata,diff --git a/frontend/src/react/components/SchemaEditorLite/useAlgorithm.ts b/frontend/src/react/components/SchemaEditorLite/useAlgorithm.tsindex 4552afda76..633b1125d5 100644--- a/frontend/src/react/components/SchemaEditorLite/useAlgorithm.ts+++ b/frontend/src/react/components/SchemaEditorLite/useAlgorithm.ts@@ -1,22 +1,16 @@import { cloneDeep } from "lodash-es";import { useCallback } from "react";-import { DiffMerge } from "@/components/SchemaEditorLite/algorithm/diff-merge";-import type { RebuildMetadataEditReset } from "@/components/SchemaEditorLite/algorithm/rebuild";-import type { EditStatus } from "@/components/SchemaEditorLite/types";import type {Database,DatabaseMetadata,} from "@/types/proto-es/v1/database_service_pb";+import {+ DiffMerge,+ type DiffMergeContext,+ type RebuildMetadataEditReset,+} from "./core/algorithm";import type { EditStatusContext, EditTarget } from "./types";-/**- * Adapter interface that DiffMerge needs from context.- * DiffMerge only calls `markEditStatusByKey` on the context object.- */-interface DiffMergeAdapter {- markEditStatusByKey: (key: string, status: EditStatus) => void;-}-export function useAlgorithm(editStatus: EditStatusContext,callbacks: {@@ -29,16 +23,13 @@ export function useAlgorithm(editStatus.clearEditStatus();const { database, metadata, baselineMetadata } = target;- const adapter: DiffMergeAdapter = {+ const adapter: DiffMergeContext = {markEditStatusByKey: editStatus.markEditStatusByKey,+ markEditStatus: editStatus.markEditStatus,};- // DiffMerge expects a context with markEditStatusByKey.- // We cast the adapter since DiffMerge only uses this one method at runtime.const dm = new DiffMerge({- context: adapter as unknown as ConstructorParameters<- typeof DiffMerge- >[0]["context"],+ context: adapter,database,sourceMetadata: baselineMetadata,targetMetadata: metadata,diff --git a/frontend/src/react/components/SchemaEditorLite/useEditStatus.ts b/frontend/src/react/components/SchemaEditorLite/useEditStatus.tsindex eff04b638a..8ca9103a75 100644--- a/frontend/src/react/components/SchemaEditorLite/useEditStatus.ts+++ b/frontend/src/react/components/SchemaEditorLite/useEditStatus.ts@@ -1,6 +1,4 @@import { useCallback, useMemo, useRef, useState } from "react";-import { keyForResource } from "@/components/SchemaEditorLite/context/common";-import type { EditStatus } from "@/components/SchemaEditorLite/types";import type {ColumnMetadata,Database,@@ -11,6 +9,8 @@ import type {TablePartitionMetadata,ViewMetadata,} from "@/types/proto-es/v1/database_service_pb";+import { keyForResource } from "./core/keyForResource";+import type { EditStatus } from "./core/types";import type { EditStatusContext, SchemaResourceMetadata } from "./types";export function useEditStatus(): EditStatusContext {@@ -198,6 +198,7 @@ export function useEditStatus(): EditStatusContext {return {isDirty,+ version,markEditStatus,markEditStatusByKey,getEditStatusByKey,diff --git a/frontend/src/react/components/SchemaEditorLite/useSelection.ts b/frontend/src/react/components/SchemaEditorLite/useSelection.tsindex d2127b5020..a9ac3b10c7 100644--- a/frontend/src/react/components/SchemaEditorLite/useSelection.ts+++ b/frontend/src/react/components/SchemaEditorLite/useSelection.ts@@ -1,7 +1,5 @@import { pick } from "lodash-es";import { useCallback, useMemo } from "react";-import { keyForResource } from "@/components/SchemaEditorLite/context/common";-import type { RolloutObject } from "@/components/SchemaEditorLite/types";import type {ColumnMetadata,Database,@@ -12,6 +10,8 @@ import type {TableMetadata,ViewMetadata,} from "@/types/proto-es/v1/database_service_pb";+import { keyForResource } from "./core/keyForResource";+import type { RolloutObject } from "./core/types";import type { SelectionContext, SelectionState } from "./types";const EMPTY_STATE: SelectionState = { checked: false, indeterminate: false };diff --git a/frontend/src/react/components/SchemaEditorLite/useTabs.ts b/frontend/src/react/components/SchemaEditorLite/useTabs.tsindex a4f045f311..93292e2db9 100644--- a/frontend/src/react/components/SchemaEditorLite/useTabs.ts+++ b/frontend/src/react/components/SchemaEditorLite/useTabs.ts@@ -1,9 +1,6 @@import { useCallback, useMemo, useRef, useState } from "react";import { v1 as uuidv1 } from "uuid";-import type {- CoreTabContext,- TabContext,-} from "@/components/SchemaEditorLite/types";+import type { CoreTabContext, TabContext } from "./core/types";import type { TabsContext } from "./types";export function useTabs(): TabsContext {diff --git a/frontend/src/react/components/monaco/MonacoEditor.tsx b/frontend/src/react/components/monaco/MonacoEditor.tsxindex 2dab62f44f..54cd549d68 100644--- a/frontend/src/react/components/monaco/MonacoEditor.tsx+++ b/frontend/src/react/components/monaco/MonacoEditor.tsx@@ -407,7 +407,17 @@ export function MonacoEditor({if (!editor || !model) return;if (model.getValue() !== contentRef.current) {isApplyingExternalChangeRef.current = true;- trySetContentWithUndo(editor, contentRef.current, "sync-content");+ // `executeEdits` (used by trySetContentWithUndo) is a no-op when the+ // editor is in readOnly mode — Monaco silently rejects edits regardless+ // of source. ReadonlyMonaco surfaces async data via prop changes, so we+ // must use `editor.setValue` (which bypasses the readOnly gate) for the+ // content sync to actually take effect. Editable editors keep the+ // undo-history-friendly path.+ if (readOnlyRef.current) {+ editor.setValue(contentRef.current);+ } else {+ trySetContentWithUndo(editor, contentRef.current, "sync-content");+ }isApplyingExternalChangeRef.current = false;}setContentHeight(editor.getContentHeight());diff --git a/frontend/src/react/components/sql-editor/Panels/common/tables/ColumnsTable.tsx b/frontend/src/react/components/sql-editor/Panels/common/tables/ColumnsTable.tsxindex 8e548fd28a..9d00f9c87b 100644--- a/frontend/src/react/components/sql-editor/Panels/common/tables/ColumnsTable.tsx+++ b/frontend/src/react/components/sql-editor/Panels/common/tables/ColumnsTable.tsx@@ -1,7 +1,7 @@import { useEffect, useMemo, useRef } from "react";import { useTranslation } from "react-i18next";-import { engineSupportsMultiSchema } from "@/components/SchemaEditorLite/spec";import { HighlightLabelText } from "@/react/components/HighlightLabelText";+import { engineSupportsMultiSchema } from "@/react/components/SchemaEditorLite/core/spec";import {Table,TableBody,diff --git a/frontend/src/react/components/sql-editor/SchemaPane/HoverPanel/ColumnInfo.tsx b/frontend/src/react/components/sql-editor/SchemaPane/HoverPanel/ColumnInfo.tsxindex c739cc76ca..9b5d8648cb 100644--- a/frontend/src/react/components/sql-editor/SchemaPane/HoverPanel/ColumnInfo.tsx+++ b/frontend/src/react/components/sql-editor/SchemaPane/HoverPanel/ColumnInfo.tsx@@ -1,7 +1,7 @@import { create } from "@bufbuild/protobuf";import { Check, X } from "lucide-react";import { useTranslation } from "react-i18next";-import { getColumnDefaultValuePlaceholder } from "@/components/SchemaEditorLite/utils/columnDefaultValue";+import { getColumnDefaultValuePlaceholder } from "@/react/components/SchemaEditorLite/core/columnDefaultValue";import { useVueState } from "@/react/hooks/useVueState";import { useDatabaseV1Store, useDBSchemaV1Store } from "@/store";import { Engine } from "@/types/proto-es/v1/common_pb";diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.jsonindex fa2a38a8b7..f134dd4cc4 100644--- a/frontend/src/react/locales/en-US.json+++ b/frontend/src/react/locales/en-US.json@@ -2006,6 +2006,8 @@"unique": "Unique"},"indexes": "Indexes",+ "insert-sql": "Insert SQL",+ "no-diff": "No changes to apply","partition": {"expression": "Expression","type": "Type",@@ -2018,6 +2020,7 @@"duplicate-name": "Schema name already exists","name-placeholder": "Schema name"},+ "self": "Schema editor","table": {"duplicate-name": "Table name already exists","name-placeholder": "Table name",@@ -2029,7 +2032,8 @@"partitions": "Partitions","type": "Type","value": "Value"- }+ },+ "template-database": "Template database"},"schema-template": {"classification": {diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.jsonindex c717835b5a..9dc9df3211 100644--- a/frontend/src/react/locales/es-ES.json+++ b/frontend/src/react/locales/es-ES.json@@ -1993,6 +1993,8 @@"unique": "Unique"},"indexes": "Indexes",+ "insert-sql": "Insertar SQL",+ "no-diff": "No hay cambios para aplicar","partition": {"expression": "Expression","type": "Type",@@ -2005,6 +2007,7 @@"duplicate-name": "Schema name already exists","name-placeholder": "Schema name"},+ "self": "Editor de esquema","table": {"duplicate-name": "Table name already exists","name-placeholder": "Table name",@@ -2016,7 +2019,8 @@"partitions": "Particiones","type": "Tipo","value": "Valor"- }+ },+ "template-database": "Base de datos plantilla"},"schema-template": {"classification": {diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.jsonindex ede84f5884..22044c7a9f 100644--- a/frontend/src/react/locales/ja-JP.json+++ b/frontend/src/react/locales/ja-JP.json@@ -1993,6 +1993,8 @@"unique": "Unique"},"indexes": "Indexes",+ "insert-sql": "SQL を挿入",+ "no-diff": "適用する変更はありません","partition": {"expression": "Expression","type": "Type",@@ -2005,6 +2007,7 @@"duplicate-name": "Schema name already exists","name-placeholder": "Schema name"},+ "self": "スキーマエディタ","table": {"duplicate-name": "Table name already exists","name-placeholder": "Table name",@@ -2016,7 +2019,8 @@"partitions": "パーティション","type": "タイプ","value": "値"- }+ },+ "template-database": "テンプレートデータベース"},"schema-template": {"classification": {diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.jsonindex 7b246d9020..f3bf7dc1d3 100644--- a/frontend/src/react/locales/vi-VN.json+++ b/frontend/src/react/locales/vi-VN.json@@ -1993,6 +1993,8 @@"unique": "Unique"},"indexes": "Indexes",+ "insert-sql": "Chèn SQL",+ "no-diff": "Không có thay đổi nào để áp dụng","partition": {"expression": "Expression","type": "Type",@@ -2005,6 +2007,7 @@"duplicate-name": "Schema name already exists","name-placeholder": "Schema name"},+ "self": "Trình chỉnh sửa lược đồ","table": {"duplicate-name": "Table name already exists","name-placeholder": "Table name",@@ -2016,7 +2019,8 @@"partitions": "Phân vùng","type": "Loại","value": "Giá trị"- }+ },+ "template-database": "Cơ sở dữ liệu mẫu"},"schema-template": {"classification": {diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.jsonindex 0510ffb43a..1de2cf45d9 100644--- a/frontend/src/react/locales/zh-CN.json+++ b/frontend/src/react/locales/zh-CN.json@@ -1993,6 +1993,8 @@"unique": "Unique"},"indexes": "Indexes",+ "insert-sql": "插入 SQL",+ "no-diff": "没有需要应用的变更","partition": {"expression": "Expression","type": "Type",@@ -2005,6 +2007,7 @@"duplicate-name": "Schema name already exists","name-placeholder": "Schema name"},+ "self": "Schema 编辑器","table": {"duplicate-name": "Table name already exists","name-placeholder": "Table name",@@ -2016,7 +2019,8 @@"partitions": "分区","type": "类型","value": "值"- }+ },+ "template-database": "模板数据库"},"schema-template": {"classification": {diff --git a/frontend/src/react/pages/project/database-detail/overview/DatabaseObjectExplorer.tsx b/frontend/src/react/pages/project/database-detail/overview/DatabaseObjectExplorer.tsxindex 08d784c421..3122e1c027 100644--- a/frontend/src/react/pages/project/database-detail/overview/DatabaseObjectExplorer.tsx+++ b/frontend/src/react/pages/project/database-detail/overview/DatabaseObjectExplorer.tsx@@ -1,6 +1,6 @@import { useEffect, useState } from "react";import { useTranslation } from "react-i18next";-import { getColumnDefaultValuePlaceholder } from "@/components/SchemaEditorLite/utils/columnDefaultValue";+import { getColumnDefaultValuePlaceholder } from "@/react/components/SchemaEditorLite/core/columnDefaultValue";import { Input } from "@/react/components/ui/input";import { useVueState } from "@/react/hooks/useVueState";import { router } from "@/router";diff --git a/frontend/src/react/pages/project/plan-detail/components/PlanDetailStatementSection.tsx b/frontend/src/react/pages/project/plan-detail/components/PlanDetailStatementSection.tsxindex 7c5b2da0b0..1c6f7b4f69 100644--- a/frontend/src/react/pages/project/plan-detail/components/PlanDetailStatementSection.tsx+++ b/frontend/src/react/pages/project/plan-detail/components/PlanDetailStatementSection.tsx@@ -1,6 +1,6 @@import { clone, create } from "@bufbuild/protobuf";import dayjs from "dayjs";-import { ExternalLink, Loader2, Package, Upload } from "lucide-react";+import { ExternalLink, Loader2, Package, Table, Upload } from "lucide-react";import { type ChangeEvent, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import {@@ -11,6 +11,7 @@ import {import { MonacoEditor, ReadonlyMonaco } from "@/react/components/monaco";import { Alert } from "@/react/components/ui/alert";import { Button } from "@/react/components/ui/button";+import { useVueState } from "@/react/hooks/useVueState";import { cn } from "@/react/lib/utils";import { pushNotification, useDatabaseV1Store, useSheetV1Store } from "@/store";import {@@ -33,6 +34,7 @@ import {} from "@/types/proto-es/v1/release_service_pb";import { GetSheetRequestSchema } from "@/types/proto-es/v1/sheet_service_pb";import { extractDatabaseResourceName, hasProjectPermissionV2 } from "@/utils";+import { engineSupportsSchemaEditor } from "@/utils/schemaEditor";import { getStatementSize, MAX_UPLOAD_FILE_SIZE_MB } from "@/utils/sheet";import { getInstanceResource } from "@/utils/v1/database";import { sheetNameOfSpec } from "@/utils/v1/issue/plan";@@ -47,6 +49,7 @@ import {getLocalSheetByName,} from "../utils/localSheet";import { getSQLAdviceMarkers } from "../utils/sqlAdvice";+import { SchemaEditorSheet } from "./SchemaEditorSheet";const MAX_DISPLAYED_RELEASE_FILES = 4;@@ -79,6 +82,7 @@ export function PlanDetailStatementSection({const [isSaving, setIsSaving] = useState(false);const [statement, setStatement] = useState("");const [draftStatement, setDraftStatement] = useState("");+ const [isSchemaEditorOpen, setIsSchemaEditorOpen] = useState(false);const inputRef = useRef<HTMLInputElement>(null);const editingScope = useMemo(() => `statement:${spec.id}`, [spec.id]);@@ -91,6 +95,30 @@ export function PlanDetailStatementSection({}return (spec.config.value.targets ?? []).find(isValidDatabaseName) ?? "";}, [spec]);+ // All valid database targets — used by Schema Editor to load template metadata.+ const targetDatabaseNames = useMemo(() => {+ if (spec.config?.case !== "changeDatabaseConfig") return [];+ return (spec.config.value.targets ?? []).filter(isValidDatabaseName);+ }, [spec]);+ // Hydrate target databases so the engine check below isn't flying blind on+ // the unknownDatabase() stub returned for cache misses.+ useEffect(() => {+ if (targetDatabaseNames.length > 0) {+ void databaseStore.batchGetOrFetchDatabases(targetDatabaseNames);+ }+ }, [targetDatabaseNames, databaseStore]);+ // Show Schema Editor only when at least one target's engine supports it.+ // Wrapped in useVueState so the eligibility flips back on once the Pinia+ // store hydrates the targets — otherwise a Plan opened before its targets+ // are cached would render with the button perpetually hidden.+ const schemaEditorEligible = useVueState(() => {+ if (targetDatabaseNames.length === 0) return false;+ return targetDatabaseNames.some((name) => {+ const db = databaseStore.getDatabaseByName(name);+ if (!db || !isValidDatabaseName(db.name)) return false;+ return engineSupportsSchemaEditor(getInstanceResource(db).engine);+ });+ });const language = useMemo(() => {if (!targetDatabaseName) return "sql";const database = databaseStore.getDatabaseByName(targetDatabaseName);@@ -254,6 +282,15 @@ export function PlanDetailStatementSection({setIsEditing(true);};+ const handleSchemaEditorInsert = (nextStatement: string) => {+ if (page.isCreating) {+ updateLocalStatement(nextStatement);+ return;+ }+ setDraftStatement(nextStatement);+ setIsEditing(true);+ };+const patchPlanStatement = (nextSheetName: string) => {const planPatch = clone(PlanSchema, page.plan);const specToPatch = planPatch.specs.find(@@ -378,6 +415,16 @@ export function PlanDetailStatementSection({<Upload className="h-3.5 w-3.5" />{t("issue.upload-sql")}</Button>+ {schemaEditorEligible && (+ <Button+ onClick={() => setIsSchemaEditorOpen(true)}+ size="xs"+ variant="outline"+ >+ <Table className="h-3.5 w-3.5" />+ {t("schema-editor.self")}+ </Button>+ )}{!isEditing ? (canEdit ? (<Button@@ -442,7 +489,7 @@ export function PlanDetailStatementSection({{t("common.loading")}</div>) : statement || draftStatement || isEditing ? (- <div className="relative">+ <div className="relative overflow-hidden rounded-sm border border-control-border">{isEditing ? (<MonacoEditoradvices={page.isCreating ? markers : []}@@ -472,6 +519,15 @@ export function PlanDetailStatementSection({{t("common.no-data")}</div>)}+ {project && schemaEditorEligible && (+ <SchemaEditorSheet+ open={isSchemaEditorOpen}+ onOpenChange={setIsSchemaEditorOpen}+ databaseNames={targetDatabaseNames}+ project={project}+ onInsert={handleSchemaEditorInsert}+ />+ )}</div>);}diff --git a/frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx b/frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsxnew file mode 100644index 0000000000..2b0c8fae25--- /dev/null+++ b/frontend/src/react/pages/project/plan-detail/components/SchemaEditorSheet.tsx@@ -0,0 +1,256 @@+import { cloneDeep } from "lodash-es";+import { Loader2 } from "lucide-react";+import { useCallback, useEffect, useRef, useState } from "react";+import { useTranslation } from "react-i18next";+import { SchemaEditorLite } from "@/react/components/SchemaEditorLite";+import { generateDiffDDL } from "@/react/components/SchemaEditorLite/core/generateDiffDDL";+import type { EditTarget } from "@/react/components/SchemaEditorLite/core/types";+import type { SchemaEditorHandle } from "@/react/components/SchemaEditorLite/types";+import { Button } from "@/react/components/ui/button";+import { Combobox } from "@/react/components/ui/combobox";+import {+ Sheet,+ SheetContent,+ SheetFooter,+ SheetHeader,+ SheetTitle,+} from "@/react/components/ui/sheet";+import { useVueState } from "@/react/hooks/useVueState";+import {+ pushNotification,+ useDatabaseV1Store,+ useDBSchemaV1Store,+} from "@/store";+import { isValidDatabaseName } from "@/types";+import type { Project } from "@/types/proto-es/v1/project_service_pb";+import { extractDatabaseResourceName, getInstanceResource } from "@/utils";+import { engineSupportsSchemaEditor } from "@/utils/schemaEditor";++interface Props {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ databaseNames: string[];+ project: Project;+ onInsert: (sql: string) => void;+}++export function SchemaEditorSheet({+ open,+ onOpenChange,+ databaseNames,+ project,+ onInsert,+}: Props) {+ const { t } = useTranslation();+ return (+ <Sheet open={open} onOpenChange={onOpenChange}>+ <SheetContent width="xlarge" className="flex flex-col">+ <SheetHeader>+ <SheetTitle>{t("schema-editor.self")}</SheetTitle>+ </SheetHeader>+ {open && (+ <SchemaEditorSheetBody+ databaseNames={databaseNames}+ project={project}+ onInsert={onInsert}+ onCancel={() => onOpenChange(false)}+ />+ )}+ </SheetContent>+ </Sheet>+ );+}++interface BodyProps {+ databaseNames: string[];+ project: Project;+ onInsert: (sql: string) => void;+ onCancel: () => void;+}++function SchemaEditorSheetBody({+ databaseNames,+ project,+ onInsert,+ onCancel,+}: BodyProps) {+ const { t } = useTranslation();+ const dbSchemaStore = useDBSchemaV1Store();+ const databaseStore = useDatabaseV1Store();+ const schemaEditorRef = useRef<SchemaEditorHandle>(null);++ const [selectedDatabaseName, setSelectedDatabaseName] = useState(+ databaseNames[0] ?? ""+ );+ const [targets, setTargets] = useState<EditTarget[]>([]);+ const [isPreparingMetadata, setIsPreparingMetadata] = useState(false);+ const [isInserting, setIsInserting] = useState(false);+ // Monotonic id for prepareMetadata calls. Switching template database+ // quickly can let an older request resolve last and clobber `targets`+ // with metadata for the wrong database; bumping the id and discarding+ // stale resolutions is the standard last-write-wins guard.+ const prepareIdRef = useRef(0);++ // Kick off hydration for any targets the store hasn't seen yet so the+ // option list below can resolve real engine + title (otherwise unhydrated+ // entries fall back to the raw resource name and stay disabled).+ useEffect(() => {+ if (databaseNames.length > 0) {+ void databaseStore.batchGetOrFetchDatabases(databaseNames);+ }+ }, [databaseNames, databaseStore]);++ // Subscribed to the Pinia store via useVueState — re-derives once the+ // hydration above completes so newly-fetched targets switch from the+ // bare-name placeholder to a real "<db> (<instance>)" label.+ const databaseOptions = useVueState(() =>+ databaseNames.map((name) => {+ const db = databaseStore.getDatabaseByName(name);+ const hydrated = db && isValidDatabaseName(db.name);+ const instance = hydrated ? getInstanceResource(db) : undefined;+ const databaseLabel = extractDatabaseResourceName(name).databaseName;+ const label = instance+ ? `${databaseLabel} (${instance.title})`+ : databaseLabel;+ return {+ value: name,+ label,+ // Until a target is hydrated we don't know its engine yet; keep it+ // disabled rather than rendering it as supported and letting the+ // user pick something we'd then have to reject.+ disabled: !instance || !engineSupportsSchemaEditor(instance.engine),+ };+ })+ );++ const prepareMetadata = useCallback(+ async (databaseName: string) => {+ if (!databaseName) return;+ const id = ++prepareIdRef.current;+ setIsPreparingMetadata(true);+ setTargets([]);+ try {+ const [metadata, database] = await Promise.all([+ dbSchemaStore.getOrFetchDatabaseMetadata({+ database: databaseName,+ skipCache: true,+ limit: 200,+ }),+ databaseStore.getOrFetchDatabaseByName(databaseName),+ ]);+ // A newer prepareMetadata call superseded us — drop this result so+ // the user can't end up editing one database while seeing another+ // selected in the combobox.+ if (id !== prepareIdRef.current) return;+ setTargets([+ {+ database,+ metadata: cloneDeep(metadata),+ baselineMetadata: metadata,+ },+ ]);+ } finally {+ if (id === prepareIdRef.current) {+ setIsPreparingMetadata(false);+ }+ }+ },+ [dbSchemaStore, databaseStore]+ );++ useEffect(() => {+ void prepareMetadata(selectedDatabaseName);+ }, [selectedDatabaseName, prepareMetadata]);++ const handleInsert = useCallback(async () => {+ const handle = schemaEditorRef.current;+ if (!handle) return;+ const target = targets[0];+ if (!target) return;+ try {+ setIsInserting(true);+ const { metadata } = handle.applyMetadataEdit(+ target.database,+ target.metadata+ );+ const result = await generateDiffDDL({+ database: target.database,+ sourceMetadata: target.baselineMetadata,+ targetMetadata: metadata,+ });+ // Surface diff failures (RPC error, schema validation) instead of+ // letting the spinner stop with no feedback — that "silent no-op"+ // is indistinguishable from "no changes" and blocks recovery.+ if (result.errors.length > 0) {+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: t("common.error"),+ description: result.errors.join("\n"),+ });+ return;+ }+ if (!result.statement) {+ // No errors and no diff = the edits cancel out. Tell the user so+ // they don't think the button is broken.+ pushNotification({+ module: "bytebase",+ style: "INFO",+ title: t("schema-editor.no-diff"),+ });+ return;+ }+ onInsert(result.statement);+ onCancel();+ } finally {+ setIsInserting(false);+ }+ }, [targets, onInsert, onCancel, t]);++ return (+ <>+ <div className="flex flex-1 flex-col gap-y-3 overflow-hidden px-4 pb-2">+ {databaseNames.length > 1 && (+ <div className="flex items-center gap-x-2">+ <span className="text-sm text-control-light">+ {t("schema-editor.template-database")}:+ </span>+ <Combobox+ value={selectedDatabaseName}+ onChange={setSelectedDatabaseName}+ options={databaseOptions}+ disabled={isPreparingMetadata}+ clearable={false}+ className="w-80"+ portal+ />+ </div>+ )}+ <div className="relative flex-1 overflow-hidden">+ <SchemaEditorLite+ ref={schemaEditorRef}+ project={project}+ targets={targets}+ loading={isPreparingMetadata}+ />+ </div>+ </div>+ <SheetFooter>+ <div className="flex w-full items-center justify-end gap-x-2">+ <Button variant="outline" onClick={onCancel}>+ {t("common.cancel")}+ </Button>+ <Button+ disabled={+ isPreparingMetadata || isInserting || targets.length === 0+ }+ onClick={() => void handleInsert()}+ >+ {isInserting && <Loader2 className="size-4 animate-spin" />}+ {t("schema-editor.insert-sql")}+ </Button>+ </div>+ </SheetFooter>+ </>+ );+}