diff --git a/packages/web/src/appobj/ConnectionAppObject.svelte b/packages/web/src/appobj/ConnectionAppObject.svelte index 854a128b3..e67d49107 100644 --- a/packages/web/src/appobj/ConnectionAppObject.svelte +++ b/packages/web/src/appobj/ConnectionAppObject.svelte @@ -16,6 +16,7 @@ import openNewTab from '../utility/openNewTab'; import { getDatabaseMenuItems } from './DatabaseAppObject.svelte'; import getElectron from '../utility/getElectron'; + import getConnectionLabel from '../utility/getConnectionLabel'; export let data; @@ -66,7 +67,7 @@ }; const handleDelete = () => { showModal(ConfirmModal, { - message: `Really delete connection ${data.displayName || data.server}?`, + message: `Really delete connection ${getConnectionLabel(data)}?`, onConfirm: () => axiosInstance.post('connections/delete', data), }); }; @@ -74,7 +75,7 @@ axiosInstance.post('connections/save', { ...data, _id: undefined, - displayName: `${data.displayName || data.server} - copy`, + displayName: `${getConnectionLabel(data)} - copy`, }); }; const handleCreateDatabase = () => { @@ -90,7 +91,7 @@ }); }; const handleNewQuery = () => { - const tooltip = `${data.displayName || data.server}`; + const tooltip = `${getConnectionLabel(data)}`; openNewTab({ title: 'Query #', icon: 'img sql-file', @@ -172,30 +173,12 @@ statusTitle = null; } } - - // const handleEdit = () => { - // showModal(modalState => ); - // }; - // const handleDelete = () => { - // showModal(modalState => ( - // axios.post('connections/delete', data)} - // /> - // )); - // }; - // const handleCreateDatabase = () => { - // showModal(modalState => ); - // }; { - const tooltip = `${connection.displayName || connection.server}\n${name}`; + const tooltip = `${getConnectionLabel(connection)}\n${name}`; openNewTab({ title: 'Query #', icon: 'img sql-file', @@ -66,6 +66,8 @@
@@ -33,10 +35,10 @@ {databaseName}
{/if} - {#if connection && (connection.displayName || connection.server)} + {#if connectionLabel}
- {connection.displayName || connection.server} + {connectionLabel}
{/if} {#if connection && connection.user} diff --git a/packages/web/src/widgets/TabsPanel.svelte b/packages/web/src/widgets/TabsPanel.svelte index 34092324c..9ce64bbbb 100644 --- a/packages/web/src/widgets/TabsPanel.svelte +++ b/packages/web/src/widgets/TabsPanel.svelte @@ -49,7 +49,7 @@ if (tab.props && tab.props.conid && tab.props.database) return tab.props.database; if (tab.props && tab.props.conid) { const connection = connectionList?.find(x => x._id == tab.props.conid); - if (connection) return connection.displayName || connection.server; + if (connection) return getConnectionLabel(connection.displayName, { allowExplicitDatabase: false }); return '???'; } if (tab.props && tab.props.archiveFolder) return tab.props.archiveFolder; @@ -124,6 +124,7 @@ import tabs from '../tabs'; import { setSelectedTab } from '../utility/common'; import contextMenu from '../utility/contextMenu'; + import getConnectionLabel from '../utility/getConnectionLabel'; import { getConnectionInfo, useConnectionList } from '../utility/metadataLoaders'; import { duplicateTab } from '../utility/openNewTab';