Skip to content

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

chore: optimize VCS SQL review (#3014)

ecmadao6e8e6fde506a
diff --git a/frontend/src/components/RepositoryPanel.vue b/frontend/src/components/RepositoryPanel.vue
index 1340ca3f92..4daff3262e 100644
--- a/frontend/src/components/RepositoryPanel.vue
+++ b/frontend/src/components/RepositoryPanel.vue
@@ -135,14 +135,14 @@
</div>
</BBModal>
<BBModal
- v-if="state.showRemoveSQLReviewCIModal"
+ v-if="state.showRestoreSQLReviewCIModal"
class="relative overflow-hidden"
:title="$t('repository.sql-review-ci-remove')"
@close="onSQLReviewCIModalClose"
>
<div class="space-y-4 max-w-[32rem]">
<div class="whitespace-pre-wrap">
- {{ $t("repository.sql-review-ci-remove-modal") }}
+ {{ $t("repository.sql-review-ci-restore-modal") }}
</div>
<div class="flex justify-end pt-4 gap-x-2">
@@ -156,6 +156,28 @@
</div>
</div>
</BBModal>
+ <BBModal
+ v-if="state.showDisableSQLReviewCIModal"
+ class="relative overflow-hidden"
+ :title="$t('repository.sql-review-ci-remove')"
+ @close="state.showDisableSQLReviewCIModal = false"
+ >
+ <div class="space-y-4 max-w-[32rem]">
+ <div class="whitespace-pre-wrap">
+ {{ $t("repository.sql-review-ci-remove-modal") }}
+ </div>
+
+ <div class="flex justify-end pt-4 gap-x-2">
+ <button
+ type="button"
+ class="btn-normal"
+ @click.prevent="state.showDisableSQLReviewCIModal = false"
+ >
+ {{ $t("common.close") }}
+ </button>
+ </div>
+ </div>
+ </BBModal>
<FeatureModal
v-if="state.showFeatureModal"
feature="bb.feature.vcs-sql-review"
@@ -191,7 +213,8 @@ interface LocalState {
showFeatureModal: boolean;
showSetupSQLReviewCIModal: boolean;
showLoadingSQLReviewPRModal: boolean;
- showRemoveSQLReviewCIModal: boolean;
+ showDisableSQLReviewCIModal: boolean;
+ showRestoreSQLReviewCIModal: boolean;
sqlReviewCIPullRequestURL: string;
}
@@ -229,7 +252,8 @@ export default defineComponent({
showFeatureModal: false,
showSetupSQLReviewCIModal: false,
showLoadingSQLReviewPRModal: false,
- showRemoveSQLReviewCIModal: false,
+ showDisableSQLReviewCIModal: false,
+ showRestoreSQLReviewCIModal: false,
sqlReviewCIPullRequestURL: "",
});
@@ -276,7 +300,7 @@ export default defineComponent({
);
});
- const removeSQLReviewCI = computed(() => {
+ const disableSQLReviewCI = computed(() => {
return (
props.repository.enableSQLReviewCI &&
!state.repositoryConfig.enableSQLReviewCI
@@ -284,13 +308,13 @@ export default defineComponent({
});
const onSQLReviewCIModalClose = () => {
- state.showRemoveSQLReviewCIModal = false;
+ state.showRestoreSQLReviewCIModal = false;
restoreToUIWorkflowType(false);
};
const restoreToUIWorkflowType = (checkSQLReviewCI: boolean) => {
if (checkSQLReviewCI && props.repository.enableSQLReviewCI) {
- state.showRemoveSQLReviewCIModal = true;
+ state.showRestoreSQLReviewCIModal = true;
return;
}
repositoryStore.deleteRepositoryByProjectId(props.project.id).then(() => {
@@ -373,7 +397,7 @@ export default defineComponent({
});
}
- const removeSQLReview = removeSQLReviewCI.value;
+ const disableSQLReview = disableSQLReviewCI.value;
const updatedRepository =
await repositoryStore.updateRepositoryByProjectId({
@@ -386,8 +410,8 @@ export default defineComponent({
state.showLoadingSQLReviewPRModal = false;
state.showSetupSQLReviewCIModal = true;
window.open(updatedRepository.sqlReviewCIPullRequestURL, "_blank");
- } else if (removeSQLReview) {
- state.showRemoveSQLReviewCIModal = true;
+ } else if (disableSQLReview) {
+ state.showDisableSQLReviewCIModal = true;
}
pushNotification({
module: "bytebase",
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index d8a0db50e1..c5cdc71414 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -939,6 +939,7 @@
"sql-review-ci-setup-modal": "We have created a {pr} for your repository to set up the SQL review CI. Please review and merge the {pr}.",
"sql-review-ci-remove": "Remove SQL Review CI",
"sql-review-ci-remove-modal": "SQL Review CI is disabled. You need to remove the CI from your repository.",
+ "sql-review-ci-restore-modal": "Once you restore to the UI workflow, the SQL review CI will be disabled for your repository. You can remove the CI file from your repository.",
"git-provider": "Git provider",
"version-control-status": "@.capitalize:common.version-control is {status}",
"version-control-description-file-path": "Database migration scripts are stored in {fullPath}. To make schema changes, a developer would create a migration script matching file path pattern {fullPathTemplate}.",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index ab77bc647b..5558c5a4bf 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -939,6 +939,7 @@
"sql-review-ci-setup-modal": "我们为您的代码仓库创建了一个{pr}来配置 SQL 审核 CI。请审核并合并该{pr}。",
"sql-review-ci-remove": "清除 SQL 审核 CI",
"sql-review-ci-remove-modal": "SQL 审核 CI 已禁用。您还需手动删除代码仓库中的 SQL 审核 CI 文件。",
+ "sql-review-ci-restore-modal": "恢复到 UI 工作流后,SQL 审核 CI 将会被禁用,您可手动删除代码仓库中的 SQL 审核 CI 文件。",
"git-provider": "Git 提供方",
"version-control-status": "@.capitalize:common.version-control 已{status}",
"version-control-description-file-path": "数据库变更脚本存放在 {fullPath}。为了进行一次变更,开发者需要创建一个匹配 {fullPathTemplate} 文件路径格式的变更脚本。",
diff --git a/server/webhook.go b/server/webhook.go
index ceb0bd7f7b..6ea347346d 100644
--- a/server/webhook.go
+++ b/server/webhook.go
@@ -175,6 +175,13 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
)
return false, nil
}
+ if !repo.EnableSQLReviewCI {
+ log.Debug("Skip repository as the SQL review CI is not enabled.",
+ zap.Int("repository_id", repo.ID),
+ zap.String("repository_external_id", repo.ExternalID),
+ )
+ return false, nil
+ }
return c.Request().Header.Get("X-SQL-Review-Token") == repo.WebhookSecretToken && strings.HasPrefix(repo.WebURL, request.WebURL), nil
}
ctx := c.Request().Context()