Skip to content

Commit 26e5afc

Browse files
committed
feat(connections): toggle connect button label/icon by connection state
When a connection is already active, the primary button now shows a log-out icon and 'Close Connection' tooltip instead of 'Connect', which implied reconnecting.
1 parent 742e8d4 commit 26e5afc

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

‎src/components/connections/ServerCard.vue‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ const handleEdit = () => emit('edit', props.connection)
9393
const handleDelete = () => emit('delete', props.connection)
9494
const handleDuplicate = () => emit('duplicate', props.connection)
9595
const handleDisconnect = () => emit('disconnect', props.connection)
96+
97+
const isConnected = computed(() => props.connectionStatus === ConnectionStatus.CONNECTED)
98+
const connectTooltip = computed(() =>
99+
isConnected.value ? t('components.serverCard.actions.closeConnection') : t('components.serverCard.actions.connect'),
100+
)
96101
</script>
97102

98103
<template>
@@ -229,6 +234,24 @@ const handleDisconnect = () => emit('disconnect', props.connection)
229234
<TooltipTrigger as-child>
230235
<Button variant="ghost" size="icon" class="h-8 w-8" @click="handleConnect">
231236
<svg
237+
v-if="isConnected"
238+
xmlns="http://www.w3.org/2000/svg"
239+
width="24"
240+
height="24"
241+
viewBox="0 0 24 24"
242+
fill="none"
243+
stroke="currentColor"
244+
stroke-width="2"
245+
stroke-linecap="round"
246+
stroke-linejoin="round"
247+
class="h-4 w-4"
248+
>
249+
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
250+
<polyline points="16 17 21 12 16 7" />
251+
<line x1="21" x2="9" y1="12" y2="12" />
252+
</svg>
253+
<svg
254+
v-else
232255
xmlns="http://www.w3.org/2000/svg"
233256
width="24"
234257
height="24"
@@ -247,7 +270,7 @@ const handleDisconnect = () => emit('disconnect', props.connection)
247270
</Button>
248271
</TooltipTrigger>
249272
<TooltipContent>
250-
<p>{{ t('components.serverCard.actions.connect') }}</p>
273+
<p>{{ connectTooltip }}</p>
251274
</TooltipContent>
252275
</Tooltip>
253276
</TooltipProvider>

0 commit comments

Comments
 (0)