mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-02 12:33:58 +00:00
new UX - fixed support for singledb connections
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
const databases = getLocalStorage(`database_list_${_id}`) || [];
|
const databases = getLocalStorage(`database_list_${_id}`) || [];
|
||||||
return filterName(filter, ...databases.map(x => x.name));
|
return filterName(filter, ...databases.map(x => x.name));
|
||||||
};
|
};
|
||||||
export function openConnection(connection) {
|
export function openConnection(connection, disableExpand = false) {
|
||||||
if (connection.singleDatabase) {
|
if (connection.singleDatabase) {
|
||||||
if (getOpenedSingleDatabaseConnections().includes(connection._id)) {
|
if (getOpenedSingleDatabaseConnections().includes(connection._id)) {
|
||||||
return;
|
return;
|
||||||
@@ -37,7 +37,10 @@
|
|||||||
conid: connection._id,
|
conid: connection._id,
|
||||||
keepOpen: true,
|
keepOpen: true,
|
||||||
});
|
});
|
||||||
expandedConnections.update(x => _.uniq([...x, connection._id]));
|
|
||||||
|
if (!disableExpand) {
|
||||||
|
expandedConnections.update(x => _.uniq([...x, connection._id]));
|
||||||
|
}
|
||||||
|
|
||||||
// if (!config.runAsPortal && getCurrentSettings()['defaultAction.connectionClick'] != 'connect') {
|
// if (!config.runAsPortal && getCurrentSettings()['defaultAction.connectionClick'] != 'connect') {
|
||||||
// expandedConnections.update(x => _.uniq([...x, connection._id]));
|
// expandedConnections.update(x => _.uniq([...x, connection._id]));
|
||||||
@@ -132,8 +135,8 @@
|
|||||||
|
|
||||||
const electron = getElectron();
|
const electron = getElectron();
|
||||||
|
|
||||||
const handleConnect = () => {
|
const handleConnect = (disableExpand = false) => {
|
||||||
openConnection(data);
|
openConnection(data, disableExpand);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOpenConnectionTab = () => {
|
const handleOpenConnectionTab = () => {
|
||||||
@@ -148,12 +151,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDoubleClick = async () => {
|
const handleDoubleClick = async () => {
|
||||||
const config = getCurrentConfig();
|
// const config = getCurrentConfig();
|
||||||
if (config.runAsPortal) {
|
// if (config.runAsPortal) {
|
||||||
await tick();
|
// await tick();
|
||||||
handleConnect();
|
// handleConnect(true);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if ($openedSingleDatabaseConnections.includes(data._id)) {
|
if ($openedSingleDatabaseConnections.includes(data._id)) {
|
||||||
switchCurrentDatabase({ connection: data, name: data.defaultDatabase });
|
switchCurrentDatabase({ connection: data, name: data.defaultDatabase });
|
||||||
return;
|
return;
|
||||||
@@ -161,17 +165,28 @@
|
|||||||
if ($openedConnections.includes(data._id)) {
|
if ($openedConnections.includes(data._id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await tick();
|
||||||
|
handleConnect(true);
|
||||||
|
|
||||||
if (getCurrentSettings()['defaultAction.connectionClick'] == 'openDetails') {
|
// if (getCurrentSettings()['defaultAction.connectionClick'] == 'openDetails') {
|
||||||
handleOpenConnectionTab();
|
// handleOpenConnectionTab();
|
||||||
} else {
|
// } else {
|
||||||
await tick();
|
// await tick();
|
||||||
handleConnect();
|
// handleConnect();
|
||||||
}
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClick = async e => {
|
const handleClick = async e => {
|
||||||
focusedConnectionOrDatabase.set({ conid: data?._id });
|
focusedConnectionOrDatabase.set({
|
||||||
|
conid: data?._id,
|
||||||
|
connection: data,
|
||||||
|
database: data.singleDatabase ? data.defaultDatabase : null,
|
||||||
|
});
|
||||||
|
console.log('SET focusedConnectionOrDatabase', {
|
||||||
|
conid: data?._id,
|
||||||
|
connection: data,
|
||||||
|
database: data.singleDatabase ? data.defaultDatabase : null,
|
||||||
|
});
|
||||||
openNewTab({
|
openNewTab({
|
||||||
title: getConnectionLabel(data),
|
title: getConnectionLabel(data),
|
||||||
icon: 'img connection',
|
icon: 'img connection',
|
||||||
@@ -344,8 +359,8 @@
|
|||||||
title={getConnectionLabel(data, { showUnsaved: true })}
|
title={getConnectionLabel(data, { showUnsaved: true })}
|
||||||
icon={data.singleDatabase ? 'img database' : 'img server'}
|
icon={data.singleDatabase ? 'img database' : 'img server'}
|
||||||
isBold={data.singleDatabase
|
isBold={data.singleDatabase
|
||||||
? _.get($currentDatabase, 'connection._id') == data._id && _.get($currentDatabase, 'name') == data.defaultDatabase
|
? $currentDatabase?.connection?._id == data._id && $currentDatabase?.name == data.defaultDatabase
|
||||||
: _.get($currentDatabase, 'connection._id') == data._id}
|
: $currentDatabase?.connection?._id == data._id}
|
||||||
statusIcon={statusIcon || engineStatusIcon}
|
statusIcon={statusIcon || engineStatusIcon}
|
||||||
statusTitle={statusTitle || engineStatusTitle}
|
statusTitle={statusTitle || engineStatusTitle}
|
||||||
statusTitleToCopy={statusTitle || engineStatusTitle}
|
statusTitleToCopy={statusTitle || engineStatusTitle}
|
||||||
@@ -356,11 +371,14 @@
|
|||||||
on:click={handleClick}
|
on:click={handleClick}
|
||||||
on:dblclick
|
on:dblclick
|
||||||
on:expand
|
on:expand
|
||||||
on:dblclick={handleConnect}
|
on:dblclick={handleDoubleClick}
|
||||||
on:middleclick={() => {
|
on:middleclick={() => {
|
||||||
_.flattenDeep(getContextMenu())
|
_.flattenDeep(getContextMenu())
|
||||||
.find(x => x.isNewQuery)
|
.find(x => x.isNewQuery)
|
||||||
.onClick();
|
.onClick();
|
||||||
}}
|
}}
|
||||||
isChoosed={data._id == $focusedConnectionOrDatabase?.conid && !$focusedConnectionOrDatabase?.database}
|
isChoosed={data._id == $focusedConnectionOrDatabase?.conid &&
|
||||||
|
(data.singleDatabase
|
||||||
|
? $focusedConnectionOrDatabase?.database == data.defaultDatabase
|
||||||
|
: !$focusedConnectionOrDatabase?.database)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -87,6 +87,7 @@
|
|||||||
res.push({
|
res.push({
|
||||||
connection: con,
|
connection: con,
|
||||||
conid: con._id,
|
conid: con._id,
|
||||||
|
database: con.singleDatabase ? con.defaultDatabase : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
if ((expanded.includes(con._id) && opened.includes(con._id)) || filter) {
|
if ((expanded.includes(con._id) && opened.includes(con._id)) || filter) {
|
||||||
@@ -218,7 +219,11 @@
|
|||||||
handleObjectClick={(data, options) => {
|
handleObjectClick={(data, options) => {
|
||||||
if (data.database) {
|
if (data.database) {
|
||||||
if (options.focusTab) {
|
if (options.focusTab) {
|
||||||
switchCurrentDatabase({ connection: data.connection, name: data.database });
|
if ($openedSingleDatabaseConnections.includes(data.conid)) {
|
||||||
|
switchCurrentDatabase({ connection: data.connection, name: data.database });
|
||||||
|
} else {
|
||||||
|
switchCurrentDatabase({ connection: data.connection, name: data.database });
|
||||||
|
}
|
||||||
// console.log('FOCUSING DB', passProps);
|
// console.log('FOCUSING DB', passProps);
|
||||||
// passProps?.onFocusSqlObjectList?.();
|
// passProps?.onFocusSqlObjectList?.();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user