Skip to content

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

feat: frontend support for empty database name template (#2868)

Danny Xuacfe70cb8638
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
index eb8c7254fb..3530fbd229 100644
--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
@@ -355,6 +355,9 @@ export default defineComponent({
});
const allowGenerateTenant = computed(() => {
+ // All databases will be in the same group if dbNameTemplate is empty.
+ if (isTenantProject.value && state.project?.dbNameTemplate === "")
+ return true;
if (!state.selectedDatabaseName) return false;
// not allowed when database list filtered by deployment config is empty
diff --git a/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue b/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue
index a2d7506393..bee6e6b167 100644
--- a/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue
@@ -180,6 +180,10 @@ const deployment = computed(() => {
const databaseListGroupByName = computed(
(): { name: string; list: Database[] }[] => {
if (!props.project) return [];
+ // All databases will be in the same group if dbNameTemplate is empty.
+ if (props.project.dbNameTemplate === "") {
+ return [{ name: "", list: props.databaseList }];
+ }
if (props.project.dbNameTemplate && labelList.value.length === 0) return [];
const dict = groupBy(props.databaseList, (db) => {
@@ -189,8 +193,6 @@ const databaseListGroupByName = computed(
props.project!.dbNameTemplate,
labelList.value
);
- } else {
- return db.name;
}
});
return Object.keys(dict).map((name) => ({
diff --git a/frontend/src/components/ProjectCreate.vue b/frontend/src/components/ProjectCreate.vue
index fbf95d8c30..a95535992e 100644
--- a/frontend/src/components/ProjectCreate.vue
+++ b/frontend/src/components/ProjectCreate.vue
@@ -203,7 +203,9 @@ export default defineComponent({
watch(
() => state.enableDbNameTemplate,
(on) => {
- if (!on) {
+ if (on) {
+ state.project.dbNameTemplate = "{{DB_NAME}}_{{TENANT}}";
+ } else {
state.project.dbNameTemplate = "";
}
}
diff --git a/frontend/src/components/TenantDatabaseTable/TenantDatabaseTable.vue b/frontend/src/components/TenantDatabaseTable/TenantDatabaseTable.vue
index 62459a540f..e42d63c75f 100644
--- a/frontend/src/components/TenantDatabaseTable/TenantDatabaseTable.vue
+++ b/frontend/src/components/TenantDatabaseTable/TenantDatabaseTable.vue
@@ -70,6 +70,9 @@ export default defineComponent({
const environmentList = useEnvironmentList();
const databaseListGroupByName = computed((): DatabaseGroupByName[] => {
+ if (props.project.dbNameTemplate === "") {
+ return [{ name: "", databaseList: props.databaseList }];
+ }
if (props.project.dbNameTemplate) {
if (props.labelList.length === 0) return [];
}
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 2f1ddc2bb8..0d083ac306 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1326,7 +1326,7 @@
"setting": {
"description": "A label is a key-value pair that helps you identify the tenant for a database. {link}."
},
- "db-name-template-tips": "Allow you to group databases with the same {placeholder} from different tenants. {link}.",
+ "db-name-template-tips": "The name of all tenant databases should follow a naming template. The databases with the same {placeholder} will be the same group. {link}.",
"confirm-change": "Are you sure to change '{label}' ?",
"parsed-from-template": "Parsed from {name} by template {template}.",
"cannot-transfer-template-not-match": "Database '{name}' cannot be transferred to this project. Since its name doesn't match the template {template}."
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 05b863fd12..d485efc9df 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1326,7 +1326,7 @@
"setting": {
"description": "标签是一组可用于标识数据库租户的键值对。{link}。"
},
- "db-name-template-tips": "让您能够把属于不同租户但是有相同 {placeholder} 的数据库分成一组。{link}。",
+ "db-name-template-tips": "所有租户数据库名字遵循命名模版。有着相同 {placeholder} 的数据库会被分成一组。{link}。",
"confirm-change": "您确定要修改 '{label}' 吗?",
"parsed-from-template": "从 {name} 中依据模板 {template} 解析得出",
"cannot-transfer-template-not-match": "数据库 '{name}' 无法转移到这个项目,因为它的名称不符合模板 {template}。"