From 847a57a49aef525d2f7f429a30e58a34cf69d43f Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sun, 25 Jun 2023 23:22:49 +0100 Subject: [PATCH] Shelf permissions: Removed unused 'create' permission from view Was causing confusion. Added test to cover. Also added migration to remove existing create entries to pre-emptively avoid issues in future if 'create' is used again. --- ...ve_bookshelf_create_entity_permissions.php | 29 +++++++++++++++++++ .../form/entity-permissions-row.blade.php | 2 +- tests/Permissions/EntityPermissionsTest.php | 9 ++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2023_06_25_181952_remove_bookshelf_create_entity_permissions.php diff --git a/database/migrations/2023_06_25_181952_remove_bookshelf_create_entity_permissions.php b/database/migrations/2023_06_25_181952_remove_bookshelf_create_entity_permissions.php new file mode 100644 index 000000000..efb65972b --- /dev/null +++ b/database/migrations/2023_06_25_181952_remove_bookshelf_create_entity_permissions.php @@ -0,0 +1,29 @@ +where('entity_type', '=', 'bookshelf') + ->update(['create' => 0]); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // No structural changes to make, and we cannot know the permissions to re-assign. + } +}; diff --git a/resources/views/form/entity-permissions-row.blade.php b/resources/views/form/entity-permissions-row.blade.php index 6b515af86..5c2e86741 100644 --- a/resources/views/form/entity-permissions-row.blade.php +++ b/resources/views/form/entity-permissions-row.blade.php @@ -44,7 +44,7 @@ $inheriting - Boolean if the current row should be marked as inheriting default 'disabled' => $inheriting ]) - @if($entityType !== 'page') + @if($entityType !== 'page' && $entityType !== 'bookshelf')
@include('form.custom-checkbox', [ 'name' => 'permissions[' . $role->id . '][create]', diff --git a/tests/Permissions/EntityPermissionsTest.php b/tests/Permissions/EntityPermissionsTest.php index 3c4bf4a77..035546593 100644 --- a/tests/Permissions/EntityPermissionsTest.php +++ b/tests/Permissions/EntityPermissionsTest.php @@ -413,6 +413,15 @@ class EntityPermissionsTest extends TestCase $this->entityRestrictionFormTest(Page::class, 'Page Permissions', 'delete', '2'); } + public function test_shelf_create_permission_not_visible() + { + $shelf = $this->entities->shelf(); + + $resp = $this->asAdmin()->get($shelf->getUrl('/permissions')); + $html = $this->withHtml($resp); + $html->assertElementNotExists('input[name$="[create]"]'); + } + public function test_restricted_pages_not_visible_in_book_navigation_on_pages() { $chapter = $this->entities->chapter();