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: optimize sql review panel (#12254)
ecmadao8ea89119b178
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vueindex fe26fbf6dd..43a64baca5 100644--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue@@ -7,19 +7,11 @@size: 'small',}"class="justify-end"- >- <template #result="{ advices, isRunning }">- <SQLCheckSummary- v-if="advices !== undefined && !isRunning"- :database="database"- :advices="advices"- />- </template>- </SQLCheckButton>+ /></template><script lang="ts" setup>import { toRef } from "vue";-import { SQLCheckButton, SQLCheckSummary } from "@/components/SQLCheck";+import { SQLCheckButton } from "@/components/SQLCheck";import type { ComposedDatabase } from "@/types";import { useSchemaEditorSQLCheck } from "./useSchemaEditorSQLCheck";diff --git a/frontend/src/components/Branch/BranchSQLCheckButton.vue b/frontend/src/components/Branch/BranchSQLCheckButton.vueindex a5f6070730..42b5b22e8b 100644--- a/frontend/src/components/Branch/BranchSQLCheckButton.vue+++ b/frontend/src/components/Branch/BranchSQLCheckButton.vue@@ -8,20 +8,12 @@:button-style="{height: '28px',}"- >- <template #result="{ advices, isRunning }">- <SQLCheckSummary- v-if="advices !== undefined && !isRunning"- :database="database"- :advices="advices"- />- </template>- </SQLCheckButton>+ /></template><script lang="ts" setup>import { computed } from "vue";-import { SQLCheckButton, SQLCheckSummary } from "@/components/SQLCheck";+import { SQLCheckButton } from "@/components/SQLCheck";import { useDatabaseV1Store } from "@/store";import type { Branch } from "@/types/proto/v1/branch_service";diff --git a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vueindex c67d18012f..ae1343a387 100644--- a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue+++ b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue@@ -83,12 +83,15 @@ const getStatement = async () => {};};-const handleToggleOnlineMigration = (on: boolean, confirm: Defer<boolean>) => {+const handleToggleOnlineMigration = (+ on: boolean,+ confirm: Defer<boolean> | undefined+) => {if (on) {events.emit("toggle-online-migration", {on: true,});- confirm.resolve(false);+ confirm?.resolve(false);}};diff --git a/frontend/src/components/SQLCheck/SQLCheckButton.vue b/frontend/src/components/SQLCheck/SQLCheckButton.vueindex bbda4425d5..1efface184 100644--- a/frontend/src/components/SQLCheck/SQLCheckButton.vue+++ b/frontend/src/components/SQLCheck/SQLCheckButton.vue@@ -1,6 +1,13 @@<template><div class="flex flex-row items-center gap-2">- <slot name="result" :advices="advices" :is-running="isRunning" />+ <slot name="result" :advices="advices" :is-running="isRunning">+ <SQLCheckSummary+ v-if="advices !== undefined && !isRunning"+ :database="database"+ :advices="advices"+ @click="showDetailPanel = true"+ />+ </slot><NPopover :disabled="policyErrors.length === 0" to="body"><template #trigger>@@ -10,7 +17,7 @@:style="buttonStyle"tag="div"v-bind="buttonProps"- @click="runChecks"+ @click="handleButtonClick"><template #icon><BBSpin v-if="isRunning" :size="20" />@@ -48,12 +55,12 @@</NPopover><SQLCheckPanel- v-if="database && advices && confirmDialog"+ v-if="database && advices && showDetailPanel":database="database":advices="advices":confirm="confirmDialog":override-title="$t('issue.sql-check.sql-review-violations')"- @close="confirmDialog = undefined"+ @close="onPanelClose"><template #row-extra="{ row }"><slot name="row-extra" :row="row" :confirm="confirmDialog" />@@ -79,7 +86,7 @@ import { Advice, Advice_Status } from "@/types/proto/v1/sql_service";import type { Defer, VueStyle } from "@/utils";import { defer, hasWorkspacePermissionV2 } from "@/utils";import ErrorList from "../misc/ErrorList.vue";-import SQLCheckPanel from "./SQLCheckPanel.vue";+import SQLCheckSummary from "./SQLCheckSummary.vue";import { useSQLCheckContext } from "./context";const props = withDefaults(@@ -104,6 +111,7 @@ const currentUser = useCurrentUserV1();// SKIP_CHECK_THRESHOLD is the MaxSheetCheckSize in the backend.const SKIP_CHECK_THRESHOLD = 1024 * 1024;const isRunning = ref(false);+const showDetailPanel = ref(false);const advices = ref<Advice[]>();const context = useSQLCheckContext();const confirmDialog = ref<Defer<boolean>>();@@ -152,6 +160,13 @@ const runCheckInternal = async (return result;};+const handleButtonClick = async () => {+ await runChecks();+ if (hasError.value) {+ showDetailPanel.value = true;+ }+};+const runChecks = async () => {if (policyErrors.value.length > 0) {return;@@ -188,6 +203,19 @@ const runChecks = async () => {}};+const onPanelClose = () => {+ showDetailPanel.value = false;+ confirmDialog.value = undefined;+};++const hasError = computed(() => {+ return advices.value?.some(+ (advice) =>+ advice.status === Advice_Status.ERROR ||+ advice.status === Advice_Status.WARNING+ );+});+onMounted(() => {if (!context) return;context.runSQLCheck.value = async () => {@@ -197,18 +225,12 @@ onMounted(() => {}await runChecks();-- const hasError = advices.value?.some(- (advice) =>- advice.status === Advice_Status.ERROR ||- advice.status === Advice_Status.WARNING- );- if (hasError) {+ if (hasError.value) {const d = defer<boolean>();confirmDialog.value = d;- d.promise.finally(() => {- confirmDialog.value = undefined;- });+ d.promise.finally(onPanelClose);++ showDetailPanel.value = true;return d.promise;}diff --git a/frontend/src/components/SQLCheck/SQLCheckSummary.vue b/frontend/src/components/SQLCheck/SQLCheckSummary.vueindex c13446109b..f8cbb2252d 100644--- a/frontend/src/components/SQLCheck/SQLCheckSummary.vue+++ b/frontend/src/components/SQLCheck/SQLCheckSummary.vue@@ -2,7 +2,7 @@<div v-if="summary.warningCount === 0 && summary.errorCount === 0"><heroicons:check class="w-4 h-4 text-success" /></div>- <NButton v-else quaternary size="small" @click="showDetailPanel = true">+ <NButton v-else quaternary size="small" @click="$emit('click')"><div class="inline-flex items-center gap-x-1"><heroicons:exclamation-circle class="w-4 h-4 text-error" /><span>{{ summary.errorCount }}</span>@@ -10,22 +10,14 @@<span>{{ summary.warningCount }}</span></div></NButton>-- <SQLCheckPanel- v-if="showDetailPanel"- :database="database"- :advices="advices"- @close="showDetailPanel = false"- /></template><script setup lang="ts">import { NButton } from "naive-ui";-import { computed, ref } from "vue";+import { computed } from "vue";import type { ComposedDatabase } from "@/types";import type { Advice } from "@/types/proto/v1/sql_service";import { Advice_Status } from "@/types/proto/v1/sql_service";-import SQLCheckPanel from "./SQLCheckPanel.vue";type Summary = {successCount: number;@@ -38,7 +30,9 @@ const props = defineProps<{advices: Advice[];}>();-const showDetailPanel = ref(false);+defineEmits<{+ (event: "click"): void;+}>();const summary = computed(() => {const summary: Summary = {