Add the possibility to delete pages in place from the tree - #781
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds AJAX-based page deletion functionality to the pages tree view, enabling in-place deletion without page reloads. The implementation follows the existing pattern used for file deletion.
- Introduces a new
deletePageItemmodal with command-based actions for AJAX requests - Updates the
PagesController::deletemethod to handle both traditional form submissions and XHR requests with JSON responses - Adds TypeScript handling for the delete operation with dynamic UI updates (removing items, updating parent state)
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| panel/views/pages/tree.php | Updates modal reference and data attribute for AJAX-based deletion |
| panel/src/ts/components/views/pages.ts | Adds modal handlers for AJAX page deletion with UI state management |
| panel/modals/deletePageItem.yaml | Defines new command-based modal configuration for tree item deletion |
| panel/config/routes/routes.php | Enables XHR support for the delete route |
| formwork/src/Panel/Controllers/PagesController.php | Adds JSON response handling for AJAX delete requests |
馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the user experience and robustness of deleting pages in the panel by introducing a dedicated modal for page deletion and enhancing both backend and frontend handling of delete actions, especially for AJAX (XHR) requests. The changes ensure that errors and success messages are communicated appropriately whether the action is performed via a standard HTTP request or an XHR request, and that the UI updates dynamically after deletion.
Backend enhancements for delete actions:
PagesController@deletemethod now returns JSON error responses for XHR requests when the page is not found, the language is invalid, or the page is not deletable, ensuring AJAX requests receive structured error feedback. [1] [2]panel.pages.deleteroute now explicitly supports both HTTP and XHR request types, clarifying its usage for AJAX operations.Frontend and modal improvements:
deletePageItem.yamlis added for deleting pages, with clear messaging and command handling.deletePageItemModalfor delete actions, and the modal is properly initialized in the TypeScript logic. [1] [2] [3]pages.ts) is updated to handle the new modal's open and command events, sending the delete request via AJAX, updating the UI to remove the deleted page, and showing notifications based on the server response.These changes collectively make page deletion more user-friendly, reliable, and consistent across different types of requests.