{#if host && connection} ({ id: dbKey, collCount: Object.keys(connection.databases[dbKey].collections || {}).length || '', children: Object.keys(connection.databases[dbKey].collections).map(collKey => ({ id: collKey, menu: [ { label: `Drop ${collKey}…`, fn: () => dropCollection(dbKey, collKey) }, { label: `Drop ${dbKey}…`, fn: () => dropDatabase(dbKey) }, { separator: true }, { label: 'New database…', fn: () => dispatch('newDatabase') }, { label: 'New collection…', fn: () => dispatch('newCollection') }, ], })).sort((a, b) => a.id.localeCompare(b)) || [], menu: [ { label: `Drop ${dbKey}…`, fn: () => dropDatabase(dbKey) }, { separator: true }, { label: 'New database…', fn: () => dispatch('newDatabase') }, { label: 'New collection…', fn: () => dispatch('newCollection') }, ], }))} actions={[ { icon: 'reload', fn: reload }, { icon: '+', fn: evt => { if (activeDbKey) { contextMenu.show(evt, [ { label: 'New database…', fn: () => dispatch('newDatabase') }, { label: 'New collection…', fn: () => dispatch('newCollection') }, ]); } else { dispatch('newDatabase'); } } }, { icon: '-', fn: evt => { if (activeCollKey) { contextMenu.show(evt, [ { label: 'Drop database…', fn: () => dropDatabase(activeDbKey) }, { label: 'Drop collection…', fn: () => dropCollection(activeDbKey, activeCollKey) }, ]); } else { dropDatabase(activeDbKey); } }, disabled: !activeDbKey }, ]} bind:activeKey={activeDbKey} bind:activeChildKey={activeCollKey} on:select={e => openDatabase(e.detail)} on:selectChild={e => openCollection(e.detail)} /> {/if}