Skip to content

Commit e64c511

Browse files
scottgraysonclaude
andcommitted
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) <noreply@anthropic.com>
1 parent 66de033 commit e64c511

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/Resources/LibraryItemResource.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,18 @@ public static function table(Table $table): Table
167167
})
168168
->icon(fn (?LibraryItem $record): string => $record?->getDisplayIcon() ?? 'heroicon-o-document')
169169
->iconPosition('before')
170+
->description(function (?LibraryItem $record): ?string {
171+
$user = auth()->user();
172+
if (! $user || ! $record) {
173+
return null;
174+
}
175+
176+
if ($record->created_by !== $user->id && $record->permissions()->where('user_id', $user->id)->exists()) {
177+
return 'Shared with you';
178+
}
179+
180+
return null;
181+
})
170182
->url(function (?LibraryItem $record): ?string {
171183
if (! $record) {
172184
return null;

src/Resources/Pages/ListLibraryItems.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ protected function getTableQuery(): \Illuminate\Database\Eloquent\Builder
240240
// Creators can see their own items (even if private)
241241
if ($user) {
242242
$q->orWhere('created_by', $user->id);
243+
244+
// Users can see items explicitly shared with them
245+
$q->orWhereHas('permissions', function ($pq) use ($user) {
246+
$pq->where('user_id', $user->id);
247+
});
243248
}
244249
})
245250
->where('name', 'not like', "%'s Personal Folder");

0 commit comments

Comments
 (0)