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.
This commit is contained in:
		
							parent
							
								
									c74a2608c4
								
							
						
					
					
						commit
						847a57a49a
					
				| 
						 | 
					@ -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.
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -44,7 +44,7 @@ $inheriting - Boolean if the current row should be marked as inheriting default
 | 
				
			||||||
                'disabled' => $inheriting
 | 
					                'disabled' => $inheriting
 | 
				
			||||||
            ])
 | 
					            ])
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        @if($entityType !== 'page')
 | 
					        @if($entityType !== 'page' && $entityType !== 'bookshelf')
 | 
				
			||||||
            <div class="px-l">
 | 
					            <div class="px-l">
 | 
				
			||||||
                @include('form.custom-checkbox', [
 | 
					                @include('form.custom-checkbox', [
 | 
				
			||||||
                    'name' =>  'permissions[' . $role->id . '][create]',
 | 
					                    'name' =>  'permissions[' . $role->id . '][create]',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -413,6 +413,15 @@ class EntityPermissionsTest extends TestCase
 | 
				
			||||||
        $this->entityRestrictionFormTest(Page::class, 'Page Permissions', 'delete', '2');
 | 
					        $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()
 | 
					    public function test_restricted_pages_not_visible_in_book_navigation_on_pages()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $chapter = $this->entities->chapter();
 | 
					        $chapter = $this->entities->chapter();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue