Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Enable db action button only if the user is owne or dba or is the member of project owning the db
天舟cad4617ba5df
diff --git a/frontend/src/components/BackupTable.vue b/frontend/src/components/BackupTable.vueindex a38f8794a5..24a1dffe62 100644--- a/frontend/src/components/BackupTable.vue+++ b/frontend/src/components/BackupTable.vue@@ -17,7 +17,11 @@<BBTableHeaderCell class="w-48" :title="columnList[2].title" /><BBTableHeaderCell class="w-16" :title="columnList[3].title" /><BBTableHeaderCell class="w-16" :title="columnList[4].title" />- <BBTableHeaderCell class="w-4" :title="columnList[5].title" />+ <BBTableHeaderCell+ v-if="allowEdit"+ class="w-4"+ :title="columnList[5].title"+ /></template><template v-slot:body="{ rowData: backup }"><BBTableCell :leftPadding="4">@@ -85,7 +89,7 @@<BBTableCell>{{ backup.creator.name }}</BBTableCell>- <BBTableCell>+ <BBTableCell v-if="allowEdit"><buttonclass="btn-icon"@click.stop="@@ -146,7 +150,7 @@ import { bytesToString } from "../utils";import { useStore } from "vuex";import CreateDatabasePrepForm from "../components/CreateDatabasePrepForm.vue";-const columnList: BBTableColumn[] = [+const EDIT_COLUMN_LIST: BBTableColumn[] = [{title: "Status",},@@ -167,6 +171,24 @@ const columnList: BBTableColumn[] = [},];+const NON_EDIT_COLUMN_LIST: BBTableColumn[] = [+ {+ title: "Status",+ },+ {+ title: "Name",+ },+ {+ title: "Comment",+ },+ {+ title: "Time",+ },+ {+ title: "Creator",+ },+];+interface LocalState {showRestoreBackupModal: boolean;restoredBackup?: Backup;@@ -184,6 +206,10 @@ export default {required: true,type: Object as PropType<Backup[]>,},+ allowEdit: {+ required: true,+ type: Boolean,+ },},setup(props, ctx) {const store = useStore();@@ -235,6 +261,10 @@ export default {}};+ const columnList = computed(() => {+ return props.allowEdit ? EDIT_COLUMN_LIST : NON_EDIT_COLUMN_LIST;+ });+return {state,columnList,diff --git a/frontend/src/components/DatabaseBackupPanel.vue b/frontend/src/components/DatabaseBackupPanel.vueindex 18c44c36e5..50fa7b0d0c 100644--- a/frontend/src/components/DatabaseBackupPanel.vue+++ b/frontend/src/components/DatabaseBackupPanel.vue@@ -10,6 +10,7 @@<span class="ml-1 text-success">enabled</span></div><button+ v-if="allowEdit"type="button"class="ml-4 btn-normal"@click.prevent="toggleAutoBackup(false)"@@ -30,7 +31,7 @@Automatic weekly backup<span class="ml-1 text-control-light">disabled</span><button- v-if="!state.autoBackupEnabled"+ v-if="allowEdit && !state.autoBackupEnabled"type="button"class="ml-4 btn-primary"@click.prevent="toggleAutoBackup(true)"@@ -43,6 +44,7 @@<div class="flex justify-between items-center"><div class="text-lg leading-6 font-medium text-main">Backups</div><button+ v-if="allowEdit"@click.prevent="state.showCreateBackupModal = true"type="button"class="btn-normal whitespace-nowrap items-center"@@ -50,7 +52,11 @@Backup now</button></div>- <BackupTable :database="database" :backupList="backupList" />+ <BackupTable+ :database="database"+ :backupList="backupList"+ :allowEdit="allowEdit"+ /></div><BBModalv-if="state.showCreateBackupModal"@@ -104,6 +110,10 @@ export default {required: true,type: Object as PropType<Database>,},+ allowEdit: {+ required: true,+ type: Boolean,+ },},components: {BackupTable,diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vueindex 021915505e..7f00f11524 100644--- a/frontend/src/views/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail.vue@@ -194,7 +194,7 @@<DatabaseOverviewPanel id="overview" :database="database" /></template><template v-if="state.selectedIndex == BACKUP_TAB">- <DatabaseBackupPanel :database="database" />+ <DatabaseBackupPanel :database="database" :allowEdit="allowEdit" /></template></div></template>@@ -300,6 +300,22 @@ export default {return false;});+ // Database can be edited if meets either of the condition below:+ // - Workspace owner, dba+ // - db's project member+ 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;@@ -365,6 +381,7 @@ export default {database,databaseConsoleLink,allowChangeProject,+ allowEdit,tryTransferProject,updateProject,selectTab,