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: filter advices (#12780)
Liu Ji9404cf12d9b5
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vueindex c9b5d18588..bd9def9c03 100644--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue@@ -12,6 +12,7 @@size: 'small',}":show-code-location="false"+ :advice-filter="(advice) => advice.title !== 'advice.online-migration'"class="justify-end"><template #row-title-extra="{ row, confirm }">diff --git a/frontend/src/components/Branch/BranchSQLCheckButton.vue b/frontend/src/components/Branch/BranchSQLCheckButton.vueindex 42b5b22e8b..8e5c06d226 100644--- a/frontend/src/components/Branch/BranchSQLCheckButton.vue+++ b/frontend/src/components/Branch/BranchSQLCheckButton.vue@@ -4,10 +4,11 @@:database="database":database-metadata="databaseMetadata":get-statement="getStatement"- class="justify-end":button-style="{height: '28px',}"+ :advice-filter="(advice) => advice.title !== 'advice.online-migration'"+ class="justify-end"/></template>diff --git a/frontend/src/components/SQLCheck/SQLCheckButton.vue b/frontend/src/components/SQLCheck/SQLCheckButton.vueindex 15366c0afb..32df7c677a 100644--- a/frontend/src/components/SQLCheck/SQLCheckButton.vue+++ b/frontend/src/components/SQLCheck/SQLCheckButton.vue@@ -1,10 +1,10 @@<template><div class="flex flex-row items-center gap-2">- <slot name="result" :advices="advices" :is-running="isRunning">+ <slot name="result" :advices="filteredAdvices" :is-running="isRunning"><SQLCheckSummary- v-if="advices !== undefined && !isRunning"+ v-if="filteredAdvices !== undefined && !isRunning":database="database"- :advices="advices"+ :advices="filteredAdvices"@click="showDetailPanel = true"/></slot>@@ -55,12 +55,13 @@</NPopover><SQLCheckPanel- v-if="database && advices && showDetailPanel"+ v-if="database && filteredAdvices && showDetailPanel":database="database"- :advices="advices"+ :advices="filteredAdvices":confirm="confirmDialog":override-title="$t('issue.sql-check.sql-review-violations')":show-code-location="showCodeLocation"+ :ignore-issue-creation-restriction="ignoreIssueCreationRestriction"@close="onPanelClose"><template #row-title-extra="{ row }">@@ -99,6 +100,8 @@ const props = withDefaults(buttonStyle?: VueStyle;changeType?: CheckRequest_ChangeType;showCodeLocation?: boolean;+ ignoreIssueCreationRestriction?: boolean;+ adviceFilter?: (advices: Advice, index: number) => boolean;}>(),{databaseMetadata: undefined,@@ -106,6 +109,8 @@ const props = withDefaults(buttonStyle: undefined,changeType: undefined,showCodeLocation: undefined,+ ignoreIssueCreationRestriction: false,+ adviceFilter: undefined,});@@ -119,10 +124,18 @@ const currentUser = useCurrentUserV1();const SKIP_CHECK_THRESHOLD = 1024 * 1024;const isRunning = ref(false);const showDetailPanel = ref(false);-const advices = ref<Advice[]>();+const rawAdvices = ref<Advice[]>();const context = useSQLCheckContext();const confirmDialog = ref<Defer<boolean>>();+const filteredAdvices = computed(() => {+ const { adviceFilter } = props;+ if (!adviceFilter) {+ return rawAdvices.value;+ }+ return rawAdvices.value?.filter(adviceFilter);+});+const reviewPolicy = useReviewPolicyForDatabase(computed(() => {return props.database;@@ -190,7 +203,7 @@ const runChecks = async () => {const handleErrors = (errors: string[]) => {// Mock the pre-check errors to advices- advices.value = errors.map((err) =>+ rawAdvices.value = errors.map((err) =>Advice.fromPartial({title: "Pre check",status: Advice_Status.WARNING,@@ -201,8 +214,8 @@ const runChecks = async () => {};isRunning.value = true;- if (!advices.value) {- advices.value = [];+ if (!rawAdvices.value) {+ rawAdvices.value = [];}const { statement, errors } = await props.getStatement();if (statement.length > SKIP_CHECK_THRESHOLD) {@@ -213,7 +226,7 @@ const runChecks = async () => {}try {const result = await runCheckInternal(statement, props.databaseMetadata);- advices.value = result.advices;+ rawAdvices.value = result.advices;} finally {isRunning.value = false;}@@ -225,7 +238,7 @@ const onPanelClose = () => {};const hasError = computed(() => {- return advices.value?.some(+ return filteredAdvices.value?.some((advice) =>advice.status === Advice_Status.ERROR ||advice.status === Advice_Status.WARNING@@ -260,7 +273,7 @@ onUnmounted(() => {context.runSQLCheck.value = undefined;});-watch(advices, (advices) => {+watch(filteredAdvices, (advices) => {emit("update:advices", advices);});</script>diff --git a/frontend/src/components/SQLCheck/SQLCheckPanel.vue b/frontend/src/components/SQLCheck/SQLCheckPanel.vueindex 312efc8dc2..d5ee3d8664 100644--- a/frontend/src/components/SQLCheck/SQLCheckPanel.vue+++ b/frontend/src/components/SQLCheck/SQLCheckPanel.vue@@ -55,7 +55,7 @@ import { Advice_Status } from "@/types/proto/v1/sql_service";import type { Defer } from "@/utils";import PlanCheckDetail from "../IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue";-const { advices, database } = defineProps<{+const props = defineProps<{database: ComposedDatabase;advices: Advice[];overrideTitle?: string;@@ -74,7 +74,7 @@ const policyV1Store = usePolicyV1Store();const restrictIssueCreationForSQLReview = computed((): boolean => {return (restrictIssueCreationForSqlReviewPolicy.value &&- advices.some((advice) => advice.status === Advice_Status.ERROR)+ props.advices.some((advice) => advice.status === Advice_Status.ERROR));});@@ -91,7 +91,7 @@ watchEffect(async () => {const projectLevelPolicy =await policyV1Store.getOrFetchPolicyByParentAndType({- parentPath: database.project,+ parentPath: props.database.project,policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,});if (projectLevelPolicy?.restrictIssueCreationForSqlReviewPolicy?.disallow) {@@ -103,7 +103,7 @@ watchEffect(async () => {const planCheckRun = computed((): PlanCheckRun => {return PlanCheckRun.fromPartial({status: PlanCheckRun_Status.DONE,- results: advices.map((advice) => {+ results: props.advices.map((advice) => {let status = PlanCheckRun_Result_Status.STATUS_UNSPECIFIED;switch (advice.status) {case Advice_Status.SUCCESS: