Skip to content

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

Disallow delete if there is only one environment left

Tianzhou Chencca4eb5e602c
diff --git a/frontend/src/components/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm.vue
index 2213a9b560..04465bcf25 100644
--- a/frontend/src/components/EnvironmentForm.vue
+++ b/frontend/src/components/EnvironmentForm.vue
@@ -37,13 +37,16 @@
</div>
<!-- Update button group -->
<div v-else class="flex justify-between pt-5">
- <button
- type="button"
- class="btn-danger py-2 px-4"
- @click.prevent="$emit('delete')"
- >
- Delete
- </button>
+ <div>
+ <button
+ v-show="allowDelete"
+ type="button"
+ class="btn-danger py-2 px-4"
+ @click.prevent="$emit('delete')"
+ >
+ Delete
+ </button>
+ </div>
<div>
<button
type="button"
@@ -82,6 +85,10 @@ export default {
type: Boolean,
default: false,
},
+ allowDelete: {
+ type: Boolean,
+ default: true,
+ },
environment: {
// Can be false when create is true
required: false,
diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vue
index aa5e4e7d91..4ce776152b 100644
--- a/frontend/src/views/EnvironmentDashboard.vue
+++ b/frontend/src/views/EnvironmentDashboard.vue
@@ -30,7 +30,12 @@
Apply new order
</button>
</div>
- <EnvironmentDetail v-else :environment="item" @delete="doDelete" />
+ <EnvironmentDetail
+ v-else
+ :allowDelete="environmentList.length > 1"
+ :environment="item"
+ @delete="doDelete"
+ />
</BBTabPanel>
</BBTab>
</div>
diff --git a/frontend/src/views/EnvironmentDetail.vue b/frontend/src/views/EnvironmentDetail.vue
index 8d359dffce..993dc7b684 100644
--- a/frontend/src/views/EnvironmentDetail.vue
+++ b/frontend/src/views/EnvironmentDetail.vue
@@ -1,6 +1,7 @@
<template>
<EnvironmentForm
v-if="state.environment"
+ :allowDelete="allowDelete"
:environment="state.environment"
@submit="doUpdate"
@delete="state.showDeleteModal = true"
@@ -41,6 +42,10 @@ export default {
required: true,
type: Object as PropType<Environment>,
},
+ allowDelete: {
+ type: Boolean,
+ default: true,
+ },
},
setup(props, { emit }) {
const store = useStore();