Skip to content

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

Rename BBButonTrash to BBButtonConfirm and support delete/archive/restore style

天舟1f394a08721f
diff --git a/frontend/src/bbkit/BBButtonTrash.vue b/frontend/src/bbkit/BBButtonConfirm.vue
similarity index 61%
rename from frontend/src/bbkit/BBButtonTrash.vue
rename to frontend/src/bbkit/BBButtonConfirm.vue
index 428db0fe4d..821205c100 100644
--- a/frontend/src/bbkit/BBButtonTrash.vue
+++ b/frontend/src/bbkit/BBButtonConfirm.vue
@@ -4,7 +4,7 @@
@click.prevent="
() => {
if (requireConfirm) {
- state.showDeleteModal = true;
+ state.showModal = true;
} else {
$emit('confirm');
}
@@ -19,38 +19,58 @@
xmlns="http://www.w3.org/2000/svg"
>
<path
+ v-if="style == 'DELETE'"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
></path>
+ <path
+ v-if="style == 'ARCHIVE'"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"
+ ></path>
+ <path
+ v-if="style == 'RESTORE'"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
+ ></path>
</svg>
<span v-if="buttonText" class="ml-1">{{ buttonText }}</span>
</button>
<BBAlert
- v-if="state.showDeleteModal"
+ v-if="state.showModal"
:style="'CRITICAL'"
:okText="okText"
:title="confirmTitle"
:description="confirmDescription"
@ok="
() => {
- state.showDeleteModal = false;
+ state.showModal = false;
$emit('confirm');
}
"
- @cancel="state.showDeleteModal = false"
+ @cancel="state.showModal = false"
>
</BBAlert>
</template>
<script lang="ts">
-import { reactive } from "vue";
+import { PropType, reactive } from "vue";
+import { BBButtonConfirmStyle } from "./types";
export default {
- name: "BBButtonTrash",
+ name: "BBButtonConfirm",
emits: ["confirm"],
props: {
+ style: {
+ default: "DELETE",
+ type: String as PropType<BBButtonConfirmStyle>,
+ },
buttonText: {
default: "",
type: String,
@@ -74,7 +94,7 @@ export default {
},
setup(props, ctx) {
const state = reactive({
- showDeleteModal: false,
+ showModal: false,
});
return {
diff --git a/frontend/src/bbkit/index.ts b/frontend/src/bbkit/index.ts
index a87a46b7de..db4f01b13c 100644
--- a/frontend/src/bbkit/index.ts
+++ b/frontend/src/bbkit/index.ts
@@ -1,7 +1,7 @@
import BBAlert from "./BBAlert.vue";
import BBAvatar from "./BBAvatar.vue";
import BBButtonAdd from "./BBButtonAdd.vue";
-import BBButtonTrash from "./BBButtonTrash.vue";
+import BBButtonConfirm from "./BBButtonConfirm.vue";
import BBCheckbox from "./BBCheckbox.vue";
import BBContextMenu from "./BBContextMenu.vue";
import BBModal from "./BBModal.vue";
@@ -25,7 +25,7 @@ export {
BBAlert,
BBAvatar,
BBButtonAdd,
- BBButtonTrash,
+ BBButtonConfirm,
BBCheckbox,
BBContextMenu,
BBModal,
diff --git a/frontend/src/bbkit/types.ts b/frontend/src/bbkit/types.ts
index 61ad47cdd5..f47a68465b 100644
--- a/frontend/src/bbkit/types.ts
+++ b/frontend/src/bbkit/types.ts
@@ -1,3 +1,5 @@
+export type BBButtonConfirmStyle = "DELETE" | "ARCHIVE" | "RESTORE";
+
export type BBTableColumn = {
title: string;
};
diff --git a/frontend/src/components/DataSourceMemberTable.vue b/frontend/src/components/DataSourceMemberTable.vue
index 20c80b2292..6deafbbb20 100644
--- a/frontend/src/components/DataSourceMemberTable.vue
+++ b/frontend/src/components/DataSourceMemberTable.vue
@@ -74,7 +74,7 @@
{{ humanizeTs(member.createdTs) }}
</BBTableCell>
<BBTableCell>
- <BBButtonTrash
+ <BBButtonConfirm
v-if="allowEdit"
:requireConfirm="true"
:okText="'Revoke'"
diff --git a/frontend/src/components/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm.vue
index cd8795d3e1..37c3da9d81 100644
--- a/frontend/src/components/EnvironmentForm.vue
+++ b/frontend/src/components/EnvironmentForm.vue
@@ -35,8 +35,9 @@
<!-- Update button group -->
<div v-else class="flex justify-between items-center pt-5">
<div v-if="state.environment.rowStatus == 'NORMAL'">
- <BBButtonTrash
+ <BBButtonConfirm
v-if="allowArchive"
+ :style="'ARCHIVE'"
:buttonText="'Archive this environment'"
:okText="'Archive'"
:confirmTitle="
@@ -48,7 +49,8 @@
/>
</div>
<div v-else-if="state.environment.rowStatus == 'ARCHIVED'">
- <BBButtonTrash
+ <BBButtonConfirm
+ :style="'RESTORE'"
:buttonText="'Restore this environment'"
:okText="'Restore'"
:confirmTitle="
diff --git a/frontend/src/components/InstanceForm.vue b/frontend/src/components/InstanceForm.vue
index 474c23f31d..486bc5b337 100644
--- a/frontend/src/components/InstanceForm.vue
+++ b/frontend/src/components/InstanceForm.vue
@@ -240,7 +240,7 @@ input[type="number"] {
</div>
<!-- Update button group -->
<div v-else class="flex justify-between">
- <BBButtonTrash
+ <BBButtonConfirm
:buttonText="'Delete this entire instance'"
:requireConfirm="true"
:confirmTitle="`Are you sure to delete '${state.instance.name}'?`"
diff --git a/frontend/src/components/MemberTable.vue b/frontend/src/components/MemberTable.vue
index d0109808f3..cb5d7f257c 100644
--- a/frontend/src/components/MemberTable.vue
+++ b/frontend/src/components/MemberTable.vue
@@ -100,7 +100,7 @@
</div>
</BBTableCell>
<BBTableCell>
- <BBButtonTrash
+ <BBButtonConfirm
v-if="allowEdit"
:requireConfirm="true"
:okText="'Revoke'"
diff --git a/frontend/src/main.js b/frontend/src/main.js
index fb0d45c9ca..e6e7cec948 100644
--- a/frontend/src/main.js
+++ b/frontend/src/main.js
@@ -11,7 +11,7 @@ import {
BBAlert,
BBAvatar,
BBButtonAdd,
- BBButtonTrash,
+ BBButtonConfirm,
BBCheckbox,
BBContextMenu,
BBModal,
@@ -84,7 +84,7 @@ app
.component("BBAlert", BBAlert)
.component("BBAvatar", BBAvatar)
.component("BBButtonAdd", BBButtonAdd)
- .component("BBButtonTrash", BBButtonTrash)
+ .component("BBButtonConfirm", BBButtonConfirm)
.component("BBCheckbox", BBCheckbox)
.component("BBContextMenu", BBContextMenu)
.component("BBModal", BBModal)
diff --git a/frontend/src/views/DataSourceDetail.vue b/frontend/src/views/DataSourceDetail.vue
index 3b3f357bec..2157d1f441 100644
--- a/frontend/src/views/DataSourceDetail.vue
+++ b/frontend/src/views/DataSourceDetail.vue
@@ -143,7 +143,7 @@
<!-- Hide deleting data source list for now, as we don't allow deleting data source after creating the database. -->
<div v-if="false" class="pt-4 flex justify-start">
- <BBButtonTrash
+ <BBButtonConfirm
v-if="allowEdit"
:buttonText="'Delete this entire data source'"
:requireConfirm="true"