Problem/Motivation
If there are no content types defined, attempting to enable a workflow for content types gets a no-options dialog. It would be helpful to explain why the dialog is blank and provide a remediation link.
Steps to reproduce
Steps:
1. Go to simplytest.me
2. Create a site with the current version of Drupal (11.4.4)
3. Log in as admin
4. Go to /admin/modules
5. Enable Content Moderation and Workflows
6. Go to /admin/config/workflow/workflows
7. On the row for Editorial, click Edit
8. Scroll down to This workflow applies to
9. On the row for Content Types, click Select
Result: Select the content types for the Editorial workflow dialog contains a blank area plus Save and Cancel buttons. The admin is left to wonder why the dialog is blank.
Proposed resolution
If no content types currently exist, display in the dialog the message:
No content types available. Add content type.
where "Add content type" is a link to /admin/structure/types/add
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | restrict_role.png | 45.06 KB | chaitanyadessai |
| #7 | after.png | 56.97 KB | chaitanyadessai |
| #7 | before.png | 48.96 KB | chaitanyadessai |
Issue fork drupal-3614140
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
charles belovComment #7
chaitanyadessai commentedPlease review MR.
Comment #8
charles belovTested with Drupal 11.4.6.
I've confirmed that it works for content types.
I briefly thought about whether it would be good to redirect back to the workflows configuration after creating the content type. I quickly rejected that because once somebody creates a content type, they will also generally want to create fields for that content type. Since there is no way for Drupal to know when they are done doing that, a redirect back to workflows would not be feasible.
When I read the code, I saw that other entity types besides Content are supported for this. However, both content block types and taxonomy term types already had one entity each. Just to be thorough I went and deleted those entities, then confirmed that workflow presented the appropriate message and link.
So, I've tested for content types, content block types, and taxonomy term types and found the patch to work as desired.
Comment #9
smustgrave commentedThink we will need to do an access check too. What if a user doesn't have permission to create these types (node, media, etc) they would have a link to a page they'd get access denied on.
So may need to handle a fallback text if they don't
Comment #10
charles belovHow about:
If they have access to administer workflows but not entities
then display:
Wording probably needs an edit.
Comment #11
chaitanyadessai commentedChanges have been addressed. Please review.
Comment #12
smustgrave commentedNot a fan of that phrase but should have test coverage