diff --git a/src/components/sidebar/TreeItem.vue b/src/components/sidebar/TreeItem.vue
index 82a26ee491..28cf3c089c 100644
--- a/src/components/sidebar/TreeItem.vue
+++ b/src/components/sidebar/TreeItem.vue
@@ -4,7 +4,7 @@ import { useI18n } from "vue-i18n";
import {
Database, Table, Columns3, Eye, ChevronRight, ChevronDown,
Loader2, FolderOpen, Trash2, TerminalSquare, RefreshCw,
- Copy, TableProperties, Key, Link, Zap, ListTree, Pencil,
+ Copy, TableProperties, Key, Link, Zap, ListTree, Pencil, Plug, Unplug,
} from "lucide-vue-next";
import {
ContextMenu, ContextMenuContent, ContextMenuItem,
@@ -15,6 +15,10 @@ import { useQueryStore } from "@/stores/queryStore";
import type { TreeNode, TreeNodeType } from "@/types/database";
import * as api from "@/lib/tauri";
import DatabaseIcon from "@/components/icons/DatabaseIcon.vue";
+import {
+ Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter,
+} from "@/components/ui/dialog";
+import { Button } from "@/components/ui/button";
const { t } = useI18n();
const connectionStore = useConnectionStore();
@@ -175,7 +179,13 @@ async function refresh() {
await toggle();
}
+const showDeleteConfirm = ref(false);
+
function deleteConnection() {
+ showDeleteConfirm.value = true;
+}
+
+function confirmDelete() {
const node = props.node;
if (node.connectionId) {
connectionStore.disconnect(node.connectionId);
@@ -193,8 +203,19 @@ function editConnection() {
}
}
+function disconnectConnection() {
+ if (props.node.connectionId) {
+ connectionStore.disconnect(props.node.connectionId);
+ props.node.isExpanded = false;
+ props.node.children = [];
+ }
+}
+
const canExpand = !leafTypes.has(props.node.type);
const paddingLeft = `${props.depth * 16 + 8}px`;
+const isConnected = computed(() =>
+ props.node.type === "connection" && !!props.node.connectionId && connectionStore.connectedIds.has(props.node.connectionId)
+);
const CHILDREN_PAGE_SIZE = 100;
const displayLimit = ref(CHILDREN_PAGE_SIZE);
@@ -235,6 +256,7 @@ function showMore() {
{{ isGroupLabel(node) ? t(node.label) : node.label }}
+
@@ -252,9 +274,12 @@ function showMore() {
-
+
{{ t('contextMenu.openConnection') }}
+
+ {{ t('contextMenu.closeConnection') }}
+
{{ t('contextMenu.newQuery') }}
@@ -305,4 +330,17 @@ function showMore() {
+
+
diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts
index 86c5d4356f..2e79ab259f 100644
--- a/src/i18n/locales/en.ts
+++ b/src/i18n/locales/en.ts
@@ -72,7 +72,7 @@ export default {
},
welcome: {
title: "Database Workspace",
- subtitle: "Choose a connection on the left to browse schema, or open a query tab directly. DBX supports multiple databases, query history, grid editing, and an AI SQL assistant.",
+ subtitle: "Choose a connection on the left to browse schema, or open a query tab directly.",
connections: "Connections",
connected: "Connected",
databaseTypes: "Database Types",
@@ -81,6 +81,8 @@ export default {
shortcuts: "Shortcuts",
shortcutsHint: "Start the next action from here.",
tip: "You can also expand connections on the left and right-click databases or tables for more actions.",
+ tipSidebar: "Click a table on the left to view data",
+ tipExecute: "to execute query",
},
common: {
language: "Language",
@@ -124,6 +126,8 @@ export default {
openConnection: "Open Connection",
closeConnection: "Close Connection",
deleteConnection: "Delete Connection",
+ confirmDeleteTitle: "Delete Connection",
+ confirmDeleteMessage: "Are you sure you want to delete \"{name}\"? This cannot be undone.",
editConnection: "Edit Connection",
newQuery: "New Query",
viewData: "View Data",
diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts
index 08eddb0e68..4642252a2f 100644
--- a/src/i18n/locales/zh-CN.ts
+++ b/src/i18n/locales/zh-CN.ts
@@ -124,6 +124,8 @@ export default {
openConnection: "打开连接",
closeConnection: "关闭连接",
deleteConnection: "删除连接",
+ confirmDeleteTitle: "删除连接",
+ confirmDeleteMessage: "确定要删除「{name}」吗?此操作不可撤销。",
editConnection: "编辑连接",
newQuery: "新建查询",
viewData: "查看数据",
diff --git a/src/stores/connectionStore.ts b/src/stores/connectionStore.ts
index b49a65bf9d..3c6a757f67 100644
--- a/src/stores/connectionStore.ts
+++ b/src/stores/connectionStore.ts
@@ -74,7 +74,11 @@ export const useConnectionStore = defineStore("connection", () => {
async function disconnect(connectionId: string) {
await api.disconnectDb(connectionId);
connectedIds.value.delete(connectionId);
- treeNodes.value = treeNodes.value.filter((n) => n.id !== connectionId);
+ const node = treeNodes.value.find((n) => n.connectionId === connectionId);
+ if (node) {
+ node.isExpanded = false;
+ node.children = [];
+ }
if (activeConnectionId.value === connectionId) {
activeConnectionId.value = null;
}