This is an automated email from the ASF dual-hosted git repository.

tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new b86f319c9ed kie-issues#880: On the DMN Editor, all DRG elements list 
should show invalid names in red (#2144)
b86f319c9ed is described below

commit b86f319c9edc811a0234347f1fb484e5acefe9aa
Author: Tiago Bento <[email protected]>
AuthorDate: Tue Feb 6 08:52:27 2024 -0500

    kie-issues#880: On the DMN Editor, all DRG elements list should show 
invalid names in red (#2144)
---
 .../src/externalNodes/DmnObjectListItem.tsx        | 41 ++++++++++++++--------
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/packages/dmn-editor/src/externalNodes/DmnObjectListItem.tsx 
b/packages/dmn-editor/src/externalNodes/DmnObjectListItem.tsx
index 335c5f16c39..eb5ab1965db 100644
--- a/packages/dmn-editor/src/externalNodes/DmnObjectListItem.tsx
+++ b/packages/dmn-editor/src/externalNodes/DmnObjectListItem.tsx
@@ -25,9 +25,12 @@ import { NodeIcon } from "../icons/Icons";
 import { getNodeTypeFromDmnObject } from "../diagram/maths/DmnMaths";
 import { buildFeelQNameFromNamespace } from "../feel/buildFeelQName";
 import { Flex } from "@patternfly/react-core/dist/js/layouts/Flex";
-import { DmnBuiltInDataType } from 
"@kie-tools/boxed-expression-component/dist/api";
+import { DmnBuiltInDataType, generateUuid } from 
"@kie-tools/boxed-expression-component/dist/api";
 import { useDmnEditorStore } from "../store/StoreContext";
 import { useExternalModels } from 
"../includedModels/DmnEditorDependenciesContext";
+import { DMN15_SPEC } from "../Dmn15Spec";
+import { useCallback } from "react";
+import { State } from "../store/Store";
 
 export function DmnObjectListItem({
   dmnObject,
@@ -45,12 +48,29 @@ export function DmnObjectListItem({
   const allTopLevelDataTypesByFeelName = useDmnEditorStore(
     (s) => 
s.computed(s).getDataTypes(externalModelsByNamespace).allTopLevelDataTypesByFeelName
   );
-  if (!dmnObject) {
-    return <>{dmnObjectHref}</>;
-  }
 
-  const Icon = NodeIcon(getNodeTypeFromDmnObject(dmnObject));
-  return (
+  const displayName = dmnObject
+    ? buildFeelQNameFromNamespace({
+        namedElement: dmnObject,
+        importsByNamespace,
+        namespace,
+        relativeToNamespace,
+      }).full
+    : dmnObjectHref;
+
+  const isValid = useDmnEditorStore((s) =>
+    DMN15_SPEC.namedElement.isValidName(
+      dmnObject?.["@_id"] ?? generateUuid(),
+      displayName,
+      s.computed(s).getAllFeelVariableUniqueNames()
+    )
+  );
+
+  const Icon = dmnObject ? NodeIcon(getNodeTypeFromDmnObject(dmnObject)) : () 
=> <></>;
+
+  return !dmnObject ? (
+    <>{dmnObjectHref}</>
+  ) : (
     <Flex
       alignItems={{ default: "alignItemsCenter" }}
       justifyContent={{ default: "justifyContentFlexStart" }}
@@ -59,14 +79,7 @@ export function DmnObjectListItem({
       <div style={{ width: "40px", height: "40px", marginRight: 0 }}>
         <Icon />
       </div>
-      <div>{`${
-        buildFeelQNameFromNamespace({
-          namedElement: dmnObject,
-          importsByNamespace,
-          namespace,
-          relativeToNamespace,
-        }).full
-      }`}</div>
+      <div style={{ color: isValid ? undefined : "red" 
}}>{`${displayName}`}</div>
       <div>
         {dmnObject.__$$element !== "knowledgeSource" ? (
           <>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to