diff --git a/packages/types/index.d.ts b/packages/types/index.d.ts index a5356c50d..193612d5c 100644 --- a/packages/types/index.d.ts +++ b/packages/types/index.d.ts @@ -6,6 +6,16 @@ export interface OpenedDatabaseConnection { structure: DatabaseInfo; subprocess: ChildProcess; } + +export interface StoredConnection { + engine: string; + server: string; + port?: number; + user: string; + password: string; + displayName: string; +} + export * from "./engines"; export * from "./dbinfo"; export * from "./query"; diff --git a/packages/web/src/TabsPanel.js b/packages/web/src/TabsPanel.js index 963f90c88..64ee14621 100644 --- a/packages/web/src/TabsPanel.js +++ b/packages/web/src/TabsPanel.js @@ -47,11 +47,17 @@ export default function TabsPanel() { setOpenedTabs(files => files.filter(x => x.tabid != tabid)); } }; + console.log( + 't', + tabs.map(x => x.tooltip) + ); + return ( <> {tabs.map(tab => ( handleTabClick(tab.tabid)} onMouseUp={e => handleMouseUp(e, tab.tabid)} diff --git a/packages/web/src/appobj/tableAppObject.js b/packages/web/src/appobj/tableAppObject.js index a19d8d7b4..b8ba53e7b 100644 --- a/packages/web/src/appobj/tableAppObject.js +++ b/packages/web/src/appobj/tableAppObject.js @@ -6,10 +6,16 @@ import ConnectionModal from '../modals/ConnectionModal'; import axios from '../utility/axios'; import { openNewTab } from '../utility/common'; import { useSetOpenedTabs } from '../utility/globalState'; +import getConnectionInfo from '../utility/getConnectionInfo'; +import fullDisplayName from '../utility/fullDisplayName'; + +async function openTableDetail(setOpenedTabs, tabComponent, { schemaName, pureName, conid, database }) { + const connection = await getConnectionInfo(conid); + const tooltip = `${connection.displayName || connection.server}\n${database}\n${fullDisplayName({schemaName, pureName})}`; -function openTableDetail(setOpenedTabs, tabComponent, { schemaName, pureName, conid, database }) { openNewTab(setOpenedTabs, { title: pureName, + tooltip, icon: 'table2.svg', tabComponent, props: { diff --git a/packages/web/src/utility/fullDisplayName.js b/packages/web/src/utility/fullDisplayName.js new file mode 100644 index 000000000..49574a291 --- /dev/null +++ b/packages/web/src/utility/fullDisplayName.js @@ -0,0 +1,4 @@ +export default function fullDisplayName({ schemaName, pureName }) { + if (schemaName) return `${schemaName}.${pureName}`; + return pureName; +} diff --git a/packages/web/src/utility/getConnectionInfo.js b/packages/web/src/utility/getConnectionInfo.js new file mode 100644 index 000000000..9ab0a79fb --- /dev/null +++ b/packages/web/src/utility/getConnectionInfo.js @@ -0,0 +1,12 @@ +import axios from './axios'; + +export default async function getConnectionInfo(conid) { + const resp = await axios.request({ + method: 'get', + params: { conid }, + url: 'connections/get', + }); + /** @type {import('@dbgate/types').StoredConnection} */ + const res = resp.data; + return res; +}