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(frontend): update review policy (#1165)
ecmadao252da9d7fde6
diff --git a/frontend/src/bbkit/BBBadge.vue b/frontend/src/bbkit/BBBadge.vueindex c636f9fe76..e062b85a6d 100644--- a/frontend/src/bbkit/BBBadge.vue+++ b/frontend/src/bbkit/BBBadge.vue@@ -25,11 +25,13 @@import { computed, withDefaults } from "vue";import { BBAttentionStyle } from "./types";+export type BBBadgeStyle = BBAttentionStyle | "DISABLED";+const props = withDefaults(defineProps<{text: string;canRemove?: boolean;- style?: BBAttentionStyle;+ style?: BBBadgeStyle;}>(),{style: "INFO",@@ -38,7 +40,6 @@ const props = withDefaults(});-// eslint-disable-next-line vue/return-in-computed-propertyconst color = computed(() => {switch (props.style) {case "INFO":@@ -47,6 +48,8 @@ const color = computed(() => {return "yellow";case "CRITICAL":return "red";+ case "DISABLED":+ return "gray";}});const emit = defineEmits(["remove"]);diff --git a/frontend/src/components/DatabaseSchemaReview/SchemaReviewCreation.vue b/frontend/src/components/DatabaseSchemaReview/SchemaReviewCreation.vueindex e2964add88..b30c0b6228 100644--- a/frontend/src/components/DatabaseSchemaReview/SchemaReviewCreation.vue+++ b/frontend/src/components/DatabaseSchemaReview/SchemaReviewCreation.vue@@ -4,7 +4,7 @@class="my-4":step-item-list="STEP_LIST":allow-next="allowNext"- :finish-title="$t(`common.confirm-and-${reviewId ? 'update' : 'add'}`)"+ :finish-title="$t(`common.confirm-and-${policyId ? 'update' : 'add'}`)"@try-change-step="tryChangeStep"@try-finish="tryFinishSetup"@cancel="onCancel"@@ -16,7 +16,7 @@:available-environment-list="availableEnvironmentList":template-list="TEMPLATE_LIST":selected-template-index="state.templateIndex"- :is-edit="!!reviewId"+ :is-edit="!!policyId"@select-template="tryApplyTemplate"@name-change="(val) => (state.name = val)"@env-change="(env) => onEnvChange(env)"@@ -103,13 +103,13 @@ interface LocalState {const props = withDefaults(defineProps<{- reviewId?: number;+ policyId?: number;name?: string;selectedEnvironment?: Environment;selectedRuleList?: RuleTemplate[];}>(),{- reviewId: undefined,+ policyId: undefined,name: "",selectedEnvironment: undefined,selectedRuleList: () => [],@@ -176,6 +176,10 @@ const TEMPLATE_LIST: SchemaReviewPolicyTemplate[] = [["column.required", "column.no-null"],RuleLevel.WARNING),+ ...getRuleListWithLevel(+ ["schema.backward-compatibility"],+ RuleLevel.ERROR+ ),],},{@@ -199,7 +203,7 @@ const TEMPLATE_LIST: SchemaReviewPolicyTemplate[] = [),...getRuleListWithLevel(["table.require-pk"], RuleLevel.ERROR),...getRuleListWithLevel(- ["column.required", "column.no-null"],+ ["column.required", "column.no-null", "schema.backward-compatibility"],RuleLevel.WARNING),],@@ -229,7 +233,7 @@ const state = reactive<LocalState>({: [...TEMPLATE_LIST[DEFAULT_TEMPLATE_INDEX].ruleList],ruleUpdated: false,showAlertModal: false,- templateIndex: props.reviewId ? -1 : DEFAULT_TEMPLATE_INDEX,+ templateIndex: props.policyId ? -1 : DEFAULT_TEMPLATE_INDEX,pendingApplyTemplateIndex: -1,});@@ -238,14 +242,14 @@ const availableEnvironmentList = computed((): Environment[] => {const filteredList = store.availableEnvironments(environmentList.value,- props.reviewId+ props.policyId);return filteredList;});const onCancel = () => {- if (props.reviewId) {+ if (props.policyId) {emit("cancel");} else {router.push({@@ -294,9 +298,9 @@ const tryFinishSetup = (allowChangeCallback: () => void) => {),};- if (props.reviewId) {+ if (props.policyId) {store.updateReviewPolicy({- id: props.reviewId,+ id: props.policyId,...upsert,});} else {@@ -310,7 +314,7 @@ const tryFinishSetup = (allowChangeCallback: () => void) => {module: "bytebase",style: "SUCCESS",title: t(- `schema-review-policy.${props.reviewId ? "update" : "create"}-review`+ `schema-review-policy.${props.policyId ? "update" : "create"}-review`),});@@ -332,7 +336,7 @@ const onTemplateApply = (index: number) => {};const tryApplyTemplate = (index: number) => {- if (state.ruleUpdated || props.reviewId) {+ if (state.ruleUpdated || props.policyId) {state.showAlertModal = true;state.pendingApplyTemplateIndex = index;return;diff --git a/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleConfig.vue b/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleConfig.vueindex ff898c03b7..aaf468e3a2 100644--- a/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleConfig.vue+++ b/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleConfig.vue@@ -87,7 +87,9 @@type="text"pattern="[a-z]+"class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full border-gray-300 rounded-md"- placeholder="Input the value then press enter to add"+ :placeholder="+ $t('schema-review-policy.payload-config.input-then-press-enter')+ "@keyup.enter="(e) => pushToList(index, e)"/></div>diff --git a/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleLevelBadge.vue b/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleLevelBadge.vueindex 5160c1de1e..3aecc054f2 100644--- a/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleLevelBadge.vue+++ b/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleLevelBadge.vue@@ -9,7 +9,7 @@<script lang="ts" setup>import { PropType, computed } from "vue";import { RuleLevel } from "@/types/schemaSystem";-import { BBAttentionStyle } from "@/bbkit/types";+import { BBBadgeStyle } from "@/bbkit/BBBadge.vue";const props = defineProps({level: {@@ -18,14 +18,14 @@ const props = defineProps({},});-const style = computed((): BBAttentionStyle => {+const style = computed((): BBBadgeStyle => {switch (props.level) {case RuleLevel.ERROR:return "CRITICAL";case RuleLevel.WARNING:return "WARN";default:- return "INFO";+ return "DISABLED";}});</script>diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.ymlindex 3b770a3bcc..d22b7cded0 100644--- a/frontend/src/locales/en.yml+++ b/frontend/src/locales/en.yml@@ -1434,6 +1434,7 @@ schema-review-policy:statement: Statementtable: Tablecolumn: Column+ schema: Schematemplate:policy-for-prod:title: Schema review for Prod@@ -1479,6 +1480,9 @@ schema-review-policy:statement-where-no-leading-wildcard-like:title: Disallow leading wildcard likedescription: Disallow leading '%' in LIKE, e.g. LIKE foo = '%x' is not allowed.+ schema-backward-compatibility:+ title: Backward compatibility+ description: MySQL and TiDB support checking whether the schema change is backward compatible.payload-config:table-name-format: Table name format (regex)column-name-format: Column name format (regex)@@ -1486,6 +1490,7 @@ schema-review-policy:uk-name-format: Unique key name formatidx-name-format: Index name formatrequired-column: Required column names+ input-then-press-enter: Input the value then press enter to addtemplate:table-name: The table namecolumn-list: Index column names, joined by _diff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.ymlindex ea90863507..6ee3f93833 100644--- a/frontend/src/locales/zh-CN.yml+++ b/frontend/src/locales/zh-CN.yml@@ -1264,6 +1264,7 @@ schema-review-policy:statement: 语句table: 表column: 列+ schema: Schematemplate:policy-for-prod:title: 针对生产环境的审核策略@@ -1309,6 +1310,9 @@ schema-review-policy:statement-where-no-leading-wildcard-like:title: 禁止左模糊description: WHERE 语句中禁止使用左模糊匹配,例如禁止 LIKE foo = '%x'。+ schema-backward-compatibility:+ title: 向后兼容+ description: MySQL 和 TiDB 支持检测 schema 变更是否向后兼容payload-config:table-name-format: 表命名规则(正则)column-name-format: 列命名规则(正则)@@ -1316,6 +1320,7 @@ schema-review-policy:uk-name-format: 唯一键命名规则idx-name-format: 索引命名规则required-column: 必须包含的字段名+ input-then-press-enter: 输入后按下回车来添加template:table-name: 表名column-list: 索引包含的字段名,通过 _ 连接diff --git a/frontend/src/types/schemaSystem.ts b/frontend/src/types/schemaSystem.tsindex cda4d3f38f..4afcaac613 100644--- a/frontend/src/types/schemaSystem.ts+++ b/frontend/src/types/schemaSystem.ts@@ -13,7 +13,8 @@ export type CategoryType =| "NAMING"| "STATEMENT"| "TABLE"- | "COLUMN";+ | "COLUMN"+ | "SCHEMA";// The rule levelexport enum RuleLevel {@@ -75,7 +76,8 @@ export type RuleType =| "column.no-null"| "statement.select.no-select-all"| "statement.where.require"- | "statement.where.no-leading-wildcard-like";+ | "statement.where.no-leading-wildcard-like"+ | "schema.backward-compatibility";// The naming format rule payload.// Used by the backend.@@ -385,6 +387,13 @@ export const ruleTemplateList: RuleTemplate[] = [level: RuleLevel.ERROR,componentList: [],},+ {+ type: "schema.backward-compatibility",+ category: "SCHEMA",+ engine: "MYSQL",+ level: RuleLevel.ERROR,+ componentList: [],+ },];interface RuleCategory {@@ -397,10 +406,11 @@ export const convertToCategoryList = (ruleList: RuleTemplate[]): RuleCategory[] => {const categoryOrder: Map<CategoryType, number> = new Map([- ["ENGINE", 5],- ["NAMING", 4],- ["STATEMENT", 3],- ["TABLE", 2],+ ["ENGINE", 6],+ ["NAMING", 5],+ ["STATEMENT", 4],+ ["TABLE", 3],+ ["SCHEMA", 2],["COLUMN", 1],]);diff --git a/frontend/src/views/SettingWorkspaceSchemaReviewDetail.vue b/frontend/src/views/SettingWorkspaceSchemaReviewDetail.vueindex 6711757ce4..2ae21f0755 100644--- a/frontend/src/views/SettingWorkspaceSchemaReviewDetail.vue+++ b/frontend/src/views/SettingWorkspaceSchemaReviewDetail.vue@@ -2,7 +2,7 @@<transition appear name="slide-from-bottom" mode="out-in"><SchemaReviewCreationv-if="state.editMode"- :review-id="reviewPolicy.id"+ :policy-id="reviewPolicy.id":name="reviewPolicy.name":selected-environment="reviewPolicy.environment":selected-rule-list="selectedRuleList"