Skip to content

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

chore: double warning (#10309)

Liu Jiae42359c3b7b
diff --git a/frontend/src/components/Branch/BranchDetailView.vue b/frontend/src/components/Branch/BranchDetailView.vue
index 85fde8ca6d..cf3f5f690f 100644
--- a/frontend/src/components/Branch/BranchDetailView.vue
+++ b/frontend/src/components/Branch/BranchDetailView.vue
@@ -90,7 +90,7 @@
</div>
</div>
- <div class="w-full flex-1 flex flex-col">
+ <div class="w-full flex-1 flex flex-col overflow-hidden">
<SchemaDesignEditorLite
ref="schemaDesignerRef"
:project="project"
@@ -104,7 +104,7 @@
:style="'DELETE'"
:button-text="$t('database.delete-this-branch')"
:require-confirm="true"
- @confirm="deleteBranch"
+ @confirm="deleteBranch(false)"
/>
</div>
</div>
@@ -124,7 +124,8 @@
import { asyncComputed } from "@vueuse/core";
import dayjs from "dayjs";
import { cloneDeep } from "lodash-es";
-import { NButton, NDivider, NInput } from "naive-ui";
+import { NButton, NDivider, NInput, useDialog } from "naive-ui";
+import { Status } from "nice-grpc-common";
import { CSSProperties, computed, nextTick, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
@@ -144,6 +145,8 @@ import { getProjectAndBranchId } from "@/store/modules/v1/common";
import { ComposedProject } from "@/types";
import { Branch } from "@/types/proto/v1/branch_service";
import { DatabaseMetadata } from "@/types/proto/v1/database_service";
+import { defer } from "@/utils";
+import { getErrorCode } from "@/utils/grpcweb";
import { provideSQLCheckContext } from "../SQLCheck";
import { generateDiffDDL } from "../SchemaEditorLite";
import MaskSpinner from "../misc/MaskSpinner.vue";
@@ -185,6 +188,7 @@ const state = reactive<LocalState>({
savingStatus: "",
applyingToDatabaseStatus: false,
});
+const $dialog = useDialog();
const selectTargetDatabasesContext = ref<{
show: boolean;
}>({
@@ -488,11 +492,38 @@ const generateIssueName = (databaseNameList: string[]) => {
return issueNameParts.join(" ");
};
-const deleteBranch = async () => {
- const branch = props.dirtyBranch;
- await branchStore.deleteBranch(branch.name);
- router.replace({
- name: PROJECT_V1_ROUTE_BRANCHES,
+const confirmForceDeleteBranch = () => {
+ const d = defer<boolean>();
+ $dialog.warning({
+ title: t("common.warning"),
+ content: t("branch.deleting-parent-branch"),
+ style: "z-index: 100000",
+ negativeText: t("common.cancel"),
+ positiveText: t("branch.force-delete"),
+ onNegativeClick: () => {
+ d.resolve(false);
+ },
+ onPositiveClick: () => {
+ d.resolve(true);
+ },
});
+ return d.promise;
+};
+
+const deleteBranch = async (force: boolean) => {
+ const branch = props.dirtyBranch;
+ try {
+ await branchStore.deleteBranch(branch.name, force);
+ router.replace({
+ name: PROJECT_V1_ROUTE_BRANCHES,
+ });
+ } catch (ex) {
+ if (getErrorCode(ex) === Status.FAILED_PRECONDITION) {
+ const confirmed = await confirmForceDeleteBranch();
+ if (confirmed) {
+ deleteBranch(true);
+ }
+ }
+ }
};
</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 9efbf3c475..4d2f15a514 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -3426,6 +3426,8 @@
},
"index": {
"drop-index-confirm": "Drop index?"
- }
+ },
+ "force-delete": "Force delete",
+ "deleting-parent-branch": "Deleting a parent branch."
}
}
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index dc44c3cc0d..4a1aa8c05a 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -3424,6 +3424,8 @@
},
"index": {
"drop-index-confirm": "¿Índice de caída?"
- }
+ },
+ "force-delete": "Forzar eliminación",
+ "deleting-parent-branch": "Eliminando una rama principal."
}
}
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 9cc4bddd96..efe28a8b4e 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -3419,6 +3419,8 @@
},
"index": {
"drop-index-confirm": "删除索引?"
- }
+ },
+ "force-delete": "强制删除",
+ "deleting-parent-branch": "将要删除一个父分支。"
}
}
diff --git a/frontend/src/store/modules/branch.ts b/frontend/src/store/modules/branch.ts
index 0523a96688..215f5d8012 100644
--- a/frontend/src/store/modules/branch.ts
+++ b/frontend/src/store/modules/branch.ts
@@ -102,11 +102,16 @@ export const useBranchStore = defineStore("schema_design", () => {
return branchMapByName.get(name);
};
- const deleteBranch = async (name: string) => {
- await branchServiceClient.deleteBranch({
- name,
- force: true,
- });
+ const deleteBranch = async (name: string, force = false) => {
+ await branchServiceClient.deleteBranch(
+ {
+ name,
+ force,
+ },
+ {
+ silent: true,
+ }
+ );
branchMapByName.delete(name);
};