cu-uis / cu-starterkit-project

Development repository for Pantheon's recommended (future) Drupal 9+ upstream
1 stars 2 forks source link

Request - As a CE, I want to be able to use Moderation States with Taxonomy changes #4

Open kreynen opened 2 years ago

kreynen commented 2 years ago

A basic State of published/unpublished was added to taxonomy terms along with support for revisioning was added to Drupal core with https://www.drupal.org/project/drupal/issues/2880149, but there are still several limitations to using a Content Moderation Workflow with taxonomy terms.

online.cu.edu leverages terms for managing Degree Levels, Programs and Specializations because of the support for hierarchies included included in taxonomy and implemented in modules like https://www.drupal.org/project/webform_shs, but without support for some of the same features content nodes have, working with terms in different states problematic.

We need to create a simpler use case to work though the issues with managing terms in a draft, published and archived states.

kreynen commented 2 years ago

Related Drupal issues include https://www.drupal.org/project/drupal/issues/2936995, https://www.drupal.org/project/drupal/issues/3145661, https://www.drupal.org/project/drupal/issues/3101738, and https://www.drupal.org/project/drupal/issues/3250084, https://www.drupal.org/node/962664

kreynen commented 2 years ago

Add this to the list of repositories.

 {
            "type": "package",
            "package": {
                "name": "drupal/taxonomy_revision_ui",
                "type": "drupal-module",
                "version": "1.0.0",
                "source": {
                    "type": "git",
                    "url": "https://git.drupalcode.org/sandbox/hugronaphor-3064521.git",
                    "reference": "8ecf8c3757cd5f4c2e3dde5ce05bdbb5d2f865e1"
                }
            }
        }

Add this to dependencies...

"drupal/taxonomy_revision_ui": "^1.0"

Add to patches...

"Taxonomy Index for unpublished entities": "https://www.drupal.org/files/issues/2021-02-03/962664-drupal-add-unpublished-nodes-to-taxonomy-index-168.patch", 
"Enable Content Moderation integration for taxonomy terms": "https://www.drupal.org/files/issues/2021-07-23/3047110-32.patch"

Manual Steps:

kreynen commented 2 years ago

Steps for testing basic Moderation State functionality on terms:

  1. As an CE, go to admin/structure/taxonomy/manage/tags/overview
  2. Click Add Term
  3. Not that the default state is Draft
  4. Enter of title and Save
  5. Attempt to access taxonomy/term/1

Expected Result: Term title on page

  1. As an anonymous user, attempt to access taxonomy/term/1

The expected result is a 404

  1. As a CE, go to taxonomy/term/1/edit and update the edit-moderation-state-0-state = published
  2. As an Anonymous user, attempt to access taxonomy/term/1

Expected Result: Term title on page

kreynen commented 2 years ago

Manual Steps for SHS test:

  1. Enable SHS
  2. Add Taxonomy Reference field to Basic Page admin/structure/types/manage/page/fields/add-field
  3. Select Tags taxonomy
  4. Change widget in Form Display = SHS at admin/structure/types/manage/page/form-display

When there is a published and unpublished term, the expectation is that the CE user wouldn't see the unpublished term in SHS. Instead, the term is displayed as an option, but the validation fails if the CE user tries to save the page with that term selected.

Screen Shot 2022-03-01 at 2 33 40 PM
kreynen commented 2 years ago

Manual Steps for Webform SHS test:

  1. Enable Webform SHS
  2. Create a Webform with a SHS field
  3. Test with just 6 terms; 4 published, 2 as a drafts at each level
Screen Shot 2022-03-01 at 3 45 32 PM

If you visit the Webform as an Anonymous user first, you will see the expect result. Only the published terms... unless the parent term is unpublished. BUT you will also see that when viewing the Webform as an admin user. If the cache is cleared (twice?) and the form is reloaded as an admin user, the anonymous user will see the unpublished terms.

anon_first admin_after_anon_first anon_after_admin_first

To replicate this with just SHS, you have to allow anonymous users to create the content type the SHS field is attached to. An unlikely configuration, but it is the endpoint itself that is exposing the unpublished terms.

/shs-term-data/tags/tags/1

[{"tid":"4","name":"Test 3 - Unpublished Draft Level 2","description__value":null,"langcode":"1","hasChildren":false}]
kreynen commented 2 years ago

The rc3 update to https://www.drupal.org/project/shs solves part the Draft/Unpublished problem, but additional support for moderation states in the core Taxonomy View handlers will be required to fully support an Archived state.

kreynen commented 2 years ago

I opened https://www.drupal.org/project/drupal/issues/3274845 to address the lack of Published or Admin filters in Taxonomy Views.