Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-8693] Add docs for visibility rules accepting arrays #4128

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions docs/extending/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,74 @@ Rules can accept other rules as parameters:
It is also possible to use inline references to registered evaluators without declaring rules,
in case you do not need providing extra parameters, or chaining multiple rules together.

```json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also adapt the docs in extensions.schema.json?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can update the schema as part of ACS-8694, since this PR is already merged, and I have to make changes near the same code there anyway. Please see commits here and here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both looks good, thank you!

{
"$schema": "../../../extension.schema.json",
"$version": "1.0.0",
"$name": "plugin1",

"features": {
"toolbar": [
{
"id": "app.toolbar.share",
"rules": {
"visible": "app.record.canShareRecord"
}
}
]
}
}
```

**Handling Multiple Extensions**

When multiple extensions rely on the same component, the visibility rules from all extensions
should be **passed as an array**. This way, the rules will be merged and evaluated, ensuring that all conditions
from different extensions are considered.

For example, if the `app.toolbar.share` component is modified by both the `Extension1` and
`Extension2` extensions, the visibility rules will be combined:

```json
{
"$schema": "../../../extension.schema.json",
"$version": "1.0.0",
"$name": "Extension1",

"features": {
"toolbar": [
{
"id": "app.toolbar.share",
"rules": {
"visible": ["extension1.rule1"]
}
}
]
}
}
```

```json
{
"$schema": "../../../extension.schema.json",
"$version": "1.0.0",
"$name": "Extension2",

"features": {
"toolbar": [
{
"id": "app.toolbar.share",
"rules": {
"visible": ["extension2.rule2"]
}
}
]
}
}
```

In this case, the component will be visible only if both extension1.rule1 and extension2.rule2 evaluate to true.

## Core Evaluators

You can create new rules by chaining other rules and evaluators.
Expand Down
Loading