Problem/Motivation
We have defined a workflow with these states:
- Draft
- Needs Review
- Published
We have two roles:
- author (Who creates content in draft and sets it to "needs review")
- admin (Who can transition from "needs review" to "published")
Steps to reproduce
- Enable the Content moderation and Content translations modules, and their requirements.
- Add another language to the site.
- Enable translation for Content (nodes) for at least one content type.
- Enable the Editorial workflow for at least one translatable content type.
- Configure the workflow with the 3 states listed above (draft, needs review, published), and 4 transitions:
- draft -> draft
- draft -> needs review
- needs review -> draft
- needs review -> published
- Configure 2 roles:
- author (with permission to use draft -> draft and draft -> needs review transitions)
- editor (with permission to use all of the above workflow transitions)
- An author has created a node in English, and sets it to "needs review".
- Now the author wants to add a translation for this node. They go to the Translate tab and click on the "Add" Button.
- The form where they can edit the node and add the german texts is displayed.
- When they click "Save", they gets the error message "Invalid state transition from Needs review to Needs review".
Logically that is correct, because the author role doesn't have the permission to edit nodes which are in the state "needs review".
But shouldn't new translations be treated as new nodes and therefore be created as "draft"?
Proposed resolution
Preserve the existing behavior for BC, but add a way to configure this when defining a workflow.
Whatever new UI is introduced should only be visible if both Content moderation and Content translation modules are enabled.
Option B
(Other rejected proposals removed, this is what we're going with).
- Have a simple toggle for the current behavior vs using the default moderation state (same as A)
- UI is 2 radios.
- Setting stores a string, ID would be 'translation_default_moderation_state_behavior' or so, with values like 'current' vs. 'default'.
- In some UIs, explicit radios for different options can be more clear than a checkbox (if each choice requires a little explanation).
Example UI:
Initial moderation state when adding a new translation:
(*) Default moderation state
( ) Current moderation state of the original content
Open questions
- Option B - radio buttons. See #45
- Yes (@larowlan in #42)
- YES
- ? YES
- Using 'current' per @larowlan in #42
- YES
- YES:
https://www.drupal.org/node/3240957 β
- YES:
- YES (per @larowlan in #44). DONE in patch #47
- YES (per @larowlan in #42). DONE in patch #47
- NO, leave it as 'current' (per @larowlan in #42).
-
- Use
hook_entity_translation_create()
YES.
- NO
- See #101.
Remaining tasks
-
- Done in #47
- Done in #47.
- UX team proposed a solution in #101, implemented in #104
- RTBC
User interface changes
A new setting when creating/editing a workflow:
Before
What you see without the patch applied, or when content_moderation is enabled but content_translation is not, at paths like /admin/config/workflow/workflows/manage/editorial:
After
With the patch applied, and both content_moderation and content_translation enabled:
Initial moderation state when translating existing content*
(*) Default moderation state
( ) Published if existing content is published, otherwise Draft
API changes
None.
Data model changes
New config schema for a setting on workflow type plugins.
Release notes snippet
TBD.