Skip to content

[jsscripting] Refine file-based vs. UI-based labelling #19430

@florian-h05

Description

@florian-h05

The merge of #19019 has kicked off a discussion about labelling of UI-based and file-based scripts. I agree that the current naming is not technically correct and not optimal, but it shouldn't be too technical as well for the users.

I think file-based is problematic as well, as that's not really the criteria. "Standard rules" could work, but I would rather emphasize what is "non-standard" about those aren't. I think the whole thing has been "simplified" so much that I'm not sure that the criteria always are the same. I would prefer if things were referred to according to what they actually are.

I suspect that most often the difference is between SimpleRule implementations and "other rules". In a development context, I think SimpleRule should be an acceptable description, but if the term is user-facing, that might not be very helpful, since the use of SimpleRule is usually hidden from them via the helper libraries. As a consequence, they probably have no idea what a SimpleRule is. Preferably, a term that makes sense for the scripting language in question, e.g. jsscripting, could be used. I don't know what you call things, but I know that you have something called RuleBuilder or similar... and that it's not the same as "a normal JS rule"? I'd think that you should have some name for rules using the helper library in such a way that they end up being SimpleRules?

I don't know how it works in jsscripting since I can't get GraalVM to work under Eclipse as I've mentioned before, but I know that in Ruby for example, you can create rules with or without using the helper library. So, you can actually create "non-SimpleRules" (FullRules?) using Ruby via JSR223 as well. Most people don't do it, because using the helper library is easier, but you can if you have a reason to. Such a rule has certain advantages, it can be duplicated to a managed rule from the UI for example.

So, I think the term should depend on the context, and should strive to describe what "actually matters" in that context. In this context, "wrap standard rule scripts" would probably be a reasonable description.

If you look at isUiBasedScript() in this PR, what it actually checks is whether it's a transformation. So, the name is clearly misleading. I would rename it isTransformation() and then negate the evaluation. So, there are actually no measure here to not affect SimpleRule based rules. The Action of a SimpleRule is what's special, you only have one Action, and that Action only exists as compiled bytecode in memory. So, you will never encounter such an Action as a "script" that is served to the jsscripting add-on, which is why you don't really need to do anything to prevent it from being wrapped. If you want to add a Condition to a SimpleRule, you would be affected. SimpleRules are only "special" when it comes to the one Action they have, Triggers and Conditions follow the rules of a standard rule. So, the condition from a SimpleRule would be wrapped too. That said, I don't even know if the helper library supports Conditions, I have the impression that Conditions are largely ignored by the scripting add-ons, and that the evaluations that should be done in a Condition is usually done once the Action has been fired instead, aborting the Action if the conditions aren't right. That's not how it's supposed to work though, so that's also somewhat of an "abuse", but that's another matter. I'm just saying this to explain why I don't expect many to come "into contact with" this Condition situation for rules created through scripting add-ons.

Originally posted by @Nadahar in #19019 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions