Add uninstall plugin dynamic

This commit is contained in:
cyril lopez 2017-11-02 17:05:37 +01:00
parent f8866e09f3
commit 8c9f9e496d
4 changed files with 14 additions and 2 deletions

View File

@ -20,7 +20,8 @@ export function* deletePlugin() {
}
} catch(error) {
console.log(error);
yield put(deletePluginSucceeded());
window.Strapi.notification.error('app.components.listPluginsPage.deletePlugin.error');
}
}
// Individual exports for testing

View File

@ -18,6 +18,7 @@
"app.components.ListPluginsPage.helmet.title": "List plugins",
"app.components.ListPluginsPage.title": "Plugins",
"app.components.ListPluginsPage.description": "List of the installed plugins in the project.",
"app.components.listPluginsPage.deletePlugin.error": "An error occurred during the plugin uninstallation",
"app.components.listPlugins.title.singular": "{number} plugin is installed",
"app.components.listPlugins.title.plural": "{number} plugins are installed",
"app.components.listPlugins.title.none": "No plugin is installed",

View File

@ -18,6 +18,7 @@
"app.components.ListPluginsPage.helmet.title": "List plugins",
"app.components.ListPluginsPage.title": "Plugins",
"app.components.ListPluginsPage.description": "Liste des plugins installés dans le projet.",
"app.components.listPluginsPage.deletePlugin.error": "Une erreur est survenue pendant la désintallation",
"app.components.listPlugins.title.singular": "{number} est disponible",
"app.components.listPlugins.title.plural": "{number} sont disponibles",
"app.components.listPlugins.title.none": "Aucun plugin n'est installé",

View File

@ -2,6 +2,7 @@
const fs = require('fs');
const path = require('path');
const exec = require('child_process').execSync;
/**
* A set of functions called "actions" for `Admin`
@ -45,9 +46,17 @@ module.exports = {
uninstallPlugin: async ctx => {
try {
const { plugin } = ctx.params;
console.log('plugin', plugin);
strapi.reload.isWatching = false;
strapi.log.info(`Uninstalling ${plugin}...`);
exec(`strapi uninstall ${plugin}`);
ctx.send({ ok: true });
strapi.reload();
} catch(err) {
strapi.reload.isWatching = true;
ctx.badRequest(null, [{ messages: [{ id: 'An error occured' }] }]);
}
}