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

Issue fork drupal-3614140

Command icon 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

charles belov created an issue. See original summary.

charles belov’s picture

Title: Add helpful link if there are not content types » Add helpful link if there are no content types

chaitanyadessai made their first commit to this issue’s fork.

chaitanyadessai changed the visibility of the branch 3614140-add-helpful-link to hidden.

chaitanyadessai changed the visibility of the branch 3614140-add-helpful-link to active.

chaitanyadessai’s picture

Status: Active » Needs review
StatusFileSize
new48.96 KB
new56.97 KB

Please review MR.

charles belov’s picture

Tested 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.

smustgrave’s picture

Status: Needs review » Needs work

Think 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

charles belov’s picture

How about:

If they have access to administer workflows but not entities
then display:

No [entity type] available. Someone with permission to administer [entity type] will need to create one before you can use this option.

Wording probably needs an edit.

chaitanyadessai’s picture

Status: Needs work » Needs review
StatusFileSize
new45.06 KB

Changes have been addressed. Please review.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs usability review

Not a fan of that phrase but should have test coverage