table tab tooltip

This commit is contained in:
Jan Prochazka 2020-03-03 07:45:35 +01:00
parent e2e46ec398
commit a4a470de45
5 changed files with 39 additions and 1 deletions

View File

@ -6,6 +6,16 @@ export interface OpenedDatabaseConnection {
structure: DatabaseInfo; structure: DatabaseInfo;
subprocess: ChildProcess; subprocess: ChildProcess;
} }
export interface StoredConnection {
engine: string;
server: string;
port?: number;
user: string;
password: string;
displayName: string;
}
export * from "./engines"; export * from "./engines";
export * from "./dbinfo"; export * from "./dbinfo";
export * from "./query"; export * from "./query";

View File

@ -47,11 +47,17 @@ export default function TabsPanel() {
setOpenedTabs(files => files.filter(x => x.tabid != tabid)); setOpenedTabs(files => files.filter(x => x.tabid != tabid));
} }
}; };
console.log(
't',
tabs.map(x => x.tooltip)
);
return ( return (
<> <>
{tabs.map(tab => ( {tabs.map(tab => (
<FileTabItem <FileTabItem
{...tab} {...tab}
title={tab.tooltip}
key={tab.tabid} key={tab.tabid}
onClick={() => handleTabClick(tab.tabid)} onClick={() => handleTabClick(tab.tabid)}
onMouseUp={e => handleMouseUp(e, tab.tabid)} onMouseUp={e => handleMouseUp(e, tab.tabid)}

View File

@ -6,10 +6,16 @@ import ConnectionModal from '../modals/ConnectionModal';
import axios from '../utility/axios'; import axios from '../utility/axios';
import { openNewTab } from '../utility/common'; import { openNewTab } from '../utility/common';
import { useSetOpenedTabs } from '../utility/globalState'; 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, { openNewTab(setOpenedTabs, {
title: pureName, title: pureName,
tooltip,
icon: 'table2.svg', icon: 'table2.svg',
tabComponent, tabComponent,
props: { props: {

View File

@ -0,0 +1,4 @@
export default function fullDisplayName({ schemaName, pureName }) {
if (schemaName) return `${schemaName}.${pureName}`;
return pureName;
}

View File

@ -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;
}