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: delete group (#18244)
ecmadao87f69fdab3f9
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vueindex d6e8114b9d..25813a2833 100644--- a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue@@ -1,6 +1,6 @@<template>- <div class="flex flex-col">- <div class="flex-1">+ <div class="flex-1 flex flex-col">+ <div class="flex-1 mb-6"><div class="w-full"><p class="font-medium text-main mb-2">{{ $t("common.name") }}</p><NInput@@ -46,22 +46,27 @@</div></div>- <div v-if="!readonly" class="sticky bottom-0 z-10 mt-4">+ <div v-if="!isCreating" class="py-6 border-t">+ <BBButtonConfirm+ :type="'DELETE'"+ :button-text="$t('database-group.delete-group')"+ :ok-text="$t('common.delete')"+ :confirm-title="+ $t('database-group.delete-group', { name: databaseGroup?.title })+ "+ :require-confirm="true"+ @confirm="doDelete"+ />+ </div>++ <div v-if="!readonly" class="sticky bottom-0 z-10"><div- class="flex justify-between w-full pt-4 border-t border-block-border bg-white"+ class="flex justify-end w-full py-4 border-t border-block-border bg-white gap-x-3">- <NButton v-if="!isCreating" type="error" text @click="doDelete">- <template #icon>- <Trash2Icon class="w-4 h-auto" />- </template>- {{ $t("common.delete") }}+ <NButton @click="$emit('dismiss')">{{ $t("common.cancel") }}</NButton>+ <NButton type="primary" :disabled="!allowConfirm" @click="doConfirm">+ {{ isCreating ? $t("common.save") : $t("common.confirm") }}</NButton>- <div class="flex-1 flex flex-row justify-end items-center gap-x-3">- <NButton @click="$emit('dismiss')">{{ $t("common.cancel") }}</NButton>- <NButton type="primary" :disabled="!allowConfirm" @click="doConfirm">- {{ isCreating ? $t("common.save") : $t("common.confirm") }}- </NButton>- </div></div></div></div>@@ -70,11 +75,11 @@<script lang="ts" setup>import { create } from "@bufbuild/protobuf";import { cloneDeep, head, isEqual } from "lodash-es";-import { Trash2Icon } from "lucide-vue-next";-import { NButton, NDivider, NInput, useDialog } from "naive-ui";+import { NButton, NDivider, NInput } from "naive-ui";import { computed, onMounted, reactive, ref } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";+import { BBButtonConfirm } from "@/bbkit";import ExprEditor from "@/components/ExprEditor";import type { ConditionGroupExpr } from "@/plugins/cel";import {@@ -136,7 +141,6 @@ const state = reactive<LocalState>({});const resourceIdField = ref<InstanceType<typeof ResourceIdField>>();const router = useRouter();-const dialog = useDialog();const isCreating = computed(() => props.databaseGroup === undefined);@@ -167,25 +171,17 @@ onMounted(async () => {}});-const doDelete = () => {- dialog.error({- title: "Confirm to delete",- positiveText: t("common.confirm"),- negativeText: t("common.cancel"),- onPositiveClick: async () => {- const databaseGroup = props.databaseGroup as DatabaseGroup;- await dbGroupStore.deleteDatabaseGroup(databaseGroup.name);- if (- router.currentRoute.value.name ===- PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL- ) {- router.replace({- name: PROJECT_V1_ROUTE_DATABASE_GROUPS,- });- }- emit("dismiss");- },- });+const doDelete = async () => {+ const databaseGroup = props.databaseGroup as DatabaseGroup;+ await dbGroupStore.deleteDatabaseGroup(databaseGroup.name);+ if (+ router.currentRoute.value.name === PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL+ ) {+ router.replace({+ name: PROJECT_V1_ROUTE_DATABASE_GROUPS,+ });+ }+ emit("dismiss");};const allowConfirm = computed(() => {diff --git a/frontend/src/components/Plan/components/SpecDetailView/AllTargetsDrawer.vue b/frontend/src/components/Plan/components/SpecDetailView/AllTargetsDrawer.vueindex cda13f4343..d6e54f548d 100644--- a/frontend/src/components/Plan/components/SpecDetailView/AllTargetsDrawer.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/AllTargetsDrawer.vue@@ -42,7 +42,7 @@/><DatabaseGroupName:database-group="- dbGroupStore.getDBGroupByName(target) as DatabaseGroup+ dbGroupStore.getDBGroupByName(target)":link="false":plain="true"@@ -85,7 +85,6 @@ import {useDBGroupStore,} from "@/store";import { isValidDatabaseGroupName, isValidDatabaseName } from "@/types";-import type { DatabaseGroup } from "@/types/proto-es/v1/database_group_service_pb";import DatabaseDisplay from "../common/DatabaseDisplay.vue";interface Props {diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vueindex e098581f4d..d9094caf64 100644--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue@@ -41,7 +41,7 @@<DatabaseGroupIcon class="w-4 h-4 text-control-light shrink-0" /><DatabaseGroupName:database-group="- dbGroupStore.getDBGroupByName(target) as DatabaseGroup+ dbGroupStore.getDBGroupByName(target)":link="false":plain="true"@@ -51,6 +51,7 @@{{ $t("plan.targets.type.database-group") }}</NTag><div+ v-if="isValidDatabaseGroupName(dbGroupStore.getDBGroupByName(target).name)"class="flex items-center justify-end cursor-pointer opacity-60 hover:opacity-100"@click="gotoDatabaseGroupDetailPage(target)">@@ -94,6 +95,7 @@<script setup lang="ts">import { create } from "@bufbuild/protobuf";+import { isEqual } from "lodash-es";import { ExternalLinkIcon } from "lucide-vue-next";import { NButton, NTag } from "naive-ui";import { computed, ref, watch } from "vue";@@ -113,10 +115,7 @@ import {useProjectV1Store,} from "@/store";import { isValidDatabaseGroupName, isValidDatabaseName } from "@/types";-import {- type DatabaseGroup,- DatabaseGroupView,-} from "@/types/proto-es/v1/database_group_service_pb";+import { DatabaseGroupView } from "@/types/proto-es/v1/database_group_service_pb";import { UpdatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";import { extractProjectResourceName } from "@/utils";import { usePlanContext } from "../../logic/context";@@ -252,7 +251,11 @@ const gotoDatabaseGroupDetailPage = (dbGroup: string) => {// Watch for target changes and load datawatch(targets,- () => {+ (newTargets, oldTargets) => {+ // Only reload if targets actually changed+ if (isEqual(newTargets, oldTargets)) {+ return;+ }loadTargetData();},{ immediate: true }diff --git a/frontend/src/components/ProjectSettingPanel.vue b/frontend/src/components/ProjectSettingPanel.vueindex 3020808294..986649627f 100644--- a/frontend/src/components/ProjectSettingPanel.vue+++ b/frontend/src/components/ProjectSettingPanel.vue@@ -48,7 +48,7 @@</div></div>- <div class="py-6 lg:flex">+ <div class="py-6"><ProjectArchiveRestoreButton :project="project" /></div>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex db909ecd24..a14de4c794 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2820,7 +2820,8 @@"self": "Condition"},"select": "Select database group",- "no-matched-databases": "No matched databases"+ "no-matched-databases": "No matched databases",+ "delete-group": "Delete the database group {name}"},"export-center": {"self": "Export Center",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 68fb9bb48e..9f37e79171 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2820,7 +2820,8 @@"self": "Condición"},"select": "Seleccionar grupo de bases de datos",- "no-matched-databases": "No hay bases de datos coincidentes"+ "no-matched-databases": "No hay bases de datos coincidentes",+ "delete-group": "Eliminar el grupo de bases de datos {name}"},"export-center": {"self": "centro de exportacion",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex f3d88c4ff7..5971549bd6 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -2820,7 +2820,8 @@"self": "状態"},"select": "データベースグループを選択",- "no-matched-databases": "一致するデータベースはありません"+ "no-matched-databases": "一致するデータベースはありません",+ "delete-group": "データベースグループを削除する"},"export-center": {"self": "エクスポートセンター",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 88f5ec75e4..9bd3cd6571 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -2820,7 +2820,8 @@"self": "Điều kiện"},"select": "Chọn nhóm cơ sở dữ liệu",- "no-matched-databases": "Không có cơ sở dữ liệu phù hợp"+ "no-matched-databases": "Không có cơ sở dữ liệu phù hợp",+ "delete-group": "Xóa nhóm cơ sở dữ liệu {name}"},"export-center": {"self": "Trung tâm xuất",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex e8557f9470..34016ee01d 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2820,7 +2820,8 @@"self": "条件"},"select": "选择数据库分组",- "no-matched-databases": "没有匹配的数据库"+ "no-matched-databases": "没有匹配的数据库",+ "delete-group": "删除数据库组 {name}"},"export-center": {"self": "导出中心",diff --git a/frontend/src/store/modules/dbGroup.ts b/frontend/src/store/modules/dbGroup.tsindex 65fc1f664d..5e57f76966 100644--- a/frontend/src/store/modules/dbGroup.ts+++ b/frontend/src/store/modules/dbGroup.ts@@ -8,6 +8,7 @@ import { databaseGroupServiceClientConnect } from "@/grpcweb";import { silentContextKey } from "@/grpcweb/context-key";import type { ConditionGroupExpr } from "@/plugins/cel";import { buildCELExpr } from "@/plugins/cel";+import { isValidDatabaseGroupName, unknownDatabaseGroup } from "@/types";import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";import type { DatabaseGroup } from "@/types/proto-es/v1/database_group_service_pb";import {@@ -71,23 +72,22 @@ export const useDBGroupStore = defineStore("db-group", () => {const getOrFetchDBGroupByName = async (name: string,- options?: Partial<{- skipCache: boolean;- silent: boolean;- view: DatabaseGroupView;- }>+ options?: {+ skipCache?: boolean;+ silent?: boolean;+ view?: DatabaseGroupView;+ }) => {- const { skipCache, silent, view } = {- ...{- skipCache: false,- silent: false,- view: DatabaseGroupView.BASIC,- },- ...options,- };+ const {+ skipCache = false,+ silent = false,+ view = DatabaseGroupView.BASIC,+ } = options ?? {};if (!skipCache) {- const cached = cacheByName.getEntity([name, view]);- if (cached) return cached;+ const cached = getDBGroupByName(name, view);+ if (isValidDatabaseGroupName(cached.name)) {+ return cached;+ }}const request = create(GetDatabaseGroupRequestSchema, {@@ -121,8 +121,8 @@ export const useDBGroupStore = defineStore("db-group", () => {const getDBGroupByName = (name: string,view?: DatabaseGroupView- ): DatabaseGroup | undefined => {- return getCacheWithFallback(name, view);+ ): DatabaseGroup => {+ return getCacheWithFallback(name, view) ?? unknownDatabaseGroup();};const createDatabaseGroup = async ({diff --git a/frontend/src/types/dbGroup.ts b/frontend/src/types/dbGroup.tsindex 3648a77505..b041c179da 100644--- a/frontend/src/types/dbGroup.ts+++ b/frontend/src/types/dbGroup.ts@@ -1,8 +1,22 @@+import { create } from "@bufbuild/protobuf";import { UNKNOWN_ID } from "@/types";+import {+ type DatabaseGroup,+ DatabaseGroupSchema,+} from "@/types/proto-es/v1/database_group_service_pb";import { extractDatabaseGroupName } from "@/utils";+import { unknownProject } from "./v1/project";export const isValidDatabaseGroupName = (name: string): boolean => {if (typeof name !== "string") return false;const dbGroupName = extractDatabaseGroupName(name);return Boolean(dbGroupName) && dbGroupName !== String(UNKNOWN_ID);};++export const unknownDatabaseGroup = (): DatabaseGroup => {+ const projectEntity = unknownProject();+ return create(DatabaseGroupSchema, {+ name: `${projectEntity.name}/databaseGroups/${UNKNOWN_ID}`,+ title: "<<Unknown database group>>",+ });+};diff --git a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue b/frontend/src/views/project/ProjectDatabaseGroupDetail.vueindex b974e8e71e..b07b534c5b 100644--- a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue+++ b/frontend/src/views/project/ProjectDatabaseGroupDetail.vue@@ -2,7 +2,7 @@<divv-if="databaseGroup"v-bind="$attrs"- class="h-full flex-1 relative flex flex-col gap-y-4"+ class="min-h-full flex-1 relative flex flex-col gap-y-4 pt-4"><FeatureAttention:feature="PlanFeature.FEATURE_DATABASE_GROUPS"@@ -60,6 +60,7 @@ import { computed, reactive, watchEffect } from "vue";import DatabaseGroupForm from "@/components/DatabaseGroup/DatabaseGroupForm.vue";import FeatureAttention from "@/components/FeatureGuard/FeatureAttention.vue";import { AddSpecDrawer } from "@/components/Plan";+import { useBodyLayoutContext } from "@/layouts/common";import { featureToRef, useDBGroupStore, useProjectByName } from "@/store";import {databaseGroupNamePrefix,@@ -115,4 +116,8 @@ watchEffect(async () => {view: DatabaseGroupView.FULL,});});++const { overrideMainContainerClass } = useBodyLayoutContext();++overrideMainContainerClass("py-0!");</script>diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vueindex c2aea512da..0980940dd5 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue@@ -224,6 +224,7 @@ import type {import {DEFAULT_SQL_EDITOR_TAB_MODE,getDataSourceTypeI18n,+ isValidDatabaseGroupName,isValidDatabaseName,isValidProjectName,UNKNOWN_ENVIRONMENT_NAME,@@ -320,7 +321,7 @@ const flattenSelectedDatabasesFromGroup = computed(() => {for (const groupName of tabStore.currentTab?.batchQueryContext?.databaseGroups ?? []) {const group = dbGroupStore.getDBGroupByName(groupName);- if (!group) {+ if (!isValidDatabaseGroupName(group.name)) {continue;}for (const db of group.matchedDatabases) {