diff --git a/resources/js/components/collections/Listing.vue b/resources/js/components/collections/Listing.vue
index cdb1e30507b..802abb73045 100644
--- a/resources/js/components/collections/Listing.vue
+++ b/resources/js/components/collections/Listing.vue
@@ -3,7 +3,7 @@
- {{ __(collection.title) }}
+ {{ __(collection.title) }}
diff --git a/resources/js/components/navigation/Listing.vue b/resources/js/components/navigation/Listing.vue
index 256d8c6300e..8f6e71dc5b5 100644
--- a/resources/js/components/navigation/Listing.vue
+++ b/resources/js/components/navigation/Listing.vue
@@ -3,7 +3,7 @@
-
+
diff --git a/src/CP/Navigation/CoreNav.php b/src/CP/Navigation/CoreNav.php
index 383c4af0733..913ddbe7ddc 100644
--- a/src/CP/Navigation/CoreNav.php
+++ b/src/CP/Navigation/CoreNav.php
@@ -16,8 +16,10 @@
use Statamic\Facades\GlobalSet as GlobalSetAPI;
use Statamic\Facades\Nav as NavAPI;
use Statamic\Facades\Role as RoleAPI;
+use Statamic\Facades\Site;
use Statamic\Facades\Stache;
use Statamic\Facades\Taxonomy as TaxonomyAPI;
+use Statamic\Facades\User;
use Statamic\Facades\UserGroup as UserGroupAPI;
use Statamic\Facades\Utility;
use Statamic\Statamic;
@@ -65,11 +67,20 @@ protected function makeContentSection()
->icon('/content-writing')
->can('index', Collection::class)
->children(function () {
- return CollectionAPI::all()->sortBy->title()->map(function ($collection) {
- return Nav::item($collection->title())
- ->url($collection->showUrl())
- ->can('view', $collection);
- });
+ return CollectionAPI::all()->sortBy->title()
+ ->filter(function ($collection) {
+ return User::current()->can('configure collections')
+ || $collection->sites()->contains(Site::selected()->handle());
+ })
+ ->map(function ($collection) {
+ return Nav::item($collection->title())
+ ->url(
+ $collection->sites()->contains(Site::selected()->handle())
+ ? $collection->showUrl()
+ : $collection->editUrl()
+ )
+ ->can('view', $collection);
+ });
});
Nav::content('Navigation')
@@ -77,11 +88,20 @@ protected function makeContentSection()
->icon('/hierarchy-files')
->can('index', NavContract::class)
->children(function () {
- return NavAPI::all()->sortBy->title()->map(function ($nav) {
- return Nav::item($nav->title())
- ->url($nav->showUrl())
- ->can('view', $nav);
- });
+ return NavAPI::all()->sortBy->title()
+ ->filter(function ($nav) {
+ return User::current()->can('configure navs')
+ || $nav->sites()->contains(Site::selected()->handle());
+ })
+ ->map(function ($nav) {
+ return Nav::item($nav->title())
+ ->url(
+ $nav->sites()->contains(Site::selected()->handle())
+ ? $nav->showUrl()
+ : $nav->editUrl()
+ )
+ ->can('view', $nav);
+ });
});
Nav::content('Taxonomies')
@@ -113,13 +133,18 @@ protected function makeContentSection()
->icon('/earth')
->can('index', GlobalSet::class)
->children(function () {
- return GlobalSetAPI::all()->sortBy->title()->map(function ($globalSet) {
- $localized = $globalSet->inSelectedSite();
+ return GlobalSetAPI::all()->sortBy->title()
+ ->filter(function ($globalSet) {
+ return User::current()->can('configure globals')
+ || ! is_null($globalSet->inSelectedSite());
+ })
+ ->map(function ($globalSet) {
+ $localized = $globalSet->inSelectedSite();
- return Nav::item($globalSet->title())
- ->url($localized ? $localized->editUrl() : $globalSet->editUrl())
- ->can('view', $globalSet);
- })->filter();
+ return Nav::item($globalSet->title())
+ ->url($localized ? $localized->editUrl() : $globalSet->editUrl())
+ ->can('view', $globalSet);
+ })->filter();
});
return $this;
diff --git a/src/Http/Controllers/CP/Collections/CollectionsController.php b/src/Http/Controllers/CP/Collections/CollectionsController.php
index b73a40d953a..84d39313e6b 100644
--- a/src/Http/Controllers/CP/Collections/CollectionsController.php
+++ b/src/Http/Controllers/CP/Collections/CollectionsController.php
@@ -24,7 +24,9 @@ public function index()
$this->authorize('index', CollectionContract::class, __('You are not authorized to view collections.'));
$collections = Collection::all()->filter(function ($collection) {
- return User::current()->can('view', $collection);
+ return User::current()->can('configure collections')
+ || User::current()->can('view', $collection)
+ && $collection->sites()->contains(Site::selected()->handle());
})->map(function ($collection) {
return [
'id' => $collection->handle(),
@@ -39,6 +41,7 @@ public function index()
'deleteable' => User::current()->can('delete', $collection),
'editable' => User::current()->can('edit', $collection),
'blueprint_editable' => User::current()->can('configure fields'),
+ 'available_in_selected_site' => $collection->sites()->contains(Site::selected()->handle()),
];
})->values();
diff --git a/src/Http/Controllers/CP/Navigation/NavigationController.php b/src/Http/Controllers/CP/Navigation/NavigationController.php
index 11537dd73e6..4df03b64117 100644
--- a/src/Http/Controllers/CP/Navigation/NavigationController.php
+++ b/src/Http/Controllers/CP/Navigation/NavigationController.php
@@ -18,7 +18,8 @@ public function index()
$this->authorize('index', NavContract::class, __('You are not authorized to view navs.'));
$navs = Nav::all()->filter(function ($nav) {
- return User::current()->can('view', $nav);
+ return User::current()->can('configure navs')
+ || ($nav->sites()->contains(Site::selected()->handle()) && User::current()->can('view', $nav));
})->map(function ($structure) {
return [
'id' => $structure->handle(),
@@ -27,6 +28,7 @@ public function index()
'edit_url' => $structure->editUrl(),
'delete_url' => $structure->deleteUrl(),
'deleteable' => User::current()->can('delete', $structure),
+ 'available_in_selected_site' => $structure->sites()->contains(Site::selected()->handle()),
];
})->values();
diff --git a/tests/Feature/Collections/ViewCollectionListingTest.php b/tests/Feature/Collections/ViewCollectionListingTest.php
index 8e50ab5afb6..739aacd51f8 100644
--- a/tests/Feature/Collections/ViewCollectionListingTest.php
+++ b/tests/Feature/Collections/ViewCollectionListingTest.php
@@ -42,6 +42,7 @@ public function it_shows_a_list_of_collections()
'deleteable' => true,
'editable' => true,
'blueprint_editable' => true,
+ 'available_in_selected_site' => true,
],
[
'id' => 'bar',
@@ -56,6 +57,7 @@ public function it_shows_a_list_of_collections()
'deleteable' => true,
'editable' => true,
'blueprint_editable' => true,
+ 'available_in_selected_site' => true,
],
]))
->assertDontSee('no-results');