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 i18n for column type restriction (#7350)
boojack802cda72100a
diff --git a/frontend/src/components/SchemaEditor/Panels/TableEditor.vue b/frontend/src/components/SchemaEditor/Panels/TableEditor.vueindex e69c66793b..d11a35e92d 100644--- a/frontend/src/components/SchemaEditor/Panels/TableEditor.vue+++ b/frontend/src/components/SchemaEditor/Panels/TableEditor.vue@@ -281,7 +281,7 @@:show="state.showSchemaTemplateDrawer"@close="state.showSchemaTemplateDrawer = false">- <DrawerContent :title="$t('schema-template.field-template')">+ <DrawerContent :title="$t('schema-template.field-template.self')"><div class="w-[calc(100vw-36rem)] min-w-[64rem] max-w-[calc(100vw-8rem)]"><FieldTemplates:engine="databaseEngine"diff --git a/frontend/src/components/SchemaTemplate/FieldTemplateForm.vue b/frontend/src/components/SchemaTemplate/FieldTemplateForm.vueindex 1f4ea02de5..00e22c8939 100644--- a/frontend/src/components/SchemaTemplate/FieldTemplateForm.vue+++ b/frontend/src/components/SchemaTemplate/FieldTemplateForm.vue@@ -1,5 +1,5 @@<template>- <DrawerContent :title="$t('schema-template.field-template')">+ <DrawerContent :title="$t('schema-template.field-template.self')"><div class="space-y-6 divide-y divide-block-border"><div class="space-y-6"><!-- category -->diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex eed8b3596e..26e478b65e 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1378,7 +1378,7 @@"select-repository-attention-gitlab": "Bytebase only lists GitLab projects granting you at least the 'Maintainer' role, which allows to configure the project webhook to observe the code push event.","select-repository-attention-github": "Bytebase only lists GitHub repositories you have admin permissions, which allows to configure the repository webhook to observe the code push event.","select-repository-attention-bitbucket": "Bytebase only lists Bitbucket repositories you have admin permissions, which allows to configure the repository webhook to observe the code push event.",- "select-repository-attention-azure-devops": "Bytebase only lists Azure DevOps repositories under the organization which third-party application access via OAuth is granted. If you don't see the repository you want, please go to Organization -> Organization Settings -> Policies to enable third-party application access.",+ "select-repository-attention-azure-devops": "Bytebase only lists Azure DevOps repositories under the organization which third-party application access via OAuth is granted. If you don't see the repository you want, please go to Organization -> Organization Settings -> Policies to enable third-party application access.","select-repository-search": "Search repository","linked": "Linked repositories"},@@ -2640,9 +2640,22 @@},"schema-template": {"self": "Schema template",- "field-template": "Field Template",+ "field-template": {+ "self": "Field Template",+ "description": "You can pre-define the field template, then apply the template during the schema change."+ },+ "column-type-restriction": {+ "self": "Column Type Restriction",+ "description": "You can restrict the allowed column types for each database engine.",+ "allow-all": "Allow all",+ "allow-limited-types": "Allow limited types",+ "save-all": "Save all",+ "messages": {+ "unable-to-update": "Unable to update restriction",+ "following-column-types-are-used": "Following column types are still used by field tempalte"+ }+ },"add-field": "Add field template",- "description": "You can pre-define the field template, then apply the template during the schema change.","search-by-name-or-comment": "Search by name or comment","form": {"category": "Category",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 8bdc7489f7..d3690bbab6 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2639,9 +2639,22 @@},"schema-template": {"self": "Plantilla de esquema",- "field-template": "Plantilla de campo",+ "field-template": {+ "self": "Plantilla de campo",+ "description": "Predefina la plantilla de campo, luego aplique la plantilla durante el cambio de esquema."+ },+ "column-type-restriction": {+ "self": "Restricción de tipos de columna",+ "description": "Para cada motor de base de datos, puede limitar los tipos de columna permitidos.",+ "allow-all": "Permitir todos los tipos",+ "allow-limited-types": "Permitir solo algunos tipos",+ "save-all": "Guardar todo",+ "messages": {+ "unable-to-update": "No se puede actualizar la restricción",+ "following-column-types-are-used": "Los siguientes tipos de columna todavía se usan en la plantilla de campos."+ }+ },"add-field": "Agregar plantilla de campo",- "description": "Predefina la plantilla de campo, luego aplique la plantilla durante el cambio de esquema.","search-by-name-or-comment": "Buscar por nombre o comentario","form": {"category": "Categoría",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex c58836a5c7..926e88ad43 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2631,9 +2631,22 @@},"schema-template": {"self": "Schema 模板",- "field-template": "字段模板",+ "field-template": {+ "self": "字段模板",+ "description": "预定义 Schema 模板,之后可以在变更或设计 Schema 时应用这些模板。"+ },+ "column-type-restriction": {+ "self": "列类型约束",+ "description": "在每一个数据库引擎上,您可以限制允许使用的列类型。",+ "allow-all": "允许所有类型",+ "allow-limited-types": "只允许部分类型",+ "save-all": "保存所有",+ "messages": {+ "unable-to-update": "无法更新限制",+ "following-column-types-are-used": "以下列类型仍在字段模板中使用。"+ }+ },"add-field": "新增字段模板",- "description": "预定义 Schema 模板,之后可以在变更或设计 Schema 时应用这些模板。","search-by-name-or-comment": "根据名称或备注搜索","form": {"category": "分类",diff --git a/frontend/src/views/SchemaTemplate/ColumnTypes.vue b/frontend/src/views/SchemaTemplate/ColumnTypes.vueindex 3ab4409d9e..17b18adcf5 100644--- a/frontend/src/views/SchemaTemplate/ColumnTypes.vue+++ b/frontend/src/views/SchemaTemplate/ColumnTypes.vue@@ -7,7 +7,7 @@<div class="space-y-4"><div class="flex items-center justify-between gap-x-6"><div class="flex-1 textinfolabel !leading-8">- You can restrict the allowed column types for each database engine.+ {{ $t("schema-template.column-type-restriction.description") }}</div></div></div>@@ -20,10 +20,19 @@<NRadioGroupv-model:value="columnTypeTemplateForMySQL.enabled"class="gap-x-2"+ :disabled="!hasPermission || !hasFeature"@change="handleMySQLEnabledChange">- <NRadio :value="false" :label="'Allow all'" />- <NRadio :value="true" :label="'Allow limited types'" />+ <NRadio+ :value="false"+ :label="$t('schema-template.column-type-restriction.allow-all')"+ />+ <NRadio+ :value="true"+ :label="+ $t('schema-template.column-type-restriction.allow-limited-types')+ "+ /></NRadioGroup></div><NSelect@@ -32,12 +41,14 @@filterablemultipletag- :show-on-focus="true"- :disabled="!columnTypeTemplateForMySQL.enabled"+ :disabled="+ !columnTypeTemplateForMySQL.enabled || !hasPermission || !hasFeature+ "placeholder="Input, press enter to create type":show-arrow="false":show="false"@blur="handleMySQLTypesChange"+ @update:value="handleMySQLTypesChange"/></div><div class="w-full max-w-lg flex flex-col justify-start items-start gap-2">@@ -49,10 +60,19 @@<NRadioGroupv-model:value="columnTypeTemplateForPostgreSQL.enabled"class="gap-x-2"+ :disabled="!hasPermission || !hasFeature"@change="handlePostgreSQLEnabledChange">- <NRadio :value="false" :label="'Allow all'" />- <NRadio :value="true" :label="'Allow limited types'" />+ <NRadio+ :value="false"+ :label="$t('schema-template.column-type-restriction.allow-all')"+ />+ <NRadio+ :value="true"+ :label="+ $t('schema-template.column-type-restriction.allow-limited-types')+ "+ /></NRadioGroup></div><NSelect@@ -61,19 +81,31 @@filterablemultipletag- :disabled="!columnTypeTemplateForPostgreSQL.enabled"+ :disabled="+ !columnTypeTemplateForPostgreSQL.enabled ||+ !hasPermission ||+ !hasFeature+ "placeholder="Input, press enter to create type":show-arrow="false":show="false"@blur="handlePostgreSQLTypesChange"+ @update:value="handlePostgreSQLTypesChange"/></div></div>+ <FeatureModal+ feature="bb.feature.schema-template"+ :open="state.showFeatureModal"+ @cancel="state.showFeatureModal = false"+ />+<ColumnTypesUpdateFailedModalv-if="unmatchedFieldTemplates.length > 0":field-templates="unmatchedFieldTemplates"@close="unmatchedFieldTemplates = []"+ @save-all="handleSaveAllUnmatchedFieldTemplates"/></template>@@ -82,7 +114,7 @@ import { cloneDeep, isEqual, uniq, uniqBy } from "lodash-es";import { NSelect, NRadioGroup, NRadio } from "naive-ui";import { onMounted, ref } from "vue";import { Engine } from "@/types/proto/v1/common";-import { pushNotification, useSettingV1Store } from "@/store";+import { featureToRef, pushNotification, useSettingV1Store } from "@/store";import {SchemaTemplateSetting,SchemaTemplateSetting_ColumnType,@@ -90,18 +122,20 @@ import {} from "@/types/proto/v1/setting_service";import EngineIcon from "@/components/Icon/EngineIcon.vue";import ColumnTypesUpdateFailedModal from "./ColumnTypesUpdateFailedModal.vue";+import { useWorkspacePermissionV1 } from "@/utils";+import { useDebounceFn } from "@vueuse/core";++interface LocalState {+ showFeatureModal: boolean;+}const settingStore = useSettingV1Store();-const fieldTemplates = ref<SchemaTemplateSetting_FieldTemplate[]>([]);-const originColumnTypeTemplateForMySQL = ref(- SchemaTemplateSetting_ColumnType.fromPartial({- engine: Engine.MYSQL,- })-);-const originColumnTypeTemplateForPostgreSQL = ref(- SchemaTemplateSetting_ColumnType.fromPartial({- engine: Engine.POSTGRES,- })+const state = ref<LocalState>({+ showFeatureModal: false,+});+const hasFeature = featureToRef("bb.feature.schema-template");+const hasPermission = useWorkspacePermissionV1(+ "bb.permission.workspace.manage-general");const columnTypeTemplateForMySQL = ref(SchemaTemplateSetting_ColumnType.fromPartial({@@ -118,7 +152,7 @@ const typesSelectorRefForMySQL = ref<InstanceType<typeof NSelect>>();const typesSelectorRefForPostgreSQL = ref<InstanceType<typeof NSelect>>();const unmatchedFieldTemplates = ref<SchemaTemplateSetting_FieldTemplate[]>([]);-onMounted(async () => {+const getOrFetchSchemaTemplate = async () => {const setting = await settingStore.getOrFetchSettingByName("bb.workspace.schema-template");@@ -130,35 +164,76 @@ onMounted(async () => {const postgresqlColumnTypes = columnTypes.find((item) => item.engine === Engine.POSTGRES);+ return {+ fieldTemplates:+ setting.value?.schemaTemplateSettingValue?.fieldTemplates || [],+ mysqlColumnTypes,+ postgresqlColumnTypes,+ };+};++onMounted(async () => {+ const { mysqlColumnTypes, postgresqlColumnTypes } =+ await getOrFetchSchemaTemplate();if (mysqlColumnTypes) {- originColumnTypeTemplateForMySQL.value = mysqlColumnTypes;columnTypeTemplateForMySQL.value = cloneDeep(mysqlColumnTypes);}if (postgresqlColumnTypes) {- originColumnTypeTemplateForPostgreSQL.value = postgresqlColumnTypes;columnTypeTemplateForPostgreSQL.value = cloneDeep(postgresqlColumnTypes);}- fieldTemplates.value =- setting.value?.schemaTemplateSettingValue?.fieldTemplates || [];});+const handleSaveAllUnmatchedFieldTemplates = (+ fieldTemplates: SchemaTemplateSetting_FieldTemplate[]+) => {+ if (fieldTemplates.length === 0) {+ return;+ }++ const engine = fieldTemplates[0].engine;+ if (engine === Engine.MYSQL) {+ columnTypeTemplateForMySQL.value.types = uniqBy(+ [+ ...columnTypeTemplateForMySQL.value.types,+ ...fieldTemplates.map((item) => item.column?.type || ""),+ ],+ (item) => item+ );+ typesSelectorRefForMySQL.value?.focus();+ } else if (engine === Engine.POSTGRES) {+ columnTypeTemplateForPostgreSQL.value.types = uniqBy(+ [+ ...columnTypeTemplateForPostgreSQL.value.types,+ ...fieldTemplates.map((item) => item.column?.type || ""),+ ],+ (item) => item+ );+ typesSelectorRefForPostgreSQL.value?.focus();+ }+ unmatchedFieldTemplates.value = [];+};+const handleMySQLEnabledChange = (event: InputEvent) => {const value = (event.target as HTMLInputElement).value === "true";columnTypeTemplateForMySQL.value.enabled = value;if (value) {typesSelectorRefForMySQL.value?.focus();+ typesSelectorRefForMySQL.value?.triggerRef?.focusInput();} else {handleMySQLTypesChange();}};-const handleMySQLTypesChange = async () => {- if (- isEqual(- columnTypeTemplateForMySQL.value,- originColumnTypeTemplateForMySQL.value- )- ) {+// Update the column types for MySQL in the following cases:+// 1. When the column types are deleted and the selector is not focused.+// 2. When selector is blurred.+const handleMySQLTypesChange = useDebounceFn(async () => {+ if (typesSelectorRefForMySQL.value?.focused) {+ return;+ }++ const { fieldTemplates, mysqlColumnTypes } = await getOrFetchSchemaTemplate();+ if (isEqual(columnTypeTemplateForMySQL.value, mysqlColumnTypes)) {return;}@@ -174,9 +249,13 @@ const handleMySQLTypesChange = async () => {return;}+ const mysqlFieldTemplates = uniq(+ fieldTemplates.filter(+ (item) => item.engine === Engine.MYSQL && item.column?.type+ )+ );const fieldTemplateTypesOfMySQL = uniq(- fieldTemplates.value- .filter((item) => item.engine === Engine.MYSQL && item.column?.type)+ mysqlFieldTemplates.map((item) => (item.column?.type || "") as string).filter(Boolean));@@ -184,7 +263,7 @@ const handleMySQLTypesChange = async () => {(item) => !columnTypeTemplateForMySQL.value.types.includes(item));if (uncoveredTypes.length > 0) {- unmatchedFieldTemplates.value = fieldTemplates.value.filter((item) =>+ unmatchedFieldTemplates.value = mysqlFieldTemplates.filter((item) =>uncoveredTypes.includes(item.column?.type || ""));return;@@ -216,25 +295,32 @@ const handleMySQLTypesChange = async () => {style: "SUCCESS",title: "Success to update column types",});-};+}, 1000);const handlePostgreSQLEnabledChange = (event: InputEvent) => {+ if (!hasFeature.value) {+ state.value.showFeatureModal = true;+ return;+ }+const value = (event.target as HTMLInputElement).value === "true";columnTypeTemplateForPostgreSQL.value.enabled = value;if (value) {typesSelectorRefForPostgreSQL.value?.focus();+ typesSelectorRefForPostgreSQL.value?.triggerRef?.focusInput();} else {handlePostgreSQLTypesChange();}};-const handlePostgreSQLTypesChange = async () => {- if (- isEqual(- columnTypeTemplateForPostgreSQL.value,- originColumnTypeTemplateForPostgreSQL.value- )- ) {+const handlePostgreSQLTypesChange = useDebounceFn(async () => {+ if (typesSelectorRefForPostgreSQL.value?.focused) {+ return;+ }++ const { fieldTemplates, postgresqlColumnTypes } =+ await getOrFetchSchemaTemplate();+ if (isEqual(columnTypeTemplateForPostgreSQL.value, postgresqlColumnTypes)) {return;}@@ -250,9 +336,13 @@ const handlePostgreSQLTypesChange = async () => {return;}+ const postgresFieldTemplates = uniq(+ fieldTemplates.filter(+ (item) => item.engine === Engine.POSTGRES && item.column?.type+ )+ );const fieldTemplateTypesOfPostgreSQL = uniq(- fieldTemplates.value- .filter((item) => item.engine === Engine.POSTGRES && item.column?.type)+ postgresFieldTemplates.map((item) => (item.column?.type || "") as string).filter(Boolean));@@ -260,7 +350,7 @@ const handlePostgreSQLTypesChange = async () => {(item) => !columnTypeTemplateForPostgreSQL.value.types.includes(item));if (uncoveredTypes.length > 0) {- unmatchedFieldTemplates.value = fieldTemplates.value.filter((item) =>+ unmatchedFieldTemplates.value = postgresFieldTemplates.filter((item) =>uncoveredTypes.includes(item.column?.type || ""));return;@@ -292,5 +382,5 @@ const handlePostgreSQLTypesChange = async () => {style: "SUCCESS",title: "Success to update column types",});-};+}, 1000);</script>diff --git a/frontend/src/views/SchemaTemplate/ColumnTypesUpdateFailedModal.vue b/frontend/src/views/SchemaTemplate/ColumnTypesUpdateFailedModal.vueindex 8cfecb88b4..86aff61375 100644--- a/frontend/src/views/SchemaTemplate/ColumnTypesUpdateFailedModal.vue+++ b/frontend/src/views/SchemaTemplate/ColumnTypesUpdateFailedModal.vue@@ -1,15 +1,18 @@<template><BBModal- :title="'Unable to update restriction'"+ :title="+ $t('schema-template.column-type-restriction.messages.unable-to-update')+ "class="!w-[32rem] !max-w-full"@close="emits('close')">- <template #header>- <div>{{ $t("custom-approval.security-rule.template.view") }}</div>- </template><div class="w-full"><p class="mt-1 mb-2">- {{ "Following column types are still used by field tempalte:" }}+ {{+ $t(+ "schema-template.column-type-restriction.messages.following-column-types-are-used"+ )+ }}</p><divv-for="unmatchedField in unmatchedFieldMap.keys()"@@ -25,6 +28,18 @@</div></div></div>+ <div class="mt-7 flex justify-end space-x-2">+ <button type="button" class="btn-normal" @click.prevent="$emit('close')">+ {{ $t("common.close") }}+ </button>+ <button+ type="button"+ class="btn-primary"+ @click="$emit('save-all', props.fieldTemplates)"+ >+ {{ $t("schema-template.column-type-restriction.save-all") }}+ </button>+ </div></BBModal></template>@@ -38,6 +53,10 @@ const props = defineProps<{const emits = defineEmits<{(event: "close"): void;+ (+ event: "save-all",+ fieldTemplates: SchemaTemplateSetting_FieldTemplate[]+ ): void;}>();const unmatchedFieldMap = computed(() => {diff --git a/frontend/src/views/SchemaTemplate/FieldTemplates.vue b/frontend/src/views/SchemaTemplate/FieldTemplates.vueindex dde8d469d0..e664aa8ae1 100644--- a/frontend/src/views/SchemaTemplate/FieldTemplates.vue+++ b/frontend/src/views/SchemaTemplate/FieldTemplates.vue@@ -7,7 +7,7 @@<div class="space-y-4"><div class="flex items-center justify-between gap-x-6"><div class="flex-1 textinfolabel">- {{ $t("schema-template.description") }}+ {{ $t("schema-template.field-template.description") }}</div><div><NButtondiff --git a/frontend/src/views/SettingWorkspaceSchemaTemplate.vue b/frontend/src/views/SettingWorkspaceSchemaTemplate.vueindex 1987ac612c..feec0100d6 100644--- a/frontend/src/views/SettingWorkspaceSchemaTemplate.vue+++ b/frontend/src/views/SettingWorkspaceSchemaTemplate.vue@@ -1,9 +1,15 @@<template><NTabs v-model:value="state.selectedTab" type="line">- <NTabPane name="FIELD_TEMPLATE" tab="Field Template">+ <NTabPane+ name="FIELD_TEMPLATE"+ :tab="$t('schema-template.field-template.self')"+ ><FieldTemplates /></NTabPane>- <NTabPane name="COLUMN_TYPE_RESTRICTION" tab="Column Type Restriction">+ <NTabPane+ name="COLUMN_TYPE_RESTRICTION"+ :tab="$t('schema-template.column-type-restriction.self')"+ ><ColumnTypes /></NTabPane></NTabs>