show unsaved connections in connection tree

This commit is contained in:
SPRINX0\prochazka
2024-12-03 14:54:22 +01:00
parent 6b3f398de3
commit 72bd536aec
4 changed files with 19 additions and 12 deletions

View File

@@ -12,7 +12,7 @@
...(allowChooseModel ? [{ label: '(DB Model)', value: '__model' }] : []), ...(allowChooseModel ? [{ label: '(DB Model)', value: '__model' }] : []),
..._.sortBy( ..._.sortBy(
($connections || []) ($connections || [])
.filter(conn => !conn.unsaved && (direction == 'target' ? !conn.isReadOnly : true)) .filter(conn => (direction == 'target' ? !conn.isReadOnly : true))
.map(conn => ({ .map(conn => ({
value: conn._id, value: conn._id,
label: getConnectionLabel(conn), label: getConnectionLabel(conn),

View File

@@ -93,7 +93,7 @@
{ value: null, label: 'The same as root' }, { value: null, label: 'The same as root' },
..._.sortBy( ..._.sortBy(
($connections || []) ($connections || [])
.filter(x => !x.unsaved) // .filter(x => !x.unsaved)
.map(conn => ({ .map(conn => ({
value: conn._id, value: conn._id,
label: getConnectionLabel(conn), label: getConnectionLabel(conn),

View File

@@ -51,7 +51,7 @@
if ( if (
!$openedTabs.find(x => x.closedTime == null) && !$openedTabs.find(x => x.closedTime == null) &&
!(await getConnectionList()).find(x => !x.unsaved) && !(await getConnectionList()).length &&
$commandsCustomized['new.connection']?.enabled $commandsCustomized['new.connection']?.enabled
) { ) {
openNewTab({ openNewTab({

View File

@@ -49,6 +49,17 @@
let domContainer = null; let domContainer = null;
let domFilter = null; let domFilter = null;
// function extractConnectionParent(data, openedConnections, openedSingleDatabaseConnections) {
// if (data.parent) {
// return data.parent;
// }
// if (data.unsaved && !openedConnections.includes(data._id) && !openedSingleDatabaseConnections.includes(data._id)) {
// return 'Recent & unsaved';
// }
// return null;
// }
$: connectionsWithStatus = $: connectionsWithStatus =
$connections && $serverStatus $connections && $serverStatus
? $connections.map(conn => ({ ? $connections.map(conn => ({
@@ -57,19 +68,15 @@
})) }))
: $connections; : $connections;
$: connectionsWithStatusFiltered = connectionsWithStatus?.filter(
x => !x.unsaved || $openedConnections.includes(x._id) || $openedSingleDatabaseConnections.includes(x._id)
);
$: connectionsWithParent = _.sortBy( $: connectionsWithParent = _.sortBy(
connectionsWithStatusFiltered connectionsWithStatus
? connectionsWithStatusFiltered?.filter(x => x.parent !== undefined && x.parent !== null && x.parent.length !== 0) ? connectionsWithStatus?.filter(x => x.parent !== undefined && x.parent !== null && x.parent.length !== 0)
: [], : [],
connection => (getConnectionLabel(connection) || '').toUpperCase() connection => (getConnectionLabel(connection) || '').toUpperCase()
); );
$: connectionsWithoutParent = _.sortBy( $: connectionsWithoutParent = _.sortBy(
connectionsWithStatusFiltered connectionsWithStatus
? connectionsWithStatusFiltered?.filter(x => x.parent === undefined || x.parent === null || x.parent.length === 0) ? connectionsWithStatus?.filter(x => x.parent === undefined || x.parent === null || x.parent.length === 0)
: [], : [],
connection => (getConnectionLabel(connection) || '').toUpperCase() connection => (getConnectionLabel(connection) || '').toUpperCase()
); );
@@ -293,7 +300,7 @@
}} }}
/> />
</AppObjectListHandler> </AppObjectListHandler>
{#if $connections && !$connections.find(x => !x.unsaved) && $openedConnections.length == 0 && $commandsCustomized['new.connection']?.enabled && !$openedTabs.find(x => !x.closedTime && x.tabComponent == 'ConnectionTab' && !x.props?.conid)} {#if $connections && $connections.length == 0 && $openedConnections.length == 0 && $commandsCustomized['new.connection']?.enabled && !$openedTabs.find(x => !x.closedTime && x.tabComponent == 'ConnectionTab' && !x.props?.conid)}
<LargeButton icon="icon new-connection" on:click={() => runCommand('new.connection')} fillHorizontal <LargeButton icon="icon new-connection" on:click={() => runCommand('new.connection')} fillHorizontal
>Add new connection</LargeButton >Add new connection</LargeButton
> >