Skip to content

Commit 847a57a

Browse files
committed
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.
1 parent c74a260 commit 847a57a

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Support\Facades\DB;
5+
6+
return new class extends Migration
7+
{
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
DB::table('entity_permissions')
16+
->where('entity_type', '=', 'bookshelf')
17+
->update(['create' => 0]);
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*
23+
* @return void
24+
*/
25+
public function down()
26+
{
27+
// No structural changes to make, and we cannot know the permissions to re-assign.
28+
}
29+
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ 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')
47+
@if($entityType !== 'page' && $entityType !== 'bookshelf')
4848
<div class="px-l">
4949
@include('form.custom-checkbox', [
5050
'name' => 'permissions[' . $role->id . '][create]',

tests/Permissions/EntityPermissionsTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,15 @@ 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()
417+
{
418+
$shelf = $this->entities->shelf();
419+
420+
$resp = $this->asAdmin()->get($shelf->getUrl('/permissions'));
421+
$html = $this->withHtml($resp);
422+
$html->assertElementNotExists('input[name$="[create]"]');
423+
}
424+
416425
public function test_restricted_pages_not_visible_in_book_navigation_on_pages()
417426
{
418427
$chapter = $this->entities->chapter();

0 commit comments

Comments
 (0)