delete plugin through modal confirmation
This commit is contained in:
parent
4de090b4c6
commit
60c337fe95
|
@ -0,0 +1,31 @@
|
||||||
|
<script>
|
||||||
|
import { goto } from "@roxi/routify"
|
||||||
|
import { Body, ModalContent, notifications } from "@budibase/bbui"
|
||||||
|
|
||||||
|
import { plugins } from "stores/portal"
|
||||||
|
|
||||||
|
export let plugin
|
||||||
|
|
||||||
|
async function deletePlugin() {
|
||||||
|
try {
|
||||||
|
await plugins.deletePlugin(plugin._id, plugin._rev)
|
||||||
|
notifications.success(`Plugin ${plugin?.name} deleted.`)
|
||||||
|
$goto("./")
|
||||||
|
} catch (error) {
|
||||||
|
notifications.error("Error deleting plugin")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ModalContent
|
||||||
|
warning
|
||||||
|
onConfirm={deletePlugin}
|
||||||
|
title="Delete Plugin"
|
||||||
|
confirmText="Delete plugin"
|
||||||
|
cancelText="Cancel"
|
||||||
|
showCloseIcon={false}
|
||||||
|
>
|
||||||
|
<Body>
|
||||||
|
Are you sure you want to delete <strong>{plugin?.name}</strong>
|
||||||
|
</Body>
|
||||||
|
</ModalContent>
|
|
@ -1,6 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
import { Icon, Body, ActionMenu, MenuItem, Detail } from "@budibase/bbui"
|
import { Icon, Body, ActionMenu, MenuItem, Detail } from "@budibase/bbui"
|
||||||
import { plugins } from "stores/portal"
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
export let plugin
|
export let plugin
|
||||||
$: console.log(plugin)
|
$: console.log(plugin)
|
||||||
|
@ -9,6 +11,14 @@
|
||||||
function editGroup() {
|
function editGroup() {
|
||||||
modal.show()
|
modal.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const remove = plugin => {
|
||||||
|
dispatch("delete", {
|
||||||
|
_id: plugin._id,
|
||||||
|
_rev: plugin._rev,
|
||||||
|
name: plugin.name,
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -41,9 +51,7 @@
|
||||||
<span slot="control">
|
<span slot="control">
|
||||||
<Icon hoverable name="More" />
|
<Icon hoverable name="More" />
|
||||||
</span>
|
</span>
|
||||||
<MenuItem
|
<MenuItem on:click={() => remove(plugin)} icon="Delete">Delete</MenuItem
|
||||||
on:click={() => plugins.deletePlugin(plugin._id, plugin._rev)}
|
|
||||||
icon="Delete">Delete</MenuItem
|
|
||||||
>
|
>
|
||||||
<MenuItem on:click={() => editGroup(plugin)} icon="Edit">Edit</MenuItem>
|
<MenuItem on:click={() => editGroup(plugin)} icon="Edit">Edit</MenuItem>
|
||||||
</ActionMenu>
|
</ActionMenu>
|
||||||
|
|
|
@ -13,9 +13,12 @@
|
||||||
import { plugins } from "stores/portal"
|
import { plugins } from "stores/portal"
|
||||||
import PluginRow from "./_components/PluginRow.svelte"
|
import PluginRow from "./_components/PluginRow.svelte"
|
||||||
import AddPluginModal from "./_components/AddPluginModal.svelte"
|
import AddPluginModal from "./_components/AddPluginModal.svelte"
|
||||||
|
import DeletePluginModal from "./_components/DeletePluginModal.svelte"
|
||||||
|
|
||||||
let modal
|
let modal
|
||||||
|
let deleteModal
|
||||||
let searchTerm = ""
|
let searchTerm = ""
|
||||||
|
let removePlugin
|
||||||
|
|
||||||
let filterOptions = [
|
let filterOptions = [
|
||||||
{ label: "All Plugins", value: "all" },
|
{ label: "All Plugins", value: "all" },
|
||||||
|
@ -31,6 +34,14 @@
|
||||||
.filter(plugin =>
|
.filter(plugin =>
|
||||||
plugin?.name?.toLowerCase().includes(searchTerm.toLowerCase())
|
plugin?.name?.toLowerCase().includes(searchTerm.toLowerCase())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deletePlugin = evt => {
|
||||||
|
const { detail } = evt
|
||||||
|
|
||||||
|
deleteModal.show()
|
||||||
|
removePlugin = detail
|
||||||
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await plugins.load()
|
await plugins.load()
|
||||||
})
|
})
|
||||||
|
@ -66,7 +77,7 @@
|
||||||
|
|
||||||
{#if $plugins}
|
{#if $plugins}
|
||||||
{#each filteredPlugins as plugin}
|
{#each filteredPlugins as plugin}
|
||||||
<PluginRow {plugin} />
|
<PluginRow {plugin} on:delete={deletePlugin} />
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -75,6 +86,9 @@
|
||||||
<Modal bind:this={modal}>
|
<Modal bind:this={modal}>
|
||||||
<AddPluginModal />
|
<AddPluginModal />
|
||||||
</Modal>
|
</Modal>
|
||||||
|
<Modal bind:this={deleteModal}>
|
||||||
|
<DeletePluginModal plugin={removePlugin} />
|
||||||
|
</Modal>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.filters {
|
.filters {
|
||||||
|
|
Loading…
Reference in New Issue