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: hide empty environments by default (#16834)
ecmadao8a0abc9d463e
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 24afc01f3a..f8753a8560 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1979,6 +1979,7 @@"sync-in-progress": "Sync in progress","create-a-worksheet": "Create a new worksheet","select-a-database-to-start": "Select a database to start",+ "show-empty-environments": "Show empty environments","select-encoding": "Select encoding","redis-command": {"self": "Run redis command on",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex c32b64243c..12a66a97f0 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1979,6 +1979,7 @@"sync-in-progress": "Sincronización en progreso","create-a-worksheet": "Crear una hoja de trabajo","select-a-database-to-start": "Seleccione una base de datos para comenzar",+ "show-empty-environments": "Mostrar entornos vacíos","select-encoding": "Seleccionar codificación","redis-command": {"self": "Ejecute el comando redis en",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 069a631742..a661b7c52e 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1979,6 +1979,7 @@"sync-in-progress": "同期中","create-a-worksheet": "新しいワークシートを作成する","select-a-database-to-start": "開始するにはデータベースを選択してください",+ "show-empty-environments": "空の環境を表示","select-encoding": "エンコーディングの選択","redis-command": {"self": "redisコマンドを実行する",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 9fd9b6a6f5..6bb4e3d420 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1979,6 +1979,7 @@"sync-in-progress": "Đang đồng bộ","create-a-worksheet": "Tạo một trang tính mới","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","redis-command": {"self": "Chạy lệnh redis trên",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 33cc535c7f..28405f4ac2 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1979,6 +1979,7 @@"sync-in-progress": "正在同步","create-a-worksheet": "新建工作表","select-a-database-to-start": "选择数据库以开始",+ "show-empty-environments": "显示空环境","select-encoding": "选择编码","redis-command": {"self": "运行 redis 命令",diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vueindex c0071ffdab..777710ba1e 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue@@ -87,42 +87,54 @@:data-height="treeContainerHeight"><template v-if="treeStore.state === 'READY'">+ <NCheckbox+ v-if="existEmptyEnvironment"+ v-model:checked="state.showEmptyEnvironment"+ >+ {{ $t("sql-editor.show-empty-environments") }}+ </NCheckbox><divv-for="[environment, treeState] of treeByEnvironment.entries()":key="environment"class="flex flex-col space-y-2 pt-2 pb-2">- <NTree- :block-line="true"- :data="treeState.tree.value"- :show-irrelevant-nodes="false"- :selected-keys="selectedKeys"- :expand-on-click="true"- v-model:expanded-keys="treeState.expandedState.value.expandedKeys"- :node-props="nodeProps"- :theme-overrides="{ nodeHeight: '21px' }"- :render-label="renderLabel"- />- <div- v-if="- !!treeState.fetchDataState.value.nextPageToken &&- treeState.expandedState.value.expandedKeys.includes(environment)- "- class="w-full flex items-center justify-start pl-4"- >- <NButton- quaternary- :size="'small'"- :loading="treeState.fetchDataState.value.loading"- @click="- () =>- treeState- .fetchDatabases(filter)- .then(() => treeState.buildTree())+ <div v-if="!treeIsEmpty(treeState) || state.showEmptyEnvironment">+ <NTree+ :block-line="true"+ :data="treeState.tree.value"+ :show-irrelevant-nodes="false"+ :selected-keys="selectedKeys"+ :expand-on-click="true"+ v-model:expanded-keys="treeState.expandedState.value.expandedKeys"+ :node-props="nodeProps"+ :theme-overrides="{ nodeHeight: '21px' }"+ :render-label="renderLabel"+ />+ <div+ v-if="+ !!treeState.fetchDataState.value.nextPageToken &&+ treeState.expandedState.value.expandedKeys.includes(+ environment+ ) &&+ (!treeIsEmpty(treeState) ||+ treeState.showMissingQueryDatabases.value)"+ class="w-full flex items-center justify-start pl-4">- {{ $t("common.load-more") }}- </NButton>+ <NButton+ quaternary+ :size="'small'"+ :loading="treeState.fetchDataState.value.loading"+ @click="+ () =>+ treeState+ .fetchDatabases(filter)+ .then(() => treeState.buildTree())+ "+ >+ {{ $t("common.load-more") }}+ </NButton>+ </div></div></div></template>@@ -169,6 +181,7 @@ import {NRadioGroup,NRadio,NTooltip,+ NCheckbox,type TreeOption,} from "naive-ui";import { ref, shallowRef, nextTick, watch, h, computed, reactive } from "vue";@@ -235,6 +248,7 @@ interface LocalState {selectedDatabases: Set<string>;params: SearchParams;showFeatureModal: boolean;+ showEmptyEnvironment: boolean;batchQueryDataSourceType?: QueryDataSourceType;}@@ -280,6 +294,7 @@ const state = reactive<LocalState>({scopes: [],},showFeatureModal: false,+ showEmptyEnvironment: false,batchQueryDataSourceType: DataSourceType.READ_ONLY,});@@ -287,6 +302,26 @@ const treeByEnvironment = shallowRef<Map<string /* environment full name */, TreeByEnvironment>>(new Map());+const existEmptyEnvironment = computed(() => {+ for (const [_, value] of treeByEnvironment.value.entries()) {+ if (treeIsEmpty(value)) {+ return true;+ }+ }+ return false;+});++const treeIsEmpty = (value: TreeByEnvironment) => {+ if (value.tree.value.length === 0) {+ return true;+ }+ const children = value.tree.value[0].children;+ if (!children || children.length === 0) {+ return true;+ }+ return false;+};+watch(() => state.batchQueryDataSourceType,(dataSourceType) => {@@ -585,18 +620,20 @@ watch();const prepareDatabases = async () => {- for (const environment of environmentList.value) {- if (!treeByEnvironment.value.has(environment.name)) {- treeByEnvironment.value.set(- environment.name,- useSQLEditorTreeByEnvironment(environment.name)- );- }- await treeByEnvironment.value- .get(environment.name)- ?.prepareDatabases(filter.value);- treeByEnvironment.value.get(environment.name)?.buildTree();- }+ await Promise.all(+ environmentList.value.map(async (environment) => {+ if (!treeByEnvironment.value.has(environment.name)) {+ treeByEnvironment.value.set(+ environment.name,+ useSQLEditorTreeByEnvironment(environment.name)+ );+ }+ await treeByEnvironment.value+ .get(environment.name)+ ?.prepareDatabases(filter.value);+ treeByEnvironment.value.get(environment.name)?.buildTree();+ })+ );};watch(diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/tree.ts b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/tree.tsindex 65638362d1..5e9e16a24d 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/tree.ts+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/tree.ts@@ -8,8 +8,10 @@ import {useSQLEditorStore,useCurrentUserV1,useDatabaseV1Store,+ useEnvironmentV1Store,type DatabaseFilter,buildTreeImpl,+ mapTreeNodeByType,} from "@/store";import type {ComposedDatabase,@@ -41,6 +43,7 @@ export type TreeByEnvironment = {loading: boolean;nextPageToken?: string;}>;+ showMissingQueryDatabases: ComputedRef<boolean>;};export const useSQLEditorTreeByEnvironment = (@@ -49,6 +52,7 @@ export const useSQLEditorTreeByEnvironment = (const databaseStore = useDatabaseV1Store();const { project } = storeToRefs(useSQLEditorStore());const currentUser = useCurrentUserV1();+ const environmentStore = useEnvironmentV1Store();const databaseList = ref<ComposedDatabase[]>([]);const fetchDataState = ref<{@@ -130,6 +134,13 @@ export const useSQLEditorTreeByEnvironment = (defaultEnvironmentFactor.factor,]);+ if (tree.value.length === 0) {+ const env = environmentStore.getEnvironmentByName(environment);+ const rootNode = mapTreeNodeByType("environment", env, undefined);+ rootNode.children = [];+ tree.value = [rootNode];+ }+if (hasMissingQueryDatabases.value) {for (const node of tree.value) {node.suffix = () => {@@ -168,6 +179,7 @@ export const useSQLEditorTreeByEnvironment = (buildTree,prepareDatabases,fetchDatabases,+ showMissingQueryDatabases: computed(() => showMissingQueryDatabases.value),fetchDataState: computed(() => fetchDataState.value),};};