diff --git a/frontend/src/components/sidebar/ConnectionTree.vue b/frontend/src/components/sidebar/ConnectionTree.vue index ffd60a0..87b35a6 100644 --- a/frontend/src/components/sidebar/ConnectionTree.vue +++ b/frontend/src/components/sidebar/ConnectionTree.vue @@ -21,7 +21,7 @@ import usePreferencesStore from 'stores/preferences.js' const themeVars = useThemeVars() const i18n = useI18n() -const openingConnection = ref(false) +const connectingServer = ref('') const connectionStore = useConnectionStore() const tabStore = useTabStore() const prefStore = usePreferencesStore() @@ -287,18 +287,21 @@ const onUpdateSelectedKeys = (keys, option) => { */ const openConnection = async (name) => { try { + connectingServer.value = name if (!connectionStore.isConnected(name)) { - openingConnection.value = true await connectionStore.openConnection(name) } - tabStore.upsertTab({ - server: name, - }) + // check if connection already canceled before finish open + if (!isEmpty(connectingServer.value)) { + tabStore.upsertTab({ + server: name, + }) + } } catch (e) { $message.error(e.message) // node.isLeaf = undefined } finally { - openingConnection.value = false + connectingServer.value = '' } } @@ -467,6 +470,13 @@ const handleDrop = ({ node, dragNode, dropPosition }) => { connectionStore.connections = Array.from(connectionStore.connections) saveSort() } + +const onCancelOpen = () => { + if (!isEmpty(connectingServer.value)) { + connectionStore.closeConnection(connectingServer.value) + connectingServer.value = '' + } +}