From e14f4669244a0321a9c6017594c382ba792fd098 Mon Sep 17 00:00:00 2001
From: Dennis Collaris <d.collaris@me.com>
Date: Thu, 22 Aug 2024 22:42:09 +0200
Subject: [PATCH] refactor: do not show number of nodes if no stats received
 (instead of showing "nodefined")

---
 libs/shared/lib/schema/panel/Schema.tsx                | 10 +++++-----
 .../lib/schema/pills/nodes/SchemaPopUp/SchemaPopUp.tsx |  4 ++--
 .../schema/pills/nodes/relation/SchemaRelationPill.tsx |  1 -
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/libs/shared/lib/schema/panel/Schema.tsx b/libs/shared/lib/schema/panel/Schema.tsx
index 96e48a22a..e59d1aabd 100644
--- a/libs/shared/lib/schema/panel/Schema.tsx
+++ b/libs/shared/lib/schema/panel/Schema.tsx
@@ -104,14 +104,14 @@ export const Schema = (props: Props) => {
       nodesWithRef = schemaFlow.nodes.map((node) => {
         return {
           ...node,
-          data: { ...node.data, reactFlowRef, tooltipClose: false, nodeCount: 'NoDefined' },
+          data: { ...node.data, reactFlowRef, tooltipClose: false },
         };
       });
 
       edgesWithRef = schemaFlow.edges.map((edge) => {
         return {
           ...edge,
-          data: { ...edge.data, reactFlowRef, tooltipClose: false, nodeCount: 'NoDefined' },
+          data: { ...edge.data, reactFlowRef, tooltipClose: false },
         };
       });
 
@@ -168,8 +168,8 @@ export const Schema = (props: Props) => {
         nds.map((node) => {
           const { id, type, data } = node;
 
-          const nodeCount = type === 'entity' ? nodeStatsMap[id]?.count ?? 'noDefined' : 'noDefined';
-
+          const nodeCount = nodeStatsMap[id]?.count;
+          
           return {
             ...node,
             data: {
@@ -187,7 +187,7 @@ export const Schema = (props: Props) => {
         edg.map((edge) => {
           const { id, type, data } = edge;
 
-          const nodeCount = type === 'entity' ? edgeStatsMap[id]?.count ?? 'noDefined' : 'noDefined';
+          const nodeCount = edgeStatsMap[id]?.count;
 
           return {
             ...edge,
diff --git a/libs/shared/lib/schema/pills/nodes/SchemaPopUp/SchemaPopUp.tsx b/libs/shared/lib/schema/pills/nodes/SchemaPopUp/SchemaPopUp.tsx
index 3626a05e3..91865cf57 100644
--- a/libs/shared/lib/schema/pills/nodes/SchemaPopUp/SchemaPopUp.tsx
+++ b/libs/shared/lib/schema/pills/nodes/SchemaPopUp/SchemaPopUp.tsx
@@ -9,14 +9,14 @@ const formatNumber = (number: number) => {
 export type SchemaPopUpProps = {
   data: Record<string, any>;
   connections?: { to: string; from: string };
-  numberOfElements: any;
+  numberOfElements?: number;
 };
 
 export const SchemaPopUp: React.FC<SchemaPopUpProps> = ({ data, numberOfElements, connections }) => {
   return (
     <>
       <div className="">
-        {numberOfElements && (
+        {numberOfElements != null && numberOfElements != 0 && (
           <div className="border-b border-sec-200">
             <div className="flex flex-row gap-1 items-center justify-between px-3 py-1">
               <Icon component="icon-[ic--baseline-numbers]" size={24} />
diff --git a/libs/shared/lib/schema/pills/nodes/relation/SchemaRelationPill.tsx b/libs/shared/lib/schema/pills/nodes/relation/SchemaRelationPill.tsx
index f292c766b..f5ca399d1 100644
--- a/libs/shared/lib/schema/pills/nodes/relation/SchemaRelationPill.tsx
+++ b/libs/shared/lib/schema/pills/nodes/relation/SchemaRelationPill.tsx
@@ -92,7 +92,6 @@ export const SchemaRelationPill = React.memo(({ id, selected, data, ...props }:
                           )
                         : {}
                     }
-                    numberOfElements={'NoDefined'}
                     connections={{ from: data.from, to: data.to }}
                   />
                 </VisualizationTooltip>
-- 
GitLab