Skip to content

Commit ae83405

Browse files
committed
Shelf permissions: reverted create removal
Reverted work in 847a57a. 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
1 parent a831501 commit ae83405

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

database/migrations/2023_06_25_181952_remove_bookshelf_create_entity_permissions.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
*/
1313
public function up()
1414
{
15-
DB::table('entity_permissions')
16-
->where('entity_type', '=', 'bookshelf')
17-
->update(['create' => 0]);
15+
// Note: v23.06.2
16+
// Migration removed since change to remove bookshelf create permissions was reverted.
17+
// Create permissions were removed as incorrectly thought to be unused, but they did
18+
// have a use via shelf permission copy-down to books.
1819
}
1920

2021
/**

lang/en/entities.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
'shelves_permissions_updated' => 'Shelf Permissions Updated',
107107
'shelves_permissions_active' => 'Shelf Permissions Active',
108108
'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.',
109+
'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.',
109110
'shelves_copy_permissions_to_books' => 'Copy Permissions to Books',
110111
'shelves_copy_permissions' => 'Copy Permissions',
111112
'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.',

resources/views/form/entity-permissions-row.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ class="ml-auto flex-none text-small text-link text-button hover-underline item-l
4444
'disabled' => $inheriting
4545
])
4646
</div>
47-
@if($entityType !== 'page' && $entityType !== 'bookshelf')
47+
@if($entityType !== 'page')
4848
<div class="px-l">
4949
@include('form.custom-checkbox', [
5050
'name' => 'permissions[' . $role->id . '][create]',
51-
'label' => trans('common.create'),
51+
'label' => trans('common.create') . ($entityType === 'bookshelf' ? ' *' : ''),
5252
'value' => 'true',
5353
'checked' => $permission->create,
5454
'disabled' => $inheriting

resources/views/form/entity-permissions.blade.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,17 @@ class="bold">{{ trans('entities.permissions_role_override') }}</span></label>
7070

7171
<hr class="mb-m">
7272

73-
<div class="text-right">
74-
<a href="{{ $model->getUrl() }}" class="button outline">{{ trans('common.cancel') }}</a>
75-
<button type="submit" class="button">{{ trans('entities.permissions_save') }}</button>
73+
<div class="flex-container-row justify-space-between gap-m wrap">
74+
<div class="flex min-width-m">
75+
@if($model instanceof \BookStack\Entities\Models\Bookshelf)
76+
<p class="small text-muted mb-none">
77+
* {{ trans('entities.shelves_permissions_create') }}
78+
</p>
79+
@endif
80+
</div>
81+
<div class="text-right">
82+
<a href="{{ $model->getUrl() }}" class="button outline">{{ trans('common.cancel') }}</a>
83+
<button type="submit" class="button">{{ trans('entities.permissions_save') }}</button>
84+
</div>
7685
</div>
7786
</form>

tests/Permissions/EntityPermissionsTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,14 @@ public function test_page_restriction_form()
413413
$this->entityRestrictionFormTest(Page::class, 'Page Permissions', 'delete', '2');
414414
}
415415

416-
public function test_shelf_create_permission_not_visible()
416+
public function test_shelf_create_permission_visible_with_notice()
417417
{
418418
$shelf = $this->entities->shelf();
419419

420420
$resp = $this->asAdmin()->get($shelf->getUrl('/permissions'));
421421
$html = $this->withHtml($resp);
422-
$html->assertElementNotExists('input[name$="[create]"]');
422+
$html->assertElementExists('input[name$="[create]"]');
423+
$resp->assertSee('Shelf create permissions are only used for copying permissions to child books using the action below.');
423424
}
424425

425426
public function test_restricted_pages_not_visible_in_book_navigation_on_pages()

0 commit comments

Comments
 (0)