Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: implement view matched/unmatched databases/tables (#6358)
boojack9e72e3cb3698
diff --git a/frontend/src/assets/css/tailwind.css b/frontend/src/assets/css/tailwind.cssindex e15c000296..a43b73a37f 100644--- a/frontend/src/assets/css/tailwind.css+++ b/frontend/src/assets/css/tailwind.css@@ -178,7 +178,7 @@}.textfield {- @apply text-main disabled:text-control disabled:bg-gray-50 focus:ring-control focus:border-control sm:text-sm border-control-border rounded-md;+ @apply text-main disabled:text-control disabled:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-70 focus:ring-control focus:border-control sm:text-sm border-control-border rounded-md;}.textarea {diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vueindex d90bca2536..e212a7e5f7 100644--- a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue@@ -63,12 +63,14 @@v-if="resourceType === 'DATABASE_GROUP'":project="project":environment-id="state.environmentId || ''"+ :database-group="databaseGroup as DatabaseGroup":expr="state.expr"/><MatchedTableViewv-if="resourceType === 'SCHEMA_GROUP'":project="project"- :environment-id="state.environmentId || ''"+ :schema-group="databaseGroup as SchemaGroup"+ :database-group-name="state.selectedDatabaseGroupId || ''":expr="state.expr"/></div>@@ -103,6 +105,7 @@ import {getProjectNameAndDatabaseGroupNameAndSchemaGroupName,} from "@/store/modules/v1/common";import { projectNamePrefix } from "@/store/modules/v1/common";+import { useDebounceFn } from "@vueuse/core";const props = defineProps<{project: ComposedProject;@@ -158,61 +161,76 @@ onMounted(async () => {}state.expr = convertResult.conditionGroupExpr;} else {- const expression =- (databaseGroup as SchemaGroup).tableExpr?.expression ?? "";+ const schemaGroup = databaseGroup as SchemaGroup;+ const expression = schemaGroup.tableExpr?.expression ?? "";const [projectName, databaseGroupName, schemaGroupName] =- getProjectNameAndDatabaseGroupNameAndSchemaGroupName(databaseGroup.name);+ getProjectNameAndDatabaseGroupNameAndSchemaGroupName(schemaGroup.name);state.resourceId = schemaGroupName;state.selectedDatabaseGroupId = `${projectNamePrefix}${projectName}/${databaseGroupNamePrefix}${databaseGroupName}`;- const convertResult = await convertCELStringToExpr(expression);- state.expr = convertResult;- }-});--const validateResourceId = async (- resourceId: ResourceId-): Promise<ValidatedMessage[]> => {- if (!resourceId) {- return [];- }+ const expr = await convertCELStringToExpr(expression);+ state.expr = expr;- let request = undefined;- if (props.resourceType === "DATABASE_GROUP") {- request = dbGroupStore.getOrFetchDBGroupById(- `${props.project.name}/databaseGroups/${resourceId}`+ // Fetch related database group environment.+ const relatedDatabaseGroup = await dbGroupStore.getOrFetchDBGroupByName(+ `${projectNamePrefix}${projectName}/${databaseGroupNamePrefix}${databaseGroupName}`+ );+ const convertResult = await convertDatabaseGroupExprFromCEL(+ relatedDatabaseGroup.databaseExpr?.expression ?? "");- } else if (props.resourceType === "SCHEMA_GROUP") {- if (state.selectedDatabaseGroupId) {- request = dbGroupStore.getOrFetchSchemaGroupById(- `${state.selectedDatabaseGroupId}/schemaGroups/${resourceId}`+ if (convertResult.environmentId) {+ const environment = environmentStore.getEnvironmentByName(+ convertResult.environmentId);+ state.environmentId = environment?.uid;}}+});- if (!request) {- return [];- }+const validateResourceId = useDebounceFn(+ async (resourceId: ResourceId): Promise<ValidatedMessage[]> => {+ if (!resourceId) {+ return [];+ }- try {- const data = await request;- if (data) {- return [- {- type: "error",- message: t("resource-id.validation.duplicated", {- resource: t(`resource.${resourceIdType.value}`),- }),- },- ];+ let request = undefined;+ if (props.resourceType === "DATABASE_GROUP") {+ request = dbGroupStore.getOrFetchDBGroupByName(+ `${props.project.name}/databaseGroups/${resourceId}`+ );+ } else if (props.resourceType === "SCHEMA_GROUP") {+ if (state.selectedDatabaseGroupId) {+ request = dbGroupStore.getOrFetchSchemaGroupByName(+ `${state.selectedDatabaseGroupId}/schemaGroups/${resourceId}`+ );+ }}- } catch (error) {- if (getErrorCode(error) !== Status.NOT_FOUND) {- throw error;++ if (!request) {+ return [];}- }- return [];-};+ try {+ const data = await request;+ if (data) {+ return [+ {+ type: "error",+ message: t("resource-id.validation.duplicated", {+ resource: t(`resource.${resourceIdType.value}`),+ }),+ },+ ];+ }+ } catch (error) {+ if (getErrorCode(error) !== Status.NOT_FOUND) {+ throw error;+ }+ }++ return [];+ },+ 500+);defineExpose({getFormState: () => {diff --git a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vueindex e7f674d334..05501dc217 100644--- a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue+++ b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue@@ -58,9 +58,9 @@</div><div v-show="state.showUnmatchedDatabaseList"><div- v-for="database in matchedDatabaseList"+ v-for="database in unmatchedDatabaseList":key="database.name"- class="w-full flex flex-row justify-between items-center"+ class="w-full flex flex-row justify-between items-center px-2 py-1 gap-x-2"><span>{{ database.databaseName }}</span><div class="flex flex-row justify-end items-center">@@ -75,12 +75,19 @@</template><script lang="ts" setup>-import { computed, ref, watch, reactive } from "vue";+import { ref, watch, reactive, computed } from "vue";import { ConditionGroupExpr } from "@/plugins/cel";-import { useDatabaseV1Store } from "@/store";+import { useDatabaseV1Store, useEnvironmentV1Store } from "@/store";import { ComposedDatabase, ComposedProject } from "@/types";-import { sortDatabaseV1List } from "@/utils";import { InstanceV1EngineIcon } from "../v2";+import {+ DatabaseGroup,+ DatabaseGroupView,+} from "@/types/proto/v1/project_service";+import { projectServiceClient } from "@/grpcweb";+import { stringifyDatabaseGroupExpr } from "@/utils/databaseGroup/cel";+import { Expr } from "@/types/proto/google/type/expr";+import { useDebounceFn } from "@vueuse/core";interface LocalState {showMatchedDatabaseList: boolean;@@ -91,28 +98,82 @@ const props = defineProps<{project: ComposedProject;environmentId: string;expr: ConditionGroupExpr;+ databaseGroup?: DatabaseGroup;}>();+const environmentStore = useEnvironmentV1Store();+const databaseStore = useDatabaseV1Store();const state = reactive<LocalState>({showMatchedDatabaseList: false,showUnmatchedDatabaseList: false,});const matchedDatabaseList = ref<ComposedDatabase[]>([]);const unmatchedDatabaseList = ref<ComposedDatabase[]>([]);-const databaseList = computed(() => {- const list = useDatabaseV1Store().databaseListByProject(props.project.name);- return sortDatabaseV1List(list);-});-watch(- () => [databaseList.value, props.expr],- async () => {- // TODO: fetch matched and unmatched database list with expr.- matchedDatabaseList.value = databaseList.value;- unmatchedDatabaseList.value = [];- },- {- immediate: true,+const isCreating = computed(() => props.databaseGroup === undefined);++const updateMatchingState = useDebounceFn(async () => {+ const matchedDatabaseNameList: string[] = [];+ const unmatchedDatabaseNameList: string[] = [];++ if (isCreating.value) {+ const environment = environmentStore.getEnvironmentByUID(+ props.environmentId+ );+ const celString = stringifyDatabaseGroupExpr({+ environmentId: environment.name,+ conditionGroupExpr: props.expr,+ });+ const validateOnlyResourceId = "creating-database-group";+ const result = await projectServiceClient.createDatabaseGroup({+ parent: props.project.name,+ databaseGroup: {+ name: `${props.project.name}/databaseGroups/${validateOnlyResourceId}`,+ databasePlaceholder: validateOnlyResourceId,+ databaseExpr: Expr.fromJSON({+ expression: celString,+ }),+ },+ databaseGroupId: validateOnlyResourceId,+ validateOnly: true,+ });+ matchedDatabaseNameList.push(+ ...result.matchedDatabases.map((item) => item.name)+ );+ unmatchedDatabaseNameList.push(+ ...result.unmatchedDatabases.map((item) => item.name)+ );+ } else {+ const result = await projectServiceClient.getDatabaseGroup({+ name: props.databaseGroup!.name,+ view: DatabaseGroupView.DATABASE_GROUP_VIEW_FULL,+ });+ matchedDatabaseNameList.push(+ ...result.matchedDatabases.map((item) => item.name)+ );+ unmatchedDatabaseNameList.push(+ ...result.unmatchedDatabases.map((item) => item.name)+ );}-);++ matchedDatabaseList.value = [];+ unmatchedDatabaseList.value = [];+ for (const name of matchedDatabaseNameList) {+ const database = await databaseStore.getOrFetchDatabaseByName(name);+ if (database) {+ matchedDatabaseList.value.push(database);+ }+ }+ for (const name of unmatchedDatabaseNameList) {+ const database = await databaseStore.getOrFetchDatabaseByName(name);+ if (database) {+ unmatchedDatabaseList.value.push(database);+ }+ }+}, 500);++watch(() => props, updateMatchingState, {+ immediate: true,+ deep: true,+});</script>diff --git a/frontend/src/components/DatabaseGroup/MatchedTableView.vue b/frontend/src/components/DatabaseGroup/MatchedTableView.vueindex 410debc5a5..fb5e46afd4 100644--- a/frontend/src/components/DatabaseGroup/MatchedTableView.vue+++ b/frontend/src/components/DatabaseGroup/MatchedTableView.vue@@ -17,16 +17,13 @@</div><div v-show="state.showMatchedTableList" class="w-full"><div- v-for="database in matchedTableList"- :key="database.name"+ v-for="table in matchedTableList"+ :key="table.database"class="w-full flex flex-row justify-between items-center px-2 py-1 gap-x-2">- <span>{{ database.databaseName }}</span>+ <span>{{ table.table }}</span><div class="flex flex-row justify-end items-center">- <InstanceV1EngineIcon :instance="database.instanceEntity" />- <span class="ml-1 text-sm text-gray-400">{{- database.instanceEntity.title- }}</span>+ <DatabaseView :database-name="table.database" /></div></div></div>@@ -52,16 +49,13 @@</div><div v-show="state.showUnmatchedTableList"><div- v-for="database in matchedTableList"- :key="database.name"- class="w-full flex flex-row justify-between items-center"+ v-for="table in unmatchedTableList"+ :key="table.database"+ class="w-full flex flex-row justify-between items-center px-2 py-1 gap-x-2">- <span>{{ database.databaseName }}</span>+ <span>{{ table.table }}</span><div class="flex flex-row justify-end items-center">- <InstanceV1EngineIcon :instance="database.instanceEntity" />- <span class="ml-1 text-sm text-gray-400">{{- database.instanceEntity.title- }}</span>+ <DatabaseView :database-name="table.database" /></div></div></div>@@ -70,11 +64,18 @@<script lang="ts" setup>import { computed, ref, watch, reactive } from "vue";-import { ConditionGroupExpr } from "@/plugins/cel";-import { useDatabaseV1Store } from "@/store";-import { ComposedDatabase, ComposedProject } from "@/types";-import { sortDatabaseV1List } from "@/utils";-import { InstanceV1EngineIcon } from "../v2";+import { ConditionGroupExpr, convertToCELString } from "@/plugins/cel";+import { ComposedProject } from "@/types";+import { DatabaseView } from "../v2";+import {+ SchemaGroup,+ SchemaGroupView,+ SchemaGroup_Table,+} from "@/types/proto/v1/project_service";+import { projectServiceClient } from "@/grpcweb";+import { Expr } from "@/types/proto/google/type/expr";+import { useDebounceFn } from "@vueuse/core";+import { schemaGroupNamePrefix } from "@/store/modules/v1/common";interface LocalState {showMatchedTableList: boolean;@@ -83,30 +84,55 @@ interface LocalState {const props = defineProps<{project: ComposedProject;- environmentId: string;+ databaseGroupName: string;expr: ConditionGroupExpr;+ schemaGroup?: SchemaGroup;}>();const state = reactive<LocalState>({showMatchedTableList: false,showUnmatchedTableList: false,});-const matchedTableList = ref<ComposedDatabase[]>([]);-const unmatchedTableList = ref<ComposedDatabase[]>([]);-const databaseList = computed(() => {- const list = useDatabaseV1Store().databaseListByProject(props.project.name);- return sortDatabaseV1List(list);-});+const matchedTableList = ref<SchemaGroup_Table[]>([]);+const unmatchedTableList = ref<SchemaGroup_Table[]>([]);++const isCreating = computed(() => props.schemaGroup === undefined);-watch(- () => [databaseList.value, props.expr],- async () => {- // TODO: fetch matched and unmatched table list with expr.- matchedTableList.value = databaseList.value;- unmatchedTableList.value = [];- },- {- immediate: true,+const updateMatchingState = useDebounceFn(async () => {+ const tempMatchedTableList: SchemaGroup_Table[] = [];+ const tempUnmatchedTableList: SchemaGroup_Table[] = [];++ if (isCreating.value) {+ const celString = convertToCELString(props.expr);+ const validateOnlyResourceId = "creating-schema-group";+ const result = await projectServiceClient.createSchemaGroup({+ parent: props.databaseGroupName,+ schemaGroup: {+ name: `${props.databaseGroupName}/${schemaGroupNamePrefix}/${validateOnlyResourceId}`,+ tablePlaceholder: validateOnlyResourceId,+ tableExpr: Expr.fromJSON({+ expression: celString,+ }),+ },+ schemaGroupId: validateOnlyResourceId,+ validateOnly: true,+ });+ tempMatchedTableList.push(...result.matchedTables);+ tempUnmatchedTableList.push(...result.unmatchedTables);+ } else {+ const result = await projectServiceClient.getSchemaGroup({+ name: props.schemaGroup!.name,+ view: SchemaGroupView.SCHEMA_GROUP_VIEW_FULL,+ });+ tempMatchedTableList.push(...result.matchedTables);+ tempUnmatchedTableList.push(...result.unmatchedTables);}-);+ matchedTableList.value = tempMatchedTableList;+ unmatchedTableList.value = tempUnmatchedTableList;+}, 500);++watch(() => props, updateMatchingState, {+ immediate: true,+ deep: true,+});</script>diff --git a/frontend/src/components/v2/Form/ResourceIdInput.vue b/frontend/src/components/v2/Form/ResourceIdInput.vueindex 2c73a3ca68..40a3ec8093 100644--- a/frontend/src/components/v2/Form/ResourceIdInput.vue+++ b/frontend/src/components/v2/Form/ResourceIdInput.vue@@ -110,7 +110,7 @@ const handleResourceIdChange = async (newValue: string) => {}// custom validation for resource id. (e.g. check if the resource id is already used)- if (props.validate) {+ if (state.validatedMessages.length === 0 && props.validate) {const messages = await props.validate(state.resourceId);state.validatedMessages.push(...messages);}diff --git a/frontend/src/components/v2/Model/DatabaseView.vue b/frontend/src/components/v2/Model/DatabaseView.vuenew file mode 100644index 0000000000..7348161953--- /dev/null+++ b/frontend/src/components/v2/Model/DatabaseView.vue@@ -0,0 +1,37 @@+<template>+ <div+ v-if="database && instance"+ class="flex flex-row justify-start items-center"+ >+ <InstanceV1EngineIcon :instance="instance" />+ <span class="text-sm ml-0.5 text-gray-500">{{+ database.databaseName+ }}</span>+ </div>+</template>++<script lang="ts" setup>+import { useDatabaseV1Store, useInstanceV1Store } from "@/store";+import { ComposedDatabase } from "@/types";+import { onMounted, ref } from "vue";+import { InstanceV1EngineIcon } from "./Instance";+import { Instance } from "@/types/proto/v1/instance_service";++const props = defineProps<{+ databaseName: string;+}>();++const databaseStore = useDatabaseV1Store();+const instanceStore = useInstanceV1Store();+const database = ref<ComposedDatabase>();+const instance = ref<Instance>();++onMounted(async () => {+ database.value = await databaseStore.getOrFetchDatabaseByName(+ props.databaseName+ );+ instance.value = await instanceStore.getOrFetchInstanceByName(+ database.value.instance+ );+});+</script>diff --git a/frontend/src/components/v2/Model/index.ts b/frontend/src/components/v2/Model/index.tsindex 55fb802fe8..bbd58984bf 100644--- a/frontend/src/components/v2/Model/index.ts+++ b/frontend/src/components/v2/Model/index.ts@@ -8,6 +8,7 @@ import ProductionEnvironmentV1Icon from "./ProductionEnvironmentV1Icon.vue";import ProjectName from "./ProjectName.vue";import ProjectV1Name from "./ProjectV1Name.vue";import ProjectV1Table from "./ProjectV1Table.vue";+import DatabaseView from "./DatabaseView.vue";export * from "./Instance";export {@@ -21,4 +22,5 @@ export {ProjectName,ProjectV1Name,ProjectV1Table,+ DatabaseView,};diff --git a/frontend/src/store/modules/dbGroup.ts b/frontend/src/store/modules/dbGroup.tsindex 3e3c86be3e..1dce188e3f 100644--- a/frontend/src/store/modules/dbGroup.ts+++ b/frontend/src/store/modules/dbGroup.ts@@ -5,25 +5,25 @@ import { projectServiceClient } from "@/grpcweb";import { DatabaseGroup, SchemaGroup } from "@/types/proto/v1/project_service";export const useDBGroupStore = defineStore("db-group", () => {- const dbGroupMapById = ref<Map<string, DatabaseGroup>>(new Map());- const schemaGroupMapById = ref<Map<string, SchemaGroup>>(new Map());+ const dbGroupMapByName = ref<Map<string, DatabaseGroup>>(new Map());+ const schemaGroupMapByName = ref<Map<string, SchemaGroup>>(new Map());const cachedProjectNameSet = ref<Set<string>>(new Set());- const getOrFetchDBGroupById = async (dbGroupId: string) => {- const cached = dbGroupMapById.value.get(dbGroupId);+ const getOrFetchDBGroupByName = async (name: string) => {+ const cached = dbGroupMapByName.value.get(name);if (cached) return cached;const databaseGroup = await projectServiceClient.getDatabaseGroup({- name: dbGroupId,+ name: name,});- dbGroupMapById.value.set(dbGroupId, databaseGroup);+ dbGroupMapByName.value.set(name, databaseGroup);return databaseGroup;};const getOrFetchDBGroupListByProjectName = async (projectName: string) => {const hasCache = cachedProjectNameSet.value.has(projectName);if (hasCache) {- return Array.from(dbGroupMapById.value.values()).filter((dbGroup) =>+ return Array.from(dbGroupMapByName.value.values()).filter((dbGroup) =>dbGroup.name.startsWith(projectName));}@@ -32,20 +32,20 @@ export const useDBGroupStore = defineStore("db-group", () => {parent: projectName,});for (const dbGroup of databaseGroups) {- dbGroupMapById.value.set(dbGroup.name, dbGroup);+ dbGroupMapByName.value.set(dbGroup.name, dbGroup);}cachedProjectNameSet.value.add(projectName);return databaseGroups;};const getDBGroupListByProjectName = (projectName: string) => {- return Array.from(dbGroupMapById.value.values()).filter((dbGroup) =>+ return Array.from(dbGroupMapByName.value.values()).filter((dbGroup) =>dbGroup.name.startsWith(projectName));};const getDBGroupByName = (name: string) => {- return dbGroupMapById.value.get(name);+ return dbGroupMapByName.value.get(name);};const createDatabaseGroup = async (@@ -54,18 +54,18 @@ export const useDBGroupStore = defineStore("db-group", () => {DatabaseGroup,"name" | "databasePlaceholder" | "databaseExpr">,- databaseGroupId: string+ name: string) => {// Note: use resource id as placeholder right now.- databaseGroup.databasePlaceholder = databaseGroupId;+ databaseGroup.databasePlaceholder = name;const createdDatabaseGroup = await projectServiceClient.createDatabaseGroup({parent: projectName,databaseGroup,- databaseGroupId,+ databaseGroupId: name,});- dbGroupMapById.value.set(createdDatabaseGroup.name, createdDatabaseGroup);+ dbGroupMapByName.value.set(createdDatabaseGroup.name, createdDatabaseGroup);return createdDatabaseGroup;};@@ -75,7 +75,7 @@ export const useDBGroupStore = defineStore("db-group", () => {"name" | "databasePlaceholder" | "databaseExpr">) => {- const rawDatabaseGroup = dbGroupMapById.value.get(databaseGroup.name);+ const rawDatabaseGroup = dbGroupMapByName.value.get(databaseGroup.name);if (!rawDatabaseGroup) {throw new Error("Database group not found");}@@ -89,7 +89,7 @@ export const useDBGroupStore = defineStore("db-group", () => {updateMask,});- dbGroupMapById.value.set(updatedDatabaseGroup.name, updatedDatabaseGroup);+ dbGroupMapByName.value.set(updatedDatabaseGroup.name, updatedDatabaseGroup);return updatedDatabaseGroup;};@@ -97,17 +97,17 @@ export const useDBGroupStore = defineStore("db-group", () => {await projectServiceClient.deleteDatabaseGroup({name: name,});- dbGroupMapById.value.delete(name);+ dbGroupMapByName.value.delete(name);};- const getOrFetchSchemaGroupById = async (schemaGroupId: string) => {- const cached = schemaGroupMapById.value.get(schemaGroupId);+ const getOrFetchSchemaGroupByName = async (name: string) => {+ const cached = schemaGroupMapByName.value.get(name);if (cached) return cached;const schemaGroup = await projectServiceClient.getSchemaGroup({- name: schemaGroupId,+ name: name,});- schemaGroupMapById.value.set(schemaGroupId, schemaGroup);+ schemaGroupMapByName.value.set(name, schemaGroup);return schemaGroup;};@@ -118,41 +118,41 @@ export const useDBGroupStore = defineStore("db-group", () => {parent: dbGroupName,});for (const schemaGroup of schemaGroups) {- schemaGroupMapById.value.set(schemaGroup.name, schemaGroup);+ schemaGroupMapByName.value.set(schemaGroup.name, schemaGroup);}return schemaGroups;};const getSchemaGroupListByDBGroupName = (dbGroupName: string) => {- return Array.from(schemaGroupMapById.value.values()).filter((schemaGroup) =>- schemaGroup.name.startsWith(dbGroupName)+ return Array.from(schemaGroupMapByName.value.values()).filter(+ (schemaGroup) => schemaGroup.name.startsWith(dbGroupName));};const getSchemaGroupByName = (name: string) => {- return schemaGroupMapById.value.get(name);+ return schemaGroupMapByName.value.get(name);};const createSchemaGroup = async (dbGroupName: string,schemaGroup: Pick<SchemaGroup, "name" | "tablePlaceholder" | "tableExpr">,- schemaGroupId: string+ name: string) => {// Note: use resource id as placeholder right now.- schemaGroup.tablePlaceholder = schemaGroupId;+ schemaGroup.tablePlaceholder = name;const createdSchemaGroup = await projectServiceClient.createSchemaGroup({parent: dbGroupName,schemaGroup,- schemaGroupId,+ schemaGroupId: name,});- schemaGroupMapById.value.set(createdSchemaGroup.name, createdSchemaGroup);+ schemaGroupMapByName.value.set(createdSchemaGroup.name, createdSchemaGroup);return createdSchemaGroup;};const updateSchemaGroup = async (schemaGroup: Pick<SchemaGroup, "name" | "tablePlaceholder" | "tableExpr">) => {- const rawSchemaGroup = schemaGroupMapById.value.get(schemaGroup.name);+ const rawSchemaGroup = schemaGroupMapByName.value.get(schemaGroup.name);if (!rawSchemaGroup) {throw new Error("Schema group not found");}@@ -164,7 +164,7 @@ export const useDBGroupStore = defineStore("db-group", () => {schemaGroup,updateMask,});- schemaGroupMapById.value.set(updatedSchemaGroup.name, updatedSchemaGroup);+ schemaGroupMapByName.value.set(updatedSchemaGroup.name, updatedSchemaGroup);return updatedSchemaGroup;};@@ -172,18 +172,18 @@ export const useDBGroupStore = defineStore("db-group", () => {await projectServiceClient.deleteSchemaGroup({name: name,});- schemaGroupMapById.value.delete(name);+ schemaGroupMapByName.value.delete(name);};return {- getOrFetchDBGroupById,+ getOrFetchDBGroupByName,getOrFetchDBGroupListByProjectName,getDBGroupListByProjectName,getDBGroupByName,createDatabaseGroup,updateDatabaseGroup,deleteDatabaseGroup,- getOrFetchSchemaGroupById,+ getOrFetchSchemaGroupByName,getOrFetchSchemaGroupListByDBGroupName,getSchemaGroupListByDBGroupName,getSchemaGroupByName,diff --git a/frontend/src/views/DatabaseGroupDetail.vue b/frontend/src/views/DatabaseGroupDetail.vueindex 49160176bb..e22d64847c 100644--- a/frontend/src/views/DatabaseGroupDetail.vue+++ b/frontend/src/views/DatabaseGroupDetail.vue@@ -76,6 +76,7 @@:project="project":environment-id="state.environment?.name || ''":expr="state.expr!"+ :database-group="databaseGroup"/></div></div>@@ -183,7 +184,7 @@ const project = computed(() => {});onMounted(async () => {- await dbGroupStore.getOrFetchDBGroupById(databaseGroupResourceName.value);+ await dbGroupStore.getOrFetchDBGroupByName(databaseGroupResourceName.value);});const handleEditDatabaseGroup = () => {diff --git a/frontend/src/views/SchemaGroupDetail.vue b/frontend/src/views/SchemaGroupDetail.vueindex e2c3d688af..da36feb4f1 100644--- a/frontend/src/views/SchemaGroupDetail.vue+++ b/frontend/src/views/SchemaGroupDetail.vue@@ -62,9 +62,10 @@</div><div class="col-span-2"><p class="text-lg mb-2">Databases</p>- <MatchedDatabaseView+ <MatchedTableView:project="project"- :environment-id="''"+ :database-group-name="databaseGroupName"+ :schema-group="schemaGroup":expr="state.expr!"/></div>@@ -93,7 +94,7 @@ import { convertCELStringToExpr } from "@/utils/databaseGroup/cel";import { ConditionGroupExpr } from "@/plugins/cel";import DatabaseGroupPanel from "@/components/DatabaseGroup/DatabaseGroupPanel.vue";import ExprEditor from "@/components/DatabaseGroup/common/ExprEditor";-import MatchedDatabaseView from "@/components/DatabaseGroup/MatchedDatabaseView.vue";+import MatchedTableView from "@/components/DatabaseGroup/MatchedTableView.vue";interface LocalState {isLoaded: boolean;@@ -136,7 +137,7 @@ const schemaGroup = computed(() => {watch(() => [props, schemaGroup.value],async () => {- const schemaGroup = await dbGroupStore.getOrFetchSchemaGroupById(+ const schemaGroup = await dbGroupStore.getOrFetchSchemaGroupByName(`${projectNamePrefix}${props.projectName}/${databaseGroupNamePrefix}${props.databaseGroupName}/${schemaGroupNamePrefix}${props.schemaGroupName}`);