Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: remove listDatabases in frontend (#11128)
boojacke9546ccafae6
diff --git a/frontend/src/components/AnomalyCenter/AnomalyCenterDashboard.vue b/frontend/src/components/AnomalyCenter/AnomalyCenterDashboard.vueindex b3a1913fbd..83a8d4da8c 100644--- a/frontend/src/components/AnomalyCenter/AnomalyCenterDashboard.vue+++ b/frontend/src/components/AnomalyCenter/AnomalyCenterDashboard.vue@@ -175,8 +175,9 @@ const environmentList = useEnvironmentV1List(false /* !showDeleted */);const prepareDatabaseList = () => {// It will also be called when user logoutif (currentUserV1.value.name !== UNKNOWN_USER_NAME) {- databaseStore.searchOrListDatabases({- parent: "instances/-",+ const filter = `instance == "instances/-"`;+ databaseStore.searchDatabases({+ filter,});}};diff --git a/frontend/src/components/Issue/panel/RequestExportPanel/ExportResourceForm/DatabaseResourceSelector.vue b/frontend/src/components/Issue/panel/RequestExportPanel/ExportResourceForm/DatabaseResourceSelector.vueindex 44a9804faf..2023e5446d 100644--- a/frontend/src/components/Issue/panel/RequestExportPanel/ExportResourceForm/DatabaseResourceSelector.vue+++ b/frontend/src/components/Issue/panel/RequestExportPanel/ExportResourceForm/DatabaseResourceSelector.vue@@ -77,9 +77,12 @@ watch(loading.value = true;const project = await useProjectV1Store().getOrFetchProjectByUID(projectId);- const databaseList = await databaseStore.searchOrListDatabases({- parent: "instances/-",- filter: `project == "${project.name}"`,+ const filters = [+ `instance == "instances/-"`,+ `project == "${project.name}"`,+ ];+ const databaseList = await databaseStore.searchDatabases({+ filter: filters.join(" && "),});for (const database of databaseList) {diff --git a/frontend/src/components/Issue/panel/RequestQueryPanel/DatabaseResourceForm/DatabaseResourceSelector.vue b/frontend/src/components/Issue/panel/RequestQueryPanel/DatabaseResourceForm/DatabaseResourceSelector.vueindex 3173c3d172..273357d2bd 100644--- a/frontend/src/components/Issue/panel/RequestQueryPanel/DatabaseResourceForm/DatabaseResourceSelector.vue+++ b/frontend/src/components/Issue/panel/RequestQueryPanel/DatabaseResourceForm/DatabaseResourceSelector.vue@@ -80,9 +80,12 @@ watch(const project = await useProjectV1Store().getOrFetchProjectByUID(props.projectId);- const databaseList = await databaseStore.searchOrListDatabases({- parent: "instances/-",- filter: `project == "${project.name}"`,+ const filters = [+ `instance == "instances/-"`,+ `project == "${project.name}"`,+ ];+ const databaseList = await databaseStore.searchDatabases({+ filter: filters.join(" && "),});for (const database of databaseList) {diff --git a/frontend/src/components/IssueV1/logic/initialize/create.ts b/frontend/src/components/IssueV1/logic/initialize/create.tsindex 26a5780593..987578d80b 100644--- a/frontend/src/components/IssueV1/logic/initialize/create.ts+++ b/frontend/src/components/IssueV1/logic/initialize/create.ts@@ -547,9 +547,9 @@ export const prepareDatabaseList = async (};const prepareDatabaseListByProject = async (project: string) => {- await useDatabaseV1Store().searchOrListDatabases({- parent: `instances/-`,- filter: `project == "${project}"`,+ const filters = [`instance == "instances/-"`, `project == "${project}"`];+ await useDatabaseV1Store().searchDatabases({+ filter: filters.join(" && "),});};diff --git a/frontend/src/components/ProvideDashboardContext.vue b/frontend/src/components/ProvideDashboardContext.vueindex c80fef265a..01619342b9 100644--- a/frontend/src/components/ProvideDashboardContext.vue+++ b/frontend/src/components/ProvideDashboardContext.vue@@ -27,15 +27,13 @@ const policyStore = usePolicyV1Store();const databaseStore = useDatabaseV1Store();const prepareDatabases = async () => {- let filter = "";+ const filters = [`instance == "instances/-"`];// If `projectId` is provided in the route, filter the database list by the project.if (route.params.projectId) {- filter = `project == "${projectNamePrefix}${route.params.projectId}"`;+ filters.push(`project == "${projectNamePrefix}${route.params.projectId}"`);}-- await databaseStore.searchOrListDatabases({- parent: "instances/-",- filter,+ await databaseStore.searchDatabases({+ filter: filters.join(" && "),});};diff --git a/frontend/src/components/ProvideSQLEditorContext.vue b/frontend/src/components/ProvideSQLEditorContext.vueindex a4222a1c55..c8b3e5da60 100644--- a/frontend/src/components/ProvideSQLEditorContext.vue+++ b/frontend/src/components/ProvideSQLEditorContext.vue@@ -138,14 +138,15 @@ const prepareDatabases = async () => {return;}const { project } = editorStore;- const filter = project ? `project == "${project}"` : "";-+ const filters = [`instance == "instances/-"`];+ if (project) {+ filters.push(`project == "${project}"`);+ }// `databaseList` is the database list accessible by current user.// Only accessible instances and databases will be listed in the tree.const databaseList = (- await databaseStore.searchOrListDatabases({- parent: "instances/-",- filter,+ await databaseStore.searchDatabases({+ filter: filters.join(" && "),permission: "bb.databases.query",})).filter((db) => db.syncState === State.ACTIVE);diff --git a/frontend/src/components/TransferDatabaseForm.vue b/frontend/src/components/TransferDatabaseForm.vueindex d872fdcf9a..d4a6f7ca10 100644--- a/frontend/src/components/TransferDatabaseForm.vue+++ b/frontend/src/components/TransferDatabaseForm.vue@@ -142,8 +142,9 @@ const state = reactive<LocalState>({const { project } = useProjectV1ByUID(toRef(props, "projectId"));const prepare = async () => {- await databaseStore.searchOrListDatabases({- parent: "instances/-",+ const filter = `instance == "instances/-"`;+ databaseStore.searchDatabases({+ filter,});};diff --git a/frontend/src/store/modules/v1/database.ts b/frontend/src/store/modules/v1/database.tsindex 40cf004ca4..ce73871a72 100644--- a/frontend/src/store/modules/v1/database.ts+++ b/frontend/src/store/modules/v1/database.ts@@ -2,7 +2,6 @@ import { uniq } from "lodash-es";import { defineStore } from "pinia";import { computed, reactive, ref, unref, watch } from "vue";import { databaseServiceClient } from "@/grpcweb";-import { useCurrentUserV1 } from "@/store";import {ComposedInstance,ComposedDatabase,@@ -19,23 +18,17 @@ import { DEFAULT_PROJECT_V1_NAME } from "@/types";import { User } from "@/types/proto/v1/auth_service";import {Database,- ListDatabasesRequest,UpdateDatabaseRequest,DiffSchemaRequest,SearchDatabasesRequest,} from "@/types/proto/v1/database_service";-import {- extractDatabaseResourceName,- hasWorkspaceLevelProjectPermission,- isMemberOfProjectV1,-} from "@/utils";+import { extractDatabaseResourceName, isMemberOfProjectV1 } from "@/utils";import { useGracefulRequest } from "../utils";import { useEnvironmentV1Store } from "./environment";import { useInstanceV1Store } from "./instance";import { useProjectV1Store } from "./project";export const useDatabaseV1Store = defineStore("database_v1", () => {- const currentUser = useCurrentUserV1();const databaseMapByName = reactive(new Map<string, ComposedDatabase>());const databaseMapByUID = reactive(new Map<string, ComposedDatabase>());@@ -71,26 +64,11 @@ export const useDatabaseV1Store = defineStore("database_v1", () => {}}};- const listDatabases = async (args: Partial<ListDatabasesRequest>) => {- const { databases } = await databaseServiceClient.listDatabases(args);- const composedDatabaseList = await upsertDatabaseMap(databases);- return composedDatabaseList;- };const searchDatabases = async (args: Partial<SearchDatabasesRequest>) => {const { databases } = await databaseServiceClient.searchDatabases(args);const composedDatabaseList = await upsertDatabaseMap(databases);return composedDatabaseList;};- const searchOrListDatabases = async (- args: Partial<ListDatabasesRequest | SearchDatabasesRequest>- ) => {- return hasWorkspaceLevelProjectPermission(- currentUser.value,- "bb.databases.list"- )- ? listDatabases(args)- : searchDatabases(args);- };const syncDatabase = async (database: string) => {await databaseServiceClient.syncDatabase({name: database,@@ -217,8 +195,6 @@ export const useDatabaseV1Store = defineStore("database_v1", () => {return {reset,databaseList,- searchOrListDatabases,- listDatabases,searchDatabases,syncDatabase,databaseListByUser,diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vueindex afdca66369..8d17d15b1c 100644--- a/frontend/src/views/InstanceDetail.vue+++ b/frontend/src/views/InstanceDetail.vue@@ -123,8 +123,9 @@ const environment = computed(() => {});watchEffect(() => {- databaseStore.searchOrListDatabases({- parent: instance.value.name,+ const filter = `instance == "${instance.value.name}"`;+ databaseStore.searchDatabases({+ filter,});});@@ -158,8 +159,9 @@ const syncSchema = async () => {state.syncingSchema = true;try {await instanceV1Store.syncInstance(instance.value).then(() => {- return databaseStore.searchOrListDatabases({- parent: instance.value.name,+ const filter = `instance == "${instance.value.name}"`;+ databaseStore.searchDatabases({+ filter,});});// Clear the db schema metadata cache entities.