diff --git a/.env.example b/.env.example index 8856ed4f0..bb65d8aae 100644 --- a/.env.example +++ b/.env.example @@ -99,6 +99,7 @@ FFMPEG_BINARIES= FFPROBE_BINARIES= # filament +FILAMENT_DOMAIN_NAME= FILAMENT_PATH=/admin # filesystems diff --git a/.env.example-sail b/.env.example-sail index aef8678b9..580e046c4 100644 --- a/.env.example-sail +++ b/.env.example-sail @@ -99,6 +99,10 @@ ELASTIC_MIGRATIONS_TABLE=elastic_migrations FFMPEG_BINARIES= FFPROBE_BINARIES= +# filament +FILAMENT_DOMAIN_NAME= +FILAMENT_PATH=/admin + # filesystems FILESYSTEM_DISK=local diff --git a/app/Filament/Resources/Wiki/Video.php b/app/Filament/Resources/Wiki/Video.php index 61a61f7fe..8773b59e0 100644 --- a/app/Filament/Resources/Wiki/Video.php +++ b/app/Filament/Resources/Wiki/Video.php @@ -15,6 +15,7 @@ use App\Filament\Resources\Wiki\Video\Pages\ListVideos; use App\Filament\Resources\Wiki\Video\Pages\ViewVideo; use App\Filament\Resources\Wiki\Video\RelationManagers\EntryVideoRelationManager; +use App\Filament\Resources\Wiki\Video\RelationManagers\ScriptVideoRelationManager; use App\Filament\Resources\Wiki\Video\RelationManagers\TrackVideoRelationManager; use App\Filament\TableActions\Repositories\Storage\Wiki\Video\ReconcileVideoTableAction; use App\Filament\TableActions\Storage\Wiki\Video\UploadVideoTableAction; @@ -178,27 +179,6 @@ public static function form(Form $form): Form ->label(__('filament.resources.singularLabel.audio')) ->relationship(VideoModel::RELATION_AUDIO, AudioModel::ATTRIBUTE_FILENAME) ->searchable(), - - TextInput::make(VideoModel::ATTRIBUTE_BASENAME) - ->label(__('filament.fields.video.basename.name')) - ->hiddenOn(['create', 'edit']), - - TextInput::make(VideoModel::ATTRIBUTE_FILENAME) - ->label(__('filament.fields.video.filename.name')) - ->hiddenOn(['create', 'edit']), - - TextInput::make(VideoModel::ATTRIBUTE_PATH) - ->label(__('filament.fields.video.path.name')) - ->hiddenOn(['create', 'edit']), - - TextInput::make(VideoModel::ATTRIBUTE_SIZE) - ->label(__('filament.fields.video.size.name')) - ->numeric() - ->hiddenOn(['create', 'edit']), - - TextInput::make(VideoModel::ATTRIBUTE_MIMETYPE) - ->label(__('filament.fields.video.mimetype.name')) - ->hiddenOn(['create', 'edit']), ]) ->columns(1); } @@ -313,6 +293,7 @@ public static function getRelations(): array return [ RelationGroup::make(static::getLabel(), [ EntryVideoRelationManager::class, + ScriptVideoRelationManager::class, TrackVideoRelationManager::class, ]), ]; diff --git a/app/Filament/Resources/Wiki/Video/RelationManagers/ScriptVideoRelationManager.php b/app/Filament/Resources/Wiki/Video/RelationManagers/ScriptVideoRelationManager.php new file mode 100644 index 000000000..539cb174d --- /dev/null +++ b/app/Filament/Resources/Wiki/Video/RelationManagers/ScriptVideoRelationManager.php @@ -0,0 +1,117 @@ +heading(ScriptResource::getLabel()) + ->modelLabel(ScriptResource::getLabel()) + ->recordTitleAttribute(VideoScript::ATTRIBUTE_PATH) + ->inverseRelationship(VideoScript::RELATION_VIDEO) + ->columns(ScriptResource::table($table)->getColumns()) + ->filters(static::getFilters()) + ->headerActions(static::getHeaderActions()) + ->actions(static::getActions()) + ->bulkActions(static::getBulkActions()); + } + + /** + * Get the filters available for the relation. + * + * @return array + * + * @noinspection PhpMissingParentCallCommonInspection + */ + public static function getFilters(): array + { + return array_merge( + parent::getFilters(), + [], + ); + } + + /** + * Get the actions available for the relation. + * + * @return array + * + * @noinspection PhpMissingParentCallCommonInspection + */ + public static function getActions(): array + { + return array_merge( + parent::getActions(), + [], + ); + } + + /** + * Get the bulk actions available for the relation. + * + * @return array + * + * @noinspection PhpMissingParentCallCommonInspection + */ + public static function getBulkActions(): array + { + return array_merge( + parent::getBulkActions(), + [], + ); + } + + /** + * Get the header actions available for the relation. + * + * @return array + * + * @noinspection PhpMissingParentCallCommonInspection + */ + public static function getHeaderActions(): array + { + return ScriptResource::getHeaderActions(); + } +} diff --git a/app/Filament/TableActions/Storage/Base/UploadTableAction.php b/app/Filament/TableActions/Storage/Base/UploadTableAction.php index 2aae88880..107d8e189 100644 --- a/app/Filament/TableActions/Storage/Base/UploadTableAction.php +++ b/app/Filament/TableActions/Storage/Base/UploadTableAction.php @@ -11,7 +11,6 @@ use Filament\Forms\Components\FileUpload; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; -use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Storage; /** @@ -49,11 +48,10 @@ public function getForm(Form $form): Form /** * Get the underlying storage action. * - * @param Model $model * @param array $fields * @return BaseUploadAction */ - abstract protected function storageAction(Model $model, array $fields): BaseUploadAction; + abstract protected function storageAction(array $fields): BaseUploadAction; /** * Get the file validation rules. diff --git a/app/Filament/TableActions/Storage/StorageTableAction.php b/app/Filament/TableActions/Storage/StorageTableAction.php index 82ac3d417..9e2f7478a 100644 --- a/app/Filament/TableActions/Storage/StorageTableAction.php +++ b/app/Filament/TableActions/Storage/StorageTableAction.php @@ -6,7 +6,6 @@ use App\Contracts\Actions\Storage\StorageAction as BaseStorageAction; use Filament\Tables\Actions\Action; -use Illuminate\Database\Eloquent\Model; /** * Class StorageTableAction. @@ -22,28 +21,26 @@ protected function setUp(): void { parent::setUp(); - $this->action(fn (Model $record, array $data) => $this->handle($record, $data)); + $this->action(fn (array $data) => $this->handle($data)); } /** * Get the underlying storage action. * - * @param Model $model * @param array $fields * @return BaseStorageAction */ - abstract protected function storageAction(Model $model, array $fields): BaseStorageAction; + abstract protected function storageAction(array $fields): BaseStorageAction; /** * Perform the action on the given models. * - * @param Model $model * @param array $fields * @return void */ - public function handle(Model $model, array $fields): void + public function handle(array $fields): void { - $action = $this->storageAction($model, $fields); + $action = $this->storageAction($fields); $storageResults = $action->handle(); diff --git a/app/Filament/TableActions/Storage/Wiki/Audio/UploadAudioTableAction.php b/app/Filament/TableActions/Storage/Wiki/Audio/UploadAudioTableAction.php index 4ea718684..34444c974 100644 --- a/app/Filament/TableActions/Storage/Wiki/Audio/UploadAudioTableAction.php +++ b/app/Filament/TableActions/Storage/Wiki/Audio/UploadAudioTableAction.php @@ -21,7 +21,6 @@ use App\Rules\Wiki\Submission\Format\ExtraneousMetadataFormatRule; use App\Rules\Wiki\Submission\Format\FormatNameFormatRule; use App\Rules\Wiki\Submission\Format\TotalStreamsFormatRule; -use Illuminate\Database\Eloquent\Model; use Illuminate\Http\UploadedFile; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Config; @@ -35,11 +34,10 @@ class UploadAudioTableAction extends UploadTableAction /** * Get the underlying storage action. * - * @param Model $model * @param array $fields * @return UploadAudio */ - protected function storageAction(Model $model, array $fields): UploadAudio + protected function storageAction(array $fields): UploadAudio { /** @var UploadedFile $file */ $file = Arr::get($fields, 'file'); diff --git a/app/Filament/TableActions/Storage/Wiki/Video/Script/UploadScriptTableAction.php b/app/Filament/TableActions/Storage/Wiki/Video/Script/UploadScriptTableAction.php index 34e815df0..56bcbfcac 100644 --- a/app/Filament/TableActions/Storage/Wiki/Video/Script/UploadScriptTableAction.php +++ b/app/Filament/TableActions/Storage/Wiki/Video/Script/UploadScriptTableAction.php @@ -6,11 +6,12 @@ use App\Actions\Storage\Wiki\Video\Script\UploadScriptAction as UploadScript; use App\Constants\Config\VideoConstants; +use App\Filament\Resources\BaseRelationManager; +use App\Filament\Resources\Wiki\Video\Script\Pages\ListScripts; use App\Models\Wiki\Video; use App\Filament\TableActions\Storage\Base\UploadTableAction; use Filament\Forms\Components\Hidden; use Filament\Forms\Form; -use Illuminate\Database\Eloquent\Model; use Illuminate\Http\UploadedFile; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Config; @@ -38,7 +39,7 @@ public function getForm(Form $form): Form [ Hidden::make(Video::ATTRIBUTE_ID) ->label(__('filament.resources.singularLabel.video')) - ->default(fn () => $model instanceof Video ? $model->getKey() : null), + ->default(fn (BaseRelationManager|ListScripts $livewire) => $livewire instanceof BaseRelationManager ? $livewire->getOwnerRecord()->getKey() : null), ], ) ); @@ -47,11 +48,10 @@ public function getForm(Form $form): Form /** * Get the underlying storage action. * - * @param Model $model * @param array $fields * @return UploadScript */ - protected function storageAction(Model $model, array $fields): UploadScript + protected function storageAction(array $fields): UploadScript { /** @var UploadedFile $file */ $file = Arr::get($fields, 'file'); diff --git a/app/Filament/TableActions/Storage/Wiki/Video/UploadVideoTableAction.php b/app/Filament/TableActions/Storage/Wiki/Video/UploadVideoTableAction.php index fd1a1bbf0..469d4b03d 100644 --- a/app/Filament/TableActions/Storage/Wiki/Video/UploadVideoTableAction.php +++ b/app/Filament/TableActions/Storage/Wiki/Video/UploadVideoTableAction.php @@ -40,7 +40,6 @@ use Filament\Forms\Components\Section; use Filament\Forms\Components\Select; use Filament\Forms\Form; -use Illuminate\Database\Eloquent\Model; use Illuminate\Http\UploadedFile; use Illuminate\Support\Arr; use Illuminate\Support\Str; @@ -129,11 +128,10 @@ public function getForm(Form $form): Form /** * Get the underlying storage action. * - * @param Model $model * @param array $fields * @return UploadVideo */ - protected function storageAction(Model $model, array $fields): UploadVideo + protected function storageAction(array $fields): UploadVideo { /** @var string|null $path */ $path = Arr::get($fields, 'path'); diff --git a/app/Providers/FilamentPanelProvider.php b/app/Providers/FilamentPanelProvider.php index f4efe90b0..1eceec85c 100644 --- a/app/Providers/FilamentPanelProvider.php +++ b/app/Providers/FilamentPanelProvider.php @@ -21,6 +21,7 @@ use Illuminate\Routing\Middleware\SubstituteBindings; use Illuminate\Session\Middleware\AuthenticateSession; use Illuminate\Session\Middleware\StartSession; +use Illuminate\Support\Facades\Config; use Illuminate\View\Middleware\ShareErrorsFromSession; class FilamentPanelProvider extends PanelProvider @@ -43,8 +44,9 @@ public function panel(Panel $panel): Panel return $panel ->default() - ->id('admin') - ->path('admin') + ->id(Config::get('filament.path')) + ->path(Config::get('filament.path')) + ->domain(Config::get('filament.domain')) ->login() ->databaseNotifications() ->sidebarCollapsibleOnDesktop() diff --git a/config/filament.php b/config/filament.php index f68580b16..25b062098 100644 --- a/config/filament.php +++ b/config/filament.php @@ -1,5 +1,7 @@ env('FILAMENT_DOMAIN_NAME'), + /* |-------------------------------------------------------------------------- | Filament Path diff --git a/config/livewire.php b/config/livewire.php new file mode 100644 index 000000000..eb8f6201c --- /dev/null +++ b/config/livewire.php @@ -0,0 +1,161 @@ + 'App\\Livewire', + + /* + |--------------------------------------------------------------------------- + | View Path + |--------------------------------------------------------------------------- + | + | This value is used to specify where Livewire component Blade templates are + | stored when running file creation commands like `artisan make:livewire`. + | It is also used if you choose to omit a component's render() method. + | + */ + + 'view_path' => resource_path('views/livewire'), + + /* + |--------------------------------------------------------------------------- + | Layout + |--------------------------------------------------------------------------- + | The view that will be used as the layout when rendering a single component + | as an entire page via `Route::get('/post/create', CreatePost::class);`. + | In this case, the view returned by CreatePost will render into $slot. + | + */ + + 'layout' => 'components.layouts.app', + + /* + |--------------------------------------------------------------------------- + | Lazy Loading Placeholder + |--------------------------------------------------------------------------- + | Livewire allows you to lazy load components that would otherwise slow down + | the initial page load. Every component can have a custom placeholder or + | you can define the default placeholder view for all components below. + | + */ + + 'lazy_placeholder' => null, + + /* + |--------------------------------------------------------------------------- + | Temporary File Uploads + |--------------------------------------------------------------------------- + | + | Livewire handles file uploads by storing uploads in a temporary directory + | before the file is stored permanently. All file uploads are directed to + | a global endpoint for temporary storage. You may configure this below: + | + */ + + 'temporary_file_upload' => [ + 'disk' => null, // Example: 'local', 's3' | Default: 'default' + 'rules' => ['file', 'max:204800'], // Example: ['file', 'mimes:png,jpg'] | Default: ['required', 'file', 'max:12288'] (12MB) + 'directory' => null, // Example: 'tmp' | Default: 'livewire-tmp' + 'middleware' => null, // Example: 'throttle:5,1' | Default: 'throttle:60,1' + 'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs... + 'png', 'gif', 'bmp', 'svg', 'wav', 'mp4', + 'mov', 'avi', 'wmv', 'mp3', 'm4a', + 'jpg', 'jpeg', 'mpga', 'webp', 'wma', + ], + 'max_upload_time' => 5, // Max duration (in minutes) before an upload is invalidated... + ], + + /* + |--------------------------------------------------------------------------- + | Render On Redirect + |--------------------------------------------------------------------------- + | + | This value determines if Livewire will run a component's `render()` method + | after a redirect has been triggered using something like `redirect(...)` + | Setting this to true will render the view once more before redirecting + | + */ + + 'render_on_redirect' => false, + + /* + |--------------------------------------------------------------------------- + | Eloquent Model Binding + |--------------------------------------------------------------------------- + | + | Previous versions of Livewire supported binding directly to eloquent model + | properties using wire:model by default. However, this behavior has been + | deemed too "magical" and has therefore been put under a feature flag. + | + */ + + 'legacy_model_binding' => false, + + /* + |--------------------------------------------------------------------------- + | Auto-inject Frontend Assets + |--------------------------------------------------------------------------- + | + | By default, Livewire automatically injects its JavaScript and CSS into the + | and of pages containing Livewire components. By disabling + | this behavior, you need to use @livewireStyles and @livewireScripts. + | + */ + + 'inject_assets' => true, + + /* + |--------------------------------------------------------------------------- + | Navigate (SPA mode) + |--------------------------------------------------------------------------- + | + | By adding `wire:navigate` to links in your Livewire application, Livewire + | will prevent the default link handling and instead request those pages + | via AJAX, creating an SPA-like effect. Configure this behavior here. + | + */ + + 'navigate' => [ + 'show_progress_bar' => true, + 'progress_bar_color' => '#2299dd', + ], + + /* + |--------------------------------------------------------------------------- + | HTML Morph Markers + |--------------------------------------------------------------------------- + | + | Livewire intelligently "morphs" existing HTML into the newly rendered HTML + | after each update. To make this process more reliable, Livewire injects + | "markers" into the rendered Blade surrounding @if, @class & @foreach. + | + */ + + 'inject_morph_markers' => true, + + /* + |--------------------------------------------------------------------------- + | Pagination Theme + |--------------------------------------------------------------------------- + | + | When enabling Livewire's pagination feature by using the `WithPagination` + | trait, Livewire will use Tailwind templates to render pagination views + | on the page. If you want Bootstrap CSS, you can specify: "bootstrap" + | + */ + + 'pagination_theme' => 'tailwind', +];