remove plugin cleaner

This commit is contained in:
NEOLPAR 2022-09-02 19:33:03 +01:00
parent 60c337fe95
commit bd4d7aaeaf
3 changed files with 11 additions and 22 deletions

View File

@ -4,12 +4,12 @@
import { plugins } from "stores/portal" import { plugins } from "stores/portal"
export let plugin export let removePlugin
async function deletePlugin() { async function deletePlugin() {
try { try {
await plugins.deletePlugin(plugin._id, plugin._rev) await plugins.deletePlugin(removePlugin._id, removePlugin._rev)
notifications.success(`Plugin ${plugin?.name} deleted.`) notifications.success(`Plugin ${removePlugin?.name} deleted.`)
$goto("./") $goto("./")
} catch (error) { } catch (error) {
notifications.error("Error deleting plugin") notifications.error("Error deleting plugin")
@ -26,6 +26,6 @@
showCloseIcon={false} showCloseIcon={false}
> >
<Body> <Body>
Are you sure you want to delete <strong>{plugin?.name}</strong> Are you sure you want to delete <strong>{removePlugin?.name}</strong>
</Body> </Body>
</ModalContent> </ModalContent>

View File

@ -1,24 +1,14 @@
<script> <script>
import { Icon, Body, ActionMenu, MenuItem, Detail } from "@budibase/bbui" import { Icon, Body, ActionMenu, MenuItem, Detail } from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher()
export let plugin export let plugin
export let deletePlugin
$: console.log(plugin) $: console.log(plugin)
let modal let modal
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">
@ -51,7 +41,8 @@
<span slot="control"> <span slot="control">
<Icon hoverable name="More" /> <Icon hoverable name="More" />
</span> </span>
<MenuItem on:click={() => remove(plugin)} icon="Delete">Delete</MenuItem <MenuItem on:click={() => deletePlugin(plugin)} icon="Delete"
>Delete</MenuItem
> >
<MenuItem on:click={() => editGroup(plugin)} icon="Edit">Edit</MenuItem> <MenuItem on:click={() => editGroup(plugin)} icon="Edit">Edit</MenuItem>
</ActionMenu> </ActionMenu>

View File

@ -35,11 +35,9 @@
plugin?.name?.toLowerCase().includes(searchTerm.toLowerCase()) plugin?.name?.toLowerCase().includes(searchTerm.toLowerCase())
) )
const deletePlugin = evt => { const deletePlugin = plugin => {
const { detail } = evt
deleteModal.show() deleteModal.show()
removePlugin = detail removePlugin = plugin
} }
onMount(async () => { onMount(async () => {
@ -77,7 +75,7 @@
{#if $plugins} {#if $plugins}
{#each filteredPlugins as plugin} {#each filteredPlugins as plugin}
<PluginRow {plugin} on:delete={deletePlugin} /> <PluginRow {plugin} {deletePlugin} />
{/each} {/each}
{/if} {/if}
</Layout> </Layout>
@ -87,7 +85,7 @@
<AddPluginModal /> <AddPluginModal />
</Modal> </Modal>
<Modal bind:this={deleteModal}> <Modal bind:this={deleteModal}>
<DeletePluginModal plugin={removePlugin} /> <DeletePluginModal {removePlugin} />
</Modal> </Modal>
<style> <style>