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

append new note if exist note on ThenComment.java #76

Open
wants to merge 1 commit into
base: release
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ public RuleResponse perform(EventInfo eventInfo) {
boolean hasError = true;
try {
if (eventInfo.getAnnotations() != null) {
eventInfo.getAnnotations().setNotes(text.getText(eventInfo));
hasError = false;
if (!eventInfo.getAnnotations().notes().isEmpty()) {
Copy link
Contributor

@ddwightx ddwightx Oct 9, 2024

Choose a reason for hiding this comment

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

Thanks for the contribution!

I am concerned about changing the default functionality. A way to alleviate that is to add a boolean field (checkbox) labeled something like Append that would control whether or not to append or overwrite.

That being said, I actually think this solution isn't needed. Today in the Text field, instead of putting Hello World, you can put {{a:comment}}Hello World instead. If there wasn't already a comment the final comment will be Hello World. However, if there is a comment already, it will be <existing commment here>Hello World. What are your thoughts on that?

if (!eventInfo.getAnnotations().notes().toLowerCase().contains(text.getText(eventInfo).toLowerCase())) {
eventInfo.getAnnotations().setNotes(eventInfo.getAnnotations().notes() + " , " + text.getText(eventInfo));
}
hasError = false;
}
else {
eventInfo.getAnnotations().setNotes(text.getText(eventInfo));
hasError = false;
}
}
} finally {
if (eventInfo.getDiagnostics().isEnabled()) eventInfo.getDiagnostics().logValue(this, hasError, VariableString.getTextOrDefault(eventInfo, text, null));
Expand Down