Skip to content

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

chore: show matched database (#17425)

ecmadao4bd1fbd1b7c4
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 6d038ac9cf..9bb39db991 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2074,6 +2074,8 @@
"select-a-database-to-start": "Select a database to start",
"show-empty-environments": "Show empty environments",
"select-encoding": "Select encoding",
+ "current-connection": "Current connection",
+ "matched-in-group": "Matched in the database group: {title}",
"redis-command": {
"self": "Run redis command on",
"all-nodes": "All nodes",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 354ac0a890..50df194a62 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2074,6 +2074,8 @@
"select-a-database-to-start": "Seleccione una base de datos para comenzar",
"show-empty-environments": "Mostrar entornos vacíos",
"select-encoding": "Seleccionar codificación",
+ "current-connection": "Conexión actual",
+ "matched-in-group": "Coincidido en el grupo de base de datos: {title}",
"redis-command": {
"self": "Ejecute el comando redis en",
"all-nodes": "Todos los nodos",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 19f54095ac..60f8f1aab8 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2074,6 +2074,8 @@
"select-a-database-to-start": "開始するにはデータベースを選択してください",
"show-empty-environments": "空の環境を表示",
"select-encoding": "エンコーディングの選択",
+ "current-connection": "現在の接続",
+ "matched-in-group": "データベース グループ {title} に一致しました",
"redis-command": {
"self": "redisコマンドを実行する",
"all-nodes": "すべてのノード",
@@ -2921,4 +2923,4 @@
"last-visit": "最終訪問",
"changelog-for-version": "{version} の変更履歴"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index a356b43061..f31dba35a6 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -2074,6 +2074,8 @@
"select-a-database-to-start": "Chọn một cơ sở dữ liệu để bắt đầu",
"show-empty-environments": "Hiển thị môi trường trống",
"select-encoding": "Chọn mã hóa",
+ "current-connection": "Kết nối hiện tại",
+ "matched-in-group": "Phù hợp trong nhóm cơ sở dữ liệu: {title}",
"redis-command": {
"self": "Chạy lệnh redis trên",
"all-nodes": "Tất cả các nút",
@@ -2921,4 +2923,4 @@
"last-visit": "Lần truy cập cuối",
"changelog-for-version": "Nhật ký thay đổi cho phiên bản {version}"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 8148d9b173..172c618ea9 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2074,6 +2074,8 @@
"select-a-database-to-start": "选择数据库以开始",
"show-empty-environments": "显示空环境",
"select-encoding": "选择编码",
+ "current-connection": "当前连接",
+ "matched-in-group": "在数据库组 {title} 中匹配",
"redis-command": {
"self": "运行 redis 命令",
"all-nodes": "所有节点",
@@ -2921,4 +2923,4 @@
"last-visit": "上次访问",
"changelog-for-version": "{version} 的更新日志"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/store/modules/dbGroup.ts b/frontend/src/store/modules/dbGroup.ts
index a336b7d497..895c14195e 100644
--- a/frontend/src/store/modules/dbGroup.ts
+++ b/frontend/src/store/modules/dbGroup.ts
@@ -228,7 +228,10 @@ export const useDBGroupStore = defineStore("db-group", () => {
};
});
-export const useDBGroupListByProject = (project: MaybeRef<string>) => {
+export const useDBGroupListByProject = (
+ project: MaybeRef<string>,
+ view: DatabaseGroupView = DatabaseGroupView.BASIC
+) => {
const store = useDBGroupStore();
const ready = ref(false);
const dbGroupList = ref<DatabaseGroup[]>([]);
@@ -237,7 +240,7 @@ export const useDBGroupListByProject = (project: MaybeRef<string>) => {
ready.value = false;
dbGroupList.value = [];
store
- .fetchDBGroupListByProjectName(unref(project), DatabaseGroupView.BASIC)
+ .fetchDBGroupListByProjectName(unref(project), view)
.then((response) => {
ready.value = true;
dbGroupList.value = response;
@@ -247,14 +250,17 @@ export const useDBGroupListByProject = (project: MaybeRef<string>) => {
return { dbGroupList, ready };
};
-export const useDatabaseGroupByName = (name: MaybeRef<string>) => {
+export const useDatabaseGroupByName = (
+ name: MaybeRef<string>,
+ view: DatabaseGroupView
+) => {
const store = useDBGroupStore();
const ready = ref(true);
watch(
() => unref(name),
(name) => {
ready.value = false;
- store.getOrFetchDBGroupByName(name).then(() => {
+ store.getOrFetchDBGroupByName(name, { view }).then(() => {
ready.value = true;
});
},
diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/BatchQueryDatabaseGroupSelector.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/BatchQueryDatabaseGroupSelector.vue
index e6d30f9da6..6ad9164d8f 100644
--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/BatchQueryDatabaseGroupSelector.vue
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/BatchQueryDatabaseGroupSelector.vue
@@ -67,6 +67,7 @@ import {
useDBGroupListByProject,
} from "@/store/modules";
import { isValidDatabaseName } from "@/types";
+import { DatabaseGroupView } from "@/types/proto-es/v1/database_group_service_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
interface LocalState {
@@ -92,7 +93,8 @@ const hasDatabaseGroupFeature = featureToRef(
const { database } = useConnectionOfCurrentSQLEditorTab();
const { dbGroupList, ready } = useDBGroupListByProject(
- computed(() => editorStore.project)
+ computed(() => editorStore.project),
+ DatabaseGroupView.FULL
);
const filteredDbGroupList = computed(() => {
diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue
index afdb8617dd..b453874268 100644
--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue
@@ -191,6 +191,7 @@ import {
type TreeOption,
} from "naive-ui";
import { ref, shallowRef, nextTick, watch, h, computed, reactive } from "vue";
+import { useI18n } from "vue-i18n";
import AdvancedSearch from "@/components/AdvancedSearch";
import { useCommonSearchScopeOptions } from "@/components/AdvancedSearch/useCommonSearchScopeOptions";
import { FeatureBadge, FeatureModal } from "@/components/FeatureGuard";
@@ -202,6 +203,7 @@ import {
batchGetOrFetchDatabases,
useProjectV1Store,
useDatabaseV1Store,
+ useDBGroupStore,
useSQLEditorTabStore,
useCurrentUserV1,
resolveOpeningDatabaseListFromSQLEditorTabList,
@@ -264,9 +266,11 @@ const treeStore = useSQLEditorTreeStore();
const tabStore = useSQLEditorTabStore();
const editorStore = useSQLEditorStore();
const databaseStore = useDatabaseV1Store();
+const dbGroupStore = useDBGroupStore();
const projectStore = useProjectV1Store();
const environmentList = useEnvironmentV1List();
const currentUser = useCurrentUserV1();
+const { t } = useI18n();
const expandedState = useDynamicLocalStorage<{
initialized: boolean;
@@ -306,6 +310,24 @@ const state = reactive<LocalState>({
batchQueryDataSourceType: DataSourceType.READ_ONLY,
});
+const flattenSelectedDatabasesFromGroup = computed(() => {
+ const nameMap = new Map<
+ string /* database name */,
+ string /* group title */
+ >();
+ for (const groupName of tabStore.currentTab?.batchQueryContext
+ ?.databaseGroups ?? []) {
+ const group = dbGroupStore.getDBGroupByName(groupName);
+ if (!group) {
+ continue;
+ }
+ for (const db of group.matchedDatabases) {
+ nameMap.set(db.name, group.title);
+ }
+ }
+ return nameMap;
+});
+
const treeByEnvironment = shallowRef<
Map<string /* environment full name */, TreeByEnvironment>
>(new Map());
@@ -481,9 +503,20 @@ const renderLabel = ({ option }: { option: TreeOption }) => {
databaseName = (node as SQLEditorTreeNode<"database">).meta.target.name;
}
+ const checkedByGroup =
+ flattenSelectedDatabasesFromGroup.value.get(databaseName);
+ let checkTooltip = "";
+ if (tabStore.currentTab?.connection.database === databaseName) {
+ checkTooltip = t("sql-editor.current-connection");
+ } else if (!!checkedByGroup) {
+ checkTooltip = t("sql-editor.matched-in-group", { title: checkedByGroup });
+ }
+
return h(Label, {
node,
- checked: state.selectedDatabases.has(databaseName),
+ checked: state.selectedDatabases.has(databaseName) || !!checkedByGroup,
+ checkDisabled: !!checkedByGroup,
+ checkTooltip,
keyword: state.params.query,
connected: connectedDatabases.value.has(databaseName),
"onUpdate:checked": (checked: boolean) => {
diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseGroupTag.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseGroupTag.vue
index 312990ea7e..a8b96f0739 100644
--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseGroupTag.vue
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseGroupTag.vue
@@ -13,6 +13,7 @@
import { NTag, NTooltip } from "naive-ui";
import { computed } from "vue";
import { useDatabaseGroupByName } from "@/store";
+import { DatabaseGroupView } from "@/types/proto-es/v1/database_group_service_pb";
const props = defineProps<{
databaseGroupName: string;
@@ -23,6 +24,7 @@ defineEmits<{
}>();
const { databaseGroup } = useDatabaseGroupByName(
- computed(() => props.databaseGroupName)
+ computed(() => props.databaseGroupName),
+ DatabaseGroupView.FULL
);
</script>
diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/DatabaseNode.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/DatabaseNode.vue
index 8c5aa7a063..14e782a228 100644
--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/DatabaseNode.vue
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/DatabaseNode.vue
@@ -1,17 +1,21 @@
<template>
<div class="flex items-center max-w-full overflow-hidden gap-x-1">
- <template v-if="tabStore.supportBatchMode">
- <LinkIcon
- v-if="tabStore.currentTab?.connection.database === database.name"
- class="w-4 textinfolabel"
- />
- <NCheckbox
- v-else-if="canQuery"
- :checked="checked"
- @click.stop.prevent=""
- @update:checked="$emit('update:checked', $event)"
- />
- </template>
+ <NTooltip v-if="tabStore.supportBatchMode" :disabled="!checkTooltip">
+ <template #trigger>
+ <LinkIcon
+ v-if="tabStore.currentTab?.connection.database === database.name"
+ class="w-4 textinfolabel"
+ />
+ <NCheckbox
+ v-else
+ :checked="checked"
+ :disabled="checkDisabled || !canQuery"
+ @click.stop.prevent=""
+ @update:checked="$emit('update:checked', $event)"
+ />
+ </template>
+ {{ checkTooltip }}
+ </NTooltip>
<RichDatabaseName
:database="database"
@@ -37,7 +41,7 @@
<script setup lang="ts">
import { LinkIcon } from "lucide-vue-next";
-import { NCheckbox } from "naive-ui";
+import { NCheckbox, NTooltip } from "naive-ui";
import { computed } from "vue";
import { RichDatabaseName } from "@/components/v2";
import { useSQLEditorTabStore } from "@/store";
@@ -50,6 +54,8 @@ const props = defineProps<{
keyword: string;
connected?: boolean;
checked?: boolean;
+ checkDisabled?: boolean;
+ checkTooltip?: string;
}>();
defineEmits<{
diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/Label.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/Label.vue
index 198d0bec2c..dd1a05ef44 100644
--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/Label.vue
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/Label.vue
@@ -15,6 +15,8 @@
:node="node"
:keyword="keyword"
:checked="checked"
+ :check-disabled="checkDisabled"
+ :check-tooltip="checkTooltip"
:connected="connected"
/>
</template>
@@ -35,6 +37,8 @@ const props = defineProps<{
node: TreeNode;
keyword: string;
checked: boolean;
+ checkDisabled?: boolean;
+ checkTooltip?: string;
connected: boolean;
}>();