Skip to content

Commit bd27080

Browse files
committed
feat(connections): add disconnect action to connected connection cards
The home panel action list now shows a Disconnect item for connected connections, closing the active session instead of requiring the connect button toggle.
1 parent 9353509 commit bd27080

4 files changed

Lines changed: 44 additions & 0 deletions

File tree

‎src/components/connections/ServerCard.vue‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const emit = defineEmits<{
2727
(e: 'edit', connection: ServerConnection): void
2828
(e: 'delete', connection: ServerConnection): void
2929
(e: 'duplicate', connection: ServerConnection): void
30+
(e: 'disconnect', connection: ServerConnection): void
3031
}>()
3132
3233
const { t } = useI18n()
@@ -91,6 +92,7 @@ const handleDoubleClick = () => emit('dblclick', props.connection)
9192
const handleEdit = () => emit('edit', props.connection)
9293
const handleDelete = () => emit('delete', props.connection)
9394
const handleDuplicate = () => emit('duplicate', props.connection)
95+
const handleDisconnect = () => emit('disconnect', props.connection)
9496
</script>
9597

9698
<template>
@@ -272,6 +274,29 @@ const handleDuplicate = () => emit('duplicate', props.connection)
272274
</Button>
273275
</DropdownMenuTrigger>
274276
<DropdownMenuContent align="end">
277+
<DropdownMenuItem
278+
v-if="connectionStatus === ConnectionStatus.CONNECTED"
279+
@click="handleDisconnect"
280+
>
281+
<svg
282+
xmlns="http://www.w3.org/2000/svg"
283+
width="24"
284+
height="24"
285+
viewBox="0 0 24 24"
286+
fill="none"
287+
stroke="currentColor"
288+
stroke-width="2"
289+
stroke-linecap="round"
290+
stroke-linejoin="round"
291+
class="mr-2 h-4 w-4"
292+
>
293+
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
294+
<polyline points="16 17 21 12 16 7" />
295+
<line x1="21" x2="9" y1="12" y2="12" />
296+
</svg>
297+
{{ t('components.serverCard.actions.disconnect') }}
298+
</DropdownMenuItem>
299+
<DropdownMenuSeparator v-if="connectionStatus === ConnectionStatus.CONNECTED" />
275300
<DropdownMenuItem @click="handleEdit">
276301
<svg
277302
xmlns="http://www.w3.org/2000/svg"

‎src/lang/enUS.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ export const enUS = {
11121112
serverCard: {
11131113
actions: {
11141114
connect: 'Connect',
1115+
disconnect: 'Disconnect',
11151116
edit: 'Edit',
11161117
duplicate: 'Duplicate',
11171118
delete: 'Delete',
@@ -1167,6 +1168,8 @@ export const enUS = {
11671168
showErDiagram: 'Show ER Diagram',
11681169
dropTable: 'Drop Table',
11691170
truncateTable: 'Truncate',
1171+
newQuery: 'New Query',
1172+
refresh: 'Refresh',
11701173
},
11711174
savedQueryActions: {
11721175
open: 'Open',

‎src/lang/zhCN.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ export const zhCN = {
11111111
serverCard: {
11121112
actions: {
11131113
connect: '连接',
1114+
disconnect: '断开连接',
11141115
edit: '编辑',
11151116
duplicate: '复制',
11161117
delete: '删除',
@@ -1166,6 +1167,8 @@ export const zhCN = {
11661167
showErDiagram: '展示ER图表',
11671168
dropTable: '删除表',
11681169
truncateTable: '清空',
1170+
newQuery: '新建查询',
1171+
refresh: '刷新',
11691172
},
11701173
savedQueryActions: {
11711174
open: '打开',

‎src/pages/ConnectionsPage.vue‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,18 @@ function handleDuplicateConnection(connection: ServerConnection) {
186186
isFormDialogOpen.value = true
187187
}
188188
189+
async function handleDisconnect(connection: ServerConnection) {
190+
connectError.value = null
191+
if (!connection.id)
192+
return
193+
try {
194+
await connectionStore.disconnect(connection.id)
195+
}
196+
catch (error) {
197+
connectError.value = error instanceof Error ? error.message : String(error)
198+
}
199+
}
200+
189201
async function handleSaveConnection(connection: ServerConnection) {
190202
const result = await connectionStore.saveConnection(connection)
191203
if (!result.success) {
@@ -459,6 +471,7 @@ function getConnectionStatus(connectionId: string | undefined): ConnectionStatus
459471
@edit="handleEditConnection"
460472
@delete="handleDeleteConnection"
461473
@duplicate="handleDuplicateConnection"
474+
@disconnect="handleDisconnect"
462475
/>
463476

464477
<!-- Add New Connection Card -->

0 commit comments

Comments
 (0)