The widget to allow scheduling of workflow transitions is allowing a user to choose options that are not actually configured transitions.
For instance, in my Workflow configration, I have no Draft -> Archived transition.
Yet, a user can schedule a Draft -> Archived via this widget, and it's somewhat hidden why it doesn't work when a user schedules it in this manner.

In an ideal world, the options in the widget should be the same workflow transition options in the standard Content moderation dropdown (shown above this module's widget), that takes into account the configured workflow states and transitions, and user permissions for using those transitions.

At the very least, perhaps some error handling or explanation of why the scheduled content isn't actually transitioning, because it's trying to perform an action that can't be done because there isn't a transition actually configured for it.

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

joshua.boltz created an issue. See original summary.

nord102’s picture

I have created a patch, which takes some inspiration from how the transition is currently being validated. I think it makes more sense to limit the list based on the available Workflow transitions as opposed to listing all moderation states and validating it after the fact.

Status: Needs review » Needs work

The last submitted patch, 2: lightning_scheduler-take_workflow_transitions_into_account-3115218-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

andrew.martin’s picture

This is great, thank you!

We did find one issue with this patch. We have a simple workflow - Draft -> Published -> Archived. If the user creates a new content item, publishes it and schedules it to archive. Then changes the content back to a draft. The scheduled transition remains, but it's know hidden as it's an invalid transition. If the user edits and tries to save the content, they cannot and just receive an unclear error message about the date being invalid.

deviantintegral’s picture

It also looks like the module permissions are being ignored. I currently only have two transitions enabled for a role, but the widget is allowing me to save any transition.

dhirendra.mishra made their first commit to this issue’s fork.

kristiaanvandeneynde’s picture

The main issue I see is that the widget is 100% frontend instead of using Drupal's AJAX system. Because of that, this patch will limit the scheduling to only the immediate next state.

Let's say you have Draft -> Published -> Unpublished and the item is currently in Draft.

  • The current problem: People can schedule Unpublished even though that transition will fail because it's invalid.
  • With the patch: People can't schedule both Published and Unpublished after that, e.g.: a week from now and 2 weeks after that.

Now, if the module were to use AJAX, we could only show the available states for the current state or the currently scheduled state if there is one. If you then delete any scheduled state other than the last one, all scheduled states after that should be deleted also to avoid impossible transitions being scheduled.

joseph.olstad’s picture

Status: Needs work » Needs review

triggerred tests on mysql D9.2
instead of postgres D8.9

kaszarobert’s picture

Status: Needs review » Needs work

Needs a reroll. Also, when adding multiple transitions, this would limit editors as the list will contain only the next valid transition from the current node state. It would be awesome if the UI would enable users to select valid next states only even if multiple transitions are added.