Skip to content

Commit d69a9c0

Browse files
scott graysonscott grayson
authored andcommitted
Fix file upload media collection and breadcrumb duplicates
- Fix file upload actions to use default media collection with ->toMediaCollection() - Fix duplicate breadcrumbs in EditLibraryItemPage by starting with parent - Move views to src/Resources/views and make publishing optional - Create missing views: tags-column, permissions-column, video-embed - Remove custom media collection usage in favor of default collection - Update service provider to load views from src directory
1 parent 712aa9e commit d69a9c0

File tree

18 files changed

+130
-286
lines changed

18 files changed

+130
-286
lines changed

resources/views/.gitkeep

Whitespace-only changes.

resources/views/components/folder-picker.blade.php

Lines changed: 0 additions & 85 deletions
This file was deleted.

resources/views/forms/components/folder-picker.blade.php

Lines changed: 0 additions & 53 deletions
This file was deleted.

resources/views/infolists/components/video-embed.blade.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

resources/views/tables/columns/permissions-column.blade.php

Lines changed: 0 additions & 44 deletions
This file was deleted.

resources/views/tables/columns/tags-column.blade.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/FilamentLibraryServiceProvider.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ public function configurePackage(Package $package): void
5252
$package->hasTranslations();
5353
}
5454

55-
if (file_exists($package->basePath('/../resources/views'))) {
56-
$package->hasViews(static::$viewNamespace);
57-
}
55+
// Views are loaded manually to avoid automatic publishing
56+
// Users can publish them manually with: php artisan vendor:publish --tag=filament-library-views
5857
}
5958

6059
public function packageRegistered(): void {}
@@ -90,6 +89,14 @@ public function packageBooted(): void
9089
}
9190
}
9291

92+
// Load views manually from src directory
93+
$this->loadViewsFrom(__DIR__ . '/Resources/views', static::$viewNamespace);
94+
95+
// Publish views manually (optional)
96+
$this->publishes([
97+
__DIR__ . '/Resources/views' => resource_path('views/vendor/filament-library'),
98+
], 'filament-library-views');
99+
93100
// Testing - No custom test mixins needed
94101
}
95102

src/Models/LibraryItem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public function getDisplayIcon(): string
498498
*/
499499
public function registerMediaCollections(): void
500500
{
501-
$this->addMediaCollection('files');
501+
// Using default collection - no need to register custom collection
502502
}
503503

504504
/**
@@ -516,7 +516,7 @@ public function registerMediaConversions(?Media $media = null): void
516516
*/
517517
public function getSecureUrl(?int $expirationMinutes = null): string
518518
{
519-
$media = $this->getFirstMedia('files');
519+
$media = $this->getFirstMedia();
520520

521521
if (! $media) {
522522
return '';

src/Resources/LibraryItemResource.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public static function form(Schema $schema): Schema
9595
// File form fields
9696
\Filament\Forms\Components\SpatieMediaLibraryFileUpload::make('files')
9797
->label('File')
98-
->collection('files')
9998
->visible(fn (callable $get) => $get('type') === 'file')
10099
->required(fn (callable $get) => $get('type') === 'file'),
101100

src/Resources/Pages/EditFile.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public function form(\Filament\Schemas\Schema $schema): \Filament\Schemas\Schema
3737
->maxLength(255),
3838

3939
\Filament\Forms\Components\SpatieMediaLibraryFileUpload::make('files')
40-
->label('File')
41-
->collection('files'),
40+
->label('File'),
4241

4342
\Filament\Forms\Components\Textarea::make('link_description')
4443
->label('Description')

0 commit comments

Comments
 (0)