import { Body, ModalContent, notifications } from "@budibase/bbui"
-
import { plugins } from "stores/portal"
+ import { createEventDispatcher } from "svelte"
export let plugin
- export let detailsModal
+
+ let dispatch = createEventDispatcher()
+
async function deletePlugin() {
try {
- await plugins.deletePlugin(plugin._id, plugin._rev)
- detailsModal.hide()
+ await plugins.deletePlugin(plugin._id)
notifications.success(`Plugin ${plugin?.name} deleted.`)
+ dispatch("deleted")
} catch (error) {
- notifications.error("Error deleting plugin")
+ const msg = error?.message ? error.message : JSON.stringify(error)
+ notifications.error(`Error deleting plugin: ${msg}`)
}
}
diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte
index 09a67c3583..73a6ebc700 100644
--- a/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte
+++ b/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte
@@ -19,6 +19,12 @@
plugin.schema.type === "component"
? plugin.schema.schema.icon || "Book"
: plugin.schema.schema.icon || "Beaker"
+
+ function pluginDeleted() {
+ if (detailsModal) {
+ detailsModal.hide()
+ }
+ }
detailsModal.show()}>
@@ -90,7 +96,7 @@
-
+
diff --git a/packages/builder/src/stores/portal/plugins.js b/packages/builder/src/stores/portal/plugins.js
index 981daeb715..bfdec9ae6b 100644
--- a/packages/builder/src/stores/portal/plugins.js
+++ b/packages/builder/src/stores/portal/plugins.js
@@ -9,17 +9,16 @@ export function createPluginsStore() {
set(plugins)
}
- async function deletePlugin(pluginId, pluginRev) {
- await API.deletePlugin(pluginId, pluginRev)
+ async function deletePlugin(pluginId) {
+ await API.deletePlugin(pluginId)
update(state => {
state = state.filter(existing => existing._id !== pluginId)
return state
})
}
- async function createPlugin(type, source, url, auth = null) {
+ async function createPlugin(source, url, auth = null) {
let pluginData = {
- type,
source,
url,
}
diff --git a/packages/frontend-core/src/api/plugins.js b/packages/frontend-core/src/api/plugins.js
index 64a47f35b3..8735b04caa 100644
--- a/packages/frontend-core/src/api/plugins.js
+++ b/packages/frontend-core/src/api/plugins.js
@@ -36,9 +36,9 @@ export const buildPluginEndpoints = API => ({
*
* * @param pluginId the revision of the plugin to delete
*/
- deletePlugin: async (pluginId, pluginRev) => {
+ deletePlugin: async pluginId => {
return await API.delete({
- url: `/api/plugin/${pluginId}/${pluginRev}`,
+ url: `/api/plugin/${pluginId}`,
})
},
})
diff --git a/packages/server/src/api/controllers/plugin/index.ts b/packages/server/src/api/controllers/plugin/index.ts
index 5c0cd6c197..3f3914f5ef 100644
--- a/packages/server/src/api/controllers/plugin/index.ts
+++ b/packages/server/src/api/controllers/plugin/index.ts
@@ -55,7 +55,7 @@ export async function upload(ctx: any) {
}
export async function create(ctx: any) {
- const { type, source, url, headers, githubToken } = ctx.request.body
+ const { source, url, headers, githubToken } = ctx.request.body
if (!env.SELF_HOSTED) {
ctx.throw(400, "Plugins not supported outside of self-host.")
@@ -111,14 +111,14 @@ export async function fetch(ctx: any) {
export async function destroy(ctx: any) {
const db = getGlobalDB()
- const { pluginId, pluginRev } = ctx.params
+ const { pluginId } = ctx.params
try {
const plugin = await db.get(pluginId)
const bucketPath = `${plugin.name}/`
await deleteFolder(ObjectStoreBuckets.PLUGINS, bucketPath)
- await db.remove(pluginId, pluginRev)
+ await db.remove(pluginId, plugin._rev)
} catch (err: any) {
const errMsg = err?.message ? err?.message : err
diff --git a/packages/server/src/api/routes/plugin.ts b/packages/server/src/api/routes/plugin.ts
index ab1d0408ac..d619745a4a 100644
--- a/packages/server/src/api/routes/plugin.ts
+++ b/packages/server/src/api/routes/plugin.ts
@@ -9,10 +9,6 @@ router
.post("/api/plugin/upload", authorized(BUILDER), controller.upload)
.post("/api/plugin", authorized(BUILDER), controller.create)
.get("/api/plugin", authorized(BUILDER), controller.fetch)
- .delete(
- "/api/plugin/:pluginId/:pluginRev",
- authorized(BUILDER),
- controller.destroy
- )
+ .delete("/api/plugin/:pluginId", authorized(BUILDER), controller.destroy)
export default router