wedocs-plugin icon indicating copy to clipboard operation
wedocs-plugin copied to clipboard

feat: docs duplicator

Open sapayth opened this issue 2 months ago • 1 comments
trafficstars

fixes #132

added a Duplicate option for single docs only. The duplicate functionality will clone a doc with it's child (if exists). the duplicated docs status will be draft.

CleanShot 2025-09-22 at 12 43 01

Summary by CodeRabbit

  • New Features

    • Admins can duplicate an article (and its entire subtree) from the action menu.
    • Duplicates preserve content, hierarchy, metadata, taxonomy, and featured images.
    • After duplication, the article list refreshes automatically and remains visible.
    • Success and error notifications provide immediate feedback.
  • UI/UX

    • Added a “Duplicate” option to article actions for administrators.

sapayth avatar Sep 22 '25 06:09 sapayth

[!IMPORTANT]

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds a document duplication REST endpoint and recursive copy logic; integrates a new duplicate action in the UI and data layer. Updates built assets: PHP asset manifests (version hashes, opening tags), CSS (comments/source maps), JS bundles (webpack runtime). Overhauls built store.js into modular docs/settings stores.

Changes

Cohort / File(s) Summary of changes
Asset manifests (PHP tags + version bumps)
assets/build/block.asset.php, assets/build/frontend.asset.php, assets/build/index.asset.php, assets/build/print.asset.php, assets/build/store.asset.php
Added PHP opening tags where missing; updated version hashes; dependencies arrays unchanged.
Built CSS (comments and source maps)
assets/build/frontend.css, assets/build/index.css, assets/build/print.css, assets/build/style-block.css
Added loader-generated header comments and sourceMappingURL references; reformatted/expanded CSS output; no selector/value changes.
Built JS runtime additions
assets/build/frontend.js, assets/build/print.js
Added webpack bootstrap/runtime including webpack_require.r to mark ES modules; noted CSS extraction and source maps.
Data store (built bundle refactor)
assets/build/store.js
Replaced monolithic store with modular docs and settings stores, adding actions, reducers, selectors, resolvers, and controls; registers public stores.
API: document duplication
includes/API/API.php
Added REST route /docs/{id}/duplicate; implemented duplicate_doc and private duplicate_document_recursive to deep-copy posts, meta, terms, thumbnail, and children.
UI and source data actions
src/components/DocActions.js, src/data/docs/actions.js
Added Duplicate menu action for articles (admin); implemented *duplicateDoc(docId) generator to call API and refresh docs tree; added notifications and refresh handling.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • weDevsOfficial/wedocs-plugin#203 — Refactors store and defines docs store APIs; overlaps with modular store changes and docs actions added here.
  • weDevsOfficial/wedocs-plugin#198 — Reshapes JS data store into modular docs/settings stores; directly related to the built store.js overhaul.

Suggested labels

QA Approved, Ready To Merge

Suggested reviewers

  • iftakharul-islam

Poem

A hop, a skip, I copy trees of docs,
With whiskers twitching through recursive blocks.
A click—Duplicate!—and voilà, twins bloom,
The stash refreshed, no hint of gloom.
Hashes turn, maps align, bundles sing—
A rabbit’s merge, a springy thing. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The PR is linked to issue [#132], which requests that the search widget include article tags, but the changes in this PR implement a docs duplicator (new duplicate REST route and recursive copy in includes/API/API.php, UI Duplicate action in src/components/DocActions.js, and new store actions/resolvers in src/data/docs) and contain no modifications to the search widget or search/tag query logic; therefore the PR does not satisfy the coding requirements of [#132]. Resolution: Remove the reference to issue #132 or extend the PR to implement the tag-in-search changes required by [#132] (update the search query/widget to include tags and add tests or examples demonstrating tag-based search results).
Out of Scope Changes Check ⚠️ Warning Several changes in this PR are unrelated to the linked issue's objective (include tags in search): the addition of a duplication REST API and recursive duplicator, UI/menu changes to trigger duplication, a large refactor/modularization of the client store, and numerous built asset/version updates are all outside the single search-related objective, so the PR contains out-of-scope changes relative to the linked issue. Resolution: Split the duplication feature, store refactor, and build-asset updates into a dedicated, focused PR and keep the search/tag-change work in a separate PR that directly implements and tests the tag-in-search behavior, or update the linked issue to match the actual scope of this PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “feat: docs duplicator” clearly and concisely identifies the primary change of adding a document duplication feature, follows conventional commit style, and avoids unnecessary detail or noise, making it easy for teammates to grasp the main enhancement at a glance.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Sep 22 '25 06:09 coderabbitai[bot]