Skip to content

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

chore: use store cache (#12501)

Liu Ji68d388bd4071
diff --git a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
index dc56200638..25c0a3d3f1 100644
--- a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
+++ b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
@@ -12,7 +12,7 @@ import {
import {
useDatabaseV1Store,
useInstanceV1List,
- useSearchDatabaseV1List,
+ useDatabaseV1ListByProject,
useEnvironmentV1List,
useProjectV1List,
} from "@/store";
@@ -48,19 +48,9 @@ export const useCommonSearchScopeOptions = (
const { instanceList } = useInstanceV1List(
/* !showDeleted */ false,
/* !forceUpdate */ false,
- /* parent */ computed(() => project.value)
- );
- const { databaseList } = useSearchDatabaseV1List(
- computed(() => {
- const filters = ["instance = instances/-"];
- if (project.value) {
- filters.push(`project = ${project.value}`);
- }
- return {
- filter: filters.join(" && "),
- };
- })
+ /* parent */ project
);
+ const { databaseList } = useDatabaseV1ListByProject(project);
// fullScopeOptions provides full search scopes and options.
// we need this as the source of truth.
diff --git a/frontend/src/store/modules/v1/database.ts b/frontend/src/store/modules/v1/database.ts
index 35ab175806..e1335e66f3 100644
--- a/frontend/src/store/modules/v1/database.ts
+++ b/frontend/src/store/modules/v1/database.ts
@@ -258,6 +258,22 @@ export const useSearchDatabaseV1List = (
return { databaseList, ready };
};
+export const useDatabaseV1ListByProject = (
+ project: MaybeRef<string | undefined>
+) => {
+ const store = useDatabaseV1Store();
+
+ const databaseList = computed(() => {
+ const proj = unref(project);
+ if (proj) {
+ return store.databaseListByProject(proj);
+ }
+ return store.databaseList;
+ });
+
+ return { databaseList };
+};
+
export const useDatabaseV1ByName = (name: MaybeRef<string>) => {
const store = useDatabaseV1Store();
const ready = ref(true);