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: move some to listDatabases (#12942)
Danny Xuf4c0cbf15f1d
diff --git a/frontend/src/components/Issue/panel/RequestQueryPanel/DatabaseResourceForm/DatabaseResourceSelector.vue b/frontend/src/components/Issue/panel/RequestQueryPanel/DatabaseResourceForm/DatabaseResourceSelector.vueindex c75fff0e7a..712740ff9b 100644--- a/frontend/src/components/Issue/panel/RequestQueryPanel/DatabaseResourceForm/DatabaseResourceSelector.vue+++ b/frontend/src/components/Issue/panel/RequestQueryPanel/DatabaseResourceForm/DatabaseResourceSelector.vue@@ -65,13 +65,7 @@ const defaultExpandedKeys = ref<string[]>([]);const loading = ref(true);onMounted(async () => {- const project = await useProjectV1Store().getOrFetchProjectByName(- props.projectName- );- const filters = [`instance = "instances/-"`, `project = "${project.name}"`];- await databaseStore.searchDatabases({- filter: filters.join(" && "),- });+ await databaseStore.listDatabases(props.projectName);await Promise.all(selectedValueList.value.map(async (key) => {diff --git a/frontend/src/components/IssueV1/logic/initialize/create.ts b/frontend/src/components/IssueV1/logic/initialize/create.tsindex c22982285a..3c3afb2981 100644--- a/frontend/src/components/IssueV1/logic/initialize/create.ts+++ b/frontend/src/components/IssueV1/logic/initialize/create.ts@@ -514,10 +514,7 @@ export const prepareDatabaseList = async (};const prepareDatabaseListByProject = async (project: string) => {- const filters = [`instance = "instances/-"`, `project = "${project}"`];- await useDatabaseV1Store().searchDatabases({- filter: filters.join(" && "),- });+ await useDatabaseV1Store().listDatabases(project);};export const isValidStage = (stage: Stage): boolean => {diff --git a/frontend/src/components/Plan/logic/initialize/create.ts b/frontend/src/components/Plan/logic/initialize/create.tsindex d71e2aaf70..9fa4fe79e6 100644--- a/frontend/src/components/Plan/logic/initialize/create.ts+++ b/frontend/src/components/Plan/logic/initialize/create.ts@@ -437,10 +437,7 @@ export const prepareDatabaseList = async (};const prepareDatabaseListByProject = async (project: string) => {- const filters = [`instance = "instances/-"`, `project = "${project}"`];- await useDatabaseV1Store().searchDatabases({- filter: filters.join(" && "),- });+ await useDatabaseV1Store().listDatabases(project);};export const isValidSpec = (spec: Plan_Spec): boolean => {diff --git a/frontend/src/components/ProvideDashboardContext.vue b/frontend/src/components/ProvideDashboardContext.vueindex 535d468d94..4eaf0dc073 100644--- a/frontend/src/components/ProvideDashboardContext.vue+++ b/frontend/src/components/ProvideDashboardContext.vue@@ -53,11 +53,11 @@ const fetchInstances = async (project: string) => {);};-const fetchDatabases = async (project: string) => {+const fetchDatabases = async (optionalProject: string) => {const filters = [`instance = "instances/-"`];// If `projectId` is provided in the route, filter the database list by the project.- if (project) {- filters.push(`project = "${projectNamePrefix}${project}"`);+ if (optionalProject) {+ filters.push(`project = "${projectNamePrefix}${optionalProject}"`);}await databaseStore.searchDatabases({filter: filters.join(" && "),@@ -65,11 +65,11 @@ const fetchDatabases = async (project: string) => {};const instanceAndDatabaseInitialized = new Set<string /* project */>();-const fetchInstancesAndDatabases = async (project: string) => {- if (instanceAndDatabaseInitialized.has(project || "")) return;+const fetchInstancesAndDatabases = async (optionalProject: string) => {+ if (instanceAndDatabaseInitialized.has(optionalProject || "")) return;try {- await Promise.all([fetchInstances(project), fetchDatabases(project)]);- instanceAndDatabaseInitialized.add(project || "");+ await Promise.all([fetchInstances(optionalProject), fetchDatabases(optionalProject)]);+ instanceAndDatabaseInitialized.add(optionalProject || "");} catch {// nothing}diff --git a/frontend/src/components/ProvideSQLEditorContext.vue b/frontend/src/components/ProvideSQLEditorContext.vueindex 97e9e0f0b4..b87ffe1200 100644--- a/frontend/src/components/ProvideSQLEditorContext.vue+++ b/frontend/src/components/ProvideSQLEditorContext.vue@@ -174,16 +174,9 @@ const prepareDatabases = async () => {return;}const { project } = editorStore;- 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.+ // `databaseList` is the database list in the project.const databaseList = (- await databaseStore.searchDatabases({- filter: filters.join(" && "),- })+ await databaseStore.listDatabases(project)).filter((db) => db.syncState === State.ACTIVE);editorStore.databaseList = databaseList;diff --git a/frontend/src/components/TransferDatabaseForm.vue b/frontend/src/components/TransferDatabaseForm.vueindex a9122d0396..84afaec58c 100644--- a/frontend/src/components/TransferDatabaseForm.vue+++ b/frontend/src/components/TransferDatabaseForm.vue@@ -145,9 +145,7 @@ const { project } = useProjectByName(toRef(props, "projectName"));onMounted(async () => {state.loading = true;// Prepare all databases for transfer.- await databaseStore.searchDatabases({- filter: "",- });+ await databaseStore.searchDatabases({});state.loading = false;});diff --git a/frontend/src/store/modules/v1/database.ts b/frontend/src/store/modules/v1/database.tsindex 29c75d7174..97ccc0911b 100644--- a/frontend/src/store/modules/v1/database.ts+++ b/frontend/src/store/modules/v1/database.ts@@ -83,6 +83,15 @@ export const useDatabaseV1Store = defineStore("database_v1", () => {}}};+ const listDatabases = async (parent : string) => {+ const { databases } = await databaseServiceClient.listDatabases({+ parent: parent,+ pageSize: DEFAULT_DATABASE_PAGE_SIZE,+ });+ const composedDatabaseList = await upsertDatabaseMap(databases);+ return composedDatabaseList;+ };+ // Deprecated.const searchDatabases = async (args: Partial<SearchDatabasesRequest>) => {const { databases } = await databaseServiceClient.searchDatabases({pageSize: DEFAULT_DATABASE_PAGE_SIZE,@@ -226,6 +235,7 @@ export const useDatabaseV1Store = defineStore("database_v1", () => {reset,removeCacheByInstance,databaseList,+ listDatabases,searchDatabases,syncDatabase,databaseListByUser,