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: add database groups into dashboard sidebar (#6809)
boojack941d6061ba68
diff --git a/frontend/src/bbkit/BBOutline.vue b/frontend/src/bbkit/BBOutline.vueindex 9e12c3136e..481b2149e3 100644--- a/frontend/src/bbkit/BBOutline.vue+++ b/frontend/src/bbkit/BBOutline.vue@@ -46,7 +46,10 @@class="outline-item group flex justify-between pr-1 py-1":class="'pl-' + (4 + level * 3)">- <span class="truncate" :title="item.name">{{ item.name }}</span>+ <div class="flex flex-row justify-start items-center truncate">+ <component :is="item.prefix" class="mr-1" />+ <span class="truncate" :title="item.name">{{ item.name }}</span>+ </div><buttonv-if="allowDelete && index == state.hoverIndex"class="focus:outline-none"diff --git a/frontend/src/bbkit/types.ts b/frontend/src/bbkit/types.tsindex 2e13bc2758..64886c28f6 100644--- a/frontend/src/bbkit/types.ts+++ b/frontend/src/bbkit/types.ts@@ -1,5 +1,6 @@import { VueClass } from "@/utils";import { ColumnWidth } from "./BBGrid";+import { VNode } from "vue";export type BBButtonType =| "NORMAL"@@ -80,6 +81,7 @@ export type BBOutlineItem = {childList?: BBOutlineItem[];// Only applicable if childList is specified.childCollapse?: boolean;+ prefix?: VNode;};export type BBNotificationStyle = "INFO" | "SUCCESS" | "WARN" | "CRITICAL";diff --git a/frontend/src/components/DatabaseGroupIcon.vue b/frontend/src/components/DatabaseGroupIcon.vueindex 98b15a1b79..3861ce4573 100644--- a/frontend/src/components/DatabaseGroupIcon.vue+++ b/frontend/src/components/DatabaseGroupIcon.vue@@ -56,6 +56,6 @@import { defineComponent } from "vue";export default defineComponent({- name: "TenantIcon",+ name: "DatabaseGroupIcon",});</script>diff --git a/frontend/src/components/DatabaseListSidePanel.vue b/frontend/src/components/DatabaseListSidePanel.vueindex b060e13a87..43a93c8f0c 100644--- a/frontend/src/components/DatabaseListSidePanel.vue+++ b/frontend/src/components/DatabaseListSidePanel.vue@@ -8,7 +8,7 @@</template><script lang="ts" setup>-import { computed, ref, watchEffect } from "vue";+import { computed, h, ref, watchEffect } from "vue";import { cloneDeep, uniqBy } from "lodash-es";import { useRouter } from "vue-router";import { useI18n } from "vue-i18n";@@ -20,12 +20,14 @@ import {environmentV1Name,projectV1Slug,isDatabaseV1Accessible,+ extractProjectResourceName,} from "@/utils";import {useEnvironmentV1List,useDatabaseV1Store,useCurrentUserV1,usePolicyV1Store,+ useDBGroupStore,} from "@/store";import { State } from "@/types/proto/v1/common";import { TenantMode } from "@/types/proto/v1/project_service";@@ -34,9 +36,11 @@ import {PolicyResourceType,PolicyType,} from "@/types/proto/v1/org_policy_service";+import DatabaseGroupIcon from "./DatabaseGroupIcon.vue";const { t } = useI18n();const databaseV1Store = useDatabaseV1Store();+const dbGroupStore = useDBGroupStore();const router = useRouter();const currentUserV1 = useCurrentUserV1();const rawEnvironmentList = useEnvironmentV1List();@@ -65,6 +69,7 @@ const prepareList = () => {databaseV1Store.searchDatabaseList({parent: "instances/-",});+ dbGroupStore.fetchAllDatabaseGroupList();}};@@ -121,41 +126,72 @@ const databaseListByEnvironment = computed(() => {});const tenantDatabaseListByProject = computed((): BBOutlineItem[] => {- const list = databaseList.value.filter(+ const dbList = databaseList.value.filter((db) => db.projectEntity.tenantMode === TenantMode.TENANT_MODE_ENABLED);// In case that each `db.project` is not reference equal// we run a uniq() on the list by project.idconst projectList = uniqBy(- list.map((db) => db.projectEntity),+ [+ ...dbList.map((db) => db.projectEntity),+ ...dbGroupStore+ .getAllDatabaseGroupList()+ .map((dbGroup) => dbGroup.project),+ ],(project) => project.name);// Sort the list as what <ProjectListSidePanel /> doesprojectList.sort((a, b) => a.name.localeCompare(b.name));// Then group databaseList by projectconst databaseListGroupByProject = projectList.map((project) => {- const databaseList = list.filter((db) => db.project === project.name);+ const databaseList = dbList.filter((db) => db.project === project.name);return {project,databaseList,};});- // Map groups to `BBOutlineItem[]`- const itemList = databaseListGroupByProject.map(- ({ project, databaseList }) => {- return {- id: `bb.project.${project.uid}.databases`,- name: project.title,- childList: databaseList.map<BBOutlineItem>((db) => ({+ const databaseGroupListByProject = projectList.map((project) => {+ const databaseGroupList = dbGroupStore.getDBGroupListByProjectName(+ project.name+ );+ return {+ project,+ databaseGroupList,+ };+ });++ const outlineItemList: BBOutlineItem[] = projectList.map((project) => {+ const databaseList =+ databaseListGroupByProject.find((item) => item.project === project)+ ?.databaseList || [];+ const databaseGroupList =+ databaseGroupListByProject.find((item) => item.project === project)+ ?.databaseGroupList || [];+ return {+ id: `bb.project.${project.uid}`,+ name: project.title,+ childList: [+ ...databaseList.map<BBOutlineItem>((db) => ({id: `bb.project.${project.uid}.database.${db.databaseName}`,name: `${db.databaseName} (${db.instanceEntity.title})`,link: `/project/${projectV1Slug(project)}#databases`,})),- childCollapse: true,- } as BBOutlineItem;- }- );- return itemList;+ ...databaseGroupList.map<BBOutlineItem>((dbGroup) => ({+ id: `bb.project.${project.uid}.databaseGroup.${dbGroup.name}`,+ name: dbGroup.databaseGroupName,+ link: `/projects/${extractProjectResourceName(+ project.name+ )}/database-groups/${dbGroup.databaseGroupName}`,+ prefix: h(DatabaseGroupIcon, {+ class: "w-4 h-auto",+ }),+ })),+ ],+ childCollapse: true,+ } as BBOutlineItem;+ });++ return outlineItemList;});const mixedDatabaseList = computed(() => {diff --git a/frontend/src/types/dbGroup.ts b/frontend/src/types/dbGroup.tsindex f3083b40ac..f2ef8955fd 100644--- a/frontend/src/types/dbGroup.ts+++ b/frontend/src/types/dbGroup.ts@@ -1,15 +1,12 @@import { ConditionGroupExpr } from "@/plugins/cel";import { Environment } from "./proto/v1/environment_service";-import {- DatabaseGroup,- Project,- SchemaGroup,-} from "./proto/v1/project_service";+import { DatabaseGroup, SchemaGroup } from "./proto/v1/project_service";+import { ComposedProject } from "./v1";export interface ComposedDatabaseGroup extends DatabaseGroup {databaseGroupName: string;projectName: string;- project: Project;+ project: ComposedProject;environmentName: string;environment: Environment;simpleExpr: ConditionGroupExpr;