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: remove tenant db name template grouping logic (#3869)
Liu Jif53aaa12d1c0
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vueindex be8e2deb6c..096e17cb03 100644--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue@@ -6,10 +6,7 @@<template v-if="isTenantProject"><!-- tenant mode project --><NTabs v-model:value="state.alterType">- <NTabPane- :tab="$t('alter-schema.alter-db-group')"- name="DB_GROUP"- >+ <NTabPane :tab="$t('alter-schema.alter-db-group')" name="TENANT"><ProjectTenantView:state="state":database-list="databaseList"@@ -161,7 +158,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, groupBy } from "lodash-es";+import { cloneDeep } from "lodash-es";import DatabaseTable from "../DatabaseTable.vue";import {baseDirectoryWebUrl,@@ -175,7 +172,6 @@ import {import {allowGhostMigration,allowUsingSchemaEditor,- parseDatabaseNameByTemplate,sortDatabaseList,} from "@/utils";import {@@ -192,13 +188,11 @@ import ProjectStandardView, {import ProjectTenantView, {State as ProjectTenantState,} from "./ProjectTenantView.vue";-import { State as CommonTenantState } from "./CommonTenantView.vue";import GhostDialog from "./GhostDialog.vue";import SchemaEditorModal from "./SchemaEditorModal.vue";type LocalState = ProjectStandardState &- ProjectTenantState &- CommonTenantState & {+ ProjectTenantState & {project?: Project;searchText: string;showSchemaEditorModal: boolean;@@ -247,8 +241,6 @@ const state = reactive<LocalState>({: undefined,alterType: "SINGLE_DB",selectedDatabaseIdListForEnvironment: new Map(),- tenantProjectId: undefined,- selectedDatabaseName: undefined,selectedDatabaseIdListForTenantMode: new Set<number>(),deployingTenantDatabaseList: [],searchText: "",@@ -268,7 +260,7 @@ const isTenantProject = computed((): boolean => {if (isTenantProject.value) {// For tenant mode projects, alter multiple db via DeploymentConfig// is the default suggested way.- state.alterType = "DB_GROUP";+ state.alterType = "TENANT";}const environmentList = useEnvironmentList(["NORMAL"]);@@ -379,7 +371,7 @@ const generateMultiDb = async () => {};const showGenerateTenant = computed(() => {- // True when a tenant project is selected and "DB_GROUP" is selected.+ // True when a tenant project is selected and "TENANT" is selected.if (isTenantProject.value) {return true;}@@ -393,14 +385,11 @@ 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- // which means no database will be deployed- if (state.deployingTenantDatabaseList.length === 0) return false;+ if (isTenantProject.value) {+ // not allowed when database list filtered by deployment config is empty+ // which means no database will be deployed+ return state.deployingTenantDatabaseList.length > 0;+ }return true;});@@ -423,7 +412,7 @@ const generateTenant = async () => {return;}- const projectId = props.projectId || state.tenantProjectId;+ const projectId = props.projectId;if (!projectId) return;const project = projectStore.getProjectById(projectId) as Project;@@ -436,29 +425,24 @@ const generateTenant = async () => {project: project.id,mode: "tenant",};- if (state.alterType === "DB_GROUP") {+ if (state.alterType === "TENANT") {const databaseList = useDatabaseStore().getDatabaseListByProjectId(project.id);- const databaseListGroupByName = groupBy(databaseList, (db) => {- if (project.dbNameTemplate) {- return parseDatabaseNameByTemplate(db.name, project.dbNameTemplate);- } else {- return "";- }- });- const selectedDatabaseList =- databaseListGroupByName[state.selectedDatabaseName!];- if (isAlterSchema.value && allowUsingSchemaEditor(selectedDatabaseList)) {- schemaEditorContext.value.databaseIdList = selectedDatabaseList.map(+ if (isAlterSchema.value && allowUsingSchemaEditor(databaseList)) {+ schemaEditorContext.value.databaseIdList = databaseList.map((database) => database.id);schemaEditorContext.value.tenantMode = true;state.showSchemaEditorModal = true;return;}- query.name = generateIssueName([state.selectedDatabaseName!], false);- query.databaseName = state.selectedDatabaseName;+ // In tenant deploy pipeline, we use project name instead of database name+ // if more than one databases are to be deployed.+ const name =+ databaseList.length > 1 ? project.name : databaseList[0].name;+ query.name = generateIssueName([name], false);+ query.databaseName = "";} else {const databaseList: Database[] = [];const databaseStore = useDatabaseStore();@@ -498,7 +482,6 @@ const generateTenant = async () => {.then((repository: Repository) => {window.open(baseDirectoryWebUrl(repository, {- DB_NAME: state.selectedDatabaseName!,TYPE:props.type === "bb.issue.database.schema.update" ? "ddl" : "dml",}),diff --git a/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vue b/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vueindex 55e4d1e0ae..1203d63ea2 100644--- a/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vue+++ b/frontend/src/components/AlterSchemaPrepForm/ProjectStandardView.vue@@ -118,7 +118,7 @@ import {Project,} from "../../types";-export type AlterType = "SINGLE_DB" | "MULTI_DB" | "DB_GROUP";+export type AlterType = "SINGLE_DB" | "MULTI_DB" | "TENANT";export type State = {alterType: AlterType;diff --git a/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue b/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vueindex 778ec16df5..712bbda64d 100644--- a/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue+++ b/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue@@ -25,7 +25,7 @@</i18n-t></template><template v-else>- <div v-if="databaseListGroupByName.length === 0" class="textinfolabel">+ <div v-if="databaseList.length === 0" class="textinfolabel"><i18n-t keypath="project.overview.no-db-prompt" tag="p"><template #newDb><span class="text-main">{{ $t("quick-action.new-db") }}</span>@@ -38,70 +38,16 @@</i18n-t></div><template v-else>- <div class="flex justify-between items-center py-0.5">- <div class="flex-1">- <label class="text-base text-control">- <template v-if="databaseListGroupByName.length > 1">- {{ $t("deployment-config.select-database-group") }}- </template>- <template v-else-if="state.selectedDatabaseName">- {{ state.selectedDatabaseName }}- </template>- </label>- </div>+ <div class="flex justify-end items-center py-0.5"><YAxisRadioGroup v-model:label="label" class="text-sm" /></div>- <template v-if="databaseListGroupByName.length === 1">- <DeployDatabaseTable- class="mt-4"- :database-list="databaseListGroupByName[0].list"- :label="label"- :environment-list="environmentList"- :deployment="deployment!"- />- </template>- <template v-else>- <NCollapse- display-directive="if"- accordion- :expanded-names="state.selectedDatabaseName"- @update:expanded-names="- (names) => (state.selectedDatabaseName = names[0])- "- >- <NCollapseItem- v-for="{ name, list } in databaseListGroupByName"- :key="name"- :title="name"- :name="name"- >- <template #arrow>- <!-- don't show the arrow -->- </template>- <template #header>- <input- type="radio"- class="radio mr-2"- :checked="name === state.selectedDatabaseName"- />- <span class="text-base">{{ name }}</span>- </template>- <template #header-extra>- <span class="text-control-placeholder">- {{ $t("deployment-config.n-databases", list.length) }}- </span>- </template>-- <DeployDatabaseTable- :database-list="list"- :label="label"- :environment-list="environmentList"- :deployment="deployment!"- />- </NCollapseItem>- </NCollapse>- </template>+ <DeployDatabaseTable+ :database-list="databaseList"+ :label="label"+ :environment-list="environmentList"+ :deployment="deployment!"+ /></template></template></template>@@ -111,9 +57,7 @@<script lang="ts" setup>/* eslint-disable vue/no-mutating-props */-import { computed, watchEffect, watch, ref, h } from "vue";-import { NCollapse, NCollapseItem } from "naive-ui";-import { groupBy } from "lodash-es";+import { computed, watchEffect, ref, h } from "vue";import { Translation, useI18n } from "vue-i18n";import { RouterLink } from "vue-router";import type {@@ -125,16 +69,11 @@ import type {} from "@/types";import { UNKNOWN_ID } from "@/types";import { DeployDatabaseTable } from "../TenantDatabaseTable";-import {- parseDatabaseNameByTemplate,- getPipelineFromDeploymentSchedule,- projectSlug,-} from "@/utils";+import { getPipelineFromDeploymentSchedule, projectSlug } from "@/utils";import { useDeploymentStore } from "@/store";import { useOverrideSubtitle } from "@/bbkit/BBModal.vue";export type State = {- selectedDatabaseName: string | undefined;selectedDatabaseIdListForTenantMode: Set<DatabaseId>;deployingTenantDatabaseList: DatabaseId[];};@@ -172,65 +111,20 @@ 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 }];- }-- const dict = groupBy(props.databaseList, (db) => {- if (props.project!.dbNameTemplate) {- return parseDatabaseNameByTemplate(- db.name,- props.project!.dbNameTemplate- );- }- });- return Object.keys(dict).map((name) => ({- name,- list: dict[name],- }));- }-);--watch(- databaseListGroupByName,- (groups) => {- // reset selection when databaseList changed- if (groups.length > 0) {- props.state.selectedDatabaseName = groups[0].name;- } else {- props.state.selectedDatabaseName = undefined;- }- },- { immediate: true }-);-watchEffect(() => {if (!deployment.value) return;- const name = props.state.selectedDatabaseName;- if (!name) {- props.state.deployingTenantDatabaseList = [];- } else {- // find the selected database list group by name- const databaseGroup = databaseListGroupByName.value.find(- (group) => group.name === name- );- const databaseList = databaseGroup?.list || [];+ const { databaseList } = props;- // calculate the deployment matching to preview the pipeline- const stages = getPipelineFromDeploymentSchedule(- databaseList,- deployment.value.schedule- );+ // calculate the deployment matching to preview the pipeline+ const stages = getPipelineFromDeploymentSchedule(+ databaseList,+ deployment.value.schedule+ );- // flatten all stages' database id list- // these databases are to be deployed- const databaseIdList = stages.flatMap((stage) => stage.map((db) => db.id));- props.state.deployingTenantDatabaseList = databaseIdList;- }+ // flatten all stages' database id list+ // these databases are to be deployed+ const databaseIdList = stages.flatMap((stage) => stage.map((db) => db.id));+ props.state.deployingTenantDatabaseList = databaseIdList;});useOverrideSubtitle(() => {@@ -248,7 +142,7 @@ useOverrideSubtitle(() => {{to: {path: `/project/${projectSlug(props.project!)}`,- hash: "#deployment-config",+ hash: "#databases",},activeClass: "",exactActiveClass: "",diff --git a/frontend/src/components/DatabaseListSidePanel.vue b/frontend/src/components/DatabaseListSidePanel.vueindex 3f9936f876..5baf4bc716 100644--- a/frontend/src/components/DatabaseListSidePanel.vue+++ b/frontend/src/components/DatabaseListSidePanel.vue@@ -9,18 +9,13 @@<script lang="ts">import { computed, defineComponent, watchEffect } from "vue";-import { cloneDeep, groupBy, uniqBy } from "lodash-es";+import { cloneDeep, uniqBy } from "lodash-es";import { useRouter } from "vue-router";import { useI18n } from "vue-i18n";import { Action, defineAction, useRegisterActions } from "@bytebase/vue-kbar";import type { BBOutlineItem } from "@/bbkit/types";import { Database, Environment, EnvironmentId, UNKNOWN_ID } from "@/types";-import {- databaseSlug,- environmentName,- parseDatabaseNameByTemplate,- projectSlug,-} from "@/utils";+import { databaseSlug, environmentName, projectSlug } from "@/utils";import { useEnvironmentList, useCurrentUser, useDatabaseStore } from "@/store";export default defineComponent({@@ -111,44 +106,14 @@ export default defineComponent({// Map groups to `BBOutlineItem[]`const itemList = databaseListGroupByProject.map(({ project, databaseList }) => {- const databaseListGroupByName = groupBy(databaseList, (db) => {- if (project.dbNameTemplate) {- // parse db name from template if possible- return parseDatabaseNameByTemplate(- db.name,- project.dbNameTemplate- );- } else {- // use raw db.name otherwise- return db.name;- }- });- const databaseListGroupByNameAndCount = Object.keys(- databaseListGroupByName- ).map((name) => {- return {- name,- count: databaseListGroupByName[name].length,- };- });return {id: `bb.project.${project.id}.databases`,name: project.name,- childList: databaseListGroupByNameAndCount.map<BBOutlineItem>(- ({ name, count }) => {- const label = [name];- if (count > 1) {- // Add a number beside the name when there are more than 1- // databases in single group.- label.push(`(${count})`);- }- return {- id: `bb.project.${project.id}.database.${name}`,- name: label.join(" "),- link: `/project/${projectSlug(project)}#databases`,- };- }- ),+ childList: databaseList.map<BBOutlineItem>((db) => ({+ id: `bb.project.${project.id}.database.${db.name}`,+ name: db.name,+ link: `/project/${projectSlug(project)}#databases`,+ })),childCollapse: true,} as BBOutlineItem;}diff --git a/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue b/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vueindex 4a4b4ebed7..cf3a5a8262 100644--- a/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue+++ b/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue@@ -1,9 +1,6 @@<template><div class="space-y-2 w-192 px-1">- <div- v-if="databaseListGroupByName.length === 0"- class="textinfolabel px-10 py-4"- >+ <div v-if="databaseList.length === 0" class="textinfolabel px-10 py-4"><i18n-t keypath="project.overview.no-db-prompt" tag="p"><template #newDb><span class="text-main">{{ $t("quick-action.new-db") }}</span>@@ -17,41 +14,22 @@</div><template v-else>- <div class="flex justify-between items-center py-0.5 space-x-2">- <div class="flex-1">- <select- v-if="databaseListGroupByName.length > 1"- v-model="state.selectedDatabaseName"- class="btn-select w-40 disabled:cursor-not-allowed"- >- <option disabled>{{ $t("db.select") }}</option>- <option- v-for="(group, i) in databaseListGroupByName"- :key="i"- :value="group.name"- >- {{ group.name }}- </option>- </select>- </div>-+ <div class="flex justify-end items-center py-0.5 space-x-2"><YAxisRadioGroup v-model:label="state.label" class="text-sm" /></div>- <div v-if="selectedDatabaseGroup">- <DeployDatabaseTable- :database-list="selectedDatabaseGroup.list"- :label="state.label"- :environment-list="environmentList"- :deployment="deployment"- />- </div>+ <DeployDatabaseTable+ :database-list="databaseList"+ :label="state.label"+ :environment-list="environmentList"+ :deployment="deployment"+ /></template></div></template><script lang="ts" setup>-import { computed, reactive, watch } from "vue";+import { reactive } from "vue";import {Project,DeploymentConfig,@@ -59,16 +37,9 @@ import {Database,LabelKeyType,} from "@/types";-import { groupBy } from "lodash-es";-import { parseDatabaseNameByTemplate } from "@/utils";import { DeployDatabaseTable } from "../TenantDatabaseTable";-type DatabaseGroup = {- name: string;- list: Database[];-};--const props = defineProps<{+defineProps<{project: Project;deployment: DeploymentConfig;environmentList: Environment[];@@ -77,45 +48,5 @@ const props = defineProps<{const state = reactive({label: "bb.environment" as LabelKeyType,- selectedDatabaseName: undefined as string | undefined,-});--const databaseListGroupByName = computed((): DatabaseGroup[] => {- const { dbNameTemplate } = props.project;-- if (!dbNameTemplate) {- return [{ name: "", list: props.databaseList }];- }-- const dict = groupBy(props.databaseList, (db) => {- if (dbNameTemplate) {- return parseDatabaseNameByTemplate(db.name, dbNameTemplate);- } else {- return db.name;- }- });- return Object.keys(dict).map((name) => ({- name,- list: dict[name],- }));-});--watch(- databaseListGroupByName,- (groups) => {- // reset selection when databaseList changed- if (groups.length > 0) {- state.selectedDatabaseName = groups[0].name;- } else {- state.selectedDatabaseName = undefined;- }- },- { immediate: true }-);--const selectedDatabaseGroup = computed((): DatabaseGroup | undefined => {- return databaseListGroupByName.value.find(- (group) => group.name === state.selectedDatabaseName- );});</script>diff --git a/frontend/src/components/DeploymentConfigTool/DeploymentStage.vue b/frontend/src/components/DeploymentConfigTool/DeploymentStage.vueindex 790bae4aa8..61f6e7774a 100644--- a/frontend/src/components/DeploymentConfigTool/DeploymentStage.vue+++ b/frontend/src/components/DeploymentConfigTool/DeploymentStage.vue@@ -67,7 +67,7 @@</template><script lang="ts">-import { uniq } from "lodash-es";+import { PRESET_LABEL_KEYS, RESERVED_LABEL_KEYS } from "@/utils";import { computed, defineComponent, PropType } from "vue";import { Database, Deployment, LabelSelectorRequirement } from "../../types";import SelectorItem from "./SelectorItem.vue";@@ -108,10 +108,7 @@ export default defineComponent({emits: ["remove", "prev", "next"],setup(props) {const keys = computed(() => {- const allKeys = props.databaseList.flatMap((db) =>- db.labels.map((label) => label.key)- );- return uniq(allKeys);+ return [...RESERVED_LABEL_KEYS, ...PRESET_LABEL_KEYS];});const removeSelector = (selector: LabelSelectorRequirement) => {diff --git a/frontend/src/components/TenantDatabaseTable/TenantDatabaseTable.vue b/frontend/src/components/TenantDatabaseTable/TenantDatabaseTable.vuedeleted file mode 100644index dcf6e2c198..0000000000--- a/frontend/src/components/TenantDatabaseTable/TenantDatabaseTable.vue+++ /dev/null@@ -1,94 +0,0 @@-<template>- <div class="flex flex-col space-y-4">- <DatabaseMatrix- v-for="dbGroup in databaseListGroupByName"- :key="dbGroup.name"- :name="dbGroup.name"- :database-list="dbGroup.databaseList"- :environment-list="environmentList"- :x-axis-label="xAxisLabel"- :y-axis-label="yAxisLabel"- />- </div>-</template>--<script lang="ts">-import { computed, defineComponent, PropType, watchEffect } from "vue";-import { Database, Project, LabelKeyType } from "../../types";-import { groupBy } from "lodash-es";-import DatabaseMatrix from "./DatabaseMatrix.vue";-import { parseDatabaseNameByTemplate } from "../../utils";-import { useEnvironmentList, useEnvironmentStore } from "@/store";--type Mode = "ALL" | "ALL_SHORT" | "INSTANCE" | "PROJECT" | "PROJECT_SHORT";--type DatabaseGroupByName = {- name: string;- databaseList: Database[];-};--export default defineComponent({- name: "TenantDatabaseTable",- components: { DatabaseMatrix },- props: {- bordered: {- default: true,- type: Boolean,- },- mode: {- default: "ALL",- type: String as PropType<Mode>,- },- databaseList: {- type: Object as PropType<Database[]>,- required: true,- },- project: {- type: Object as PropType<Project>,- required: true,- },- xAxisLabel: {- type: String as PropType<LabelKeyType>,- required: true,- },- yAxisLabel: {- type: String as PropType<LabelKeyType>,- required: true,- },- },- setup(props) {- const prepareList = () => {- useEnvironmentStore().fetchEnvironmentList();- };- watchEffect(prepareList);-- const environmentList = useEnvironmentList();-- const databaseListGroupByName = computed((): DatabaseGroupByName[] => {- if (props.project.dbNameTemplate === "") {- return [{ name: "", databaseList: props.databaseList }];- }-- const dict = groupBy(props.databaseList, (db) => {- if (props.project.dbNameTemplate) {- return parseDatabaseNameByTemplate(- db.name,- props.project.dbNameTemplate- );- } else {- return db.name;- }- });- return Object.keys(dict).map((name) => ({- name,- databaseList: dict[name],- }));- });-- return {- environmentList,- databaseListGroupByName,- };- },-});-</script>diff --git a/frontend/src/components/TenantDatabaseTable/index.ts b/frontend/src/components/TenantDatabaseTable/index.tsindex 3478475d45..6d82578304 100644--- a/frontend/src/components/TenantDatabaseTable/index.ts+++ b/frontend/src/components/TenantDatabaseTable/index.ts@@ -1,13 +1,5 @@-import TenantDatabaseTable from "./TenantDatabaseTable.vue";import DatabaseMatrix from "./DatabaseMatrix.vue";import DeployDatabaseTable from "./DeployDatabaseTable.vue";import YAxisRadioGroup from "./YAxisRadioGroup.vue";-export default TenantDatabaseTable;--export {- TenantDatabaseTable,- DatabaseMatrix,- DeployDatabaseTable,- YAxisRadioGroup,-};+export { DatabaseMatrix, DeployDatabaseTable, YAxisRadioGroup };diff --git a/frontend/src/components/TransferDatabaseForm/SelectDatabaseLabel.vue b/frontend/src/components/TransferDatabaseForm/SelectDatabaseLabel.vueindex d6fdb514e3..52160695c7 100644--- a/frontend/src/components/TransferDatabaseForm/SelectDatabaseLabel.vue+++ b/frontend/src/components/TransferDatabaseForm/SelectDatabaseLabel.vue@@ -1,54 +1,40 @@<template>- <template v-if="!dbNameMatchesTemplate">- <div class="textinfolabel" v-bind="$attrs">- <i18n-t keypath="label.cannot-transfer-template-not-match">- <template #name>{{ database.name }}</template>- <template #template>- <code class="text-sm font-mono bg-control-bg">- {{ targetProject.dbNameTemplate }}- </code>- </template>- </i18n-t>- </div>- </template>- <template v-else>- <div- v-if="targetProject.tenantMode === 'TENANT'"- class="space-y-4 flex flex-col justify-center items-center"- v-bind="$attrs"- >- <div v-for="label in PRESET_LABEL_KEYS" :key="label" class="w-64">- <label class="textlabel capitalize">- {{ hidePrefix(label) }}- <span v-if="isRequiredLabel(label)" style="color: red">*</span>- </label>-- <div class="flex flex-col space-y-1 w-64 mt-1">- <BBTextField- :value="getLabelValue(label)"- :placeholder="getLabelPlaceholder(label)"- class="textfield"- @input="- setLabelValue(label, ($event.target as HTMLInputElement).value)- "- />- </div>-- <div v-if="isParsedLabel(label)" class="mt-2 textinfolabel">- <i18n-t keypath="label.parsed-from-template">- <template #name>{{ database.name }}</template>- <template #template>- <code class="text-xs font-mono bg-control-bg">- {{ targetProject.dbNameTemplate }}- </code>- </template>- </i18n-t>- </div>+ <div+ v-if="targetProject.tenantMode === 'TENANT'"+ class="space-y-4 flex flex-col justify-center items-center"+ v-bind="$attrs"+ >+ <div v-for="label in PRESET_LABEL_KEYS" :key="label" class="w-64">+ <label class="textlabel capitalize">+ {{ hidePrefix(label) }}+ <span v-if="isRequiredLabel(label)" style="color: red">*</span>+ </label>++ <div class="flex flex-col space-y-1 w-64 mt-1">+ <BBTextField+ :value="getLabelValue(label)"+ :placeholder="getLabelPlaceholder(label)"+ class="textfield"+ @input="+ setLabelValue(label, ($event.target as HTMLInputElement).value)+ "+ />+ </div>++ <div v-if="isParsedLabel(label)" class="mt-2 textinfolabel">+ <i18n-t keypath="label.parsed-from-template">+ <template #name>{{ database.name }}</template>+ <template #template>+ <code class="text-xs font-mono bg-control-bg">+ {{ targetProject.dbNameTemplate }}+ </code>+ </template>+ </i18n-t></div></div>- </template>+ </div>- <slot name="buttons" :next="next" :valid="allowNext"></slot>+ <slot name="buttons" :next="next"></slot></template><script lang="ts">@@ -157,15 +143,6 @@ watch(labelListParsedFromTemplate, (list) => {});});-const allowNext = computed(() => {- if (!dbNameMatchesTemplate.value) return false;-- // every required label must be filled- return requiredLabelList.value.every((key) => {- return !!getLabelValue(key);- });-});-const getLabelPlaceholder = (key: LabelKeyType): string => {// provide "Input Tenant" if Tenant is optional// provide "Input {{TENANT}}" if Tenant is required in the templatediff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex c30e768c06..f9f9f92a8e 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1476,7 +1476,7 @@"setting": {"description": "A label is a key-value pair that helps you identify the tenant for a database. {link}."},- "db-name-template-tips": "If your tenant databases follow a naming template, you can specify it here. The databases with the same {placeholder} will be grouped together. If you don't want grouping, please uncheck the box. {link}.",+ "db-name-template-tips": "If your tenant databases follow a naming template, you can specify it here. Otherwise, please uncheck the box. {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.jsonindex da8e35c9c0..8ea034e42f 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1477,7 +1477,7 @@"setting": {"description": "标签是一组可用于标识数据库租户的键值对。{link}。"},- "db-name-template-tips": "如果您的租户数据库名字遵循命名模版,您可以在这里指定。有着相同 {placeholder} 的数据库会分在一组。如果您不想分组,就让它为空。{link}。",+ "db-name-template-tips": "如果您的租户数据库名字遵循命名模版,您可以在这里指定。否则就让它为空。{link}。","confirm-change": "您确定要修改 '{label}' 吗?","parsed-from-template": "从 {name} 中依据模板 {template} 解析得出","cannot-transfer-template-not-match": "数据库 '{name}' 无法转移到这个项目,因为它的名称不符合模板 {template}。"diff --git a/frontend/src/utils/deployment.ts b/frontend/src/utils/deployment.tsindex e8b065dab5..b1ebe84472 100644--- a/frontend/src/utils/deployment.ts+++ b/frontend/src/utils/deployment.ts@@ -48,14 +48,6 @@ export const validateDeploymentSpec = (return undefined;};-export const parseDatabaseNameByTemplate = (name: string, template: string) => {- const regex = buildDatabaseNameRegExpByTemplate(template);- const match = name.match(regex);-- // fallback to name it self when failed- return match?.groups?.DB_NAME || name;-};-export const buildDatabaseNameRegExpByTemplate = (template: string): RegExp => {let regexpString = template;diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vueindex b0fb3a57e2..9bc65a6e03 100644--- a/frontend/src/views/DatabaseDashboard.vue+++ b/frontend/src/views/DatabaseDashboard.vue@@ -15,6 +15,7 @@params: {projectSlug: DEFAULT_PROJECT_ID,},+ hash: '#databases',}"class="normal-link text-sm">diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vueindex 17d3a553ea..997992cd22 100644--- a/frontend/src/views/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail.vue@@ -233,7 +233,7 @@class="mt-4"@next="doTransfer">- <template #buttons="{ next, valid }">+ <template #buttons="{ next }"><divclass="w-full pt-4 mt-6 flex justify-end border-t border-block-border">@@ -251,9 +251,7 @@<buttontype="button"class="btn-primary ml-3 inline-flex justify-center py-2 px-4"- :disabled="- !valid || state.editingProjectId == database.project.id- "+ :disabled="state.editingProjectId == database.project.id"@click.prevent="next">{{ $t("common.transfer") }}