Skip to content

Conversation

dfdez
Copy link
Collaborator

@dfdez dfdez commented May 16, 2025

ℹ️ What's this PR do?

This update empowers DecapCMS to handle complex tasks directly within the CMS, reducing reliance on external tools. 🛠️

  • ✨ New HookContext for Event Handlers: We've introduced a HookContext that grants event handlers (like prePublish or preSave) direct access to core CMS actions (e.g., saving or publishing entries). This enables these handlers to perform more powerful operations independently.
  • ⏳ New "Processing" Status: A new "processing" status for entries has been added. This will be visible in the UI, accompanied by new confirmation messages when interacting with entries in this state.
  • 🏗️ Better Custom Actions: We've refactored the creation of custom actions, providing a clearer structure with editor (for editor-specific functionalities) and actions (for CMS operations like saving or publishing). Notably, the publishUnpublishedEntry action was previously named publishEntry.
  • 🚫 UNPUBLISHED_ENTRY_DISMISS_ERROR: This new mechanism allows event handlers to gracefully halt a standard CMS process (like saving or publishing) without triggering a general error. This offers finer control over subsequent actions.
  • 🔧 Widget Upgrades:
    • The List widget now features a "duplicate" button. 📑
    • Custom widgets can now leverage immutable more easily.
    • Minor enhancements to the Relation widget improve support for dynamic updates.
  • 🚀 Action Updates:
    • Added createLocalEmptyDraft to facilitate the local creation of empty drafts.
    • Introduced getUnpublishedEntries to fetch unpublished entries.
    • searchEntries can now retrieve all entries if no search term is provided.
    • Improved error handling for several actions to work seamlessly with UNPUBLISHED_ENTRY_DISMISS_ERROR.

These changes are pivotal for enabling more complex content operations, such as content duplication, to occur directly within the CMS. This leads to a smoother and more user-friendly experience (related to PNW-2564).


👀 Where should the reviewer start?

  • packages/decap-cms-core/src/components/Editor/Editor.js (for the createHookContext changes)
  • packages/decap-cms-core/index.d.ts (for the new HookContext type definition)
  • packages/decap-cms-core/src/backend.ts (to see how HookContext is utilized)
  • packages/decap-cms-core/src/actions/editorialWorkflow.ts and packages/decap-cms-core/src/actions/entries.ts (to understand how actions use HookContext and UNPUBLISHED_ENTRY_DISMISS_ERROR)
  • packages/decap-cms-core/src/constants/publishModes.ts (for the definition of the new "processing" status)
  • UI files related to the "processing" status: StackToolbar.js, EditorToolbar.js, WorkflowList.js.

📱 How should this be manually tested?

  • Verify that the new "processing" status displays correctly in the UI (workflow list, editor toolbar).
  • Test that event handlers (preSave, prePublish) can effectively use the new HookContext (confirm the presence and functionality of editor and actions keys).
  • Ensure the "duplicate" button in the List widget works as expected. 📑
  • Confirm that core actions like saving, publishing, and deleting entries continue to function correctly and appropriately handle UNPUBLISHED_ENTRY_DISMISS_ERROR when an event handler employs it.

🤔 Any background context you want to provide?

This work is a component of the PNW-2564 project, which aims to migrate complex content management tasks (such as duplication) from external systems directly into the CMS. These foundational changes pave the way for achieving that goal.

@dfdez dfdez self-assigned this May 16, 2025
@dfdez dfdez changed the title feature/PNW 2564 duplicate workflow PNW-2564 - duplicate workflow May 16, 2025
@dfdez dfdez changed the base branch from fork to feature/PNW-2564_merge-with-master May 16, 2025 08:58
@dfdez dfdez marked this pull request as ready for review June 5, 2025 13:15
@dfdez dfdez mentioned this pull request Jun 5, 2025
@acrusella acrusella self-requested a review June 6, 2025 07:27
Copy link

@acrusella acrusella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code wise everything looks great 🚀 :shipit:
Detailed HTT was performed here: https://github.com/Feverup/landings-cms/pull/1268#issuecomment-2949273136

