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: optimize database group (#15684)
ecmadaoe3ef611cf40e
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupDataTable.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupDataTable.vueindex 4ba82d1d59..faeacd7a75 100644--- a/frontend/src/components/DatabaseGroup/DatabaseGroupDataTable.vue+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupDataTable.vue@@ -18,18 +18,13 @@</template><script lang="tsx" setup>-import type { ComposedDatabaseGroup } from "@/types";-import { hasPermissionToCreateChangeDatabaseIssueInProject } from "@/utils";-import { generateDatabaseGroupIssueRoute } from "@/utils/databaseGroup/issue";-import {- NButton,- NDataTable,- NDropdown,- type DataTableColumn-} from "naive-ui";+import { NButton, NDataTable, NDropdown, type DataTableColumn } from "naive-ui";import { computed, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";+import type { ComposedDatabaseGroup } from "@/types";+import { hasPermissionToCreateChangeDatabaseIssueInProject } from "@/utils";+import { generateDatabaseGroupIssueRoute } from "@/utils/databaseGroup/issue";interface LocalState {selectedDatabaseGroupNameList: Set<string>;@@ -118,10 +113,12 @@ const columnList = computed((): DatabaseGroupDataTableColumn[] => {{label: `${t("database.edit-schema")} (DDL)`,key: "bb.issue.database.schema.update",+ disabled: data.matchedDatabases.length === 0,},{label: `${t("database.change-data")} (DML)`,key: "bb.issue.database.data.update",+ disabled: data.matchedDatabases.length === 0,},]}onSelect={(key) => doDatabaseGroupChangeAction(key, data)}diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vueindex ab2ecd6e22..998340b293 100644--- a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue@@ -1,92 +1,72 @@<template>- <FormLayout :title="title">- <template #body>+ <div>+ <div class="w-full grid grid-cols-3 gap-x-6"><div>- <FeatureAttentionForInstanceLicense- custom-class="mb-4"- type="warning"- feature="bb.feature.database-grouping"- />- <div class="w-full grid grid-cols-3 gap-x-6">- <div>- <p class="font-medium text-main mb-2">{{ $t("common.name") }}</p>- <NInput v-model:value="state.placeholder" />- <div class="mt-2">- <ResourceIdField- ref="resourceIdField"- editing-class="mt-4"- resource-type="database-group"- :readonly="!isCreating"- :value="state.resourceId"- :resource-title="state.placeholder"- :validate="validateResourceId"- />- </div>- </div>- </div>- <NDivider />- <div class="w-full grid grid-cols-5 gap-x-6">- <div class="col-span-3">- <p class="pl-1 font-medium text-main mb-2">- {{ $t("database-group.condition.self") }}- </p>- <ExprEditor- :expr="state.expr"- :allow-admin="true"- :enable-raw-expression="true"- :factor-list="FactorList"- :factor-support-dropdown="factorSupportDropdown"- :option-config-map="getDatabaseGroupOptionConfigMap()"- />- <p- v-if="matchingError"- class="mt-2 text-sm border border-red-600 px-2 py-1 rounded-lg bg-red-50 text-red-600"- >- {{ matchingError }}- </p>- </div>- <div class="col-span-2">- <MatchedDatabaseView- :loading="state.isRequesting"- :matched-database-list="matchedDatabaseList"- :unmatched-database-list="unmatchedDatabaseList"- />- </div>+ <p class="font-medium text-main mb-2">{{ $t("common.name") }}</p>+ <NInput v-model:value="state.placeholder" :disabled="readonly" />+ <div class="mt-2">+ <ResourceIdField+ ref="resourceIdField"+ editing-class="mt-4"+ resource-type="database-group"+ :readonly="!isCreating"+ :value="state.resourceId"+ :resource-title="state.placeholder"+ :validate="validateResourceId"+ /></div></div>- </template>- <template #footer>- <div class="w-full flex justify-between items-center">- <div>- <NButton v-if="!isCreating" text @click="doDelete">- <template #icon>- <Trash2Icon class="w-4 h-auto" />- </template>- {{ $t("common.delete") }}- </NButton>- </div>- <div class="flex flex-row justify-end items-center gap-x-2">+ </div>+ <NDivider />+ <div class="w-full grid grid-cols-5 gap-x-6">+ <div class="col-span-3">+ <p class="pl-1 font-medium text-main mb-2">+ {{ $t("database-group.condition.self") }}+ </p>+ <ExprEditor+ :expr="state.expr"+ :allow-admin="!readonly"+ :enable-raw-expression="true"+ :factor-list="FactorList"+ :factor-support-dropdown="factorSupportDropdown"+ :option-config-map="getDatabaseGroupOptionConfigMap()"+ />+ </div>+ <div class="col-span-2">+ <MatchedDatabaseView :project="project.name" :expr="state.expr" />+ </div>+ </div>++ <div v-if="!readonly" class="sticky bottom-0 z-10 mt-4">+ <div+ class="flex justify-between w-full pt-4 border-t border-block-border bg-white"+ >+ <NButton v-if="!isCreating" text @click="doDelete">+ <template #icon>+ <Trash2Icon class="w-4 h-auto" />+ </template>+ {{ $t("common.delete") }}+ </NButton>+ <div class="flex-1 flex flex-row justify-end items-center gap-x-2"><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>- </template>- </FormLayout>+ </div>+ </div></template><script lang="ts" setup>-import { useDebounceFn } from "@vueuse/core";import { cloneDeep, head, isEqual } from "lodash-es";import { Trash2Icon } from "lucide-vue-next";import { NButton, NDivider, NInput, useDialog } from "naive-ui";-import { ClientError, Status } from "nice-grpc-web";-import { computed, onMounted, reactive, ref, watch } from "vue";+import { Status } from "nice-grpc-web";+import { computed, onMounted, reactive, ref } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import ExprEditor from "@/components/ExprEditor";-import FormLayout from "@/components/v2/Form/FormLayout.vue";import type { ConditionGroupExpr } from "@/plugins/cel";import {buildCELExpr,@@ -109,7 +89,6 @@ import { Expr } from "@/types/proto/google/type/expr";import type { DatabaseGroup } from "@/types/proto/v1/database_group_service";import { batchConvertParsedExprToCELString } from "@/utils";import { getErrorCode } from "@/utils/grpcweb";-import { FeatureAttentionForInstanceLicense } from "../FeatureGuard";import { ResourceIdField } from "../v2";import MatchedDatabaseView from "./MatchedDatabaseView.vue";import {@@ -119,9 +98,9 @@ import {} from "./utils";const props = defineProps<{+ readonly: boolean;project: ComposedProject;databaseGroup?: DatabaseGroup;- title?: string;}>();const emit = defineEmits<{@@ -130,7 +109,6 @@ const emit = defineEmits<{}>();type LocalState = {- isRequesting: boolean;resourceId: string;placeholder: string;selectedDatabaseGroupId?: string;@@ -140,7 +118,6 @@ type LocalState = {const { t } = useI18n();const dbGroupStore = useDBGroupStore();const state = reactive<LocalState>({- isRequesting: false,resourceId: "",placeholder: "",expr: wrapAsGroup(emptySimpleExpr()),@@ -209,44 +186,6 @@ const validateResourceId = async (return [];};-const matchingError = ref<string | undefined>(undefined);-const matchedDatabaseList = ref<string[]>([]);-const unmatchedDatabaseList = ref<string[]>([]);-const updateDatabaseMatchingState = useDebounceFn(async () => {- if (!validateSimpleExpr(state.expr)) {- matchingError.value = undefined;- matchedDatabaseList.value = [];- unmatchedDatabaseList.value = [];- return;- }-- state.isRequesting = true;- try {- const result = await dbGroupStore.fetchDatabaseGroupMatchList({- projectName: props.project.name,- expr: state.expr,- });-- matchingError.value = undefined;- matchedDatabaseList.value = result.matchedDatabaseList;- unmatchedDatabaseList.value = result.unmatchedDatabaseList;- } catch (error) {- matchingError.value = (error as ClientError).details;- matchedDatabaseList.value = [];- unmatchedDatabaseList.value = [];- }- state.isRequesting = false;-}, 500);--watch(- [() => props.project.name, () => state.expr],- updateDatabaseMatchingState,- {- immediate: true,- deep: true,- }-);-const doDelete = () => {dialog.error({title: "Confirm to delete",@@ -364,13 +303,4 @@ const doConfirm = async () => {});emit("dismiss");};--defineExpose({- getFormState: () => {- return {- ...state,- resourceId: resourceIdField.value?.resourceId || "",- };- },-});</script>diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vuedeleted file mode 100644index 42b8b4dae0..0000000000--- a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue+++ /dev/null@@ -1,51 +0,0 @@-<template>- <Drawer- :show="show"- width="auto"- @update:show="(show: boolean) => !show && $emit('close')"- >- <DrawerContent- :title="title"- :closable="true"- class="w-[64rem] max-w-[100vw] relative"- >- <DatabaseGroupForm- :project="project"- :database-group="props.databaseGroup"- @dismiss="() => emit('close')"- @created="- (databaseGroupName: string) => emit('created', databaseGroupName)- "- />- </DrawerContent>- </Drawer>-</template>--<script lang="ts" setup>-import { computed } from "vue";-import { useI18n } from "vue-i18n";-import { Drawer, DrawerContent } from "@/components/v2";-import type { ComposedDatabaseGroup, ComposedProject } from "@/types";-import DatabaseGroupForm from "./DatabaseGroupForm.vue";--const props = defineProps<{- show: boolean;- project: ComposedProject;- databaseGroup?: ComposedDatabaseGroup;-}>();--const emit = defineEmits<{- (event: "close"): void;- (event: "created", databaseGroupName: string): void;-}>();--const { t } = useI18n();--const isCreating = computed(() => props.databaseGroup === undefined);--const title = computed(() => {- return isCreating.value- ? t("database-group.create")- : t("database-group.edit");-});-</script>diff --git a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vueindex a22a6daa4f..a95b420a1b 100644--- a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue+++ b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue@@ -1,15 +1,22 @@<template>- <div v-if="!hideTitle" class="mb-2 flex flex-row items-center">+ <div class="mb-2 flex flex-row items-center"><span class="font-medium text-main mr-2">{{ $t("common.databases") }}</span>- <BBSpin v-if="loading" class="opacity-60" />+ <BBSpin v-if="state.loading" :size="20" class="opacity-60" /></div>+ <p+ v-if="state.matchingError"+ class="my-2 text-sm border border-red-600 px-2 py-1 rounded-lg bg-red-50 text-red-600"+ >+ {{ state.matchingError }}+ </p>+<NCollapseclass="border p-2 rounded-lg"- v-model:expanded-names="collapseExpandedNames"+ v-model:expanded-names="state.collapseExpandedNames"><NCollapseItem- v-for="(item, i) in databaseLists"+ v-for="(item, i) in state.databaseMatchLists":key="item.name":title="item.title":disabled="item.databaseNameList.length === 0"@@ -53,14 +60,19 @@</template><script lang="ts" setup>+import { useDebounceFn } from "@vueuse/core";import { NButton, NEllipsis, NCollapse, NCollapseItem } from "naive-ui";-import { ref, watch } from "vue";+import { ClientError } from "nice-grpc-web";+import { watch, reactive } from "vue";import { useI18n } from "vue-i18n";import { BBSpin } from "@/bbkit";import { DatabaseV1Name, InstanceV1Name } from "@/components/v2";-import { useDatabaseV1Store } from "@/store";+import type { ConditionGroupExpr } from "@/plugins/cel";+import { validateSimpleExpr } from "@/plugins/cel";+import { useDatabaseV1Store, useDBGroupStore } from "@/store";+import { isValidDatabaseName } from "@/types";-interface DatabaseList {+interface DatabaseMatchList {index: number;loading: boolean;databaseNameList: string[];@@ -68,83 +80,119 @@ interface DatabaseList {title: string;}+interface LocalState {+ loading: boolean;+ matchingError?: string;+ databaseMatchLists: DatabaseMatchList[];+ collapseExpandedNames: string[];+}+const props = defineProps<{- matchedDatabaseList: string[];- unmatchedDatabaseList: string[];- loading?: boolean;- hideTitle?: boolean;+ project: string;+ expr: ConditionGroupExpr;}>();const { t } = useI18n();-const getInitialState = (): DatabaseList[] => [+const getInitialState = (): DatabaseMatchList[] => [{index: 0,loading: false,- databaseNameList: props.matchedDatabaseList,+ databaseNameList: [],title: t("database-group.matched-database"),name: "matched",},{index: 0,loading: false,- databaseNameList: props.unmatchedDatabaseList,+ databaseNameList: [],title: t("database-group.unmatched-database"),name: "unmatched",},];-const databaseLists = ref<DatabaseList[]>([]);+const state = reactive<LocalState>({+ loading: false,+ databaseMatchLists: getInitialState(),+ collapseExpandedNames: [],+});-const collapseExpandedNames = ref<string[]>([]);+const dbGroupStore = useDBGroupStore();const databaseStore = useDatabaseV1Store();const getDatabaseList = (i: number) => {- const { databaseNameList, index } = databaseLists.value[i];+ const { databaseNameList, index } = state.databaseMatchLists[i];return databaseNameList.slice(0, index)- .map((databaseName) => databaseStore.getDatabaseByName(databaseName));+ .map((databaseName) => databaseStore.getDatabaseByName(databaseName))+ .filter((database) => isValidDatabaseName(database.name));};const loadMore = async (i: number) => {- databaseLists.value[i].loading = true;+ state.databaseMatchLists[i].loading = true;try {- const previous = databaseLists.value[i].index;+ const previous = state.databaseMatchLists[i].index;const next = previous + 10;await Promise.all(- databaseLists.value[i].databaseNameList+ state.databaseMatchLists[i].databaseNameList.slice(previous, next).map((name) => databaseStore.getOrFetchDatabaseByName(name)));- databaseLists.value[i].index = next;+ state.databaseMatchLists[i].index = next;} finally {- databaseLists.value[i].loading = false;+ state.databaseMatchLists[i].loading = false;}};watch(- [() => props.matchedDatabaseList, () => props.unmatchedDatabaseList],- async () => {- databaseLists.value = getInitialState();- await Promise.all(databaseLists.value.map((_, i) => loadMore(i)));- },- { deep: true, immediate: true }-);--watch(- () => props.matchedDatabaseList.length,- () => {- collapseExpandedNames.value = [];- if (props.matchedDatabaseList.length > 0) {- collapseExpandedNames.value.push("matched");+ [+ () => state.databaseMatchLists[0].databaseNameList.length,+ () => state.databaseMatchLists[1].databaseNameList.length,+ ],+ ([matchedLength, unmatchedLength]) => {+ state.collapseExpandedNames = [];+ if (matchedLength > 0) {+ state.collapseExpandedNames.push("matched");}- if (props.unmatchedDatabaseList.length > 0) {- collapseExpandedNames.value.push("unmatched");+ if (unmatchedLength > 0) {+ state.collapseExpandedNames.push("unmatched");}},{immediate: true,});++const updateDatabaseMatchingState = useDebounceFn(async () => {+ if (!validateSimpleExpr(props.expr)) {+ state.matchingError = undefined;+ state.databaseMatchLists = getInitialState();+ return;+ }++ state.loading = true;+ try {+ const result = await dbGroupStore.fetchDatabaseGroupMatchList({+ projectName: props.project,+ expr: props.expr,+ });++ state.matchingError = undefined;+ state.databaseMatchLists[0].databaseNameList = result.matchedDatabaseList;+ state.databaseMatchLists[1].databaseNameList = result.unmatchedDatabaseList;+ await Promise.all(state.databaseMatchLists.map((_, i) => loadMore(i)));+ } catch (error) {+ state.matchingError = (error as ClientError).details;+ state.databaseMatchLists = getInitialState();+ } finally {+ state.loading = false;+ }+}, 500);++watch(+ [() => props.project, () => props.expr],+ () => updateDatabaseMatchingState(),+ { deep: true, immediate: true }+);</script>diff --git a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vueindex f399c88076..5ffa7dde66 100644--- a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue+++ b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue@@ -6,28 +6,15 @@:show-actions="true"@row-click="handleDatabaseGroupClick"/>-- <DatabaseGroupPanel- :show="state.showDatabaseGroupPanel"- :project="project"- :database-group="state.editingDatabaseGroup"- @close="state.showDatabaseGroupPanel = false"- /></template><script lang="ts" setup>-import { reactive, computed } from "vue";+import { computed } from "vue";import { useRouter } from "vue-router";import DatabaseGroupDataTable from "@/components/DatabaseGroup/DatabaseGroupDataTable.vue";import { PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL } from "@/router/dashboard/projectV1";import { useDBGroupListByProject } from "@/store";import type { ComposedDatabaseGroup, ComposedProject } from "@/types";-import DatabaseGroupPanel from "./DatabaseGroupPanel.vue";--interface LocalState {- showDatabaseGroupPanel: boolean;- editingDatabaseGroup?: ComposedDatabaseGroup;-}const props = defineProps<{project: ComposedProject;@@ -35,9 +22,6 @@ const props = defineProps<{}>();const router = useRouter();-const state = reactive<LocalState>({- showDatabaseGroupPanel: false,-});const { dbGroupList, ready } = useDBGroupListByProject(props.project.name);const filteredDbGroupList = computed(() => {diff --git a/frontend/src/layouts/ProjectV1Layout.vue b/frontend/src/layouts/ProjectV1Layout.vueindex 74ad818ea6..1afc690ce6 100644--- a/frontend/src/layouts/ProjectV1Layout.vue+++ b/frontend/src/layouts/ProjectV1Layout.vue@@ -31,6 +31,7 @@<router-viewv-if="hasPermission"+ class="h-full":project-id="projectId":allow-edit="allowEdit"v-bind="$attrs"diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 3b92ca4a24..a09340a7a7 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2455,13 +2455,13 @@},"database-group": {"create": "New database group",- "edit": "Edit database group","matched-database": "Matched database","unmatched-database": "Unmatched database","condition": {"self": "Condition"},- "select": "Select database group"+ "select": "Select database group",+ "no-matched-databases": "No matched databases"},"export-center": {"self": "Export Center",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 0a2a761401..bf1b739aa9 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1793,8 +1793,6 @@},"executing-query": "Ejecutando consulta","request-query": "Solicitar consulta",- "previous-row": "Fila anterior",- "next-row": "siguiente fila","copy-success": "Copiado al portapapeles","connect-in-new-tab": "Conéctate en una nueva pestaña","copy-name": "Copiar nombre",@@ -1846,7 +1844,9 @@"upload-file": "Subir archivo","copy-selected-results": "Copiar datos seleccionados por {action} o {button}","format-default": "Por defecto",- "column-display-format": "Formato de visualización de columna"+ "column-display-format": "Formato de visualización de columna",+ "next-row": "siguiente fila",+ "previous-row": "Fila anterior"},"schema-editor": {"self": "Editor de esquema",@@ -2455,13 +2455,13 @@},"database-group": {"create": "Crear grupo de bases de datos",- "edit": "Editar grupo de bases de datos","matched-database": "Base de datos coincidente","unmatched-database": "Base de datos no coincidente","condition": {"self": "Condición"},- "select": "Seleccionar grupo de bases de datos"+ "select": "Seleccionar grupo de bases de datos",+ "no-matched-databases": "No hay bases de datos coincidentes"},"export-center": {"self": "centro de exportacion",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 5f1f8d4b91..7a167748d9 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1728,6 +1728,10 @@"vertical-display": "縦型表示","no-history-found": "まだ履歴がありません","search-history": "履歴の検索",+ "binary-format": "バイナリ形式",+ "hex-format": "16進形式",+ "boolean-format": "ブール形式",+ "text-format": "テキスト形式","hint-tips": {"confirm-to-close-unsaved-sheet": {"title": "未保存のワークシートを閉じてもよろしいですか?",@@ -1789,8 +1793,6 @@},"executing-query": "クエリの実行","request-query": "リクエストクエリ",- "previous-row": "前の行",- "next-row": "次の行","copy-success": "正常にコピーされました","connect-in-new-tab": "新しいタブで接続する","copy-name": "名前をコピーする",@@ -1841,12 +1843,10 @@},"upload-file": "ファイルをアップロードする","copy-selected-results": "選択したデータを{action}または{button}でコピーします",- "binary-format": "バイナリ形式","format-default": "デフォルト",- "hex-format": "16進形式",- "text-format": "テキスト形式",- "boolean-format": "ブール形式",- "column-display-format": "列表示形式"+ "column-display-format": "列表示形式",+ "next-row": "次の行",+ "previous-row": "前の行"},"schema-editor": {"self": "スキーマエディタ",@@ -2455,13 +2455,13 @@},"database-group": {"create": "新しいデータベースグループを作成する",- "edit": "データベースグループの編集","matched-database": "マッチングデータベース","unmatched-database": "データベースが一致しません","condition": {"self": "状態"},- "select": "データベースグループを選択"+ "select": "データベースグループを選択",+ "no-matched-databases": "一致するデータベースはありません"},"export-center": {"self": "エクスポートセンター",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex ad51e7594d..68a2f72945 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1793,8 +1793,6 @@},"executing-query": "Đang thực hiện truy vấn","request-query": "Yêu cầu truy vấn",- "previous-row": "Dòng trước",- "next-row": "Dòng tiếp theo","copy-success": "Sao chép thành công","connect-in-new-tab": "Kết nối trong tab mới","copy-name": "Sao chép tên",@@ -1846,7 +1844,9 @@"upload-file": "Tải lên tệp","copy-selected-results": "Sao chép dữ liệu đã chọn bằng {action} hoặc {button}","format-default": "Mặc định",- "column-display-format": "Định dạng hiển thị cột"+ "column-display-format": "Định dạng hiển thị cột",+ "next-row": "Dòng tiếp theo",+ "previous-row": "Dòng trước"},"schema-editor": {"self": "Trình soạn thảo lược đồ",@@ -2455,13 +2455,13 @@},"database-group": {"create": "Nhóm cơ sở dữ liệu mới",- "edit": "Chỉnh sửa nhóm cơ sở dữ liệu","matched-database": "Cơ sở dữ liệu phù hợp","unmatched-database": "Cơ sở dữ liệu không phù hợp","condition": {"self": "Điều kiện"},- "select": "Chọn nhóm cơ sở dữ liệu"+ "select": "Chọn nhóm cơ sở dữ liệu",+ "no-matched-databases": "Không có cơ sở dữ liệu phù hợp"},"export-center": {"self": "Trung tâm xuất",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex a29a217914..4d2feec599 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1793,8 +1793,6 @@},"executing-query": "执行查询","request-query": "请求查询",- "previous-row": "上一行",- "next-row": "下一行","copy-success": "复制成功","connect-in-new-tab": "在新选项卡中连接","copy-name": "复制名称",@@ -1846,7 +1844,9 @@"upload-file": "上传文件","copy-selected-results": "通过 {action} 或 {button} 来快速复制选定的数据","format-default": "默认",- "column-display-format": "列显示格式"+ "column-display-format": "列显示格式",+ "next-row": "下一行",+ "previous-row": "上一行"},"schema-editor": {"self": "Schema 编辑器",@@ -2455,13 +2455,13 @@},"database-group": {"create": "新建数据库分组",- "edit": "编辑数据库分组","matched-database": "相匹配的数据库","unmatched-database": "不匹配的数据库","condition": {"self": "条件"},- "select": "选择数据库组"+ "select": "选择数据库组",+ "no-matched-databases": "没有匹配的数据库"},"export-center": {"self": "导出中心",diff --git a/frontend/src/views/project/ProjectDatabaseGroupCreate.vue b/frontend/src/views/project/ProjectDatabaseGroupCreate.vueindex 012df9cedf..b1dc5b4ccd 100644--- a/frontend/src/views/project/ProjectDatabaseGroupCreate.vue+++ b/frontend/src/views/project/ProjectDatabaseGroupCreate.vue@@ -1,8 +1,8 @@<template><DatabaseGroupFormclass="flex-1"+ :readonly="false":project="project"- :title="$t('database-group.create')"@dismiss="() => router.back()"@created="(databaseGroupName: string) => {router.push({diff --git a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue b/frontend/src/views/project/ProjectDatabaseGroupDetail.vueindex 6c38262b90..1ace588e6d 100644--- a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue+++ b/frontend/src/views/project/ProjectDatabaseGroupDetail.vue@@ -1,106 +1,75 @@<template><divv-if="databaseGroup"- class="flex-1 overflow-auto focus:outline-none"- tabindex="0"v-bind="$attrs"+ class="h-full flex-1 relative space-y-4"><FeatureAttentionfeature="bb.feature.database-grouping"- custom-class="mb-2"+ custom-class="mb-4"/>- <main class="flex-1 relative overflow-y-auto space-y-4">- <div- class="space-y-2 lg:space-y-0 lg:flex lg:items-center lg:justify-between"- >- <div class="flex-1 min-w-0 shrink-0">- <!-- Summary -->- <div class="flex items-center">- <div>- <div class="flex items-center gap-2">- <h1- class="pt-2 pb-2.5 text-xl font-bold leading-6 text-main truncate flex items-center gap-x-3"- >- {{ databaseGroup.databasePlaceholder }}- </h1>- </div>- </div>- </div>- </div>+ <FeatureAttentionForInstanceLicense+ custom-class="mb-4"+ type="warning"+ feature="bb.feature.database-grouping"+ />- <div- v-if="hasDatabaseGroupFeature"- class="flex flex-row justify-end items-center flex-wrap shrink gap-x-2 gap-y-2"- >- <NButton v-if="allowEdit" @click="handleEditDatabaseGroup">- {{ $t("common.configure") }}- </NButton>+ <div+ v-if="hasDatabaseGroupFeature && !state.editing"+ class="flex flex-row justify-end items-center flex-wrap shrink gap-x-2 gap-y-2"+ >+ <NTooltip+ v-if="hasPermissionToCreateIssue"+ :disabled="hasMatchedDatabases"+ >+ <template #trigger><NButton- v-if="hasPermissionToCreateIssue"+ :disabled="!hasMatchedDatabases"@click="previewDatabaseGroupIssue('bb.issue.database.schema.update')">{{ $t("database.edit-schema") }}</NButton>+ </template>+ {{ $t("database-group.no-matched-databases") }}+ </NTooltip>+ <NTooltip+ v-if="hasPermissionToCreateIssue"+ :disabled="hasMatchedDatabases"+ >+ <template #trigger><NButton- v-if="hasPermissionToCreateIssue"+ :disabled="!hasMatchedDatabases"@click="previewDatabaseGroupIssue('bb.issue.database.data.update')">{{ $t("database.change-data") }}</NButton>- </div>- </div>-- <NDivider />-- <div class="w-full max-w-5xl grid grid-cols-5 gap-x-6">- <div class="col-span-3">- <p class="pl-1 text-lg mb-2">- {{ $t("database-group.condition.self") }}- </p>- <ExprEditor- :expr="databaseGroup.simpleExpr"- :allow-admin="false"- :enable-raw-expression="true"- :factor-list="FactorList"- :factor-support-dropdown="factorSupportDropdown"- :option-config-map="getDatabaseGroupOptionConfigMap()"- />- </div>- <div class="col-span-2">- <MatchedDatabaseView- :loading="false"- :matched-database-list="matchedDatabaseList"- :unmatched-database-list="unmatchedDatabaseList"- />- </div>- </div>- </main>+ </template>+ {{ $t("database-group.no-matched-databases") }}+ </NTooltip>+ <NButton v-if="allowEdit" type="primary" @click="state.editing = true">+ {{ $t("common.configure") }}+ </NButton>+ </div>++ <DatabaseGroupForm+ :readonly="!state.editing"+ :project="project"+ :database-group="databaseGroup"+ @dismiss="state.editing = false"+ /></div>-- <DatabaseGroupPanel- :show="state.showEditPanel"- :project="project"- :database-group="databaseGroup"- @close="state.showEditPanel = false"- /></template><script lang="ts" setup>-import { NButton, NDivider } from "naive-ui";+import { NButton, NTooltip } from "naive-ui";import { computed, reactive, watchEffect } from "vue";import { useRouter } from "vue-router";-import DatabaseGroupPanel from "@/components/DatabaseGroup/DatabaseGroupPanel.vue";-import MatchedDatabaseView from "@/components/DatabaseGroup/MatchedDatabaseView.vue";-import {- FactorList,- factorSupportDropdown,- getDatabaseGroupOptionConfigMap,-} from "@/components/DatabaseGroup/utils";-import ExprEditor from "@/components/ExprEditor";+import DatabaseGroupForm from "@/components/DatabaseGroup/DatabaseGroupForm.vue";import FeatureAttention from "@/components/FeatureGuard/FeatureAttention.vue";+import FeatureAttentionForInstanceLicense from "@/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue";import { useDBGroupStore, useProjectByName, featureToRef } from "@/store";import {databaseGroupNamePrefix,@@ -111,7 +80,7 @@ import { hasPermissionToCreateChangeDatabaseIssueInProject } from "@/utils";import { generateDatabaseGroupIssueRoute } from "@/utils/databaseGroup/issue";interface LocalState {- showEditPanel: boolean;+ editing: boolean;}const props = defineProps<{@@ -126,7 +95,7 @@ const { project } = useProjectByName(computed(() => `${projectNamePrefix}${props.projectId}`));const state = reactive<LocalState>({- showEditPanel: false,+ editing: false,});const databaseGroupResourceName = computed(() => {@@ -141,6 +110,10 @@ const hasPermissionToCreateIssue = computed(() => {return hasPermissionToCreateChangeDatabaseIssueInProject(project.value);});+const hasMatchedDatabases = computed(+ () => (databaseGroup.value?.matchedDatabases.length ?? 0) > 0+);+const hasDatabaseGroupFeature = featureToRef("bb.feature.database-grouping");watchEffect(async () => {@@ -150,18 +123,6 @@ watchEffect(async () => {});});-const matchedDatabaseList = computed(- () => databaseGroup.value?.matchedDatabases.map((db) => db.name) || []-);--const unmatchedDatabaseList = computed(- () => databaseGroup.value?.unmatchedDatabases.map((db) => db.name) || []-);--const handleEditDatabaseGroup = () => {- state.showEditPanel = true;-};-const previewDatabaseGroupIssue = (type: "bb.issue.database.schema.update" | "bb.issue.database.data.update") => {