Skip to content

Commit

Permalink
Shelf permissions: Removed unused 'create' permission from view
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ssddanbrown committed Jun 25, 2023
1 parent c74a260 commit 847a57a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::table('entity_permissions')
->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.
}
};
2 changes: 1 addition & 1 deletion resources/views/form/entity-permissions-row.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class="ml-auto flex-none text-small text-link text-button hover-underline item-l
'disabled' => $inheriting
])
</div>
@if($entityType !== 'page')
@if($entityType !== 'page' && $entityType !== 'bookshelf')
<div class="px-l">
@include('form.custom-checkbox', [
'name' => 'permissions[' . $role->id . '][create]',
Expand Down
9 changes: 9 additions & 0 deletions tests/Permissions/EntityPermissionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,15 @@ public function test_page_restriction_form()
$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();
Expand Down

0 comments on commit 847a57a

Please sign in to comment.