Skip to content

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

Differentiate between db admin and db edit operation

天舟187a2d9d0f0a
diff --git a/frontend/src/components/DatabaseBackupPanel.vue b/frontend/src/components/DatabaseBackupPanel.vue
index 50fa7b0d0c..17dcf9c1d8 100644
--- a/frontend/src/components/DatabaseBackupPanel.vue
+++ b/frontend/src/components/DatabaseBackupPanel.vue
@@ -10,7 +10,7 @@
<span class="ml-1 text-success">enabled</span>
</div>
<button
- v-if="allowEdit"
+ v-if="allowAdmin"
type="button"
class="ml-4 btn-normal"
@click.prevent="toggleAutoBackup(false)"
@@ -31,7 +31,7 @@
Automatic weekly backup
<span class="ml-1 text-control-light">disabled</span>
<button
- v-if="allowEdit && !state.autoBackupEnabled"
+ v-if="allowAdmin && !state.autoBackupEnabled"
type="button"
class="ml-4 btn-primary"
@click.prevent="toggleAutoBackup(true)"
@@ -110,6 +110,10 @@ export default {
required: true,
type: Object as PropType<Database>,
},
+ allowAdmin: {
+ required: true,
+ type: Boolean,
+ },
allowEdit: {
required: true,
type: Boolean,
diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vue
index e4ddfbc997..518d1e9c93 100644
--- a/frontend/src/views/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail.vue
@@ -194,7 +194,11 @@
<DatabaseOverviewPanel id="overview" :database="database" />
</template>
<template v-if="state.selectedIndex == BACKUP_TAB">
- <DatabaseBackupPanel :database="database" :allowEdit="allowEdit" />
+ <DatabaseBackupPanel
+ :database="database"
+ :allowAdmin="allowAdmin"
+ :allowEdit="allowEdit"
+ />
</template>
</div>
</template>
@@ -300,10 +304,14 @@ export default {
return false;
});
- // Database can be edited if meets either of the condition below:
+ // Database can be admined if meets either of the condition below:
// - Workspace owner, dba
// - db's project owner
- const allowEdit = computed(() => {
+ //
+ // The admin operation includes
+ // - Transfer project
+ // - Enable/disable backup
+ const allowAdmin = computed(() => {
if (isCurrentUserDBAOrOwner.value) {
return true;
}
@@ -319,6 +327,25 @@ export default {
return false;
});
+ // Database can be edited if meets either of the condition below:
+ // - Workspace owner, dba
+ // - db's project member
+ //
+ // The edit operation includes
+ // - Take manual backup
+ const allowEdit = computed(() => {
+ if (isCurrentUserDBAOrOwner.value) {
+ return true;
+ }
+
+ for (const member of database.value.project.memberList) {
+ if (member.principal.id == currentUser.value.id) {
+ return true;
+ }
+ }
+ return false;
+ });
+
const tryTransferProject = () => {
state.editingProjectId = database.value.project.id;
state.showModal = true;
@@ -384,6 +411,7 @@ export default {
database,
databaseConsoleLink,
allowChangeProject,
+ allowAdmin,
allowEdit,
tryTransferProject,
updateProject,