Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(frontend): high-privileged workspace roles can see all databases while transferring (#5696)
Liu Jif636106ca7c9
diff --git a/frontend/src/components/TransferDatabaseForm.vue b/frontend/src/components/TransferDatabaseForm.vueindex 3df8453200..6a9c233192 100644--- a/frontend/src/components/TransferDatabaseForm.vue+++ b/frontend/src/components/TransferDatabaseForm.vue@@ -49,6 +49,7 @@ import {filterDatabaseByKeyword,PRESET_LABEL_KEY_PLACEHOLDERS,sortDatabaseList,+ useWorkspacePermission,} from "../utils";import {pushNotification,@@ -86,7 +87,9 @@ const state = reactive<LocalState>({searchText: "",loading: false,});-+const hasWorkspaceManageDatabasePermission = useWorkspacePermission(+ "bb.permission.workspace.manage-database"+);const project = computed(() => projectStore.getProjectById(props.projectId));// Fetch project entity when initialize and props.projectId changes.@@ -96,11 +99,11 @@ watch({ immediate: true });-const prepareDatabaseListForDefaultProject = () => {- databaseStore.fetchDatabaseListByProjectId(DEFAULT_PROJECT_ID);+const prepare = async () => {+ await databaseStore.fetchDatabaseListByProjectId(DEFAULT_PROJECT_ID);};-onBeforeMount(prepareDatabaseListForDefaultProject);+onBeforeMount(prepare);const environmentList = useEnvironmentList(["NORMAL"]);@@ -110,9 +113,14 @@ const rawDatabaseList = computed(() => {databaseStore.getDatabaseListByProjectId(DEFAULT_PROJECT_ID));} else {- return cloneDeep(- databaseStore.getDatabaseListByPrincipalId(currentUser.value.id)- ).filter((item: Database) => item.project.id != props.projectId);+ const list = hasWorkspaceManageDatabasePermission.value+ ? databaseStore.getDatabaseList()+ : databaseStore.getDatabaseListByPrincipalId(currentUser.value.id);+ return cloneDeep(list).filter(+ (item: Database) =>+ item.project.id !== props.projectId &&+ item.project.id !== DEFAULT_PROJECT_ID+ );}});diff --git a/frontend/src/components/TransferDatabaseForm/TransferMultipleDatabaseForm.vue b/frontend/src/components/TransferDatabaseForm/TransferMultipleDatabaseForm.vueindex 2b20e97203..c7f13a5e41 100644--- a/frontend/src/components/TransferDatabaseForm/TransferMultipleDatabaseForm.vue+++ b/frontend/src/components/TransferDatabaseForm/TransferMultipleDatabaseForm.vue@@ -6,9 +6,7 @@class="overflow-y-auto"style="max-height: calc(100vh - 380px)"arrow-placement="left"- :default-expanded-names="- databaseListGroupByEnvironment.map((group) => group.environment.id)- "+ :default-expanded-names="environmentList.map((env) => env.id)"><NCollapseItemv-for="{diff --git a/frontend/src/store/modules/database.ts b/frontend/src/store/modules/database.tsindex 917a500713..87ed08ca8b 100644--- a/frontend/src/store/modules/database.ts+++ b/frontend/src/store/modules/database.ts@@ -152,6 +152,13 @@ export const useDatabaseStore = defineStore("database", {): Database {return convert(database, includedList);},+ getDatabaseList(): Database[] {+ const list: Database[] = [];+ for (const [_, databaseList] of this.databaseListByInstanceId) {+ list.push(...databaseList);+ }+ return list;+ },getDatabaseListByInstanceId(instanceId: InstanceId): Database[] {return this.databaseListByInstanceId.get(instanceId) || [];},