-
Notifications
You must be signed in to change notification settings - Fork 13
Add the possibility to duplicate pages #782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds functionality to duplicate pages in the panel. Users can now duplicate pages through a new modal dialog, which copies the page content and allows setting a new title and slug for the duplicate.
Key changes:
- Added a duplicate page modal with title and slug fields
- Added duplicate buttons to the page tree view and editor view with permission checks
- Implemented backend duplication logic that copies page content and handles file operations
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| panel/views/pages/tree.php | Adds duplicate modal registration and duplicate button in dropdown menu |
| panel/views/pages/editor.php | Adds duplicate modal registration and restructures page actions into a dropdown menu containing duplicate and delete options |
| panel/translations/en.yaml | Adds translation keys for duplicate page action and default title format |
| panel/src/ts/components/views/pages.ts | Imports makeSlug utility and adds modal handler to pre-fill duplicate title/slug fields |
| panel/modals/duplicatePage.yaml | Defines modal configuration with title and slug fields |
| panel/config/routes/routes.php | Registers new route for duplicate action |
| panel/assets/icons/svg/duplicate.svg | Adds duplicate icon SVG |
| formwork/src/Panel/Controllers/PagesController.php | Implements duplicate controller action with validation and error handling |
| formwork/src/Pages/Page.php | Adds isDuplicable() method, duplicate() method, and refactors save() to use new write() method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
You are on a roll with all these PR recently :) And I see you started some work with plugins too.. That's really exciting! Thank for this great CMS |
dfc35f1 to
262f21f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request adds a "Duplicate Page" feature to the CMS, allowing users to create a copy of an existing page through the panel UI. The implementation includes backend logic for duplicating a page, frontend modal integration, new route and permissions checks, and UI updates to expose the feature in both the page editor and the page tree.
The most important changes are:
Backend functionality:
isDuplicable()andduplicate()methods to thePageclass, enabling logic to check if a page can be duplicated and to perform the duplication, including copying content and updating fields like slug and title. [1] [2] [3]duplicateinPagesControllerto handle the duplication request, validate input, and redirect the user to the new page's editor. Also added a helper methodduplicatePagefor the duplication process and content history update. [1] [2]panel.pages.duplicatefor the duplication endpoint.Frontend and UI integration:
duplicatePage.yamlfor collecting title and slug when duplicating a page.Frontend logic:
pages.tscomponent to handle opening the duplicate modal, pre-filling the title and slug fields using the original page title, and generating a slug automatically. [1] [2] [3]Localization: