Merge pull request #186 from shogunpurple/delete-databases
Delete databases
This commit is contained in:
commit
869f227519
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { tick } from "svelte"
|
import { tick } from "svelte"
|
||||||
import { store, backendUiStore } from "../builderStore"
|
import { store, backendUiStore } from "../builderStore"
|
||||||
|
import api from "../builderStore/api"
|
||||||
import getIcon from "../common/icon"
|
import getIcon from "../common/icon"
|
||||||
import { CheckIcon } from "../common/Icons"
|
import { CheckIcon } from "../common/Icons"
|
||||||
|
|
||||||
|
@ -13,6 +14,17 @@
|
||||||
backendUiStore.actions.views.select(views[0])
|
backendUiStore.actions.views.select(views[0])
|
||||||
backendUiStore.actions.database.select(database)
|
backendUiStore.actions.database.select(database)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteDatabase(database) {
|
||||||
|
const DELETE_DATABASE_URL = `/_builder/instance/_master/0/api/record/applications/${$store.appId}/instances/${database.id}`
|
||||||
|
const response = await api.delete(DELETE_DATABASE_URL)
|
||||||
|
store.update(state => {
|
||||||
|
state.appInstances = state.appInstances.filter(
|
||||||
|
db => db.id !== database.id
|
||||||
|
)
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
|
@ -24,12 +36,15 @@
|
||||||
<CheckIcon />
|
<CheckIcon />
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
|
<i
|
||||||
|
class="ri-delete-bin-7-line hoverable uk-margin-small-left"
|
||||||
|
on:click={() => deleteDatabase(database)} />
|
||||||
<button
|
<button
|
||||||
class:active={database.id === $backendUiStore.selectedDatabase.id}
|
class:active={database.id === $backendUiStore.selectedDatabase.id}
|
||||||
on:click={() => selectDatabase(database)}>
|
on:click={() => selectDatabase(database)}>
|
||||||
{database.name}
|
{database.name}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -53,6 +68,8 @@
|
||||||
|
|
||||||
li {
|
li {
|
||||||
margin: 0.5rem 0;
|
margin: 0.5rem 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
|
|
Loading…
Reference in New Issue