Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: add tips for tenant project in Schema Editor (#3875)

boojack9e4d1287a12a
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
index 096e17cb03..d1346b7967 100644
--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
@@ -147,7 +147,6 @@
<SchemaEditorModal
v-if="state.showSchemaEditorModal"
:database-id-list="schemaEditorContext.databaseIdList"
- :tenant-mode="schemaEditorContext.tenantMode"
@close="state.showSchemaEditorModal = false"
/>
</template>
@@ -223,10 +222,8 @@ const repositoryStore = useRepositoryStore();
const ghostDialog = ref<InstanceType<typeof GhostDialog>>();
const schemaEditorContext = ref<{
databaseIdList: DatabaseId[];
- tenantMode: boolean;
}>({
databaseIdList: [],
- tenantMode: false,
});
useEventListener(window, "keydown", (e) => {
@@ -433,7 +430,6 @@ const generateTenant = async () => {
schemaEditorContext.value.databaseIdList = databaseList.map(
(database) => database.id
);
- schemaEditorContext.value.tenantMode = true;
state.showSchemaEditorModal = true;
return;
}
@@ -453,7 +449,6 @@ const generateTenant = async () => {
schemaEditorContext.value.databaseIdList = Array.from(
state.selectedDatabaseIdListForTenantMode.values()
);
- schemaEditorContext.value.tenantMode = true;
state.showSchemaEditorModal = true;
return;
}
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
index 00d4c463f5..51231fd631 100644
--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
@@ -85,17 +85,30 @@
/>
</div>
</div>
- <div class="w-full flex items-center justify-end mt-2 space-x-3 pr-1 pb-1">
- <button type="button" class="btn-normal" @click="dismissModal">
- {{ $t("common.cancel") }}
- </button>
- <button
- class="btn-primary"
- :disabled="!allowPreviewIssue"
- @click="handlePreviewIssue"
- >
- {{ $t("schema-editor.preview-issue") }}
- </button>
+ <div
+ class="w-full flex flex-row justify-between items-center mt-2 pr-1 pb-1"
+ >
+ <div class="">
+ <div
+ v-if="isTenantProject"
+ class="flex flex-row items-center text-sm text-gray-500"
+ >
+ <heroicons-outline:exclamation-circle class="w-4 h-auto mr-1" />
+ {{ $t("schema-editor.tenant-mode-tips") }}
+ </div>
+ </div>
+ <div class="flex justify-end items-center space-x-3">
+ <button type="button" class="btn-normal" @click="dismissModal">
+ {{ $t("common.cancel") }}
+ </button>
+ <button
+ class="btn-primary whitespace-nowrap"
+ :disabled="!allowPreviewIssue"
+ @click="handlePreviewIssue"
+ >
+ {{ $t("schema-editor.preview-issue") }}
+ </button>
+ </div>
</div>
</BBModal>
@@ -129,6 +142,7 @@ import { allowGhostMigration } from "@/utils";
import {
useDatabaseStore,
useNotificationStore,
+ useProjectStore,
useSchemaEditorStore,
} from "@/store";
import { diffTableList } from "@/utils/schemaEditor/diffTable";
@@ -153,10 +167,6 @@ const props = defineProps({
type: Array as PropType<DatabaseId[]>,
required: true,
},
- tenantMode: {
- type: Boolean,
- default: false,
- },
});
const emit = defineEmits<{
@@ -206,9 +216,17 @@ const databaseEngineType = databaseList.reduce(
},
""
);
+const project = useProjectStore().getProjectById(
+ head(databaseList)?.projectId || UNKNOWN_ID
+);
+const isTenantProject = project.tenantMode === "TENANT";
onMounted(() => {
- if (databaseList.length === 0 || databaseEngineType === "unknown") {
+ if (
+ databaseList.length === 0 ||
+ project.id === UNKNOWN_ID ||
+ databaseEngineType === "unknown"
+ ) {
emit("close");
return;
}
@@ -363,23 +381,17 @@ const handleUploadFile = (e: Event) => {
};
const handlePreviewIssue = async () => {
- const projectId = head(databaseList)?.projectId || UNKNOWN_ID;
- if (projectId === UNKNOWN_ID) {
- console.error("project unknown");
- return;
- }
-
const query: Record<string, any> = {
template: "bb.issue.database.schema.update",
- project: projectId,
- mode: props.tenantMode ? "tenant" : "normal",
+ project: project.id,
+ mode: isTenantProject ? "tenant" : "normal",
databaseList: props.databaseIdList.join(","),
};
if (state.selectedTab === "raw-sql") {
query.sql = state.editStatement;
- if (!props.tenantMode) {
+ if (!isTenantProject) {
// We should show select ghost mode dialog only for altering table statment not create/drop table.
// TODO(steven): parse the sql check if there only alter table statement.
const actionResult = await isUsingGhostMigration(databaseList);
@@ -417,7 +429,7 @@ const handlePreviewIssue = async () => {
return;
}
- if (!props.tenantMode && hasOnlyAlterTableChanges) {
+ if (!isTenantProject && hasOnlyAlterTableChanges) {
const actionResult = await isUsingGhostMigration(databaseList);
if (actionResult === false) {
return;
@@ -431,7 +443,7 @@ const handlePreviewIssue = async () => {
}
const databaseIdList = Array.from(statementMap.keys());
const statmentList = Array.from(statementMap.values());
- if (props.tenantMode) {
+ if (isTenantProject) {
query.sql = statmentList.join("\n");
query.name = generateIssueName(
databaseList.map((db) => db.name),
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index f9f9f92a8e..4ef580ee7e 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1454,7 +1454,8 @@
"confirm-to-close": {
"title": "Confirm to close",
"description": "Are you sure you want to close the panel? Your changes will be lost."
- }
+ },
+ "tenant-mode-tips": "Changes will be applied to all selected tenant databases after clicking \"Preview issue\"."
},
"label": {
"empty-label-value": "<Empty Value>",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 8ea034e42f..4518963fad 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1455,7 +1455,8 @@
"confirm-to-close": {
"title": "确定关闭?",
"description": "关闭后更改将会丢失。"
- }
+ },
+ "tenant-mode-tips": "点击“预览工单”后,当前更改将会应用于所有选定的租户数据库。"
},
"label": {
"empty-label-value": "<空值>",