Skip to content

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

feat(sql-editor): refine database connecting UI (#11472)

Liu Ji1780f80dd413
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 427509f263..9de34b3799 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2188,7 +2188,7 @@
},
"view-all-tabs": "View all Tabs",
"sheets": "Sheets",
- "connection-holder": "Associate a database first from the Database Panel on the left",
+ "connection-holder": "Select a database to start",
"link-access": "Link access",
"private": "Private",
"private-desc": "Only you can access this sheet",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 0a77e2601e..5784fd9bd3 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2188,7 +2188,7 @@
},
"view-all-tabs": "Ver todas las pestañas",
"sheets": "Hojas",
- "connection-holder": "Asocie una base de datos primero desde el Panel de base de datos a la izquierda",
+ "connection-holder": "Seleccione una base de datos para comenzar",
"link-access": "Acceso al enlace",
"private": "Privado",
"private-desc": "Solo tú puedes acceder a esta hoja",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index f3689bbda9..e8cc2ff58d 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2188,7 +2188,7 @@
},
"view-all-tabs": "すべてのタブを表示",
"sheets": "シート",
- "connection-holder": "まず左側のデータベースパネルからデータベースを関連付けてください",
+ "connection-holder": "開始するデータベースを選択してください",
"link-access": "リンクアクセス",
"private": "プライベート",
"private-desc": "このシートにはあなたのみがアクセスできます",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 0537fec6e0..b057abff1f 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -2188,7 +2188,7 @@
},
"view-all-tabs": "Xem tất cả các Tab",
"sheets": "Trang tính",
- "connection-holder": "Liên kết cơ sở dữ liệu trước tiên từ Bảng điều khiển cơ sở dữ liệu ở bên trái",
+ "connection-holder": "Chọn cơ sở dữ liệu để bắt đầu",
"link-access": "Truy cập liên kết",
"private": "Riêng tư",
"private-desc": "Chỉ bạn mới có thể truy cập trang tính này",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index d2ceae18f0..594901b0c4 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2188,7 +2188,7 @@
},
"view-all-tabs": "查看所有标签页",
"sheets": "工作表",
- "connection-holder": "先从左侧数据库面板关联一个数据库",
+ "connection-holder": "选择数据库以开始",
"link-access": "链接访问权限",
"private": "私有",
"private-desc": "只有您自己可以访问此工作表",
diff --git a/frontend/src/plugins/ai/components/ActionBar.vue b/frontend/src/plugins/ai/components/ActionBar.vue
index 789ad3333c..f3ccadb210 100644
--- a/frontend/src/plugins/ai/components/ActionBar.vue
+++ b/frontend/src/plugins/ai/components/ActionBar.vue
@@ -1,6 +1,6 @@
<template>
<div
- class="w-full flex flex-wrap gap-y-2 justify-between sm:items-center px-4 py-2 border-b bg-white"
+ class="w-full flex flex-wrap gap-y-2 justify-between sm:items-center px-2 py-2 border-b bg-white"
>
<div
class="action-left gap-x-2 flex overflow-x-auto sm:overflow-x-hidden items-center"
diff --git a/frontend/src/plugins/ai/components/ChatPanel.vue b/frontend/src/plugins/ai/components/ChatPanel.vue
index c68c3e4933..06ccd9a1f4 100644
--- a/frontend/src/plugins/ai/components/ChatPanel.vue
+++ b/frontend/src/plugins/ai/components/ChatPanel.vue
@@ -12,7 +12,7 @@
<ChatView :conversation="selectedConversation" @enter="requestAI" />
</template>
- <div :class="[isChatMode && 'px-4 py-2 flex flex-col gap-2']">
+ <div :class="[isChatMode && 'px-2 py-2 flex flex-col gap-2']">
<div v-if="isChatMode" class="flex items-center gap-2 w-full">
<DynamicSuggestions class="flex-1" @enter="requestAI" />
</div>
diff --git a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue
index cf54b81d78..56564985bb 100644
--- a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue
@@ -20,7 +20,6 @@
<GutterBar />
</div>
<div class="h-full flex-1 flex flex-col pt-1 overflow-hidden">
- <ConnectionPane v-if="asidePanelTab === 'CONNECTION'" />
<WorksheetPane v-if="asidePanelTab === 'WORKSHEET'" />
<SchemaPane v-if="asidePanelTab === 'SCHEMA'" />
<HistoryPane v-if="asidePanelTab === 'HISTORY'" />
@@ -40,7 +39,6 @@ import {
} from "@/store";
import { UNKNOWN_ID } from "@/types";
import { useSQLEditorContext } from "../context";
-import ConnectionPane from "./ConnectionPane";
import GutterBar from "./GutterBar";
import HistoryPane from "./HistoryPane";
import SchemaPane from "./SchemaPane";
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue b/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue
index 8763be6869..6ff35e79da 100644
--- a/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/GutterBar/GutterBar.vue
@@ -1,7 +1,6 @@
<template>
<div class="h-full flex flex-col items-stretch justify-between text-sm pb-1">
<div class="divide-y border-b">
- <TabItem tab="CONNECTION" @click="handleClickTab('CONNECTION')" />
<TabItem tab="WORKSHEET" @click="handleClickTab('WORKSHEET')" />
<TabItem
tab="SCHEMA"
diff --git a/frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue b/frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue
index c3d3809143..e697e3ac7d 100644
--- a/frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/GutterBar/TabItem.vue
@@ -2,8 +2,7 @@
<NTooltip placement="right" :delay="300" :disabled="disabled">
<template #trigger>
<div class="px-2 py-3 select-none" :class="classes" v-bind="$attrs">
- <LinkIcon v-if="tab === 'CONNECTION'" class="w-4 h-4" />
- <FileCodeIcon v-else-if="tab === 'WORKSHEET'" class="w-4 h-4" />
+ <FileCodeIcon v-if="tab === 'WORKSHEET'" class="w-4 h-4" />
<DatabaseIcon v-else-if="tab === 'SCHEMA'" class="w-4 h-4" />
<HistoryIcon v-else-if="tab === 'HISTORY'" class="w-4 h-4" />
<span v-else></span>
@@ -16,7 +15,7 @@
</template>
<script setup lang="ts">
-import { LinkIcon, FileCodeIcon, HistoryIcon } from "lucide-vue-next";
+import { FileCodeIcon, HistoryIcon } from "lucide-vue-next";
import { NTooltip } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
@@ -48,8 +47,6 @@ const classes = computed(() => {
const text = computed(() => {
switch (props.tab) {
- case "CONNECTION":
- return t("common.connection");
case "WORKSHEET":
return t("sheet.sheet");
case "SCHEMA":
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/hover-state.ts b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/hover-state.ts
index 855d48091a..3ae1fcd2c2 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/hover-state.ts
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/hover-state.ts
@@ -10,7 +10,7 @@ import type {
import {
useHoverStateContext as _useHoverStateContext,
provideHoverStateContext as _provideHoverStateContext,
-} from "../../hover-state";
+} from "../../../EditorCommon";
export const KEY = "schema-pane";
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/ConnectionPane.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue
similarity index 90%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/ConnectionPane.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue
index 36c69e99ef..b2266c6104 100644
--- a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/ConnectionPane.vue
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/ConnectionPane.vue
@@ -53,6 +53,7 @@ import { useElementSize, useMounted } from "@vueuse/core";
import { head } from "lodash-es";
import { NTree, NDropdown, type TreeOption } from "naive-ui";
import { ref, computed, nextTick, watch, h } from "vue";
+import { onMounted } from "vue";
import MaskSpinner from "@/components/misc/MaskSpinner.vue";
import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener";
import {
@@ -89,7 +90,7 @@ const tabStore = useSQLEditorTabStore();
const databaseStore = useDatabaseV1Store();
const instanceStore = useInstanceV1Store();
const isLoggedIn = useIsLoggedIn();
-const { events: editorEvents } = useSQLEditorContext();
+const { events: editorEvents, showConnectionPanel } = useSQLEditorContext();
const searchHistory = useSearchHistory();
const {
state: hoverState,
@@ -206,6 +207,7 @@ const nodeProps = ({ option }: { option: TreeOption }) => {
// And ignore the fold/unfold arrow.
if (type === "database") {
setConnection(node);
+ showConnectionPanel.value = false;
}
// If the search pattern is not empty, append the selected database name to
@@ -303,7 +305,7 @@ watch(
{ immediate: true }
);
-useEmitteryEventListener(editorEvents, "tree-ready", async () => {
+const calcDefaultExpandKeys = async () => {
await nextTick();
const openingDatabaseList = resolveOpeningDatabaseListFromSQLEditorTabList();
const keys = new Set<string>();
@@ -313,17 +315,38 @@ useEmitteryEventListener(editorEvents, "tree-ready", async () => {
const nodes = treeStore.nodesByTarget("database", db);
nodes.forEach((node) => expandNodeRecursively(node.parent, keys));
});
- const tab = tabStore.currentTab;
- // Expand current tab's connected database node
- if (tab && tab.connection.database) {
- const db = useDatabaseV1Store().getDatabaseByName(tab.connection.database);
- const node = head(treeStore.nodesByTarget("database", db));
- if (node) {
- keys.add(node.key);
+ if (keys.size === 0) {
+ // Try expand till the first database node
+ const dfsWalk = (node: SQLEditorTreeNode) => {
+ if (node.meta.type === "database") {
+ expandNodeRecursively(node.parent, keys);
+ return true;
+ }
+ if (!node.children) return false;
+ for (let i = 0; i < node.children.length; i++) {
+ const child = node.children[i] as SQLEditorTreeNode;
+ if (dfsWalk(child)) {
+ return true;
+ }
+ }
+ return false;
+ };
+ for (let i = 0; i < treeStore.tree.length; i++) {
+ const node = treeStore.tree[i];
+ if (dfsWalk(node)) {
+ break;
+ }
}
}
+ console.log("defaultExpandKeys", Array.from(keys).join(","));
expandedKeys.value = Array.from(keys);
+};
+
+useEmitteryEventListener(editorEvents, "tree-ready", () => {
+ calcDefaultExpandKeys();
});
+
+onMounted(calcDefaultExpandKeys);
</script>
<style lang="postcss" scoped>
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/DatabaseHoverPanel/DatabaseHoverPanel.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseHoverPanel/DatabaseHoverPanel.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/DatabaseHoverPanel/DatabaseHoverPanel.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseHoverPanel/DatabaseHoverPanel.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/DatabaseHoverPanel/hover-state.ts b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseHoverPanel/hover-state.ts
similarity index 93%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/DatabaseHoverPanel/hover-state.ts
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseHoverPanel/hover-state.ts
index 9668b65010..e3c9cfd1c5 100644
--- a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/DatabaseHoverPanel/hover-state.ts
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseHoverPanel/hover-state.ts
@@ -2,7 +2,7 @@ import type { SQLEditorTreeNode } from "@/types";
import {
useHoverStateContext as _useHoverStateContext,
provideHoverStateContext as _provideHoverStateContext,
-} from "../../hover-state";
+} from "../../../EditorCommon";
export const KEY = "connection-pane";
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/DatabaseHoverPanel/index.ts b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseHoverPanel/index.ts
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/DatabaseHoverPanel/index.ts
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseHoverPanel/index.ts
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/FactorItem.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/FactorItem.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/FactorItem.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/FactorItem.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/FactorPanel.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/FactorPanel.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/FactorPanel.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/FactorPanel.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/FactorTag.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/FactorTag.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/FactorTag.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/FactorTag.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/FactorTags.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/FactorTags.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/FactorTags.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/FactorTags.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/GroupingBar.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/GroupingBar.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/GroupingBar.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/GroupingBar.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/index.ts b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/index.ts
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/GroupingBar/index.ts
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/GroupingBar/index.ts
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/SearchBox/index.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/index.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/SearchBox/index.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/index.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/SearchBox/useSearchHistory.ts b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/useSearchHistory.ts
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/SearchBox/useSearchHistory.ts
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/useSearchHistory.ts
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/DatabaseNode.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/DatabaseNode.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/DatabaseNode.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/DatabaseNode.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/EnvironmentNode.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/EnvironmentNode.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/EnvironmentNode.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/EnvironmentNode.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/HighlightLabelText.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/HighlightLabelText.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/HighlightLabelText.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/HighlightLabelText.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/InstanceNode.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/InstanceNode.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/InstanceNode.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/InstanceNode.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/Label.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/Label.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/Label.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/Label.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/LabelNode.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/LabelNode.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/LabelNode.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/LabelNode.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/ProjectNode.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/ProjectNode.vue
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/ProjectNode.vue
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/ProjectNode.vue
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/index.ts b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/index.ts
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/TreeNode/index.ts
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/TreeNode/index.ts
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/actions.tsx b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/actions.tsx
similarity index 90%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/actions.tsx
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/actions.tsx
index d6133fccc5..1984141230 100644
--- a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/actions.tsx
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/actions.tsx
@@ -37,7 +37,7 @@ type DropdownOptionWithTreeNode = DropdownOption & {
export const useDropdown = () => {
const router = useRouter();
- const { events: editorEvents } = useSQLEditorContext();
+ const { events: editorEvents, showConnectionPanel } = useSQLEditorContext();
const pageMode = usePageMode();
const show = ref(false);
@@ -76,18 +76,23 @@ export const useDropdown = () => {
key: "connect",
label: t("sql-editor.connect"),
icon: () => <LinkIcon class="w-4 h-4" />,
- onSelect: () => setConnection(node),
+ onSelect: () => {
+ setConnection(node);
+ showConnectionPanel.value = false;
+ },
});
items.push({
key: "connect-in-new-tab",
label: t("sql-editor.connect-in-new-tab"),
icon: () => <LinkIcon class="w-4 h-4" />,
- onSelect: () =>
+ onSelect: () => {
setConnection(
node,
{ sheet: "", mode: DEFAULT_SQL_EDITOR_TAB_MODE },
/* newTab */ true
- ),
+ );
+ showConnectionPanel.value = false;
+ },
});
}
if (allowAdmin.value) {
@@ -95,7 +100,10 @@ export const useDropdown = () => {
key: "connect-in-admin-mode",
label: t("sql-editor.connect-in-admin-mode"),
icon: () => <WrenchIcon class="w-4 h-4" />,
- onSelect: () => setConnection(node, { sheet: "", mode: "ADMIN" }),
+ onSelect: () => {
+ setConnection(node, { sheet: "", mode: "ADMIN" });
+ showConnectionPanel.value = false;
+ },
});
}
}
@@ -131,6 +139,7 @@ export const useDropdown = () => {
schema: "",
table: "",
});
+ showConnectionPanel.value = false;
},
});
}
diff --git a/frontend/src/views/sql-editor/AsidePanel/ConnectionPane/index.ts b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/index.ts
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/ConnectionPane/index.ts
rename to frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/index.ts
diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPanel.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPanel.vue
new file mode 100644
index 0000000000..fecb97b513
--- /dev/null
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPanel.vue
@@ -0,0 +1,40 @@
+<template>
+ <Drawer
+ :show="show"
+ placement="left"
+ style="--n-body-padding: 4px 0"
+ @update:show="$emit('update:show', $event)"
+ >
+ <DrawerContent
+ :title="$t('common.connection')"
+ :style="{
+ width: contentWidth,
+ }"
+ >
+ <ConnectionPane />
+ </DrawerContent>
+ </Drawer>
+</template>
+
+<script setup lang="ts">
+import { useWindowSize } from "@vueuse/core";
+import { computed } from "vue";
+import { Drawer, DrawerContent } from "@/components/v2";
+import ConnectionPane from "./ConnectionPane";
+
+defineProps<{
+ show: boolean;
+}>();
+
+defineEmits<{
+ (event: "update:show", show: boolean): void;
+}>();
+
+const { width: winWidth } = useWindowSize();
+const contentWidth = computed(() => {
+ if (winWidth.value >= 640) {
+ return "480px";
+ }
+ return "calc(100vw - 2rem)";
+});
+</script>
diff --git a/frontend/src/views/sql-editor/ConnectionPanel/index.ts b/frontend/src/views/sql-editor/ConnectionPanel/index.ts
new file mode 100644
index 0000000000..ecc11c26cb
--- /dev/null
+++ b/frontend/src/views/sql-editor/ConnectionPanel/index.ts
@@ -0,0 +1,3 @@
+import ConnectionPanel from "./ConnectionPanel.vue";
+
+export default ConnectionPanel;
diff --git a/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue b/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
index f8f45dc7bf..d363065d54 100644
--- a/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
@@ -5,25 +5,24 @@
trigger="click"
>
<template #trigger>
- <div
- class="flex flex-row justify-start items-center gap-1"
+ <NButton
+ size="small"
+ ghost
+ :type="
+ selectedDatabaseNames.length > 0 && hasBatchQueryFeature
+ ? 'primary'
+ : 'default'
+ "
@click="handleTriggerClick"
>
- <div
- class="!ml-2 w-auto h-6 px-2 border border-gray-400 flex flex-row justify-center items-center gap-1 cursor-pointer rounded hover:opacity-80"
- :class="
- selectedDatabaseNames.length > 0 && hasBatchQueryFeature
- ? 'text-accent bg-blue-50 shadow !border-accent'
- : 'text-gray-600'
- "
- >
+ <div class="flex flex-row justify-center items-center gap-1">
<span>{{ $t("sql-editor.batch-query.batch") }}</span>
<span v-if="selectedDatabaseNames.length > 0">
({{ selectedDatabaseNames.length }})
</span>
<FeatureBadge feature="bb.feature.batch-query" />
</div>
- </div>
+ </NButton>
</template>
<div class="w-128 max-h-128 overflow-y-auto p-1 pb-2">
<p class="text-gray-500 mb-1 w-full leading-4">
@@ -96,7 +95,7 @@
<script lang="ts" setup>
import type { DataTableRowKey, DataTableColumn } from "naive-ui";
-import { NPopover, NDivider, NDataTable, NTag } from "naive-ui";
+import { NPopover, NDivider, NDataTable, NTag, NButton } from "naive-ui";
import { computed, reactive, ref, watch } from "vue";
import { h } from "vue";
import { useI18n } from "vue-i18n";
diff --git a/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue b/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue
index b6e8958df5..fd29567b82 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ConnectionHolder.vue
@@ -1,12 +1,32 @@
<template>
<div class="flex items-center justify-center w-full h-full">
- <div class="flex items-start text-info">
- <heroicons-outline:lightning-bolt class="mr-1 w-5 h-5" />
- <div class="leading-5">
- <p>
- {{ $t("sql-editor.connection-holder") }}
- </p>
- </div>
+ <div class="flex items-start text-info cursor-pointer">
+ <NButton
+ type="primary"
+ ghost
+ style="
+ --n-color-hover: rgb(var(--color-accent) / 0.05);
+ --n-color-pressed: rgb(var(--color-accent) / 0.05);
+ --n-color-focus: rgb(var(--color-accent) / 0.05);
+ "
+ @click="changeConnection"
+ >
+ <template #icon>
+ <heroicons-outline:lightning-bolt class="w-5 h-5" />
+ </template>
+ {{ $t("sql-editor.connection-holder") }}
+ </NButton>
</div>
</div>
</template>
+
+<script setup lang="ts">
+import { NButton } from "naive-ui";
+import { useSQLEditorContext } from "../context";
+
+const { showConnectionPanel } = useSQLEditorContext();
+
+const changeConnection = () => {
+ showConnectionPanel.value = true;
+};
+</script>
diff --git a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
index df3ed07bb5..7140bd12a0 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ConnectionPathBar.vue
@@ -1,93 +1,115 @@
<template>
<div
- class="w-full flex flex-col sm:flex-row sm:flex-wrap lg:flex-nowrap lg:justify-between items-start bg-white overflow-hidden"
+ class="w-full shrink-0 flex flex-row flex-nowrap items-center justify-between bg-white overflow-hidden h-[42px]"
>
<div
- v-if="currentTab && !isDisconnected"
- class="flex justify-start items-center h-8 px-4 whitespace-nowrap shrink-0 gap-x-4"
+ v-if="
+ currentTab &&
+ instance.uid !== String(UNKNOWN_ID) &&
+ database.uid !== String(UNKNOWN_ID)
+ "
+ class="flex justify-start items-center h-8 px-2 whitespace-nowrap shrink-0 gap-x-2"
>
- <NPopover
- v-if="instance.uid !== String(UNKNOWN_ID)"
- :disabled="!isProductionEnvironment"
+ <NButton
+ :disabled="!projectContextReady"
+ size="small"
+ type="primary"
+ ghost
+ style="
+ --n-color-hover: rgb(var(--color-accent) / 0.05);
+ --n-color-pressed: rgb(var(--color-accent) / 0.05);
+ --n-color-focus: rgb(var(--color-accent) / 0.05);
+ "
+ @click="changeConnection"
>
- <template #trigger>
- <div
- class="inline-flex items-center px-2 border text-sm rounded-sm"
- :class="[
- isProductionEnvironment
- ? 'border-error text-error'
- : 'border-main text-main',
- ]"
- >
- {{ environment.title }}
- </div>
- </template>
- <template #default>
- <div class="max-w-[20rem]">
- {{ $t("sql-editor.sql-execute-in-production-environment") }}
- </div>
- </template>
- </NPopover>
+ <div class="flex flex-row gap-x-2 text-main">
+ <NPopover :disabled="!isProductionEnvironment">
+ <template #trigger>
+ <div
+ class="inline-flex items-center px-2 border text-sm rounded-sm"
+ :class="[
+ isProductionEnvironment
+ ? 'border-error text-error'
+ : 'border-main text-main',
+ ]"
+ >
+ {{ environment.title }}
+ </div>
+ </template>
+ <template #default>
+ <div class="max-w-[20rem]">
+ {{ $t("sql-editor.sql-execute-in-production-environment") }}
+ </div>
+ </template>
+ </NPopover>
- <label class="flex items-center text-sm space-x-1">
- <div
- v-if="instance.uid !== String(UNKNOWN_ID)"
- class="flex items-center"
- >
- <InstanceV1EngineIcon :instance="instance" show-status />
- <span class="ml-2">{{ instance.title }}</span>
- </div>
- <div
- v-if="database.uid !== String(UNKNOWN_ID)"
- class="flex items-center"
- >
- <span class="mx-2">
- <heroicons-solid:chevron-right
- class="flex-shrink-0 h-4 w-4 text-control-light"
- />
- </span>
- <heroicons-outline:database />
- <span class="ml-2">{{ database.databaseName }}</span>
- </div>
+ <div class="flex items-center">
+ <InstanceV1EngineIcon :instance="instance" show-status />
+ <span class="ml-2">{{ instance.title }}</span>
+ </div>
+ <div class="flex items-center">
+ <span class="">
+ <heroicons-solid:chevron-right
+ class="flex-shrink-0 h-4 w-4 text-control-light"
+ />
+ </span>
+ <heroicons-outline:database />
+ <span class="ml-2">{{ database.databaseName }}</span>
- <div
- v-if="showBatchQuerySelector"
- class="relative ml-2 flex items-center"
- >
- <BatchQueryDatabasesSelector />
+ <HideInStandaloneMode>
+ <ReadonlyDatasourceHint :instance="instance" class="ml-1" />
+ </HideInStandaloneMode>
+ </div>
</div>
- </label>
+ </NButton>
- <ReadonlyDatasourceHint :instance="instance" />
+ <div v-if="showBatchQuerySelector" class="relative flex items-center">
+ <BatchQueryDatabasesSelector />
+ </div>
</div>
<div
v-else
- class="flex justify-start items-center h-8 px-4 whitespace-nowrap overflow-x-auto"
+ class="flex justify-start items-center h-8 px-2 whitespace-nowrap overflow-x-auto"
>
- <div class="text-sm text-control">
+ <NButton
+ :disabled="!projectContextReady"
+ size="small"
+ type="primary"
+ ghost
+ style="
+ --n-color-hover: rgb(var(--color-accent) / 0.05);
+ --n-color-pressed: rgb(var(--color-accent) / 0.05);
+ --n-color-focus: rgb(var(--color-accent) / 0.05);
+ "
+ @click="changeConnection"
+ >
{{ $t("sql-editor.connection-holder") }}
- </div>
+ </NButton>
</div>
</div>
</template>
<script lang="ts" setup>
-import { NPopover } from "naive-ui";
+import { NButton, NPopover } from "naive-ui";
import { storeToRefs } from "pinia";
import { computed } from "vue";
+import HideInStandaloneMode from "@/components/misc/HideInStandaloneMode.vue";
import { InstanceV1EngineIcon } from "@/components/v2";
import {
useConnectionOfCurrentSQLEditorTab,
+ useSQLEditorStore,
useSQLEditorTabStore,
} from "@/store";
import { UNKNOWN_ID } from "@/types";
import { EnvironmentTier } from "@/types/proto/v1/environment_service";
+import { useSQLEditorContext } from "../context";
import BatchQueryDatabasesSelector from "./BatchQueryDatabasesSelector.vue";
import ReadonlyDatasourceHint from "./ReadonlyDatasourceHint.vue";
-const tabStore = useSQLEditorTabStore();
-const { currentTab, isDisconnected } = storeToRefs(tabStore);
+const { currentTab, isDisconnected } = storeToRefs(useSQLEditorTabStore());
+const { showConnectionPanel } = useSQLEditorContext();
+const { projectContextReady } = storeToRefs(useSQLEditorStore());
const { instance, database, environment } =
useConnectionOfCurrentSQLEditorTab();
@@ -113,4 +135,8 @@ const showBatchQuerySelector = computed(() => {
tab.mode !== "ADMIN"
);
});
+
+const changeConnection = () => {
+ showConnectionPanel.value = true;
+};
</script>
diff --git a/frontend/src/views/sql-editor/EditorCommon/ReadonlyDatasourceHint.vue b/frontend/src/views/sql-editor/EditorCommon/ReadonlyDatasourceHint.vue
index dd4a7567ba..34507fe77f 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ReadonlyDatasourceHint.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ReadonlyDatasourceHint.vue
@@ -2,7 +2,8 @@
<NPopover v-if="showReadonlyDatasourceHint" trigger="hover">
<template #trigger>
<heroicons-outline:information-circle
- class="h-5 w-5 flex-shrink-0 mr-2 text-info"
+ class="h-5 w-5 flex-shrink-0 text-info"
+ v-bind="$attrs"
/>
</template>
<p class="py-1">
diff --git a/frontend/src/views/sql-editor/AsidePanel/hover-state.ts b/frontend/src/views/sql-editor/EditorCommon/hover-state.ts
similarity index 100%
rename from frontend/src/views/sql-editor/AsidePanel/hover-state.ts
rename to frontend/src/views/sql-editor/EditorCommon/hover-state.ts
diff --git a/frontend/src/views/sql-editor/EditorCommon/index.ts b/frontend/src/views/sql-editor/EditorCommon/index.ts
index e0c0dbbd7a..68ef2afc0a 100644
--- a/frontend/src/views/sql-editor/EditorCommon/index.ts
+++ b/frontend/src/views/sql-editor/EditorCommon/index.ts
@@ -19,3 +19,5 @@ export {
DisconnectedIcon,
SheetConnectionIcon,
};
+
+export * from "./hover-state";
diff --git a/frontend/src/views/sql-editor/EditorPanel/EditorPanel.vue b/frontend/src/views/sql-editor/EditorPanel/EditorPanel.vue
index a5a139bf1f..da37d202ee 100644
--- a/frontend/src/views/sql-editor/EditorPanel/EditorPanel.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/EditorPanel.vue
@@ -1,12 +1,13 @@
<template>
<div class="flex h-full w-full flex-col justify-start items-start">
+ <ConnectionPathBar class="border-b" />
+
<template v-if="!tab || tab.editMode === 'SQL-EDITOR'">
<EditorAction @execute="handleExecute" />
<ConnectionHolder v-if="!tab" />
- <template v-else>
- <ConnectionPathBar />
+ <template v-else>
<Suspense>
<SQLEditor @execute="handleExecute" />
<template #fallback>
diff --git a/frontend/src/views/sql-editor/SQLEditorPage.vue b/frontend/src/views/sql-editor/SQLEditorPage.vue
index d3faa08185..ba66e5c7fc 100644
--- a/frontend/src/views/sql-editor/SQLEditorPage.vue
+++ b/frontend/src/views/sql-editor/SQLEditorPage.vue
@@ -98,6 +98,8 @@
<li>[Page]currentTab.id: {{ currentTab?.id }}</li>
<li>[Page]currentTab.connection: {{ currentTab?.connection }}</li>
</teleport>
+
+ <ConnectionPanel v-model:show="showConnectionPanel" />
</div>
</template>
@@ -124,6 +126,7 @@ import {
} from "@/utils";
import AccessDenied from "./AccessDenied.vue";
import AsidePanel from "./AsidePanel";
+import ConnectionPanel from "./ConnectionPanel";
import EditorPanel from "./EditorPanel/EditorPanel.vue";
import ReadonlyModeNotSupported from "./ReadonlyModeNotSupported.vue";
import ResultPanel from "./ResultPanel";
@@ -150,7 +153,7 @@ const router = useRouter();
const databaseStore = useDatabaseV1Store();
const actuatorStore = useActuatorV1Store();
const tabStore = useSQLEditorTabStore();
-const { events: editorEvents } = useSQLEditorContext();
+const { events: editorEvents, showConnectionPanel } = useSQLEditorContext();
const { showPanel: showSheetPanel } = useSheetContext();
const { currentTab, isDisconnected } = storeToRefs(tabStore);
diff --git a/frontend/src/views/sql-editor/TerminalPanel/TerminalPanelV1.vue b/frontend/src/views/sql-editor/TerminalPanel/TerminalPanelV1.vue
index 8709533d48..aae9ad79a1 100644
--- a/frontend/src/views/sql-editor/TerminalPanel/TerminalPanelV1.vue
+++ b/frontend/src/views/sql-editor/TerminalPanel/TerminalPanelV1.vue
@@ -2,10 +2,10 @@
<div
class="flex h-full w-full flex-col justify-start items-start overflow-hidden bg-dark-bg"
>
- <EditorAction @execute="handleExecute" @clear-screen="handleClearScreen" />
-
<ConnectionPathBar />
+ <EditorAction @execute="handleExecute" @clear-screen="handleClearScreen" />
+
<div
v-if="!tabStore.isDisconnected"
ref="queryListContainerRef"
diff --git a/frontend/src/views/sql-editor/context.ts b/frontend/src/views/sql-editor/context.ts
index 7083f99cb8..5c82a62fb8 100644
--- a/frontend/src/views/sql-editor/context.ts
+++ b/frontend/src/views/sql-editor/context.ts
@@ -4,7 +4,7 @@ import { inject, provide, ref } from "vue";
import { useSQLEditorStore } from "@/store";
import type { ComposedDatabase, SQLEditorTab } from "@/types";
-export type AsidePanelTab = "CONNECTION" | "SCHEMA" | "WORKSHEET" | "HISTORY";
+export type AsidePanelTab = "SCHEMA" | "WORKSHEET" | "HISTORY";
type SQLEditorEvents = Emittery<{
"save-sheet": { tab: SQLEditorTab; editTitle?: boolean };
@@ -22,6 +22,7 @@ type SQLEditorEvents = Emittery<{
export type SQLEditorContext = {
asidePanelTab: Ref<AsidePanelTab>;
+ showConnectionPanel: Ref<boolean>;
showAIChatBox: Ref<boolean>;
schemaViewer: Ref<
| {
@@ -49,6 +50,7 @@ export const provideSQLEditorContext = () => {
const editorStore = useSQLEditorStore();
const context: SQLEditorContext = {
asidePanelTab: ref("WORKSHEET"),
+ showConnectionPanel: ref(false),
showAIChatBox: ref(false),
schemaViewer: ref(undefined),
events: new Emittery(),