mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-08 10:39:27 +01:00
fixes after v4 merge
This commit is contained in:
parent
d2304d7805
commit
561aaa3ae0
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Contracts\Plugins;
|
||||
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Schemas\Components\Component;
|
||||
|
||||
interface HasPluginSettings
|
||||
{
|
||||
|
||||
@ -4,20 +4,20 @@ namespace App\Filament\Admin\Resources;
|
||||
|
||||
use App\Enums\PluginCategory;
|
||||
use App\Facades\Plugins;
|
||||
use App\Filament\Admin\Resources\PluginResource\Pages\ListPlugins;
|
||||
use App\Filament\Admin\Resources\Plugins\Pages\ListPlugins;
|
||||
use App\Models\Plugin;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Tabs;
|
||||
use Filament\Forms\Components\Tabs\Tab;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
@ -27,7 +27,7 @@ class PluginResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Plugin::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'tabler-packages';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'tabler-packages';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
@ -48,7 +48,7 @@ class PluginResource extends Resource
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return static::getModel()::count() ?: null;
|
||||
return (string) static::getEloquentQuery()->count() ?: null;
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
@ -82,7 +82,7 @@ class PluginResource extends Resource
|
||||
->tooltip(fn (Plugin $plugin) => $plugin->status_message)
|
||||
->sortable(),
|
||||
])
|
||||
->actions([
|
||||
->recordActions([
|
||||
Action::make('view')
|
||||
->label(trans('filament-actions::view.single.label'))
|
||||
->icon('tabler-eye-share')
|
||||
@ -95,7 +95,7 @@ class PluginResource extends Resource
|
||||
->icon('tabler-settings')
|
||||
->color('primary')
|
||||
->visible(fn (Plugin $plugin) => $plugin->isEnabled() && $plugin->hasSettings())
|
||||
->form(fn (Plugin $plugin) => $plugin->getSettingsForm())
|
||||
->schema(fn (Plugin $plugin) => $plugin->getSettingsForm())
|
||||
->action(fn (array $data, Plugin $plugin) => $plugin->saveSettings($data))
|
||||
->slideOver(),
|
||||
Action::make('install')
|
||||
@ -198,13 +198,14 @@ class PluginResource extends Resource
|
||||
}),
|
||||
Action::make('import')
|
||||
->label(trans('admin/plugin.import'))
|
||||
->authorize(fn (Plugin $plugin) => auth()->user()->can('create', $plugin))
|
||||
->authorize(fn () => auth()->user()->can('create', Plugin::class))
|
||||
->icon('tabler-download')
|
||||
->form([
|
||||
->schema([
|
||||
Tabs::make('Tabs')
|
||||
->contained(false)
|
||||
->tabs([
|
||||
Tab::make(trans('admin/plugin.from_file'))
|
||||
Tab::make('from_file')
|
||||
->label(trans('admin/plugin.from_file'))
|
||||
->icon('tabler-file-upload')
|
||||
->schema([
|
||||
FileUpload::make('file')
|
||||
@ -213,7 +214,8 @@ class PluginResource extends Resource
|
||||
->previewable(false)
|
||||
->storeFiles(false),
|
||||
]),
|
||||
Tab::make(trans('admin/plugin.from_url'))
|
||||
Tab::make('from_url')
|
||||
->label(trans('admin/plugin.from_url'))
|
||||
->icon('tabler-world-upload')
|
||||
->schema([
|
||||
TextInput::make('url')
|
||||
@ -254,9 +256,9 @@ class PluginResource extends Resource
|
||||
->emptyStateHeading(trans('admin/plugin.no_plugins'));
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
return $schema
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\PluginResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Plugins\Pages;
|
||||
|
||||
use App\Enums\PluginCategory;
|
||||
use App\Facades\Plugins;
|
||||
use App\Filament\Admin\Resources\PluginResource;
|
||||
use App\Models\Plugin;
|
||||
use Filament\Resources\Components\Tab;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
|
||||
class ListPlugins extends ListRecords
|
||||
{
|
||||
protected static string $resource = PluginResource::class;
|
||||
|
||||
public function reorderTable(array $order): void
|
||||
public function reorderTable(array $order, int|string|null $draggedRecordKey = null): void
|
||||
{
|
||||
Plugins::updateLoadOrder($order);
|
||||
}
|
||||
@ -23,13 +23,15 @@ class ListPlugins extends ListRecords
|
||||
$tabs = [];
|
||||
|
||||
foreach (PluginCategory::cases() as $category) {
|
||||
$tabs[$category->value] = Tab::make($category->getLabel())
|
||||
$tabs[$category->value] = Tab::make($category->value)
|
||||
->label($category->getLabel())
|
||||
->icon($category->getIcon())
|
||||
->badge(Plugin::whereCategory($category->value)->count())
|
||||
->modifyQueryUsing(fn ($query) => $query->whereCategory($category->value));
|
||||
}
|
||||
|
||||
$tabs['all'] = Tab::make(trans('admin/plugin.all'))
|
||||
$tabs['all'] = Tab::make('all')
|
||||
->label(trans('admin/plugin.all'))
|
||||
->badge(Plugin::count());
|
||||
|
||||
return $tabs;
|
||||
@ -6,7 +6,7 @@ use App\Contracts\Plugins\HasPluginSettings;
|
||||
use App\Enums\PluginCategory;
|
||||
use App\Enums\PluginStatus;
|
||||
use Exception;
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@ -6,6 +6,7 @@ use App\Filament\Admin\Resources\Servers\Pages\EditServer;
|
||||
use App\Filament\App\Resources\Servers\Pages\ListServers;
|
||||
use App\Http\Middleware\Activity\ServerSubject;
|
||||
use App\Models\Server;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Navigation\NavigationItem;
|
||||
use Filament\Panel;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user