1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2024-12-01 13:20:54 +00:00

Ensure correct use of grid in indexes.svelte

This commit is contained in:
Romein van Buren 2023-01-19 09:02:59 +01:00
parent e83dd97e9c
commit a153858730
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49

View File

@ -6,7 +6,7 @@
export let collection; export let collection;
let indexes = []; let indexes = [];
let activeKey = ''; let activePath = [];
let objectViewerData = ''; let objectViewerData = '';
async function getIndexes() { async function getIndexes() {
@ -18,12 +18,12 @@
async function drop(key) { async function drop(key) {
if (typeof key !== 'string') { if (typeof key !== 'string') {
key = activeKey; key = activePath[0];
} }
const success = await DropIndex(collection.hostKey, collection.dbKey, collection.key, key); const success = await DropIndex(collection.hostKey, collection.dbKey, collection.key, key);
if (success) { if (success) {
await getIndexes(); await getIndexes();
activeKey = ''; activePath[0] = '';
} }
} }
@ -36,7 +36,7 @@
<div class="indexes"> <div class="indexes">
<div class="actions"> <div class="actions">
<button class="btn" on:click={getIndexes}>Get indexes</button> <button class="btn" on:click={getIndexes}>Get indexes</button>
<button class="btn danger" on:click={drop} disabled={!indexes?.length || !activeKey}> <button class="btn danger" on:click={drop} disabled={!indexes?.length || !activePath[0]}>
Drop selected Drop selected
</button> </button>
<button class="btn">Create…</button> <button class="btn">Create…</button>
@ -46,7 +46,7 @@
<ObjectGrid key="name" data={indexes.map(idx => ({ <ObjectGrid key="name" data={indexes.map(idx => ({
...idx, ...idx,
menu: [ { label: 'Drop this index', fn: () => drop(idx.name) } ], menu: [ { label: 'Drop this index', fn: () => drop(idx.name) } ],
}))} bind:activeKey on:trigger={e => openJson(e.detail.itemKey)} /> }))} bind:activePath on:trigger={e => openJson(e.detail.itemKey)} />
</div> </div>
</div> </div>