diff --git a/packages/web/src/appobj/AppObjectList.svelte b/packages/web/src/appobj/AppObjectList.svelte index d95b14f23..d0b8d4cc6 100644 --- a/packages/web/src/appobj/AppObjectList.svelte +++ b/packages/web/src/appobj/AppObjectList.svelte @@ -1,5 +1,5 @@ {#if groupFunc} - {#each _.keys(groups) as group} + {#each sortGroups ? _.sortBy(_.keys(groups)) : _.keys(groups) as group} !getCurrentConfig()?.runAsPortal, + onClick: () => { + showModal(InputTextModal, { + value: '', + label: 'New connection folder name', + header: 'Create connection folder', + onConfirm: async folder => { + emptyConnectionGroupNames.update(names => { + if (!folder) return names; + if (names.includes(folder)) return names; + return [...names, folder]; + }); + }, + }); + }, +}); + registerCommand({ id: 'new.query', category: 'New', diff --git a/packages/web/src/icons/FontIcon.svelte b/packages/web/src/icons/FontIcon.svelte index 21f5063f1..713eadf3a 100644 --- a/packages/web/src/icons/FontIcon.svelte +++ b/packages/web/src/icons/FontIcon.svelte @@ -29,6 +29,7 @@ 'icon arrange': 'mdi mdi-arrange-send-to-back', 'icon app': 'mdi mdi-layers-triple', 'icon open-in-new': 'mdi mdi-open-in-new', + 'icon add-folder': 'mdi mdi-folder-plus-outline', 'icon window-restore': 'mdi mdi-window-restore', 'icon window-close': 'mdi mdi-window-close', diff --git a/packages/web/src/stores.ts b/packages/web/src/stores.ts index 817bd805c..79686d1ae 100644 --- a/packages/web/src/stores.ts +++ b/packages/web/src/stores.ts @@ -50,6 +50,7 @@ function subscribeCssVariable(store, transform, cssVariable) { } export const selectedWidget = writableWithStorage('database', 'selectedWidget'); +export const emptyConnectionGroupNames = writableWithStorage([], 'emptyConnectionGroupNames'); export const openedConnections = writable([]); export const openedSingleDatabaseConnections = writable([]); export const expandedConnections = writable([]); diff --git a/packages/web/src/widgets/ConnectionList.svelte b/packages/web/src/widgets/ConnectionList.svelte index f6e5e5d25..f475ba7f7 100644 --- a/packages/web/src/widgets/ConnectionList.svelte +++ b/packages/web/src/widgets/ConnectionList.svelte @@ -9,14 +9,13 @@ import * as connectionAppObject from '../appobj/ConnectionAppObject.svelte'; import SubDatabaseList from '../appobj/SubDatabaseList.svelte'; import { - commands, commandsCustomized, expandedConnections, openedConnections, openedSingleDatabaseConnections, openedTabs, + emptyConnectionGroupNames, } from '../stores'; - import ToolbarButton from '../buttons/ToolbarButton.svelte'; import runCommand from '../commands/runCommand'; import getConnectionLabel from '../utility/getConnectionLabel'; import { useConnectionColorFactory } from '../utility/useConnectionColor'; @@ -24,7 +23,6 @@ import CloseSearchButton from '../buttons/CloseSearchButton.svelte'; import { apiCall } from '../utility/api'; import LargeButton from '../buttons/LargeButton.svelte'; - import { matchingProps } from '../tabs/TableDataTab.svelte'; import { plusExpandIcon, chevronExpandIcon } from '../icons/expandIcons'; import { safeJsonParse } from 'dbgate-tools'; @@ -58,6 +56,9 @@ const handleDropOnGroup = (data, group) => { const json = safeJsonParse(data); if (json?._id) { + if (json.parent) { + emptyConnectionGroupNames.update(x => x.filter(y => y != json.parent)); + } apiCall('connections/update', { _id: json?._id, values: { parent: group }, @@ -75,6 +76,9 @@ runCommand('new.connection')} title="Add new connection"> + runCommand('new.connection.folder')} title="Add new connection folder"> + + {/if} @@ -104,8 +108,10 @@ groupFunc={data => data.parent} expandIconFunc={plusExpandIcon} onDropOnGroup={handleDropOnGroup} + emptyGroupNames={$emptyConnectionGroupNames} + sortGroups /> - {#if connectionsWithParent?.length > 0 && connectionsWithoutParent?.length > 0} + {#if (connectionsWithParent?.length > 0 && connectionsWithoutParent?.length > 0) || ($emptyConnectionGroupNames.length > 0 && connectionsWithoutParent?.length > 0)}
{/if}