diff --git a/packages/web/src/modals/DropDownMenu.svelte b/packages/web/src/modals/DropDownMenu.svelte index 05f7ddcf4..336a12772 100644 --- a/packages/web/src/modals/DropDownMenu.svelte +++ b/packages/web/src/modals/DropDownMenu.svelte @@ -87,12 +87,24 @@ return; } if (item.switchStore && item.switchValue) { - item.switchStore.update(x => ({ - ...x, - [item.switchValue]: !x[item.switchValue], - })); + item.switchStore.update(x => { + const res = { + ...x, + [item.switchValue]: !x[item.switchValue], + }; + if (item.switchGroupPrefix) { + for (const key of Object.keys(res)) { + if (key.startsWith(item.switchGroupPrefix) && key !== item.switchValue) { + res[key] = false; + } + } + } + return res; + }); switchIndex++; - return; + if (!item.closeOnSwitchClick) { + return; + } } dispatchClose(); if (onCloseParent) onCloseParent(); diff --git a/packages/web/src/widgets/SqlObjectList.svelte b/packages/web/src/widgets/SqlObjectList.svelte index 338f692a7..814a5372c 100644 --- a/packages/web/src/widgets/SqlObjectList.svelte +++ b/packages/web/src/widgets/SqlObjectList.svelte @@ -79,6 +79,8 @@ // $: console.log('OBJECTS', $objects); + $databaseObjectAppObjectSearchSettings?. + $: objectList = _.flatten([ ...['tables', 'collections', 'views', 'matviews', 'procedures', 'functions', 'triggers', 'schedulerEvents'].map( objectTypeField => @@ -133,19 +135,61 @@ const res = []; res.push({ label: _t('sqlObject.searchBy', { defaultMessage: 'Search by:' }), isBold: true, disabled: true }); if (driver?.databaseEngineTypes?.includes('document')) { - res.push({ label: _t('sqlObject.collectionName', { defaultMessage: 'Collection name' }), switchValue: 'pureName' }); + res.push({ + label: _t('sqlObject.collectionName', { defaultMessage: 'Collection name' }), + switchValue: 'pureName', + }); } if (driver?.databaseEngineTypes?.includes('sql')) { - res.push({ label: _t('sqlObject.tableViewProcedureName', { defaultMessage: 'Table/view/procedure name' }), switchValue: 'pureName' }); + res.push({ + label: _t('sqlObject.tableViewProcedureName', { defaultMessage: 'Table/view/procedure name' }), + switchValue: 'pureName', + }); res.push({ label: _t('sqlObject.schemaName', { defaultMessage: 'Schema' }), switchValue: 'schemaName' }); res.push({ label: _t('sqlObject.columnName', { defaultMessage: 'Column name' }), switchValue: 'columnName' }); - res.push({ label: _t('sqlObject.columnDataType', { defaultMessage: 'Column data type' }), switchValue: 'columnDataType' }); - res.push({ label: _t('sqlObject.tableComment', { defaultMessage: 'Table comment' }), switchValue: 'tableComment' }); - res.push({ label: _t('sqlObject.columnComment', { defaultMessage: 'Column comment' }), switchValue: 'columnComment' }); - res.push({ label: _t('sqlObject.viewProcedureTriggerText', { defaultMessage: 'View/procedure/trigger text' }), switchValue: 'sqlObjectText' }); + res.push({ + label: _t('sqlObject.columnDataType', { defaultMessage: 'Column data type' }), + switchValue: 'columnDataType', + }); + res.push({ + label: _t('sqlObject.tableComment', { defaultMessage: 'Table comment' }), + switchValue: 'tableComment', + }); + res.push({ + label: _t('sqlObject.columnComment', { defaultMessage: 'Column comment' }), + switchValue: 'columnComment', + }); + res.push({ + label: _t('sqlObject.viewProcedureTriggerText', { defaultMessage: 'View/procedure/trigger text' }), + switchValue: 'sqlObjectText', + }); res.push({ label: _t('sqlObject.tableEngine', { defaultMessage: 'Table engine' }), switchValue: 'tableEngine' }); - res.push({ label: _t('sqlObject.tablesWithRows', { defaultMessage: 'Only tables with rows' }), switchValue: 'tablesWithRows' }); + res.push({ + label: _t('sqlObject.tablesWithRows', { defaultMessage: 'Only tables with rows' }), + switchValue: 'tablesWithRows', + }); } + + res.push({ label: _t('sqlObject.sortBy', { defaultMessage: 'Sort by:' }), isBold: true, disabled: true }); + res.push({ + label: _t('sqlObject.name', { defaultMessage: 'Name' }), + switchValue: 'sortByName', + switchGroupPrefix: 'sortBy', + closeOnSwitchClick: true, + }); + res.push({ + label: _t('sqlObject.rowCount', { defaultMessage: 'Row count' }), + switchValue: 'sortByRowCount', + switchGroupPrefix: 'sortBy', + closeOnSwitchClick: true, + }); + res.push({ + label: _t('sqlObject.sizeBytes', { defaultMessage: 'Size bytes' }), + switchValue: 'sortBySizeBytes', + switchGroupPrefix: 'sortBy', + closeOnSwitchClick: true, + }); + return res.map(item => ({ ...item, switchStore: databaseObjectAppObjectSearchSettings, @@ -193,19 +237,25 @@
{_t('common.refresh', { defaultMessage: 'Refresh' })} {#if driver?.databaseEngineTypes?.includes('sql')}
- runCommand('new.table')}>{_t('database.newTable', { defaultMessage: 'New table' })} + runCommand('new.table')} + >{_t('database.newTable', { defaultMessage: 'New table' })} {/if} {#if driver?.databaseEngineTypes?.includes('document')}
runCommand('new.collection')} - >{_t('sqlObject.newCollection', { defaultMessage: 'New collection/container'})}{_t('sqlObject.newCollection', { defaultMessage: 'New collection/container' })} {/if} @@ -233,7 +283,7 @@ {/if} @@ -260,7 +310,10 @@ data-testid="SqlObjectList_container" > {#if ($status && ($status.name == 'pending' || $status.name == 'checkStructure' || $status.name == 'loadStructure') && $objects) || !$objects} - + {:else}