recent & unsaved connection folder

This commit is contained in:
SPRINX0\prochazka
2024-12-03 15:30:02 +01:00
parent 8e5ef98a7c
commit 8bf1dbb10d

View File

@@ -49,16 +49,18 @@
let domContainer = null; let domContainer = null;
let domFilter = null; let domFilter = null;
// function extractConnectionParent(data, openedConnections, openedSingleDatabaseConnections) { const RECENT_AND_UNSAVED_LABEL = 'Recent & unsaved';
// if (data.parent) {
// return data.parent;
// }
// if (data.unsaved && !openedConnections.includes(data._id) && !openedSingleDatabaseConnections.includes(data._id)) {
// return 'Recent & unsaved';
// }
// return 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_AND_UNSAVED_LABEL;
}
return null;
}
$: connectionsWithStatus = $: connectionsWithStatus =
$connections && $serverStatus $connections && $serverStatus
@@ -70,13 +72,17 @@
$: connectionsWithParent = _.sortBy( $: connectionsWithParent = _.sortBy(
connectionsWithStatus connectionsWithStatus
? connectionsWithStatus?.filter(x => x.parent !== undefined && x.parent !== null && x.parent.length !== 0) ? connectionsWithStatus?.filter(x =>
extractConnectionParent(x, $openedConnections, $openedSingleDatabaseConnections)
)
: [], : [],
connection => (getConnectionLabel(connection) || '').toUpperCase() connection => (getConnectionLabel(connection) || '').toUpperCase()
); );
$: connectionsWithoutParent = _.sortBy( $: connectionsWithoutParent = _.sortBy(
connectionsWithStatus connectionsWithStatus
? connectionsWithStatus?.filter(x => x.parent === undefined || x.parent === null || x.parent.length === 0) ? connectionsWithStatus?.filter(
x => !extractConnectionParent(x, $openedConnections, $openedSingleDatabaseConnections)
)
: [], : [],
connection => (getConnectionLabel(connection) || '').toUpperCase() connection => (getConnectionLabel(connection) || '').toUpperCase()
); );
@@ -124,6 +130,9 @@
}; };
const handleDropOnGroup = (data, group) => { const handleDropOnGroup = (data, group) => {
if (group == RECENT_AND_UNSAVED_LABEL) {
return;
}
const json = safeJsonParse(data); const json = safeJsonParse(data);
if (json?._id) { if (json?._id) {
// if (json.parent) { // if (json.parent) {
@@ -131,7 +140,7 @@
// } // }
apiCall('connections/update', { apiCall('connections/update', {
_id: json?._id, _id: json?._id,
values: { parent: group }, values: { parent: group, unsaved: false },
}); });
} }
}; };
@@ -275,7 +284,7 @@
expandedConnections.update(old => (value ? [...old, data._id] : old.filter(x => x != data._id))); expandedConnections.update(old => (value ? [...old, data._id] : old.filter(x => x != data._id)));
}} }}
groupIconFunc={chevronExpandIcon} groupIconFunc={chevronExpandIcon}
groupFunc={data => data.parent} groupFunc={data => extractConnectionParent(data, $openedConnections, $openedSingleDatabaseConnections)}
expandIconFunc={plusExpandIcon} expandIconFunc={plusExpandIcon}
onDropOnGroup={handleDropOnGroup} onDropOnGroup={handleDropOnGroup}
emptyGroupNames={$emptyConnectionGroupNames} emptyGroupNames={$emptyConnectionGroupNames}