diff --git a/client/src/data/server.ts b/client/src/data/server.ts index 740baa0d..86f175b6 100644 --- a/client/src/data/server.ts +++ b/client/src/data/server.ts @@ -1,4 +1,8 @@ +import {initDefaultPlugin} from "@server/init/initDefaultPlugin"; import {t} from "@server/init/t"; +import path from "path"; +import fs from "fs/promises"; +import {pubsub} from "@server/init/pubsub"; export const server = t.router({ snapshot: t.procedure.send(({ctx}) => { @@ -10,4 +14,18 @@ export const server = t.router({ const flight = ctx.flight; flight?.writeFile(true); }), + restoreDefaultPlugin: t.procedure.send(async ({ctx}) => { + // Delete any default plugins + const defaultPlugins = ctx.server.plugins.filter(p => p.default); + await Promise.all( + defaultPlugins.map(p => + fs.rm(path.dirname(p.filePath), {recursive: true, force: true}) + ) + ); + await initDefaultPlugin(); + pubsub.publish.plugin.all(); + defaultPlugins.forEach(plugin => + pubsub.publish.plugin.get({pluginId: plugin.id}) + ); + }), }); diff --git a/client/src/pages/Config/PluginEdit.tsx b/client/src/pages/Config/PluginEdit.tsx index 01049ad1..592168e1 100644 --- a/client/src/pages/Config/PluginEdit.tsx +++ b/client/src/pages/Config/PluginEdit.tsx @@ -186,84 +186,106 @@ function PluginDetails() { }); }} /> - {plugin?.active ? ( +
+ {plugin?.active ? ( + + ) : ( + + )} - ) : ( - )} - - - - Edit Plugin - + }} + > + Duplicate Plugin + + + Edit Plugin + + {plugin?.default ? ( + + ) : null} +