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

charles belov’s picture

[deleted]

chaitanyadessai’s picture

Status: Needs work » Needs review

Added Test coverage please review.

rkoller’s picture

Just got aware of this issue via the needs ux review list of issues. i've closed my own issue #3592838: If there are no instances for an entity type, provide a link instead of an empty "workflow applies to" dialog as a duplicate due to the fact that for this one already a MR exists and it has more momentum - thanks for creating and pushing it forward charles and @chaitanyadessai working on it!

I've already taken a brief look at the MR (but we will discuss the issue during one of the next ux meetings on friday as well). But i've already found a few details to denote upfront:

First the scope of the issue summary is a bit misleading. At first I thought the issue would only be about content types and assumed the MR would not fix the problem for any other entity type. but turns out the "add ... type" line is shown for the other entity types as well. successfully tested with vocabularies, media types and block types aside content types as well .

The link "Add ... type" has a too small target size to meet SC2.5.8 for minimum target size which requires at least 24px x 24 px - the height is only 20px plus the "no ... types available" line is missing some room to breath aka a padding. It feels cramped within the header and footer of the dialog modal somehow.

In the closed issue ive also ideated the same proposed resolution by adding that "add...type" line to the "select the ... type for the editorial workflow" dialog modal. but on second thought, now being able to manually test, this approach might have two flaws.... on the workflow overview page within the "this workflow applies to" section having a select button and a "none" status underneath for an entity type like for example vocabularies with no actual vocabularies available the select button and the "none" status line is sort of misleading. I wonder if for entity types with no instance available instead of showing a CTA like select show a CTA like eg "Add content type" instead that is directly forwarding you to the add entity type page? That way the user would save one click and at the same time would be aware that for example entity type a b and d have no instances available at all? On the other hand I also wonder if in a case where a user is forwarded from the context of a workflows edit page to create an initial instance of an entity type if it would be possible to circle that person back to workflow edit page after creating the missing entity type? The forward back to the workflow step might be overeager and overcomplicating things but the for example "Add content type" CTA instead of the select button in case an entity type has no instances might be more reasonable and easier to accomplish?

Either way those are just a few initial observations after testing the MR for the first time. Hope we will get to the MR in one of the next ux meetings soon as well.

rkoller’s picture

@charlesbelov

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.

i've just skimmed through the comments after posting my comment, initially only read the issue summary and tested the MR. But looks like we had the same idea and the same doubt - the not knowing when someone is done is indeed the crux. but on second thought there might be a flexible way to solve this. The easy fix might be to simply add a third button aside the "save" button (forwarding you to the entity type list page) and the "save and manage fields" button (forwarding you to the field list page of the instance of that entity type). By pressing that newly added third button it would return you to the edit page of the corresponding workflow you were coming from. strictly speaking the entity type and the corresponding workflow instance are sort of isolated objects at the moment. but there is a 0-n relationship but that is not necessarily reflected in the ui because you are unable to reach each other in context .

charles belov’s picture

@kroller: An added "save and manage fields" button makes sense and is consistent with that button already existing. Will review current MR.

smustgrave’s picture

Status: Needs review » Needs work

Don't think we need separate functional test for checking a message, seems like something that an existing test could be expanded on.