From 9aeb7d65449e29f54870755c205de8faf9f38193 Mon Sep 17 00:00:00 2001 From: Scott Grayson Date: Mon, 13 Jul 2026 11:54:52 -0400 Subject: [PATCH] fix: gate root-level shared items behind sharing config Classic consumers with show_nested_shared_in_library=false no longer see permission-shared root folders in the main Library view. Co-authored-by: Cursor --- CHANGELOG.md | 8 ++++++++ config/filament-library.php | 6 +++--- src/Resources/Pages/ListLibraryItems.php | 17 ++++++++++------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eab7407..0b9c96f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to `:package_name` will be documented in this file. +## v1.3.6 - 2026-07-13 + +### What's Changed + +* Fix `sharing.show_nested_shared_in_library` so it also gates root-level shared items in the main Library view (classic default `false` restores pre-v1.3.4 behavior) + +**Full Changelog**: https://github.com/TappNetwork/Filament-Library/compare/v1.3.5...v1.3.6 + ## v1.3.5 - 2026-07-10 ### What's Changed diff --git a/config/filament-library.php b/config/filament-library.php index 29dd32c..bf845f2 100644 --- a/config/filament-library.php +++ b/config/filament-library.php @@ -34,9 +34,9 @@ 'shared_with_me' => env('FILAMENT_LIBRARY_SHARED_WITH_ME', true), /* - | When true, nested (non-root) items with explicit per-user permissions - | also appear in the main Library view. Root-level shared items already - | appear there regardless of this setting. + | When true, items with explicit per-user permissions appear in the main + | Library view (root-level shared folders/files and nested shared items). + | When false, those items only appear on the Shared with Me page. */ 'show_nested_shared_in_library' => env('FILAMENT_LIBRARY_SHOW_NESTED_SHARED', false), ], diff --git a/src/Resources/Pages/ListLibraryItems.php b/src/Resources/Pages/ListLibraryItems.php index a779a32..f2d845d 100644 --- a/src/Resources/Pages/ListLibraryItems.php +++ b/src/Resources/Pages/ListLibraryItems.php @@ -228,12 +228,12 @@ protected function getTableQuery(): Builder $query->where('parent_id', $this->parentId); } else { $user = auth()->user(); - $showNestedShared = (bool) config('filament-library.sharing.show_nested_shared_in_library', false); + $showSharedInLibrary = (bool) config('filament-library.sharing.show_nested_shared_in_library', false); - $query->where(function (Builder $visibility) use ($user, $showNestedShared): void { - $visibility->where(function (Builder $root) use ($user): void { + $query->where(function (Builder $visibility) use ($user, $showSharedInLibrary): void { + $visibility->where(function (Builder $root) use ($user, $showSharedInLibrary): void { $root->whereNull('parent_id') - ->where(function (Builder $access) use ($user): void { + ->where(function (Builder $access) use ($user, $showSharedInLibrary): void { $access->where('general_access', 'anyone_can_view'); if ($user && FilamentLibraryPlugin::isLibraryAdmin($user)) { @@ -241,15 +241,18 @@ protected function getTableQuery(): Builder } if ($user) { - $access->orWhere('created_by', $user->id) - ->orWhereHas('permissions', function (Builder $permissions) use ($user): void { + $access->orWhere('created_by', $user->id); + + if ($showSharedInLibrary) { + $access->orWhereHas('permissions', function (Builder $permissions) use ($user): void { $permissions->where('user_id', $user->id); }); + } } }); }); - if ($user && $showNestedShared) { + if ($user && $showSharedInLibrary) { $visibility->orWhere(function (Builder $sharedNested) use ($user): void { $sharedNested->whereNotNull('parent_id') ->whereHas('permissions', function (Builder $permissions) use ($user): void {