@dfdez dfdez merged commit 805f0a9 into feature/PNW-2564_merge-with-master Jun 6, 2025
9 of 21 checks passed
dfdez added a commit that referenced this pull request Jun 6, 2025
* feat(nested collections): allow non-index files (decaporg#7359)

* feat(nested collections): allow non-index files

This commit fixes decaporg#4972 to allow nested folders with additional content
beyond an index file.

Side effect: To keep the feature simple, this will now show index files
as pages within a folder in NetlifyCMS. This enables creating additional
files alongside the given index, but is a change in behavior from the
current implementation.

Co-authored-by: Eric Gade <105373963+eric-gade@users.noreply.github.com>

* test(e2e): adapt to new way nested collections work

 We use regexps as otherwise .contains("Sub Directory") would also match "Another Sub Directory"

---------

Co-authored-by: Andrew Dunkman <adunkman@gmail.com>
Co-authored-by: Eric Gade <105373963+eric-gade@users.noreply.github.com>
Co-authored-by: Anze Demsar <anze.demsar@p-m.si>

* fix(markdown): convert inline CSS from Google Docs to Markdown (decaporg#7351)

Extends the HTML to Markdown conversion to better support bold and
italic formatting from Google Docs, which generates inline styles on a
`span` element instead of strong/b/em/i type elements.

Co-authored-by: Anze Demsar <anze.demsar@p-m.si>

* feat: visual editing (click-to-edit) (decaporg#7374)

* refactor: clean up controlRef handling

* feat: add click-to-edit

* test: update snapshots

---------

Co-authored-by: Anze Demsar <anze.demsar@p-m.si>

* fix(widgetsFor): return widgets for variable type lists (decaporg#7296)

When using a Variable Type list widget and a custom preview component,
the `widgetsFor` helper would only return a `data` list with each of the
items in the list, not a `widgets` list, e.g.

    {"data" =>
        {"markdown" => "# Title"}
        {"type" => "block_body"}
    }
    {"widgets" => undefined} 🚫

The `widgets` list should also be supplied, particularly for nested
Markdown widgets, so a fully formatted preview can be rendered:

    {"data" =>
        {"markdown" => "# Title"}
        {"type" => "block_body"}
    }
    {"widgets" =>
        {"markdown" => Object} ✅
    }

This extends support in `widgetsFor` to detect variable type list
widgets and correctly construct the `widgets` return value.

As reported at decaporg#2307 (comment)

Co-authored-by: Anze Demsar <anze.demsar@p-m.si>

* chore(release): publish

 - decap-cms@3.6.0
 - decap-cms-app@3.6.0
 - decap-cms-core@3.6.0
 - decap-cms-lib-util@3.2.0
 - decap-cms-widget-list@3.3.0
 - decap-cms-widget-markdown@3.3.0
 - decap-cms-widget-object@3.3.0
 - decap-server@3.2.0

* fix(ObjectControl): hotfix nested object validation (decaporg#7385)

* chore(release): publish

 - decap-cms@3.6.1
 - decap-cms-app@3.6.1
 - decap-cms-widget-object@3.3.1

* chore: update to upload-artifact@v4 (decaporg#7388)

* feat(nested collections) legacy mode (decaporg#7387)

* feat(nested-collections): opt-in to legacy nested folder behaviour

* style: lint

* feat(nested-collection): default subfolders to true

* test(nested-collections): keep the tests in the subfolders: false scenario

* chore(release): publish

 - decap-cms@3.6.2
 - decap-cms-app@3.6.2
 - decap-cms-core@3.6.1

* fix(nested-i18n): pass newPath only when customPath differs from current path (decaporg#7418)

* fix(decaporg#7371): Duplicate Localized Content When Duplicating Entries with i18n Enabled (decaporg#7372)

* chore: add i18n to EntryObject type

* fix: draftDuplicateEntry function duplicate i18n data

---------

Co-authored-by: Anze Demsar <anze.demsar@p-m.si>

* chore(release): publish

 - decap-cms@3.6.3
 - decap-cms-app@3.6.3
 - decap-cms-core@3.6.2

* Update README.md, fix spelling error (decaporg#7472)

* PNW-2564 - duplicate workflow (#21)

* Merge with feature/PNW-2564_duplicate--wip

* feat: duplicate workflow wip

* feat: duplicate workflow wip

* feat: added local empty draft

* feat: added isCustomEntry to edit state with data

* feat: added function to retrieve current unpublished entries

* feat: added enty and avoid problems if empty is missing

* feat: refactor context structure and error name with integration

---------

Co-authored-by: Felix Gnass <fgnass@gmail.com>
Co-authored-by: Andrew Dunkman <adunkman@gmail.com>
Co-authored-by: Eric Gade <105373963+eric-gade@users.noreply.github.com>
Co-authored-by: Anze Demsar <anze.demsar@p-m.si>
Co-authored-by: Dominic Cleal <dominic.cleal@freeagent.com>
Co-authored-by: Anze Demsar <demshy@gmail.com>
Co-authored-by: starkovio <deniss@n3xtcoder.org>
Co-authored-by: kare-rentelligent <128468921+kare-rentelligent@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants