mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-22 21:51:50 +08:00
Page Drafts: Added new "Delete Draft" action to draft menu
Provides a way for users to actually delte their user drafts where required. For #3927 Added test to cover new endpoint. Makes update to MD editor #setText so that new selection is within new range, otherwise it errors and fails operation.
This commit is contained in:
@ -5,6 +5,7 @@ namespace BookStack\Entities\Controllers;
|
||||
use BookStack\Activity\ActivityType;
|
||||
use BookStack\Entities\Models\PageRevision;
|
||||
use BookStack\Entities\Repos\PageRepo;
|
||||
use BookStack\Entities\Repos\RevisionRepo;
|
||||
use BookStack\Entities\Tools\PageContent;
|
||||
use BookStack\Exceptions\NotFoundException;
|
||||
use BookStack\Facades\Activity;
|
||||
@ -16,7 +17,8 @@ use Ssddanbrown\HtmlDiff\Diff;
|
||||
class PageRevisionController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected PageRepo $pageRepo
|
||||
protected PageRepo $pageRepo,
|
||||
protected RevisionRepo $revisionRepo,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -154,4 +156,15 @@ class PageRevisionController extends Controller
|
||||
|
||||
return redirect($page->getUrl('/revisions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys existing drafts, belonging to the current user, for the given page.
|
||||
*/
|
||||
public function destroyUserDraft(string $pageId)
|
||||
{
|
||||
$page = $this->pageRepo->getById($pageId);
|
||||
$this->revisionRepo->deleteDraftsForCurrentUser($page);
|
||||
|
||||
return response('', 200);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user