Skip to content

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

feat: allow delete spec when creating plan (#17198)

boojackf5376e1a1add
diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
index ef96cd2c0d..c698579f30 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
@@ -1,6 +1,7 @@
<template>
<div class="flex items-center">
<NTabs
+ :key="`${plan.specs.length}-${selectedSpec.id}`"
:value="selectedSpec.id"
type="line"
size="small"
@@ -9,17 +10,30 @@
@update:value="handleTabChange"
>
<NTab v-for="(spec, index) in plan.specs" :key="spec.id" :name="spec.id">
- <span v-if="plan.specs.length > 1" class="mr-1 opacity-80"
- >#{{ index + 1 }}</span
- >
- {{ getSpecTitle(spec) }}
- <span
- v-if="isSpecEmpty(spec)"
- class="text-error ml-0.5"
- :title="$t('plan.navigator.statement-empty')"
- >
- *
- </span>
+ <div class="flex items-center gap-1">
+ <span v-if="plan.specs.length > 1" class="opacity-80"
+ >#{{ index + 1 }}</span
+ >
+ {{ getSpecTitle(spec) }}
+ <span
+ v-if="isSpecEmpty(spec)"
+ class="text-error"
+ :title="$t('plan.navigator.statement-empty')"
+ >
+ *
+ </span>
+ <NButton
+ v-if="isCreating && plan.specs.length > 1"
+ quaternary
+ size="tiny"
+ :title="$t('common.delete')"
+ @click.stop="handleDeleteSpec(spec)"
+ >
+ <template #icon>
+ <XIcon :size="14" class="text-control-light" />
+ </template>
+ </NButton>
+ </div>
</NTab>
<template #suffix>
@@ -47,9 +61,10 @@
</template>
<script setup lang="ts">
-import { PlusIcon } from "lucide-vue-next";
-import { NTabs, NTab, NButton } from "naive-ui";
+import { PlusIcon, XIcon } from "lucide-vue-next";
+import { NTabs, NTab, NButton, useDialog } from "naive-ui";
import { ref } from "vue";
+import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL } from "@/router/dashboard/projectV1";
import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
@@ -60,6 +75,8 @@ import { useSpecsValidation } from "../common";
import { useSelectedSpec } from "./context";
const router = useRouter();
+const dialog = useDialog();
+const { t } = useI18n();
const { plan, isCreating } = usePlanContext();
const selectedSpec = useSelectedSpec();
const { isSpecEmpty } = useSpecsValidation(plan.value.specs);
@@ -89,4 +106,24 @@ const gotoSpec = (specId: string) => {
query: currentRoute.query || {},
});
};
+
+const handleDeleteSpec = (spec: Plan_Spec) => {
+ dialog.warning({
+ title: t("plan.spec.delete-change.title"),
+ content: t("plan.spec.delete-change.content"),
+ positiveText: t("common.delete"),
+ negativeText: t("common.cancel"),
+ onPositiveClick: () => {
+ const specIndex = plan.value.specs.findIndex((s) => s.id === spec.id);
+ if (specIndex >= 0) {
+ plan.value.specs.splice(specIndex, 1);
+
+ // If we deleted the currently selected spec, navigate to the first remaining spec
+ if (selectedSpec.value.id === spec.id && plan.value.specs.length > 0) {
+ gotoSpec(plan.value.specs[0].id);
+ }
+ }
+ },
+ });
+};
</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index b6288fd0a9..4e8c472ba7 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1118,6 +1118,10 @@
"database-change": "Database Change",
"export-data": "Export Data",
"unknown": "Unknown"
+ },
+ "delete-change": {
+ "title": "Delete Change",
+ "content": "Are you sure you want to delete this change?"
}
},
"targets": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index d00491e7b9..c2eedd85ff 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1118,6 +1118,10 @@
"database-change": "Cambio de base de datos",
"export-data": "Exportar datos",
"unknown": "Desconocido"
+ },
+ "delete-change": {
+ "title": "Eliminar cambio",
+ "content": "¿Está seguro de que desea eliminar este cambio?"
}
},
"targets": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 174a03b164..80d7c107d2 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1118,6 +1118,10 @@
"database-change": "データベースの変更",
"export-data": "データのエクスポート",
"unknown": "未知"
+ },
+ "delete-change": {
+ "title": "削除変更",
+ "content": "この変更を削除してもよろしいですか?"
}
},
"targets": {
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 6a6f9f8211..458fda4091 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1118,6 +1118,10 @@
"database-change": "Thay đổi cơ sở dữ liệu",
"export-data": "Xuất dữ liệu",
"unknown": "Không rõ"
+ },
+ "delete-change": {
+ "title": "Xóa thay đổi",
+ "content": "Bạn có chắc chắn muốn xóa thay đổi này không?"
}
},
"targets": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 8c1be8a685..a6548db083 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1118,6 +1118,10 @@
"database-change": "数据库变更",
"export-data": "导出数据",
"unknown": "未知"
+ },
+ "delete-change": {
+ "title": "删除变更项",
+ "content": "您确定要删除该变更项吗?"
}
},
"targets": {