Skip to content

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

refactor(sql-editor): move isLoadingTree field out of ConnectionContext (#2690)

Liu Ji6aad9742c17b
diff --git a/frontend/src/components/ProvideSQLEditorContext.vue b/frontend/src/components/ProvideSQLEditorContext.vue
index 36f51c3663..b7735f519f 100644
--- a/frontend/src/components/ProvideSQLEditorContext.vue
+++ b/frontend/src/components/ProvideSQLEditorContext.vue
@@ -178,10 +178,10 @@ const setConnectionFromQuery = async () => {
};
onMounted(async () => {
- sqlEditorStore.setConnectionContext({ isLoadingTree: true });
+ sqlEditorStore.isLoadingTree = true;
await prepareAccessibleConnectionByProject();
await prepareSQLEditorContext();
- sqlEditorStore.setConnectionContext({ isLoadingTree: false });
+ sqlEditorStore.isLoadingTree = false;
await setConnectionFromQuery();
await sqlEditorStore.fetchQueryHistoryList();
diff --git a/frontend/src/store/modules/sqlEditor.ts b/frontend/src/store/modules/sqlEditor.ts
index 6ea0b3db0d..e9a0ff7006 100644
--- a/frontend/src/store/modules/sqlEditor.ts
+++ b/frontend/src/store/modules/sqlEditor.ts
@@ -25,7 +25,6 @@ import { useTabStore } from "./tab";
import { emptyConnection } from "@/utils";
export const getDefaultConnectionContext = () => ({
- isLoadingTree: false,
option: {} as any,
});
@@ -33,6 +32,7 @@ export const useSQLEditorStore = defineStore("sqlEditor", {
state: (): SQLEditorState => ({
connectionTree: [],
connectionContext: getDefaultConnectionContext(),
+ isLoadingTree: false,
isExecuting: false,
isShowExecutingHint: false,
shouldFormatContent: false,
diff --git a/frontend/src/types/sqlEditor.ts b/frontend/src/types/sqlEditor.ts
index c29f694fe3..1c1a8a37e7 100644
--- a/frontend/src/types/sqlEditor.ts
+++ b/frontend/src/types/sqlEditor.ts
@@ -26,10 +26,8 @@ export enum SortText {
KEYWORD = "3",
}
-// TODO(Jim): Move `isLoadingTree` to the root of sql editor state.
-// refactor <TableSchema> to get rid of this structure totally.
+// TODO(Jim): refactor <TableSchema> to get rid of this structure totally.
export type ConnectionContext = {
- isLoadingTree: boolean;
option: ConnectionAtom;
};
diff --git a/frontend/src/types/store.ts b/frontend/src/types/store.ts
index ed630c567e..8933abcf3d 100644
--- a/frontend/src/types/store.ts
+++ b/frontend/src/types/store.ts
@@ -197,6 +197,7 @@ export interface SQLEditorState {
shouldFormatContent: boolean;
queryHistoryList: QueryHistory[];
isFetchingQueryHistory: boolean;
+ isLoadingTree: boolean;
isExecuting: boolean;
isFetchingSheet: boolean;
isShowExecutingHint: boolean;
diff --git a/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue b/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue
index 05b5d48966..f8c7d38b68 100644
--- a/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue
@@ -1,6 +1,6 @@
<template>
<div
- v-if="!sqlEditorStore.connectionContext.isLoadingTree"
+ v-if="!sqlEditorStore.isLoadingTree"
class="databases-tree p-2 space-y-2 h-full"
>
<div class="databases-tree--input">