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: tips for SQL check button when no SQL review policy configured (#8446)
Liu Ji1a0ded62eac7
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vueindex 44025c2150..3045b00b96 100644--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue@@ -21,6 +21,7 @@<script lang="ts" setup>import { debounce } from "lodash-es";import { ref, toRefs, watch } from "vue";+import { SQLCheckButton } from "@/components/SQLCheck";import { ComposedDatabase } from "@/types";import { useSchemaEditorSQLCheck } from "./useSchemaEditorSQLCheck";diff --git a/frontend/src/components/SQLCheck/SQLCheckButton.vue b/frontend/src/components/SQLCheck/SQLCheckButton.vueindex 01be527ef7..9f67a11934 100644--- a/frontend/src/components/SQLCheck/SQLCheckButton.vue+++ b/frontend/src/components/SQLCheck/SQLCheckButton.vue@@ -2,11 +2,11 @@<div class="flex flex-row items-center gap-2"><slot name="result" :advices="advices" :is-running="isRunning" />- <NTooltip :disabled="!errors || errors.length === 0">+ <NPopover :disabled="tooltipDisabled" to="body"><template #trigger><NButtonstyle="--n-padding: 0 14px 0 10px"- :disabled="disabled"+ :disabled="buttonDisabled":style="buttonStyle"tag="div"v-bind="buttonProps"@@ -27,19 +27,37 @@</NButton></template><template #default>- <ErrorList :errors="errors ?? []" />+ <template v-if="noReviewPolicyTips">+ <i18n-t :keypath="noReviewPolicyTips" tag="div">+ <template #environment>+ <span>{{ database.effectiveEnvironmentEntity.title }}</span>+ </template>+ <template #link>+ <router-link+ v-if="hasManageSQLReviewPolicyPermission"+ :to="`/setting/sql-review`"+ class="ml-1 normal-link underline"+ >+ {{ $t("common.go-to-configure") }}+ </router-link>+ </template>+ </i18n-t>+ </template>+ <ErrorList v-else :errors="errors ?? []" /></template>- </NTooltip>+ </NPopover></div></template><script lang="ts" setup>-import { ButtonProps, NButton, NTooltip } from "naive-ui";-import { computed, ref } from "vue";-import { CSSProperties } from "vue";+import { ButtonProps, NButton, NPopover } from "naive-ui";+import { CSSProperties, computed, ref } from "vue";import { sqlServiceClient } from "@/grpcweb";+import { usePolicyByParentAndType } from "@/store";import { ComposedDatabase } from "@/types";+import { PolicyType } from "@/types/proto/v1/org_policy_service";import { Advice } from "@/types/proto/v1/sql_service";+import { useWorkspacePermissionV1 } from "@/utils";import ErrorList from "../misc/ErrorList.vue";const props = defineProps<{@@ -53,10 +71,36 @@ const props = defineProps<{const isRunning = ref(false);const advices = ref<Advice[]>();-const disabled = computed(() => {+const reviewPolicy = usePolicyByParentAndType(+ computed(() => ({+ parentPath: props.database.effectiveEnvironment,+ policyType: PolicyType.SQL_REVIEW,+ }))+);++const hasManageSQLReviewPolicyPermission = useWorkspacePermissionV1(+ "bb.permission.workspace.manage-sql-review-policy"+);++const noReviewPolicyTips = computed(() => {+ if (!reviewPolicy.value?.sqlReviewPolicy) {+ if (hasManageSQLReviewPolicyPermission.value) {+ return "issue.sql-check.no-configured-sql-review-policy.admin";+ } else {+ return "issue.sql-check.no-configured-sql-review-policy.developer";+ }+ }+ return "";+});++const buttonDisabled = computed(() => {+ if (noReviewPolicyTips.value) return true;if (!props.statement) return true;return props.errors && props.errors.length > 0;});+const tooltipDisabled = computed(() => {+ return !buttonDisabled.value;+});const runChecks = async () => {const { statement, database } = props;diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 56a23537e2..a69fcd12e2 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -262,7 +262,8 @@"branches": "Branches","merge": "Merge","info": "Info",- "minutes": "Minutes"+ "minutes": "Minutes",+ "go-to-configure": "Configure"},"error-page": {"go-back-home": "Go back home"@@ -972,7 +973,11 @@"you-are-not-allowed-to-change-this-value": "You are not allowed to change this value","sql-check": {"sql-checks": "SQL Checks",- "not-executed-yet": "Not executed yet"+ "not-executed-yet": "Not executed yet",+ "no-configured-sql-review-policy": {+ "admin": "{environment} environment has not configured SQL Review Policy. {link}",+ "developer": "{environment} environment has not configured SQL Review Policy. Please ask your DBA to configure."+ }}},"alter-schema": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 4839d262e4..50c50991e7 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -262,7 +262,8 @@"branches": "Ramas","merge": "Combinar","info": "Información",- "minutes": "Minutos"+ "minutes": "Minutos",+ "go-to-configure": "Configurar"},"error-page": {"go-back-home": "Volver al inicio"@@ -971,7 +972,11 @@"you-are-not-allowed-to-change-this-value": "No tienes permitido cambiar este valor.","sql-check": {"sql-checks": "Comprobaciones SQL",- "not-executed-yet": "Aún no ejecutado"+ "not-executed-yet": "Aún no ejecutado",+ "no-configured-sql-review-policy": {+ "admin": "El entorno {environment} no ha configurado la política de revisión de SQL. {link}",+ "developer": "El entorno {environment} no ha configurado la política de revisión de SQL. \nSolicite a su DBA que configure."+ }}},"alter-schema": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex f3b401cb45..f58c74c8fe 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -260,7 +260,8 @@"branches": "分支","merge": "合并","info": "信息",- "minutes": "分钟"+ "minutes": "分钟",+ "go-to-configure": "去配置"},"error-page": {"go-back-home": "回到主页"@@ -969,7 +970,11 @@"you-are-not-allowed-to-change-this-value": "您无权更改这项值","sql-check": {"sql-checks": "SQL 检查项",- "not-executed-yet": "尚未执行"+ "not-executed-yet": "尚未执行",+ "no-configured-sql-review-policy": {+ "admin": "{environment} 环境没有配置 SQL 审核策略。{link}",+ "developer": "{environment} 环境没有配置 SQL 审核策略,请让您的 DBA 配置。"+ }}},"alter-schema": {