Handle gpm events in Admin (#508)

* Fix removing packages

* npm install "babel-preset-es2015": "^6.6.0"

* Run gulp

* Handle messages in packages install/remove/update procedures
This commit is contained in:
Flavio Copes
2016-04-20 18:55:58 +02:00
parent 4eeee01843
commit 85922f93ac
17 changed files with 73 additions and 272 deletions

View File

@@ -387,15 +387,19 @@ class AdminController
require_once __DIR__ . '/gpm.php';
$result = false;
try {
$result = \Grav\Plugin\Admin\Gpm::install($package, ['theme' => ($type == 'theme')]);
} catch (\Exception $e) {
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
return;
}
$this->admin->json_response = ['status' => 'success', 'message' => $result];
return true;
if ($result) {
$this->admin->json_response = ['status' => 'success', 'message' => "Package $package installed successfully"];
$this->admin->json_response = ['status' => 'success', 'message' => $this->admin->translate(is_string($result) ? $result : sprintf($this->admin->translate('PLUGIN_ADMIN.PACKAGE_X_INSTALLED_SUCCESSFULLY', null, true), $package))];
} else {
$this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.INSTALLATION_FAILED')];
}
@@ -434,8 +438,7 @@ class AdminController
return;
}
$this->admin->json_response = ['status' => 'success', 'message' => 'xxx'];
return true;
$result = false;
try {
$dependencies = $this->admin->dependenciesThatCanBeRemovedWhenRemoving($package);
@@ -446,7 +449,7 @@ class AdminController
}
if ($result) {
$this->admin->json_response = ['status' => 'success', 'dependencies' => $dependencies, 'message' => $this->admin->translate('PLUGIN_ADMIN.UNINSTALL_SUCCESSFUL')];
$this->admin->json_response = ['status' => 'success', 'dependencies' => $dependencies, 'message' => $this->admin->translate(is_string($result) ? $result :'PLUGIN_ADMIN.UNINSTALL_SUCCESSFUL')];
} else {
$this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.UNINSTALL_FAILED')];
}
@@ -1212,6 +1215,8 @@ class AdminController
/**
* Handles uninstalling plugins and themes
*
* @deprecated
*
* @return bool True if the action was performed
*/
public function taskUninstall()