connection workflow

This commit is contained in:
Jan Prochazka
2022-05-19 12:13:46 +02:00
parent 2f8282cbce
commit 96b2c7280d
9 changed files with 82 additions and 17 deletions

View File

@@ -8,7 +8,7 @@
import AppObjectList from '../appobj/AppObjectList.svelte';
import * as connectionAppObject from '../appobj/ConnectionAppObject.svelte';
import SubDatabaseList from '../appobj/SubDatabaseList.svelte';
import { commands, commandsCustomized, openedConnections } from '../stores';
import { commands, commandsCustomized, expandedConnections, openedConnections } from '../stores';
import ToolbarButton from '../buttons/ToolbarButton.svelte';
import runCommand from '../commands/runCommand';
import getConnectionLabel from '../utility/getConnectionLabel';
@@ -28,6 +28,10 @@
? $connections.map(conn => ({ ...conn, status: $serverStatus[conn._id] }))
: $connections;
$: connectionsWithStatusFiltered = connectionsWithStatus?.filter(
x => !x.unsaved || $openedConnections.includes(x._id)
);
const handleRefreshConnections = () => {
for (const conid of $openedConnections) {
apiCall('server-connections/refresh', { conid });
@@ -51,13 +55,16 @@
</SearchBoxWrapper>
<WidgetsInnerContainer>
<AppObjectList
list={_.sortBy(connectionsWithStatus, connection => (getConnectionLabel(connection) || '').toUpperCase())}
list={_.sortBy(connectionsWithStatusFiltered, connection => (getConnectionLabel(connection) || '').toUpperCase())}
module={connectionAppObject}
subItemsComponent={SubDatabaseList}
expandOnClick
isExpandable={data => $openedConnections.includes(data._id) && !data.singleDatabase}
{filter}
passProps={{ connectionColorFactory: $connectionColorFactory, showPinnedInsteadOfUnpin: true }}
getIsExpanded={data => $expandedConnections.includes(data._id) && !data.singleDatabase}
setIsExpanded={(data, value) =>
expandedConnections.update(old => (value ? [...old, data._id] : old.filter(x => x != data._id)))}
/>
{#if $connections && $connections.length == 0 && $commandsCustomized['new.connection']?.enabled}
<LargeButton icon="icon new-connection" on:click={() => runCommand('new.connection')} fillHorizontal

View File

@@ -22,7 +22,7 @@
});
};
const closeMultipleTabs = closeCondition => {
export const closeMultipleTabs = closeCondition => {
openedTabs.update(files => {
const newFiles = files.map(x => ({
...x,
@@ -81,6 +81,7 @@
const closeOthers = closeTabFunc((x, active) => x.tabid != active.tabid);
function getTabDbName(tab, connectionList) {
if (tab.tabComponent == 'ConnectionTab') return 'Connections';
if (tab.props && tab.props.conid && tab.props.database) return tab.props.database;
if (tab.props && tab.props.conid) {
const connection = connectionList?.find(x => x._id == tab.props.conid);
@@ -96,6 +97,7 @@
if (key.startsWith('database://')) return 'icon database';
if (key.startsWith('archive://')) return 'icon archive';
if (key.startsWith('server://')) return 'icon server';
if (key.startsWith('connections.')) return 'icon connection';
}
return 'icon file';
}