mirror of
https://github.com/flarum/core.git
synced 2025-07-27 19:50:20 +02:00
Add ability to uninstall an extension
This commit is contained in:
@@ -82,12 +82,20 @@ export default class ExtensionsPage extends Component {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// if (!enabled) {
|
if (!enabled) {
|
||||||
// items.add('uninstall', Button.component({
|
items.add('uninstall', Button.component({
|
||||||
// icon: 'trash-o',
|
icon: 'trash-o',
|
||||||
// children: 'Uninstall'
|
children: 'Uninstall',
|
||||||
// }));
|
onclick: () => {
|
||||||
// }
|
app.request({
|
||||||
|
url: app.forum.attribute('apiUrl') + '/extensions/' + extension.name,
|
||||||
|
method: 'DELETE',
|
||||||
|
}).then(() => window.location.reload());
|
||||||
|
|
||||||
|
app.modal.show(new LoadingModal());
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
// items.add('separator2', Separator.component());
|
// items.add('separator2', Separator.component());
|
||||||
|
|
||||||
|
37
framework/core/src/Api/Actions/Extensions/DeleteAction.php
Normal file
37
framework/core/src/Api/Actions/Extensions/DeleteAction.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php namespace Flarum\Api\Actions\Extensions;
|
||||||
|
|
||||||
|
use Flarum\Api\Actions\DeleteAction as BaseDeleteAction;
|
||||||
|
use Flarum\Api\Request;
|
||||||
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Flarum\Core\Exceptions\PermissionDeniedException;
|
||||||
|
use Flarum\Support\ExtensionManager;
|
||||||
|
|
||||||
|
class DeleteAction extends BaseDeleteAction
|
||||||
|
{
|
||||||
|
protected $extensions;
|
||||||
|
|
||||||
|
public function __construct(ExtensionManager $extensions)
|
||||||
|
{
|
||||||
|
$this->extensions = $extensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function delete(Request $request)
|
||||||
|
{
|
||||||
|
if (! $request->actor->isAdmin()) {
|
||||||
|
throw new PermissionDeniedException;
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = $request->get('name');
|
||||||
|
|
||||||
|
$this->extensions->disable($name);
|
||||||
|
$this->extensions->uninstall($name);
|
||||||
|
|
||||||
|
app('flarum.formatter')->flush();
|
||||||
|
|
||||||
|
$forum = app('Flarum\Forum\Actions\ClientAction');
|
||||||
|
$forum->flushAssets();
|
||||||
|
|
||||||
|
$admin = app('Flarum\Admin\Actions\ClientAction');
|
||||||
|
$admin->flushAssets();
|
||||||
|
}
|
||||||
|
}
|
@@ -306,6 +306,13 @@ class ApiServiceProvider extends ServiceProvider
|
|||||||
$this->action('Flarum\Api\Actions\Extensions\UpdateAction')
|
$this->action('Flarum\Api\Actions\Extensions\UpdateAction')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Uninstall an extension
|
||||||
|
$routes->delete(
|
||||||
|
'/extensions/{name}',
|
||||||
|
'flarum.api.extensions.delete',
|
||||||
|
$this->action('Flarum\Api\Actions\Extensions\DeleteAction')
|
||||||
|
);
|
||||||
|
|
||||||
// Update config settings
|
// Update config settings
|
||||||
$routes->post(
|
$routes->post(
|
||||||
'/config',
|
'/config',
|
||||||
|
@@ -35,4 +35,9 @@ class DatabaseSettingsRepository implements SettingsRepository
|
|||||||
|
|
||||||
$query->$method(compact('key', 'value'));
|
$query->$method(compact('key', 'value'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete($key)
|
||||||
|
{
|
||||||
|
$this->database->table('config')->where('key', $key)->delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,4 +42,11 @@ class MemoryCacheSettingsRepository implements SettingsRepository
|
|||||||
|
|
||||||
$this->inner->set($key, $value);
|
$this->inner->set($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete($key)
|
||||||
|
{
|
||||||
|
unset($this->cache[$key]);
|
||||||
|
|
||||||
|
$this->inner->delete($key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,4 +9,6 @@ interface SettingsRepository
|
|||||||
public function get($key, $default = null);
|
public function get($key, $default = null);
|
||||||
|
|
||||||
public function set($key, $value);
|
public function set($key, $value);
|
||||||
|
|
||||||
|
public function delete($key);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user