From bf655b148adea2f10b7d43112f9f37cb3e25ddd6 Mon Sep 17 00:00:00 2001 From: Scott Grayson Date: Tue, 31 Mar 2026 12:17:22 -0400 Subject: [PATCH] feat: show shared items in main Library view Items explicitly shared with a user now appear in the Library root alongside public items, instead of only in "Shared with Me." Adds a "Shared with you" label on items shared with the current user. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/Resources/LibraryItemResource.php | 12 ++++++++++++ src/Resources/Pages/ListLibraryItems.php | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/Resources/LibraryItemResource.php b/src/Resources/LibraryItemResource.php index 5fd5549..c494a2b 100644 --- a/src/Resources/LibraryItemResource.php +++ b/src/Resources/LibraryItemResource.php @@ -181,6 +181,18 @@ public static function table(Table $table): Table }) ->icon(fn (?LibraryItem $record): string => $record?->getDisplayIcon() ?? 'heroicon-o-document') ->iconPosition('before') + ->description(function (?LibraryItem $record): ?string { + $user = auth()->user(); + if (! $user || ! $record) { + return null; + } + + if ($record->created_by !== $user->id && $record->permissions()->where('user_id', $user->id)->exists()) { + return 'Shared with you'; + } + + return null; + }) ->url(function (?LibraryItem $record): ?string { if (! $record) { return null; diff --git a/src/Resources/Pages/ListLibraryItems.php b/src/Resources/Pages/ListLibraryItems.php index e444218..3f6fbf5 100644 --- a/src/Resources/Pages/ListLibraryItems.php +++ b/src/Resources/Pages/ListLibraryItems.php @@ -243,6 +243,11 @@ protected function getTableQuery(): Builder // Creators can see their own items (even if private) if ($user) { $q->orWhere('created_by', $user->id); + + // Users can see items explicitly shared with them + $q->orWhereHas('permissions', function ($pq) use ($user) { + $pq->where('user_id', $user->id); + }); } }) ->where('name', 'not like', "%'s Personal Folder");