added enabled/disable to styles
This commit is contained in:
@@ -13,6 +13,7 @@ use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use App\Models\ApiProvider;
|
||||
use Filament\Tables\Actions\Action;
|
||||
|
||||
class ListPlugins extends Page implements HasTable
|
||||
@@ -23,7 +24,7 @@ class ListPlugins extends Page implements HasTable
|
||||
|
||||
protected static string $view = 'filament.pages.list-plugins';
|
||||
|
||||
protected static ?string $navigationGroup = 'Plugins';
|
||||
protected static ?string $navigationGroup = 'Settings';
|
||||
|
||||
protected static ?string $title = 'Plugins';
|
||||
|
||||
@@ -40,7 +41,9 @@ class ListPlugins extends Page implements HasTable
|
||||
|
||||
if (class_exists($class) && in_array(ApiPluginInterface::class, class_implements($class))) {
|
||||
try {
|
||||
$instance = new $class();
|
||||
$apiProvider = ApiProvider::where('plugin', $filename)->first();
|
||||
if(!$apiProvider) continue;
|
||||
$instance = new $class($apiProvider);
|
||||
$plugins->add(new Plugin([
|
||||
'id' => $instance->getIdentifier(),
|
||||
'name' => $instance->getName(),
|
||||
@@ -78,8 +81,10 @@ class ListPlugins extends Page implements HasTable
|
||||
->icon(fn ($record) => $record->enabled ? 'heroicon-o-x-circle' : 'heroicon-o-check-circle')
|
||||
->action(function ($record) {
|
||||
try {
|
||||
$apiProvider = ApiProvider::where('plugin', $record->identifier)->first();
|
||||
if(!$apiProvider) throw new \Exception('ApiProvider not found');
|
||||
$pluginClass = 'App\\Api\\Plugins\\' . $record->identifier;
|
||||
$plugin = new $pluginClass();
|
||||
$plugin = new $pluginClass($apiProvider);
|
||||
if ($record->enabled) {
|
||||
$plugin->disable();
|
||||
} else {
|
||||
@@ -97,6 +102,7 @@ class ListPlugins extends Page implements HasTable
|
||||
->send();
|
||||
}
|
||||
}),
|
||||
|
||||
Action::make('delete')
|
||||
->label('Delete')
|
||||
->icon('heroicon-o-trash')
|
||||
|
||||
Reference in New Issue
Block a user