]> BookStack Code Mirror - bookstack/commitdiff
Shelf permissions: reverted create removal
authorDan Brown <redacted>
Wed, 12 Jul 2023 21:04:05 +0000 (22:04 +0100)
committerDan Brown <redacted>
Wed, 12 Jul 2023 21:04:05 +0000 (22:04 +0100)
Reverted work in 847a57a49aef525d2f7f429a30e58a34cf69d43f.
Left test in but updated to new expectation.
Left migration in but removed content to prevent new pre-v23.06
upgraders loosing shelf create permission status.
Added note to permission to describe use-case.

For #4375

database/migrations/2023_06_25_181952_remove_bookshelf_create_entity_permissions.php
lang/en/entities.php
resources/views/form/entity-permissions-row.blade.php
resources/views/form/entity-permissions.blade.php
tests/Permissions/EntityPermissionsTest.php

index efb65972b5f815cd4f14caf4eddfb9e363c7a91b..b5dcaee751c27bae829eabd835eed52131c1fcc2 100644 (file)
@@ -12,9 +12,10 @@ return new class extends Migration
      */
     public function up()
     {
-        DB::table('entity_permissions')
-            ->where('entity_type', '=', 'bookshelf')
-            ->update(['create' => 0]);
+        // Note: v23.06.2
+        // Migration removed since change to remove bookshelf create permissions was reverted.
+        // Create permissions were removed as incorrectly thought to be unused, but they did
+        // have a use via shelf permission copy-down to books.
     }
 
     /**
index 8cd7e925f8e7ef71710d9d45e113be9f6399c5d2..4fb043aa9d06a4ade958301c7b6eea54c77eb7a0 100644 (file)
@@ -106,6 +106,7 @@ return [
     'shelves_permissions_updated' => 'Shelf Permissions Updated',
     'shelves_permissions_active' => 'Shelf Permissions Active',
     'shelves_permissions_cascade_warning' => 'Permissions on shelves do not automatically cascade to contained books. This is because a book can exist on multiple shelves. Permissions can however be copied down to child books using the option found below.',
+    'shelves_permissions_create' => 'Shelf create permissions are only used for copying permissions to child books using the action below. They do not control the ability to create books.',
     'shelves_copy_permissions_to_books' => 'Copy Permissions to Books',
     'shelves_copy_permissions' => 'Copy Permissions',
     'shelves_copy_permissions_explain' => 'This will apply the current permission settings of this shelf to all books contained within. Before activating, ensure any changes to the permissions of this shelf have been saved.',
index 5c2e8674178b95e5ed2e3f16a4ffda0f77be7e1f..a47027d795e42d592529979d495f674245f5f310 100644 (file)
@@ -44,11 +44,11 @@ $inheriting - Boolean if the current row should be marked as inheriting default
                 'disabled' => $inheriting
             ])
         </div>
-        @if($entityType !== 'page' && $entityType !== 'bookshelf')
+        @if($entityType !== 'page')
             <div class="px-l">
                 @include('form.custom-checkbox', [
                     'name' =>  'permissions[' . $role->id . '][create]',
-                    'label' => trans('common.create'),
+                    'label' => trans('common.create') . ($entityType === 'bookshelf' ? ' *'  : ''),
                     'value' => 'true',
                     'checked' => $permission->create,
                     'disabled' => $inheriting
index 8eddac8dea0e9a1300ea60e941a7b578af4c0cbc..cf5314ad4a17d1138fa5d00ef98da45788edd075 100644 (file)
 
     <hr class="mb-m">
 
-    <div class="text-right">
-        <a href="{{ $model->getUrl() }}" class="button outline">{{ trans('common.cancel') }}</a>
-        <button type="submit" class="button">{{ trans('entities.permissions_save') }}</button>
+    <div class="flex-container-row justify-space-between gap-m wrap">
+        <div class="flex min-width-m">
+            @if($model instanceof \BookStack\Entities\Models\Bookshelf)
+                <p class="small text-muted mb-none">
+                    * {{ trans('entities.shelves_permissions_create') }}
+                </p>
+            @endif
+        </div>
+        <div class="text-right">
+            <a href="{{ $model->getUrl() }}" class="button outline">{{ trans('common.cancel') }}</a>
+            <button type="submit" class="button">{{ trans('entities.permissions_save') }}</button>
+        </div>
     </div>
 </form>
\ No newline at end of file
index 035546593d376bbf9a45d8467fb084b5d97e931c..6ea0257b81e5c1d6dced3c8c279c837e181fb122 100644 (file)
@@ -413,13 +413,14 @@ class EntityPermissionsTest extends TestCase
         $this->entityRestrictionFormTest(Page::class, 'Page Permissions', 'delete', '2');
     }
 
-    public function test_shelf_create_permission_not_visible()
+    public function test_shelf_create_permission_visible_with_notice()
     {
         $shelf = $this->entities->shelf();
 
         $resp = $this->asAdmin()->get($shelf->getUrl('/permissions'));
         $html = $this->withHtml($resp);
-        $html->assertElementNotExists('input[name$="[create]"]');
+        $html->assertElementExists('input[name$="[create]"]');
+        $resp->assertSee('Shelf create permissions are only used for copying permissions to child books using the action below.');
     }
 
     public function test_restricted_pages_not_visible_in_book_navigation_on_pages()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.