Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: handle action buttons in sql check panel (#14884)

boojack9bffe8a43d3e
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
index fe4e99cb68..c62bcfcee0 100644
--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
@@ -367,19 +367,16 @@ const generateOrGetEditingDDL = async () => {
return {
statement: state.editStatement,
errors: [],
- fatal: false,
};
}
const statementMap = await generateDiffDDLMap(/* silent */ true);
const results = Array.from(statementMap.values());
const statement = results.map((result) => result.statement).join("\n\n");
-
const errors = results.flatMap((result) => result.errors);
return {
statement,
errors,
- fatal: results.some((result) => result.fatal),
};
};
@@ -405,7 +402,7 @@ const generateDiffDDLMap = async (silent: boolean) => {
/* !allowEmptyDiffDDLWithConfigChange */ false
);
- if (result.fatal && !silent) {
+ if (result.errors.length > 0 && !silent) {
pushNotification({
module: "bytebase",
style: "CRITICAL",
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue
index 16294f8219..1e3331fb3b 100644
--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue
@@ -38,7 +38,6 @@ const props = defineProps<{
getStatement: () => Promise<{
statement: string;
errors: string[];
- fatal: boolean;
}>;
useOnlineSchemaMigration: boolean;
}>();
diff --git a/frontend/src/components/Branch/BranchDetailView.vue b/frontend/src/components/Branch/BranchDetailView.vue
index 52b36e0fd3..62f2e30fd1 100644
--- a/frontend/src/components/Branch/BranchDetailView.vue
+++ b/frontend/src/components/Branch/BranchDetailView.vue
@@ -438,7 +438,7 @@ const handleApplyToDatabase = async (databaseNameList: string[]) => {
/* !allowEmptyDiffDDLWithConfigChange */ false
);
- if (result.fatal) {
+ if (result.errors.length > 0) {
pushNotification({
module: "bytebase",
style: "CRITICAL",
diff --git a/frontend/src/components/Branch/BranchRolloutView/BranchRolloutView.vue b/frontend/src/components/Branch/BranchRolloutView/BranchRolloutView.vue
index 7003abd15c..a0e4817421 100644
--- a/frontend/src/components/Branch/BranchRolloutView/BranchRolloutView.vue
+++ b/frontend/src/components/Branch/BranchRolloutView/BranchRolloutView.vue
@@ -250,12 +250,12 @@ const handleChangeTab = async (tab: TabType) => {
};
const fetchRawSQLPreview = async () => {
- const cleanup = (errors: string[], fatal: boolean) => {
+ const cleanup = (errors: string[]) => {
if (errors.length > 0) {
rawSQLPreviewState.value = "";
pushNotification({
module: "bytebase",
- style: fatal ? "CRITICAL" : "WARN",
+ style: "CRITICAL",
title: t("common.error"),
description: errors.join("\n"),
});
@@ -287,14 +287,14 @@ const fetchRawSQLPreview = async () => {
selectedRolloutObjects.value
);
- const { statement, errors, fatal } = await generateDiffDDL(
+ const { statement, errors } = await generateDiffDDL(
db,
source,
target,
/* !allowEmptyDiffDDLWithConfigChange */ false
);
if (errors.length > 0) {
- return cleanup(errors, fatal);
+ return cleanup(errors);
}
rawSQLPreviewState.value = statement;
@@ -302,11 +302,11 @@ const fetchRawSQLPreview = async () => {
};
const handlePreviewIssue = async () => {
- const cleanup = (errors: string[], fatal: boolean) => {
+ const cleanup = (errors: string[]) => {
if (errors.length > 0) {
pushNotification({
module: "bytebase",
- style: fatal ? "CRITICAL" : "WARN",
+ style: "CRITICAL",
title: t("common.error"),
description: errors.join("\n"),
});
@@ -335,18 +335,18 @@ const handlePreviewIssue = async () => {
);
isGeneratingDDL.value = true;
- const { statement, errors, fatal } = await generateDiffDDL(
+ const { statement, errors } = await generateDiffDDL(
db,
source,
target,
/* !allowEmptyDiffDDLWithConfigChange */ false
);
if (errors.length > 0) {
- return cleanup(errors, fatal);
+ return cleanup(errors);
}
if (statement === "") {
if (!(await confirmCreateIssueWithEmptyStatement())) {
- return cleanup([], false);
+ return cleanup([]);
}
}
const sheet = Sheet.fromPartial({
diff --git a/frontend/src/components/Branch/SchemaDesignEditorLite.vue b/frontend/src/components/Branch/SchemaDesignEditorLite.vue
index 65da8869c6..ccc3eafc25 100644
--- a/frontend/src/components/Branch/SchemaDesignEditorLite.vue
+++ b/frontend/src/components/Branch/SchemaDesignEditorLite.vue
@@ -138,7 +138,7 @@ const generateDDL = async (silent: boolean) => {
applyMetadataEdit(database.value, editing);
const result = await generateDiffDDL(database.value, source, editing);
- if (result.fatal && !silent) {
+ if (result.errors.length > 0 && !silent) {
pushNotification({
module: "bytebase",
style: "CRITICAL",
@@ -166,7 +166,7 @@ const fetchRawSQLPreview = async () => {
if (result.errors.length > 0) {
pushNotification({
module: "bytebase",
- style: result.fatal ? "CRITICAL" : "WARN",
+ style: "CRITICAL",
title: t("common.error"),
description: result.errors.join("\n"),
});
diff --git a/frontend/src/components/SQLCheck/SQLCheckButton.vue b/frontend/src/components/SQLCheck/SQLCheckButton.vue
index 613e09563b..4e04aecac3 100644
--- a/frontend/src/components/SQLCheck/SQLCheckButton.vue
+++ b/frontend/src/components/SQLCheck/SQLCheckButton.vue
@@ -55,7 +55,7 @@
</NPopover>
<SQLCheckPanel
- v-if="database && filteredAdvices && showDetailPanel"
+ v-if="filteredAdvices && showDetailPanel"
:database="database"
:advices="filteredAdvices"
:confirm="confirmDialog"
@@ -99,7 +99,6 @@ const props = withDefaults(
getStatement: () => Promise<{
errors: string[];
statement: string;
- fatal?: boolean;
}>;
database: ComposedDatabase;
databaseMetadata?: DatabaseMetadata;
@@ -194,14 +193,9 @@ const handleButtonClick = async () => {
if (hasError.value) {
const d = defer<boolean>();
- confirmDialog.value = d;
d.promise.finally(onPanelClose);
-
showDetailPanel.value = true;
-
return d.promise;
- } else {
- confirmDialog.value = undefined;
}
};
@@ -226,9 +220,8 @@ const runChecks = async () => {
if (!rawAdvices.value) {
rawAdvices.value = [];
}
- const { statement, errors, fatal } = await props.getStatement();
- allowForceContinue.value = !fatal;
-
+ const { statement, errors } = await props.getStatement();
+ allowForceContinue.value = errors.length === 0;
if (new Blob([statement]).size > SKIP_CHECK_THRESHOLD) {
return handleErrors([t("issue.sql-check.statement-is-too-large")]);
}
diff --git a/frontend/src/components/SQLCheck/SQLCheckPanel.vue b/frontend/src/components/SQLCheck/SQLCheckPanel.vue
index 0cc90e3d33..2ce68a5cb1 100644
--- a/frontend/src/components/SQLCheck/SQLCheckPanel.vue
+++ b/frontend/src/components/SQLCheck/SQLCheckPanel.vue
@@ -1,12 +1,10 @@
<template>
<BBModal
:title="overrideTitle ?? $t('task.check-result.title-general')"
- :show-close="!confirm"
- :close-on-esc="!confirm"
class="!w-[56rem]"
header-class="whitespace-pre-wrap break-all gap-x-1"
container-class="!pt-0 -mt-px"
- @close="$emit('close')"
+ @close="onClose"
>
<PlanCheckRunDetail
:plan-check-run="planCheckRun"
@@ -22,7 +20,7 @@
v-if="confirm"
class="flex flex-row justify-end items-center gap-x-3 mt-3"
>
- <NButton @click="confirm!.resolve(false)">
+ <NButton @click="onClose">
{{ $t("issue.sql-check.back-to-edit") }}
</NButton>
<NButton
@@ -30,7 +28,7 @@
type="primary"
@click="confirm!.resolve(true)"
>
- {{ $t("issue.sql-check.continue-anyway") }}
+ {{ $t("common.continue-anyway") }}
</NButton>
</div>
</BBModal>
@@ -72,7 +70,7 @@ const props = withDefaults(
}
);
-defineEmits<{
+const emit = defineEmits<{
(event: "close"): void;
}>();
@@ -143,4 +141,9 @@ const planCheckRun = computed((): PlanCheckRun => {
}),
});
});
+
+const onClose = () => {
+ props.confirm?.resolve(false);
+ emit("close");
+};
</script>
diff --git a/frontend/src/components/SchemaEditorLite/common.ts b/frontend/src/components/SchemaEditorLite/common.ts
index 242a6f75f2..255dca2c8b 100644
--- a/frontend/src/components/SchemaEditorLite/common.ts
+++ b/frontend/src/components/SchemaEditorLite/common.ts
@@ -15,7 +15,6 @@ export const _generateDiffDDLTimer = new TinyTimer<"generateDiffDDL">(
export type GenerateDiffDDLResult = {
statement: string;
errors: string[];
- fatal: boolean;
};
export const generateDiffDDL = async (
@@ -24,26 +23,24 @@ export const generateDiffDDL = async (
target: DatabaseMetadata,
allowEmptyDiffDDLWithConfigChange = true
): Promise<GenerateDiffDDLResult> => {
- const finish = (statement: string, errors: string[], fatal: boolean) => {
+ const finish = (statement: string, errors: string[]) => {
_generateDiffDDLTimer.end("generateDiffDDL");
return {
statement,
errors,
- fatal,
};
};
if (isEqual(source, target)) {
- return finish("", [], false);
+ return finish("", []);
}
const validationMessages = validateDatabaseMetadata(target);
if (validationMessages.length > 0) {
- return finish(
- "",
- [t("schema-editor.message.invalid-schema"), ...validationMessages],
- true
- );
+ return finish("", [
+ t("schema-editor.message.invalid-schema"),
+ ...validationMessages,
+ ]);
}
try {
const classificationConfig = useSettingV1Store().getProjectClassification(
@@ -67,17 +64,13 @@ export const generateDiffDDL = async (
!allowEmptyDiffDDLWithConfigChange &&
!isEqual(source.schemaConfigs, target.schemaConfigs)
) {
- return finish(
- "",
- [t("schema-editor.message.cannot-change-config")],
- true
- );
+ return finish("", [t("schema-editor.message.cannot-change-config")]);
}
- return finish("", [], false);
+ return finish("", []);
}
- return finish(diff, [], false);
+ return finish(diff, []);
} catch (ex) {
console.warn("[generateDiffDDL]", ex);
- return finish("", [extractGrpcErrorMessage(ex)], true);
+ return finish("", [extractGrpcErrorMessage(ex)]);
}
};
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 051f3a59d2..2540942297 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1299,7 +1299,6 @@
},
"statement-is-too-large": "As the current statement size exceeds 2MB, the SQL check will be skipped.",
"back-to-edit": "Back to edit",
- "continue-anyway": "Continue anyway",
"sql-review-violations": "SQL Review Violations"
},
"error": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 2d218d885c..fcbf30da3e 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1299,7 +1299,6 @@
},
"statement-is-too-large": "Como el tamaño de la declaración actual supera 2MB, se omitirá la comprobación de SQL.",
"back-to-edit": "Volver a editar",
- "continue-anyway": "De todas maneras, continúe",
"sql-review-violations": "Infracciones de revisión de SQL"
},
"error": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index d7e1f9a854..94a4bce485 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1299,7 +1299,6 @@
},
"statement-is-too-large": "現在のステートメント サイズが 1MB を超えているため、SQL チェックはスキップされます。",
"back-to-edit": "編集に戻る",
- "continue-anyway": "まだ続く",
"sql-review-violations": "SQL監査ルール違反"
},
"error": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index b5e3bf6ba0..cd1415678b 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1299,7 +1299,6 @@
},
"statement-is-too-large": "当前语句大小超过 2MB,将跳过 SQL 检查。",
"back-to-edit": "返回编辑",
- "continue-anyway": "仍然继续",
"sql-review-violations": "违反的 SQL 审核规则"
},
"error": {
diff --git a/frontend/src/store/modules/v1/experimental-issue.ts b/frontend/src/store/modules/v1/experimental-issue.ts
index 050e15d03b..69d9847aa4 100644
--- a/frontend/src/store/modules/v1/experimental-issue.ts
+++ b/frontend/src/store/modules/v1/experimental-issue.ts
@@ -22,6 +22,7 @@ import {
extractUserResourceName,
hasProjectPermissionV2,
} from "@/utils";
+import { DEFAULT_PAGE_SIZE } from "../common";
export interface ComposeIssueConfig {
withPlan?: boolean;
@@ -79,7 +80,7 @@ export const composeIssue = async (
if (hasProjectPermissionV2(projectEntity, "bb.taskRuns.list")) {
const { taskRuns } = await rolloutServiceClient.listTaskRuns({
parent: `${issue.rollout}/stages/-/tasks/-`,
- pageSize: 1000, // MAX
+ pageSize: DEFAULT_PAGE_SIZE,
});
const composedTaskRuns: ComposedTaskRun[] = [];
for (const taskRun of taskRuns) {