You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "ljmotta (via GitHub)" <gi...@apache.org> on 2025/03/04 20:08:30 UTC
Re: [PR] kie-issues#315: DMN Runner table view should display validation messages [incubator-kie-tools]
ljmotta commented on code in PR #2943:
URL: https://github.com/apache/incubator-kie-tools/pull/2943#discussion_r1980149469
##########
packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx:
##########
@@ -162,6 +162,7 @@ export function DmnRunnerContextProvider(props: PropsWithChildren<Props>) {
);
const status = useMemo(() => (isExpanded ? DmnRunnerStatus.AVAILABLE : DmnRunnerStatus.UNAVAILABLE), [isExpanded]);
const dmnRunnerAjv = useMemo(() => new DmnRunnerAjv().getAjv(), []);
+ const [currentResponseMessage, setCurrentResponseMessage] = useState<Map<string, DmnEvaluationMessages>>(new Map());
Review Comment:
Please, specify what is expected in the Map. e.g. `currentResultMessagesBySourceId` (sourceId -> message).
##########
packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx:
##########
@@ -341,18 +351,11 @@ export function DmnRunnerContextProvider(props: PropsWithChildren<Props>) {
new Map<string, string>()
);
- const messagesBySourceId =
- results[currentInputIndex]?.reduce((acc, decisionResult) => {
- decisionResult.messages?.forEach((message) => {
- const messageEntry = acc.get(message.sourceId);
- if (!messageEntry) {
- acc.set(message.sourceId, [message]);
- } else {
- acc.set(message.sourceId, [...messageEntry, message]);
- }
- });
- return acc;
- }, new Map<string, DmnEvaluationMessages[]>()) ?? new Map<string, DmnEvaluationMessages[]>();
+ const messagesBySourceId = Array.from(currentResponseMessage.values()).reduce((acc, message) => {
Review Comment:
I think I've missed something here. This `reduce` isn't recreating the `currentResponseMessage`? If this is correct, we don't need the `messagesBySourceId`.
##########
packages/online-editor/src/dmnRunner/DmnRunnerContextProvider.tsx:
##########
@@ -262,6 +263,13 @@ export function DmnRunnerContextProvider(props: PropsWithChildren<Props>) {
if (canceled.get()) {
return;
}
+ const currentResults = results[currentInputIndex];
+ if (currentResults && currentResults.messages?.length > 0) {
+ const messagesMap = new Map(currentResults.messages.map((message) => [message.sourceId, message]));
+ setCurrentResponseMessage(messagesMap);
+ } else {
+ setCurrentResponseMessage(new Map());
+ }
Review Comment:
If we use the `currentInputIndex`, what will happen with the DMN Runner table? The validation messages from all rows will appear? I mean, if we have two rows, both with invalid values, we will still have two different validation messages?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org