1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-07-21 06:48:04 +00:00

Preserve state between tabs (cc #37) (fixes #56)

This commit is contained in:
2023-07-08 13:07:55 +02:00
parent 64fb9ed173
commit 5476df5fe9
12 changed files with 106 additions and 110 deletions

View File

@ -9,10 +9,18 @@
import HostTree from './hosttree.svelte';
let path = [];
let prevPath = '';
let hostTab = '';
let dbTab = '';
let collTab = '';
$: if (path.join('.') !== prevPath) {
hostTab = 'status';
dbTab = 'stats';
collTab = 'stats';
prevPath = path.join('.');
}
$: activeHostKey = path[0];
$: activeDbKey = path[1];
$: activeCollKey = path[2];
@ -55,26 +63,17 @@
</div>
{#if activeCollKey}
<CollectionView
collection={$hostTree[activeHostKey]?.databases[activeDbKey]?.collections?.[activeCollKey]}
hostKey={activeHostKey}
dbKey={activeDbKey}
collKey={activeCollKey}
bind:tab={collTab}
/>
{#key activeCollKey}
<CollectionView collection={$hostTree[activeHostKey]?.databases[activeDbKey]?.collections?.[activeCollKey]} bind:tab={collTab} />
{/key}
{:else if activeDbKey}
<DatabaseView
database={$hostTree[activeHostKey]?.databases[activeDbKey]}
hostKey={activeHostKey}
dbKey={activeDbKey}
bind:tab={dbTab}
/>
{#key activeDbKey}
<DatabaseView database={$hostTree[activeHostKey]?.databases[activeDbKey]} bind:tab={dbTab} />
{/key}
{:else if activeHostKey}
<HostView
host={$hostTree[activeHostKey]}
hostKey={activeHostKey}
bind:tab={hostTab}
/>
{#key activeHostKey}
<HostView host={$hostTree[activeHostKey]} bind:tab={hostTab} />
{/key}
{/if}
<style>