Duplicate guides (#100) #123

Merged
miko merged 2 commits from feature/100-duplicate-guide into development 2026-11-05 20:08:41 +01:00
Owner

Closes #100

Adds "Duplicate" to a guide's reading view and editor header. Every author and admin who may see a guide can use it.

What the copy gets

  • The guide's working copy:
    • steps, step lines, images and annotations
    • cover image, difficulty and duration, protective equipment, license and attachments
  • Files of its own: originals, image variants and attachments are copied under new keys, so deleting the original leaves the copy whole.
  • Its own state: a draft owned by whoever duplicated it, titled "Copy of …" / „Kopie von …“. It goes last in the same category, keeps the same visibility and has wiki mode off.
  • Not copied: versions, menu entries and the status.

Implementation

  • src/guides/duplicatedContent.ts: a pure function that gives the content new ids for steps, lines, images and attachments, and new file keys. Re-crops still share one original, and annotations are moved onto the new lines.
  • src/guides/duplicateGuide.ts: reads the working copy with the original guide locked (ADR-0013), copies the files and creates the draft.
  • src/guideVersions/freshFileKeys.ts: hands out new file keys. The guide-package import now uses it too.
  • duplicateGuideAction and DuplicateButton, plus the German translation and the CHANGELOG entry.

Open question

As the spec says, the copy is made from the working copy. An author who may only see a published guide therefore also gets the owner's unpublished changes in their own draft. If that's not wanted, people who can't edit the guide should get the latest version instead.

Tests

  • Unit tests for duplicatedContent.
  • e2e (e2e/duplicateGuide.spec.ts): another author duplicates a guide, the original is deleted and the copy is still whole; viewers get no button.
  • Full suite: 555 unit tests and 71 e2e tests pass.

🤖 Generated with Claude Code

Closes #100 Adds "Duplicate" to a guide's reading view and editor header. Every author and admin who may see a guide can use it. ## What the copy gets - The guide's **working copy**: - steps, step lines, images and annotations - cover image, difficulty and duration, protective equipment, license and attachments - **Files of its own**: originals, image variants and attachments are copied under new keys, so deleting the original leaves the copy whole. - **Its own state**: a draft owned by whoever duplicated it, titled "Copy of …" / „Kopie von …“. It goes last in the same category, keeps the same visibility and has wiki mode off. - **Not copied**: versions, menu entries and the status. ## Implementation - `src/guides/duplicatedContent.ts`: a pure function that gives the content new ids for steps, lines, images and attachments, and new file keys. Re-crops still share one original, and annotations are moved onto the new lines. - `src/guides/duplicateGuide.ts`: reads the working copy with the original guide locked (ADR-0013), copies the files and creates the draft. - `src/guideVersions/freshFileKeys.ts`: hands out new file keys. The guide-package import now uses it too. - `duplicateGuideAction` and `DuplicateButton`, plus the German translation and the CHANGELOG entry. ## Open question As the spec says, the copy is made from the working copy. An author who may only *see* a published guide therefore also gets the owner's unpublished changes in their own draft. If that's not wanted, people who can't edit the guide should get the latest version instead. ## Tests - Unit tests for `duplicatedContent`. - e2e (`e2e/duplicateGuide.spec.ts`): another author duplicates a guide, the original is deleted and the copy is still whole; viewers get no button. - Full suite: 555 unit tests and 71 e2e tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lock the original while reading its working copy, share freshFileKeys
with the package import, clearer names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miko merged commit a95db2404d into development 2026-11-05 20:08:41 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MassiveDynamic/kataba!123
No description provided.