mirror of
				https://github.com/BookStackApp/BookStack.git
				synced 2025-11-03 02:13:16 +03:00 
			
		
		
		
	Updated page delete to return to chapter if within one
- Added test to cover Closes #1715
This commit is contained in:
		@@ -304,11 +304,12 @@ class PageController extends Controller
 | 
			
		||||
        $this->checkOwnablePermission('page-delete', $page);
 | 
			
		||||
 | 
			
		||||
        $book = $page->book;
 | 
			
		||||
        $parent = $page->chapter ?? $book;
 | 
			
		||||
        $this->pageRepo->destroy($page);
 | 
			
		||||
        Activity::addMessage('page_delete', $page->name, $book->id);
 | 
			
		||||
 | 
			
		||||
        $this->showSuccessNotification(trans('entities.pages_delete_success'));
 | 
			
		||||
        return redirect($book->getUrl());
 | 
			
		||||
        return redirect($parent->getUrl());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -315,4 +315,14 @@ class EntityTest extends BrowserKitTest
 | 
			
		||||
            ->seePageIs($book->getUrl());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function test_page_within_chapter_deletion_returns_to_chapter()
 | 
			
		||||
    {
 | 
			
		||||
        $chapter = Chapter::query()->first();
 | 
			
		||||
        $page = $chapter->pages()->first();
 | 
			
		||||
 | 
			
		||||
        $this->asEditor()->visit($page->getUrl('/delete'))
 | 
			
		||||
            ->submitForm('Confirm')
 | 
			
		||||
            ->seePageIs($chapter->getUrl());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user