Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: update UI editor entry (#3644)
boojack167a54d997e5
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vueindex 2338d28d36..b061acffb2 100644--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue@@ -149,7 +149,8 @@<SchemaEditorModalv-if="state.showSchemaEditorModal"- :database-id-list="flattenSelectedDatabaseIdList"+ :database-id-list="schemaEditorContext.databaseIdList"+ :tenant-mode="schemaEditorContext.tenantMode"@close="state.showSchemaEditorModal = false"/></template>@@ -160,7 +161,7 @@ import { computed, reactive, PropType, ref } from "vue";import { useRouter } from "vue-router";import { NTabs, NTabPane } from "naive-ui";import { useEventListener } from "@vueuse/core";-import { cloneDeep } from "lodash-es";+import { cloneDeep, groupBy } from "lodash-es";import DatabaseTable from "../DatabaseTable.vue";import {baseDirectoryWebUrl,@@ -174,7 +175,7 @@ import {import {allowGhostMigration,allowUsingUIEditor,- isDev,+ parseDatabaseNameByTemplate,sortDatabaseList,} from "@/utils";import {@@ -182,6 +183,7 @@ import {useCurrentUser,useDatabaseStore,useEnvironmentList,+ useLabelList,useProjectStore,useRepositoryStore,} from "@/store";@@ -226,6 +228,13 @@ const projectStore = useProjectStore();const repositoryStore = useRepositoryStore();const ghostDialog = ref<InstanceType<typeof GhostDialog>>();+const schemaEditorContext = ref<{+ databaseIdList: DatabaseId[];+ tenantMode: boolean;+}>({+ databaseIdList: [],+ tenantMode: false,+});useEventListener(window, "keydown", (e) => {if (e.code === "Escape") {@@ -334,7 +343,10 @@ const generateMultiDb = async () => {(id) => databaseList.value.find((db) => db.id === id)!);- if (isDev() && allowUsingUIEditor(selectedDatabaseList)) {+ if (allowUsingUIEditor(selectedDatabaseList)) {+ schemaEditorContext.value.databaseIdList = cloneDeep(+ flattenSelectedDatabaseIdList.value+ );state.showSchemaEditorModal = true;return;}@@ -412,8 +424,6 @@ const generateTenant = async () => {return;}- emit("dismiss");-const projectId = props.projectId || state.tenantProjectId;if (!projectId) return;@@ -428,6 +438,31 @@ const generateTenant = async () => {mode: "tenant",};if (state.alterType === "DB_GROUP") {+ const databaseList = useDatabaseStore().getDatabaseListByProjectId(+ project.id+ );+ const labelList = useLabelList();+ const databaseListGroupByName = groupBy(databaseList, (db) => {+ if (project.dbNameTemplate) {+ return parseDatabaseNameByTemplate(+ db.name,+ project.dbNameTemplate,+ labelList.value+ );+ } else {+ return "";+ }+ });+ const selectedDatabaseList =+ databaseListGroupByName[state.selectedDatabaseName!];+ if (allowUsingUIEditor(selectedDatabaseList)) {+ schemaEditorContext.value.databaseIdList = selectedDatabaseList.map(+ (database) => database.id+ );+ schemaEditorContext.value.tenantMode = true;+ state.showSchemaEditorModal = true;+ return;+ }query.name = generateIssueName([state.selectedDatabaseName!], false);query.databaseName = state.selectedDatabaseName;} else {@@ -436,6 +471,15 @@ const generateTenant = async () => {for (const databaseId of state.selectedDatabaseIdListForTenantMode) {databaseList.push(databaseStore.getDatabaseById(databaseId));}+ if (allowUsingUIEditor(databaseList)) {+ schemaEditorContext.value.databaseIdList = Array.from(+ state.selectedDatabaseIdListForTenantMode.values()+ );+ schemaEditorContext.value.tenantMode = true;+ state.showSchemaEditorModal = true;+ return;+ }+query.name = generateIssueName(databaseList.map((database) => database.name),false@@ -445,6 +489,8 @@ const generateTenant = async () => {).join(",");}+ emit("dismiss");+router.push({name: "workspace.issue.detail",params: {@@ -465,11 +511,18 @@ const generateTenant = async () => {"_blank");});+ emit("dismiss");}};const selectDatabase = async (database: Database) => {if (database.project.workflowType == "UI") {+ if (allowUsingUIEditor([database])) {+ schemaEditorContext.value.databaseIdList = [database.id];+ state.showSchemaEditorModal = true;+ return;+ }+const mode = await isUsingGhostMigration([database]);if (mode === false) {return;diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vueindex dd0b72dba1..c89560fd45 100644--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue@@ -57,7 +57,7 @@:value="state.editStatement":auto-focus="false":dialect="(databaseEngineType as SQLDialect)"- @change="onStatementChange"+ @change="handleStatementChange"/></div></div>@@ -111,6 +111,10 @@ const props = defineProps({type: Array as PropType<DatabaseId[]>,required: true,},+ tenantMode: {+ type: Boolean,+ default: false,+ },});const emit = defineEmits<{@@ -154,7 +158,7 @@ const handleChangeTab = (tab: TabType) => {state.selectedTab = tab;};-const onStatementChange = (value: string) => {+const handleStatementChange = (value: string) => {state.editStatement = value;};@@ -255,11 +259,19 @@ const handlePreviewIssue = async () => {return;}- const mode = await isUsingGhostMigration(databaseList);- if (mode === false) {- return;+ let issueMode = "normal";++ if (props.tenantMode) {+ issueMode = "tenant";+ } else {+ const actionResult = await isUsingGhostMigration(databaseList);+ if (actionResult === false) {+ return;+ }+ issueMode = actionResult;}- const isGhostMode = mode === "online";++ const isGhostMode = issueMode === "online";const query: Record<string, any> = {template: "bb.issue.database.schema.update",name: generateIssueName(@@ -267,6 +279,7 @@ const handlePreviewIssue = async () => {isGhostMode),project: projectId,+ mode: issueMode,databaseList: props.databaseIdList.join(","),};if (isGhostMode) {@@ -304,14 +317,17 @@ const handlePreviewIssue = async () => {const databaseIdList = Array.from(databaseEditMap.keys());if (databaseIdList.length > 0) {const statmentList = Array.from(databaseEditMap.values());- query.databaseList = databaseIdList.join(",");- query.name = generateIssueName(- databaseList- .filter((database) => databaseIdList.includes(database.id))- .map((db) => db.name),- isGhostMode- );query.sql = statmentList.join("\n");++ if (!props.tenantMode) {+ query.databaseList = databaseIdList.join(",");+ query.name = generateIssueName(+ databaseList+ .filter((database) => databaseIdList.includes(database.id))+ .map((db) => db.name),+ isGhostMode+ );+ }}}diff --git a/frontend/src/utils/UIEditor/index.ts b/frontend/src/utils/UIEditor/index.tsindex 82e4fd75bf..3220106e7c 100644--- a/frontend/src/utils/UIEditor/index.ts+++ b/frontend/src/utils/UIEditor/index.ts@@ -1,10 +1,14 @@import { Database, EngineType } from "@/types";+import { isDev } from "..";-// Only allow UI Editor with MySQL.+// Only allow using UI Editor with MySQL in dev mode.export const allowUsingUIEditor = (databaseList: Database[]): boolean => {- return databaseList.every((db) => {- return db.instance.engine === "MYSQL";- });+ return (+ isDev() &&+ databaseList.every((db) => {+ return db.instance.engine === "MYSQL";+ })+ );};export const getDataTypeSuggestionList = (engineType: EngineType = "MYSQL") => {diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vueindex c99932f4e2..56a3711082 100644--- a/frontend/src/views/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail.vue@@ -294,6 +294,12 @@</div><GhostDialog ref="ghostDialog" />++ <SchemaEditorModal+ v-if="state.showSchemaEditorModal"+ :database-id-list="[database.id]"+ @close="state.showSchemaEditorModal = false"+ /></template><script lang="ts" setup>@@ -315,6 +321,7 @@ import {allowGhostMigration,isPITRDatabase,isDatabaseAccessible,+ allowUsingUIEditor,} from "@/utils";import {ProjectId,@@ -351,6 +358,7 @@ type DatabaseTabItem = {interface LocalState {showTransferDatabaseModal: boolean;showIncorrectProjectModal: boolean;+ showSchemaEditorModal: boolean;editingProjectId: ProjectId;selectedIndex: number;syncingSchema: boolean;@@ -379,6 +387,7 @@ const databaseTabItemList: DatabaseTabItem[] = [const state = reactive<LocalState>({showTransferDatabaseModal: false,showIncorrectProjectModal: false,+ showSchemaEditorModal: false,editingProjectId: UNKNOWN_ID,selectedIndex: OVERVIEW_TAB,syncingSchema: false,@@ -556,6 +565,11 @@ const createMigration = async (if (database.value.project.workflowType == "UI") {let mode: "online" | "normal" | false = "normal";if (type === "bb.issue.database.schema.update") {+ if (allowUsingUIEditor([database.value])) {+ state.showSchemaEditorModal = true;+ return;+ }+// Check and show a normal/online selection modal dialog if needed.mode = await isUsingGhostMigration([database.value]);}