Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update creating branch panel (#7811)
boojack3b72cfb11573
diff --git a/frontend/src/components/SchemaDesigner/BaselineSchemaSelector.vue b/frontend/src/components/SchemaDesigner/BaselineSchemaSelector.vueindex f393b33b91..6716bfcb88 100644--- a/frontend/src/components/SchemaDesigner/BaselineSchemaSelector.vue+++ b/frontend/src/components/SchemaDesigner/BaselineSchemaSelector.vue@@ -2,16 +2,6 @@<divclass="w-full mx-auto flex flex-col justify-start items-start space-y-3 mb-6">- <div class="w-full flex flex-row justify-start items-center">- <span class="flex w-40 items-center shrink-0 text-sm">- {{ $t("common.project") }}- </span>- <ProjectSelect- class="!w-60 shrink-0"- :selected-id="state.projectId"- @select-project-id="handleProjectSelect"- />- </div><div class="w-full flex flex-row justify-start items-center"><span class="flex w-40 items-center shrink-0 text-sm">{{ $t("common.database") }}@@ -28,7 +18,7 @@:selected-id="state.databaseId ?? String(UNKNOWN_ID)":mode="'USER'":environment-id="state.environmentId"- :project-id="state.projectId"+ :project-id="props.projectId":engine-type-list="allowedEngineTypeList":sync-status="'OK'":customize-item="true"@@ -52,7 +42,7 @@</span><divclass="w-192 flex flex-row justify-start items-center relative"- :class="isValidId(state.projectId) ? '' : 'opacity-50'"+ :class="isValidId(props.projectId) ? '' : 'opacity-50'"><BBSelectclass="w-full"@@ -116,12 +106,12 @@ import {import { instanceV1Name } from "@/utils";interface BaselineSchema {- projectId?: string;databaseId?: string;changeHistory?: ChangeHistory;}const props = defineProps<{+ projectId?: string;baselineSchema?: BaselineSchema;}>();@@ -130,7 +120,6 @@ const emit = defineEmits<{}>();interface LocalState {- projectId?: string;environmentId?: string;databaseId?: string;changeHistory?: ChangeHistory;@@ -167,18 +156,28 @@ onMounted(async () => {const database = await databaseStore.getOrFetchDatabaseByUID(props.baselineSchema.databaseId || "");- state.projectId = props.baselineSchema.projectId;state.databaseId = database.uid;state.environmentId = database.effectiveEnvironmentEntity.uid;state.changeHistory = props.baselineSchema.changeHistory;} catch (error) {// do nothing.}- } else if (props.baselineSchema?.projectId) {- state.projectId = props.baselineSchema.projectId;}});+watch(+ () => props.projectId,+ () => {+ if (!database.value || !props.projectId) {+ return;+ }+ if (database.value.projectEntity.uid !== props.projectId) {+ state.environmentId = undefined;+ state.databaseId = undefined;+ }+ }+);+watch(() => state.databaseId,async () => {@@ -245,13 +244,6 @@ const isValidId = (id: any): id is string => {return true;};-const handleProjectSelect = async (projectId: string) => {- if (projectId !== state.projectId) {- state.databaseId = String(UNKNOWN_ID);- }- state.projectId = projectId;-};-const handleEnvironmentSelect = async (environmentId: string) => {if (environmentId !== state.environmentId) {state.databaseId = String(UNKNOWN_ID);@@ -269,7 +261,6 @@ const handleDatabaseSelect = async (databaseId: string) => {const environment = environmentStore.getEnvironmentByName(database.effectiveEnvironment);- state.projectId = database.projectEntity.uid;state.environmentId = environment?.uid;state.databaseId = databaseId;dbSchemaStore.getOrFetchDatabaseMetadata(database.name);diff --git a/frontend/src/components/SchemaDesigner/CreateSchemaDesignPanel.vue b/frontend/src/components/SchemaDesigner/CreateSchemaDesignPanel.vueindex ef22b8cf76..cacbfc1fa7 100644--- a/frontend/src/components/SchemaDesigner/CreateSchemaDesignPanel.vue+++ b/frontend/src/components/SchemaDesigner/CreateSchemaDesignPanel.vue@@ -11,6 +11,16 @@><NDrawerContent :title="$t('database.new-branch')" :closable="true"><div class="space-y-3 w-full overflow-x-auto">+ <div class="w-full flex flex-row justify-start items-center pt-1">+ <span class="flex w-40 items-center shrink-0 text-sm">+ {{ $t("common.project") }}+ </span>+ <ProjectSelect+ class="!w-60 shrink-0"+ :selected-id="state.projectId"+ @select-project-id="handleProjectSelect"+ />+ </div><div class="w-full flex flex-row justify-start items-center mt-1"><span class="flex w-40 items-center text-sm">{{$t("database.branch-name")@@ -24,7 +34,14 @@"/></div>+ <NDivider />+ <div class="w-full flex flex-row justify-start items-center mt-1">+ <span class="flex w-40 items-center text-sm font-medium">{{+ $t("schema-designer.baseline-version")+ }}</span>+ </div><BaselineSchemaSelector+ :project-id="state.projectId":baseline-schema="state.baselineSchema"@update="handleBaselineSchemaChange"/>@@ -32,7 +49,7 @@ref="schemaDesignerRef":key="refreshId"class="!mt-6"- :readonly="readonly"+ :readonly="true":engine="state.schemaDesign.engine":schema-design="state.schemaDesign"/>@@ -61,8 +78,8 @@</template><script lang="ts" setup>-import { cloneDeep, isUndefined, uniqueId } from "lodash-es";-import { NButton, NDrawer, NDrawerContent } from "naive-ui";+import { cloneDeep, uniqueId } from "lodash-es";+import { NButton, NDrawer, NDrawerContent, NDivider } from "naive-ui";import { computed, reactive, ref, watch } from "vue";import { useI18n } from "vue-i18n";import {@@ -91,14 +108,13 @@ import { mergeSchemaEditToMetadata } from "./common/util";import SchemaDesigner from "./index.vue";interface BaselineSchema {- // The uid of project.- projectId?: string;// The uid of database.databaseId?: string;changeHistory?: ChangeHistory;}interface LocalState {+ projectId?: string;schemaDesignName: string;baselineSchema: BaselineSchema;schemaDesign: SchemaDesign;@@ -122,21 +138,13 @@ const schemaDesignStore = useSchemaDesignStore();const sheetStore = useSheetV1Store();const state = reactive<LocalState>({schemaDesignName: "",- baselineSchema: {- projectId: props.projectId,- },+ projectId: props.projectId,+ baselineSchema: {},schemaDesign: SchemaDesign.fromPartial({type: SchemaDesign_Type.MAIN_BRANCH,}),});const refreshId = ref<string>("");-const readonly = computed(() => {- return (- isUndefined(state.baselineSchema.projectId) ||- isUndefined(state.baselineSchema.databaseId) ||- isUndefined(state.baselineSchema.changeHistory)- );-});watch(() => [@@ -171,9 +179,7 @@ const prepareSchemaDesign = async () => {const allowConfirm = computed(() => {return (- state.schemaDesignName &&- state.baselineSchema.projectId &&- state.baselineSchema.databaseId+ state.projectId && state.schemaDesignName && state.baselineSchema.databaseId);});@@ -185,8 +191,16 @@ const confirmText = computed(() => {return t("common.create");});+const handleProjectSelect = async (projectId: string) => {+ state.projectId = projectId;+};+const handleBaselineSchemaChange = async (baselineSchema: BaselineSchema) => {state.baselineSchema = baselineSchema;+ if (baselineSchema.databaseId) {+ const database = databaseStore.getDatabaseByUID(baselineSchema.databaseId);+ state.projectId = database.projectEntity.uid;+ }state.schemaDesign = await prepareSchemaDesign();};@@ -208,7 +222,7 @@ const handleConfirm = async () => {return;}- const { project } = useProjectV1ByUID(state.baselineSchema.projectId || "");+ const { project } = useProjectV1ByUID(state.projectId || "");const database = useDatabaseV1Store().getDatabaseByUID(state.baselineSchema.databaseId || "");diff --git a/frontend/src/components/SchemaDesigner/DatabaseTree.vue b/frontend/src/components/SchemaDesigner/DatabaseTree.vueindex a56f2a720d..bd19921587 100644--- a/frontend/src/components/SchemaDesigner/DatabaseTree.vue+++ b/frontend/src/components/SchemaDesigner/DatabaseTree.vue@@ -4,8 +4,8 @@<p class="w-full flex flex-row justify-between items-center h-8 px-1"><span class="text-sm">{{ $t("schema-designer.tables") }}</span><button+ v-if="!readonly"class="text-gray-400 hover:text-gray-500 disabled:cursor-not-allowed"- :disabled="readonly"@click="handleCreateTable"><heroicons-outline:plus class="w-4 h-auto" />@@ -352,6 +352,10 @@ const renderLabel = ({ option: treeNode }: { option: TreeNode }) => {// Render a 'menu' icon in the right of the nodeconst renderSuffix = ({ option: treeNode }: { option: TreeNode }) => {+ if (readonly.value) {+ return null;+ }+const menuIcon = h(EllipsisIcon, {class: "w-4 h-auto text-gray-600",onClick: (e) => {diff --git a/frontend/src/components/SchemaDesigner/Panels/TableEditor.vue b/frontend/src/components/SchemaDesigner/Panels/TableEditor.vueindex a990d5ee24..251e44d2ca 100644--- a/frontend/src/components/SchemaDesigner/Panels/TableEditor.vue+++ b/frontend/src/components/SchemaDesigner/Panels/TableEditor.vue@@ -3,7 +3,7 @@<div class="py-2 w-full flex flex-row justify-between items-center"><div><div- v-if="state.selectedSubtab === 'column-list'"+ v-if="!readonly"class="w-full flex justify-between items-center space-x-2"><button@@ -27,7 +27,6 @@</div><div class="flex justify-end items-center"><NInput- v-if="state.selectedSubtab === 'column-list'"v-model:value="searchPattern"class="!w-48":placeholder="$t('schema-editor.search-column')"@@ -36,179 +35,152 @@<heroicons-outline:search class="w-4 h-auto text-gray-300" /></template></NInput>- <div- v-if="false"- class="flex flex-row justify-end items-center bg-gray-100 p-1 rounded"- >- <button- class="px-2 leading-7 text-sm text-gray-500 cursor-pointer select-none rounded flex justify-center items-center"- :class="- state.selectedSubtab === 'column-list' &&- 'bg-gray-200 text-gray-800'- "- @click="handleChangeTab('column-list')"- >- <heroicons-outline:queue-list class="inline w-4 h-auto mr-1" />- {{ $t("schema-editor.columns") }}- </button>- <button- class="px-2 leading-7 text-sm text-gray-500 cursor-pointer select-none rounded flex justify-center items-center"- :class="- state.selectedSubtab === 'raw-sql' && 'bg-gray-200 text-gray-800'- "- @click="handleChangeTab('raw-sql')"- >- <heroicons-outline:clipboard class="inline w-4 h-auto mr-1" />- {{ $t("schema-editor.raw-sql") }}- </button>- </div></div></div>- <template v-if="state.selectedSubtab === 'column-list'">- <!-- column table -->+ <!-- column table -->+ <div+ id="table-editor-container"+ ref="tableEditorContainerRef"+ class="w-full h-auto grid auto-rows-auto border-y relative overflow-y-auto"+ >+ <!-- column table header --><div- id="table-editor-container"- ref="tableEditorContainerRef"- class="w-full h-auto grid auto-rows-auto border-y relative overflow-y-auto"+ class="sticky top-0 z-10 grid grid-cols-[repeat(4,_minmax(0,_1fr))_repeat(2,_96px)_minmax(0,_1fr)_32px] w-full text-sm leading-6 select-none bg-gray-50 text-gray-400"+ :class="shownColumnList.length > 0 && 'border-b'">- <!-- column table header -->+ <span+ v-for="header in columnHeaderList"+ :key="header.key"+ class="table-header-item-container"+ >{{ header.label }}</span+ >+ <span></span>+ </div>+ <!-- column table body -->+ <div class="w-full"><div- class="sticky top-0 z-10 grid grid-cols-[repeat(4,_minmax(0,_1fr))_repeat(2,_96px)_minmax(0,_1fr)_32px] w-full text-sm leading-6 select-none bg-gray-50 text-gray-400"- :class="shownColumnList.length > 0 && 'border-b'"+ v-for="(column, index) in shownColumnList"+ :key="`${index}-${column.id}`"+ class="grid grid-cols-[repeat(4,_minmax(0,_1fr))_repeat(2,_96px)_minmax(0,_1fr)_32px] gr text-sm even:bg-gray-50"+ :class="[+ `column-${column.id}`,+ getColumnItemComputedClassList(column),+ ]">- <span- v-for="header in columnHeaderList"- :key="header.key"- class="table-header-item-container"- >{{ header.label }}</span- >- <span></span>- </div>- <!-- column table body -->- <div class="w-full">+ <div class="table-body-item-container">+ <input+ v-model="column.name"+ :disabled="disableAlterColumn(column)"+ placeholder="column name"+ class="column-field-input column-name-input"+ type="text"+ />+ </div><div- v-for="(column, index) in shownColumnList"- :key="`${index}-${column.id}`"- class="grid grid-cols-[repeat(4,_minmax(0,_1fr))_repeat(2,_96px)_minmax(0,_1fr)_32px] gr text-sm even:bg-gray-50"- :class="[- `column-${column.id}`,- getColumnItemComputedClassList(column),- ]"+ class="table-body-item-container flex flex-row justify-between items-center">- <div class="table-body-item-container">- <input- v-model="column.name"- :disabled="disableAlterColumn(column)"- placeholder="column name"- class="column-field-input column-name-input"- type="text"- />- </div>- <div- class="table-body-item-container flex flex-row justify-between items-center"+ <input+ v-model="column.type"+ :disabled="+ disableAlterColumn(column) ||+ schemaTemplateColumnTypes.length > 0+ "+ placeholder="column type"+ class="column-field-input column-type-input !pr-8"+ type="text"+ />+ <NDropdown+ trigger="click"+ :disabled="disableAlterColumn(column)"+ :options="columnTypeOptions"+ @select="(dataType: string) => (column.type = dataType)">- <input- v-model="column.type"- :disabled="- disableAlterColumn(column) ||- schemaTemplateColumnTypes.length > 0- "- placeholder="column type"- class="column-field-input column-type-input !pr-8"- type="text"- />- <NDropdown- trigger="click"- :disabled="disableAlterColumn(column)"- :options="columnTypeOptions"- @select="(dataType: string) => (column.type = dataType)"- >- <button class="absolute right-5">- <heroicons-solid:chevron-up-down- class="w-4 h-auto text-gray-400"- />- </button>- </NDropdown>- </div>- <div- class="table-body-item-container flex flex-row justify-between items-center"+ <button class="absolute right-5">+ <heroicons-solid:chevron-up-down+ class="w-4 h-auto text-gray-400"+ />+ </button>+ </NDropdown>+ </div>+ <div+ class="table-body-item-container flex flex-row justify-between items-center"+ >+ <input+ v-model="column.default"+ :disabled="disableAlterColumn(column)"+ :placeholder="column.default === undefined ? 'EMPTY' : 'NULL'"+ class="column-field-input !pr-8"+ type="text"+ />+ <NDropdown+ trigger="click"+ :disabled="disableAlterColumn(column)"+ :options="dataDefaultOptions"+ @select="(defaultString:string)=>handleColumnDefaultFieldChange(column, defaultString)">- <input- v-model="column.default"- :disabled="disableAlterColumn(column)"- :placeholder="column.default === undefined ? 'EMPTY' : 'NULL'"- class="column-field-input !pr-8"- type="text"- />- <NDropdown- trigger="click"- :disabled="disableAlterColumn(column)"- :options="dataDefaultOptions"- @select="(defaultString:string)=>handleColumnDefaultFieldChange(column, defaultString)"- >- <button class="absolute right-5">- <heroicons-solid:chevron-up-down- class="w-4 h-auto text-gray-400"- />- </button>- </NDropdown>- </div>- <div class="table-body-item-container">- <input- v-model="column.userComment"- :disabled="disableAlterColumn(column)"- placeholder="comment"- class="column-field-input"- type="text"- />- </div>- <div- class="table-body-item-container flex justify-start items-center"+ <button class="absolute right-5">+ <heroicons-solid:chevron-up-down+ class="w-4 h-auto text-gray-400"+ />+ </button>+ </NDropdown>+ </div>+ <div class="table-body-item-container">+ <input+ v-model="column.userComment"+ :disabled="disableAlterColumn(column)"+ placeholder="comment"+ class="column-field-input"+ type="text"+ />+ </div>+ <div+ class="table-body-item-container flex justify-start items-center"+ >+ <BBCheckbox+ class="ml-3"+ :value="!column.nullable"+ :disabled="+ disableAlterColumn(column) || isColumnPrimaryKey(column)+ "+ @toggle="(value) => (column.nullable = !value)"+ />+ </div>+ <div+ class="table-body-item-container flex justify-start items-center"+ >+ <BBCheckbox+ class="ml-3"+ :value="isColumnPrimaryKey(column)"+ :disabled="disableAlterColumn(column)"+ @toggle="(value) => setColumnPrimaryKey(column, value)"+ />+ </div>+ <div+ class="table-body-item-container foreign-key-field flex justify-start items-center"+ >+ <span+ v-if="checkColumnHasForeignKey(column)"+ class="column-field-text cursor-pointer !w-auto hover:opacity-80"+ @click="gotoForeignKeyReferencedTable(column)">- <BBCheckbox- class="ml-3"- :value="!column.nullable"- :disabled="- disableAlterColumn(column) || isColumnPrimaryKey(column)- "- @toggle="(value) => (column.nullable = !value)"- />- </div>- <div- class="table-body-item-container flex justify-start items-center"+ {{ getReferencedForeignKeyName(column) }}+ </span>+ <span v-else class="column-field-text italic text-gray-400 !w-auto"+ >EMPTY</span>- <BBCheckbox- class="ml-3"- :value="isColumnPrimaryKey(column)"- :disabled="disableAlterColumn(column)"- @toggle="(value) => setColumnPrimaryKey(column, value)"- />- </div>- <div- class="table-body-item-container foreign-key-field flex justify-start items-center"+ <button+ v-if="!readonly"+ class="foreign-key-edit-button hidden cursor-pointer hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-60"+ :disabled="disableAlterColumn(column)"+ @click="handleEditColumnForeignKey(column)">- <span- v-if="checkColumnHasForeignKey(column)"- class="column-field-text cursor-pointer !w-auto hover:opacity-80"- @click="gotoForeignKeyReferencedTable(column)"- >- {{ getReferencedForeignKeyName(column) }}- </span>- <span- v-else- class="column-field-text italic text-gray-400 !w-auto"- >EMPTY</span- >- <button- class="foreign-key-edit-button hidden cursor-pointer hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-60"- :disabled="disableAlterColumn(column)"- @click="handleEditColumnForeignKey(column)"- >- <heroicons:pencil-square class="w-4 h-auto text-gray-400" />- </button>- </div>- <div class="w-full flex justify-start items-center">+ <heroicons:pencil-square class="w-4 h-auto text-gray-400" />+ </button>+ </div>+ <div class="w-full flex justify-start items-center">+ <template v-if="!readonly"><n-tooltip v-if="!isDroppedColumn(column)" trigger="hover"><template #trigger><button@@ -233,32 +205,10 @@</template><span>{{ $t("schema-editor.actions.restore") }}</span></n-tooltip>- </div>+ </template></div></div></div>- </template>- <div- v-else-if="state.selectedSubtab === 'raw-sql'"- class="w-full h-full overflow-y-auto"- >- <div- v-if="state.isFetchingDDL"- class="w-full h-full min-h-[64px] flex justify-center items-center"- >- <BBSpin />- </div>- <template v-else>- <HighlightCodeBlock- v-if="state.statement !== ''"- class="text-sm px-3 py-2 whitespace-pre-wrap break-all"- language="sql"- :code="state.statement"- ></HighlightCodeBlock>- <div v-else class="flex px-3 py-2 italic text-sm text-gray-600">- {{ $t("schema-editor.nothing-changed") }}- </div>- </template></div></div>@@ -293,8 +243,7 @@ import { NDropdown } from "naive-ui";import scrollIntoView from "scroll-into-view-if-needed";import { computed, nextTick, reactive, ref } from "vue";import { useI18n } from "vue-i18n";-import { BBCheckbox, BBSpin } from "@/bbkit";-import HighlightCodeBlock from "@/components/HighlightCodeBlock";+import { BBCheckbox } from "@/bbkit";import { Drawer, DrawerContent } from "@/components/v2";import {hasFeature,@@ -321,10 +270,7 @@ import {} from "../common";import { isColumnChanged } from "../utils/column";-type SubtabType = "column-list" | "raw-sql";-interface LocalState {- selectedSubtab: SubtabType;isFetchingDDL: boolean;statement: string;showEditColumnForeignKeyModal: boolean;@@ -338,8 +284,6 @@ const { readonly, engine, editableSchemas, getCurrentTab, addTab } =const settingStore = useSettingV1Store();const currentTab = computed(() => getCurrentTab() as TableTabContext);const state = reactive<LocalState>({- selectedSubtab:- (currentTab.value.selectedSubtab as SubtabType) || "column-list",isFetchingDDL: false,statement: "",showEditColumnForeignKeyModal: false,@@ -548,10 +492,6 @@ const setColumnPrimaryKey = (column: Column, isPrimaryKey: boolean) => {}};-const handleChangeTab = (tab: SubtabType) => {- state.selectedSubtab = tab;-};-const handleAddColumn = () => {const column = convertColumnMetadataToColumn(ColumnMetadata.fromPartial({}));column.status = "created";diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex c2dd6dca78..58c0788241 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2812,6 +2812,7 @@"baseline-database": "Baseline database","schema-version": "Schema version","personal-draft": "Personal draft",+ "baseline-version": "Baseline version","save-draft": "Save draft","merge-to-main": "Merge to main","diff-editor": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 6bc735b369..57cc128bda 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2810,6 +2810,7 @@"baseline-database": "Base de datos de referencia","schema-version": "Versión del esquema","personal-draft": "Borrador personal",+ "baseline-version": "Versión de referencia","save-draft": "Guardar borrador","merge-to-main": "Fusionar a principal","diff-editor": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 6a87f57610..cc8907ca9e 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2805,6 +2805,7 @@"baseline-database": "基准数据库","schema-version": "Schema 版本","personal-draft": "个人草稿",+ "baseline-version": "基线版本","save-draft": "保存草稿","merge-to-main": "合并到主版本","diff-editor": {