From 700614f3e67b166d0553a9993c9c17fb3c7543a5 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 30 Aug 2022 10:50:25 +0100 Subject: [PATCH] lint --- packages/builder/src/stores/portal/index.js | 2 +- packages/builder/src/stores/portal/plugins.js | 70 +++++++++---------- packages/frontend-core/src/api/plugins.js | 11 ++- packages/server/src/api/controllers/plugin.ts | 1 - packages/server/src/api/routes/plugin.ts | 6 +- 5 files changed, 44 insertions(+), 46 deletions(-) diff --git a/packages/builder/src/stores/portal/index.js b/packages/builder/src/stores/portal/index.js index f156778fc2..fa7aa7e3cf 100644 --- a/packages/builder/src/stores/portal/index.js +++ b/packages/builder/src/stores/portal/index.js @@ -8,4 +8,4 @@ export { oidc } from "./oidc" export { templates } from "./templates" export { licensing } from "./licensing" export { groups } from "./groups" -export { plugins } from "./plugins" \ No newline at end of file +export { plugins } from "./plugins" diff --git a/packages/builder/src/stores/portal/plugins.js b/packages/builder/src/stores/portal/plugins.js index 8254f30877..6a1d7cc2cb 100644 --- a/packages/builder/src/stores/portal/plugins.js +++ b/packages/builder/src/stores/portal/plugins.js @@ -2,46 +2,42 @@ import { writable } from "svelte/store" import { API } from "api" export function createPluginsStore() { - const { subscribe, set, update } = writable([]) + const { subscribe, set, update } = writable([]) - async function load() { - const plugins = await API.getPlugins() - set(plugins) - } + async function load() { + const plugins = await API.getPlugins() + set(plugins) + } - async function deletePlugin(pluginId, pluginRev) { - await API.deletePlugin(pluginId, pluginRev) - update(state => { - state = state.filter( - existing => existing._id !== pluginId - ) - return state - }) + async function deletePlugin(pluginId, pluginRev) { + await API.deletePlugin(pluginId, pluginRev) + update(state => { + state = state.filter(existing => existing._id !== pluginId) + return state + }) + } - } - - async function uploadPlugin(file, source) { - let data = new FormData() - data.append("file", file) - let resp = await API.uploadPlugin(data, source) - let newPlugin = resp.plugins[0] - update(state => { - const currentIdx = state.findIndex(plugin => plugin._id === newPlugin._id) - if (currentIdx >= 0) { - state.splice(currentIdx, 1, newPlugin) - } else { - state.push(newPlugin) - } - return state - }) - - } - return { - subscribe, - load, - deletePlugin, - uploadPlugin - } + async function uploadPlugin(file, source) { + let data = new FormData() + data.append("file", file) + let resp = await API.uploadPlugin(data, source) + let newPlugin = resp.plugins[0] + update(state => { + const currentIdx = state.findIndex(plugin => plugin._id === newPlugin._id) + if (currentIdx >= 0) { + state.splice(currentIdx, 1, newPlugin) + } else { + state.push(newPlugin) + } + return state + }) + } + return { + subscribe, + load, + deletePlugin, + uploadPlugin, + } } export const plugins = createPluginsStore() diff --git a/packages/frontend-core/src/api/plugins.js b/packages/frontend-core/src/api/plugins.js index 125362b039..108e1b50a7 100644 --- a/packages/frontend-core/src/api/plugins.js +++ b/packages/frontend-core/src/api/plugins.js @@ -21,15 +21,14 @@ export const buildPluginEndpoints = API => ({ }, /** - * Deletes a plugin. - * @param pluginId the ID of the plugin to delete - * - * * @param pluginId the revision of the plugin to delete - */ + * Deletes a plugin. + * @param pluginId the ID of the plugin to delete + * + * * @param pluginId the revision of the plugin to delete + */ deletePlugin: async (pluginId, pluginRev) => { return await API.delete({ url: `/api/plugin/${pluginId}/${pluginRev}`, }) }, - }) diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index 98aa23e457..e8a2dd1746 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -52,7 +52,6 @@ export async function destroy(ctx: any) { await db.remove(ctx.params.pluginId, ctx.params.pluginRev) ctx.message = `Plugin ${ctx.params.pluginId} deleted.` ctx.status = 200 - } export async function processPlugin(plugin: FileType, source?: string) { diff --git a/packages/server/src/api/routes/plugin.ts b/packages/server/src/api/routes/plugin.ts index f3e5263386..1ca49cf300 100644 --- a/packages/server/src/api/routes/plugin.ts +++ b/packages/server/src/api/routes/plugin.ts @@ -8,6 +8,10 @@ const router = new Router() router .post("/api/plugin/upload/:source", authorized(BUILDER), controller.upload) .get("/api/plugin", authorized(BUILDER), controller.fetch) - .delete("/api/plugin/:pluginId/:pluginRev", authorized(BUILDER), controller.destroy) + .delete( + "/api/plugin/:pluginId/:pluginRev", + authorized(BUILDER), + controller.destroy + ) export default router