Problem/Motivation

If I attempt to publish a workspace that contains new unpublished/non-default revisions (e.g. new forward drafts) then I get a cryptic error message:

The Stage workspace can not be published because it contains 1 item in an unpublished moderation state.

This is super cryptic, mostly because I have no easy way to know which of my changes are unpublished.

Proposed resolution

Change /admin/config/workflow/workspaces/manage/stage
Recommended changes to Workspace Manage page

1. Add a new column for "Status"
2. If an item is unpublished, also show a ⚠️ icon
3. At the bottom of the page show a message: "⚠️ This workspace cannot be published until all unpublished items are published."

This code is in \Drupal\workspaces\WorkspaceViewBuilder::buildComponents()

Remaining tasks

All.

Issue fork drupal-3376702

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

dalin created an issue. See original summary.

dalin’s picture

Issue summary: View changes

The error message comes from content_moderation_workspace_access() and a code comment says "Check if any revisions that are about to be published are in a non-default revision moderation state."

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

danflanagan8’s picture

My content authoring team is asking for this same UX enhancement.

It looks like content_moderation_workspace_access() was removed in #3242564: Workspaces can't be published from the command line in favor of a new event subscriber and method WorkspaceSubscriber::onWorkspacePrePublish(). So that's where the logic is happening now.

danflanagan8’s picture

StatusFileSize
new81.64 KB

In case it helps anybody, I altered the Workspace display with a hook like so:

/**
  *  Implements hook_ENTITY_TYPE_view().
  */
function my_module_workspace_view(array &$build, EntityInterface $workspace, EntityViewDisplayInterface $display, $view_mode) {
  $build['changes']['list']['#header']['status'] = 'Status';
  foreach ($build['changes']['list'] as &$row) {
    if (is_array($row) && isset($row['#entity'])) {
      if ($row['#entity'] instanceof NodeInterface && !$row['#entity']->isPublished()) {
        $status = '⚠️ unpublished';
      }
      else {
        $status = '✔';
      }
      $row['status'] = ['#markup' => $status];
    }
  }
}

I restricted my check to nodes because we don't moderate anything else. A more sophisticated check could be used on sites that moderate of entity types.

It ends up looking something like this:

A new status column

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

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

markconroy’s picture

@danflanagan8 I think the issue is that the content that is stopping the publication of the workspace is in 'Draft' (via content moderation) rather than 'Unpublished'.

I'll create an MR to show the name(s) of the item(s) in draft.

markconroy’s picture

Status: Active » Needs review
markconroy’s picture

Screenshots

Current state

The current state only tells us that "something" is blocking publication, but not "what" is blocking publication.

1 item blocking

Multiple items blocking

New state

If 1 item is blocking, the name of it and a link to it is appended to the end of the message.

If more than 1 item is blocking, we create a list of all the blocking items, with each linked to their canonical URL.

Published

Once everything is published, we continue with the same experience we currently have.