Goal

Let's plan how condition and action forms can be embedded by contrib modules & define the API necessary to do it, such that we can iterate and improve things in future without breaking that API.

Implementation concept

- Modules will have to define the available context for their condition / action component
- Modules create the component and use the API to generate, validate and submit the form of the component
- The embedded form will contain links for adding, editing or deleting the contained expressions via the regular Rules power UI.
- After submitting the form component, the module can export the configuration of the component and store it as part of its own config entity. Config entity dependencies etc. will have to be added based on information provided by the Rules component.
- For the contained links etc. to work, the module has to integrate routes provided by Rules. The routes must be able to fetch the edited Rules component and know where to redirect back. For that the module will have to provide some sort of UIAdapter which implements that logic.
- Current Rules UI elements will have to be converted to work without a config entity, but can work based upon a Rules component. So only surrounding UI parts will have the config entity to implement further specific UI like component variables UI or event attaching/removing. Those parts need not to be re-usable anyway.

Note: The embedded will contain links, which when pressed, will leading to the loss of other unsubmitted form values. We might be able to improve that in future by converting this links to some sort of ajax submissions.

Implementation plan

- Prepare a small testing module that demonstrates the usage: #2659026: Create testing module for embedding Rules UI
- Add support for defining rules_ui paths in yml files #2659932: Add support for defining rules_ui paths in yml files
- Convert Rules UI classes to work based on the Rules component: #2659028: Convert RulesUI to work based on RulesComponent
- Document API / usage
- Possibly provide an optional "Rules-Enhances Block UI" sub-module which swaps out core block conditions and replaces them with Rules condition.

Comments

fago created an issue. See original summary.

fago’s picture

Issue summary: View changes
fago’s picture

Issue summary: View changes
fago’s picture

Issue summary: View changes
fago’s picture

Thoughts for find the right RulesComponent object on routes:
- Enhance RulesTempConverter such that it can pick up a custom config-entity storage location (my.path.to.rules.conditions) from the route definition
- Modules would have to add route subscriber and add-in routes provided by some Rules service, while providing the config-entity storage location as optional argument.
- Alternatively, Rules could allow modules to declare Rules UI locations in some sort of yml that Rules picks up and does the work for modules.
- We might want add some further information like some replaceable labels or so in future, so having a place to add that would be good. That means the yml is the better option.

fago’s picture

discussed with klausi and agreed to make a 'rules_ui' plugin with yml discovery -> so we have mymodule.rules_ui.yml

fago’s picture

Issue summary: View changes

updated implementation plan and added new issue #2659932: Add support for defining rules_ui paths in yml files

fago’s picture

fago’s picture

Status: Active » Fixed

With #2671056: Add a working example for embedded UI being done, I think this can be called fixed.

Status: Fixed » Closed (fixed)

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