In D7 we had the ability to restrict entity events to a specific bundle type when configuring a Reaction Rule.

When you did "Add a reaction rule" in D7 you got an Ajax-enabled form. The form asked you to choose the rule name, machine id, tags, and description. Below that it asked you to select an event to react on. When the event was selected, if it was an entity event, then an additional selection was made available via Ajax to let you restrict the event to a specific bundle.

For example, if I chose: "After saving a new content item" (rules_entity_insert:node) I would then see a selection element allowing me to specify the bundle, or content type, of the event. For example if I only wanted to react on new "Article" nodes being added, I could turn this event into a qualified event: "After saving a new content item of type Article" (rules_entity_insert:node--article). Then, our reaction rule would only execute if an Article was created, and would not fire if any other content type was created.

This patch accomplishes all of the above for D8. It works completely, but there are still a few things I'd like to change before committing:

I'm not very happy with the way the event labels were modified in RulesEventManager. I also still need to port the test to WebDriver (I initially copied some of the test from known-good JavascriptTestBase code, so I wanted to ensure the patch works in the testbot before I started porting the test to WebDriver). I would also like to enhance the FunctionalJavascript test and add some Functional tests.

Please test and review this patch and let me know if I missed something.

EDIT: JavaScript test now ported to WebDriver.

Comments

TR created an issue. See original summary.

tr’s picture

Well, the Javascript tests passed, that's good news. Some Unit tests failed because I injected a new service into RulesEventManager but forgot to change the Unit tests to mock the new service. And there are some coding standards problems. But the patch still works, BTW, if you're inclined to test it - these are all just problems with the test functions.

I'll work on fixing the tests and adding new tests, and I'll post a new patch soon.

tr’s picture

StatusFileSize
new18.38 KB

Here's a trial port to WebDriver plus a fix for the Unit tests. The Functional test will still have failures because I haven't worked on those yet.

tr’s picture

StatusFileSize
new18.13 KB
tr’s picture

StatusFileSize
new18.04 KB

Looks like there are still a few changes needed for the port to WebDriver.

tr’s picture

StatusFileSize
new18.15 KB
tr’s picture

StatusFileSize
new18.13 KB
tr’s picture

Issue summary: View changes
StatusFileSize
new19.44 KB

Now that it passes, let me enhance the JavaScript Ajax tests.

tr’s picture

StatusFileSize
new19.45 KB

Have to enable the taxonomy module if we're going to use taxonomy events ...

tr’s picture

Issue summary: View changes
StatusFileSize
new23.05 KB

Here with the enhanced JavaScript tests and some addition Kernel (not Functional) tests.

tr’s picture

StatusFileSize
new22.88 KB
tr’s picture

StatusFileSize
new20.74 KB

Simplified patch a bit, added/improved some tests.

tr’s picture

StatusFileSize
new20.84 KB

More cleanup.

  • TR committed 97a4659 on 8.x-3.x
    Issue #3106987 by TR: Add event bundle selection to "Add a reaction rule...
tr’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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