Problem/Motivation

I created an email template and associated it with the default Editorial workflow. I attempted to delete the template and received the warning message that the Editorial workflow was being used and would be deleted if I continued. Then, I removed all associations between the email template and Editorial workflow and tried deleting again. The warning was provided again and, on testing it, the workflow was removed along with the email template.

Steps to reproduce

  • Install Drupal with standard profile
  • Enable content_moderation and workbench_email modules
  • Create an Email Template
  • Edit the Editorial workflow
  • Edit the Publish transition
  • Enable the template created above, hit Save
  • Delete the template

Proposed resolution

Rearrange configuration so templates define which transitions they apply to and the workflow has no dependent configuration.

Remaining tasks

Review

User interface changes

Configuration of templates for each transition has moved to the template configuration form.

API changes

Data model changes

Workflows no longer have third party dependencies on workbench_email. Email templates now have dependencies on workflows.

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

jlhayes created an issue. See original summary.

jlhayes’s picture

Title: Unable to delete email template if it has ever been used with a workflow » Unable to delete email template without also deleting workflow if it has been associated
larowlan’s picture

larowlan’s picture

Issue summary: View changes
rwohleb’s picture

I've run into this as well with 8.x-1.1 from 2/25/19.

One possibility is that we simply block deletion of a template as long as it is being referenced by a workflow. Leave it to the user to clear up the dependency.

mstrelan’s picture

An alternative would be to add transitions to the template rather than adding templates to the transition. I think it makes more sense that way as that way we're not altering existing config and you can safely remove this module without affecting the transitions. Or have a separate config that maps templates and transitions.

karens’s picture

This also affects the ability to uninstall this module. If you uninstall the module, all your workflows are deleted.

acbramley’s picture

An alternative would be to add transitions to the template rather than adding templates to the transition.

I like this idea, I always find it odd having to go to a separate screen to wire the transition -> the email template.

scotwith1t’s picture

thank god for version control. hopefully this will be fixed soon. deleting the workflow makes no sense. just update the workflow if the email template is deleted to remove that enforced dependency.

larowlan’s picture

Status: Active » Needs work

Let's go with #6

mstrelan’s picture

Version: 8.x-1.x-dev » 2.x-dev

mstrelan’s picture

Here's a really rough start.

Working:

  • Transitions can be configured on the template form and are saved and loaded.

Not working:

  • Everything else
aitala’s picture

Please note that I have also not been able to disable a template for a particular workflow. If I disable it either in the workflow settings or the email template settings, it re-appears...

Eric

mstrelan’s picture

Version: 2.x-dev » 3.x-dev
mstrelan’s picture

Status: Needs work » Needs review
mstrelan’s picture

Status: Needs review » Needs work

I guess we need an update hook for existing config

mstrelan’s picture

Issue summary: View changes
Status: Needs work » Needs review
larowlan’s picture

Status: Needs review » Needs work

Looks great, left a code review

mstrelan’s picture

Status: Needs work » Needs review
larowlan’s picture

Status: Needs review » Needs work

I tested this locally on an existing project - the UI works as expected as do the dependencies

We could add an update path test here, but they've been tricky to maintain in the past, as you need to update for each major version of core.

One thing I noticed in the update path, is we didn't end up resolving the forced config dependency

e.g. the workflow still has

enforced:
     config:
       - workbench_email.workbench_email_template.needs_review

So we'll need to update that in the update path too.

mstrelan’s picture

Status: Needs work » Needs review

  • larowlan committed 894727f on 3.x authored by mstrelan
    Issue #3006343 by mstrelan, larowlan: Unable to delete email template...
larowlan’s picture

Status: Needs review » Fixed

🎉Fixed, this will go out as 3.0.0

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.