From 56790cb7e475f4a5a5d88803e97f4fcda9629f7a Mon Sep 17 00:00:00 2001
From: katarina-cala <katarinacala@gmail.com>
Date: Fri, 11 Jul 2025 12:56:27 +0200
Subject: [PATCH 1/2] first endpoint wip - NodeOptions

---
 .../components/properties/Property.tsx        |  1 +
 .../components/PropertyComboBox.tsx           | 44 ++++++++++++++++++-
 .../platform/workflowNodeOptions.queries.ts   | 27 ++++++++++++
 3 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/client/src/pages/platform/workflow-editor/components/properties/Property.tsx b/client/src/pages/platform/workflow-editor/components/properties/Property.tsx
index 0a6785d9f51..3ffb4c2b6a5 100644
--- a/client/src/pages/platform/workflow-editor/components/properties/Property.tsx
+++ b/client/src/pages/platform/workflow-editor/components/properties/Property.tsx
@@ -164,6 +164,7 @@ const Property = ({
         required = false,
         type,
     } = property;
+    // console.log('property', property);
 
     let {displayCondition} = property;
 
diff --git a/client/src/pages/platform/workflow-editor/components/properties/components/PropertyComboBox.tsx b/client/src/pages/platform/workflow-editor/components/properties/components/PropertyComboBox.tsx
index ad320ca69cc..d0f65d62c1c 100644
--- a/client/src/pages/platform/workflow-editor/components/properties/components/PropertyComboBox.tsx
+++ b/client/src/pages/platform/workflow-editor/components/properties/components/PropertyComboBox.tsx
@@ -5,7 +5,10 @@ import {Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandL
 import {Label} from '@/components/ui/label';
 import {Popover, PopoverContent, PopoverTrigger} from '@/components/ui/popover';
 import {Tooltip, TooltipContent, TooltipTrigger} from '@/components/ui/tooltip';
-import {useGetWorkflowNodeOptionsQuery} from '@/shared/queries/platform/workflowNodeOptions.queries';
+import {
+    useGetClusterElementNodeOptionsQuery,
+    useGetWorkflowNodeOptionsQuery,
+} from '@/shared/queries/platform/workflowNodeOptions.queries';
 import {CaretSortIcon, CheckIcon, QuestionMarkCircledIcon} from '@radix-ui/react-icons';
 import {FocusEventHandler, ReactNode, useEffect, useMemo, useState} from 'react';
 import InlineSVG from 'react-inlinesvg';
@@ -16,6 +19,7 @@ import getFormattedDependencyKey from '../../../utils/getFormattedDependencyKey'
 import InputTypeSwitchButton from './InputTypeSwitchButton';
 
 import type {
+    GetClusterElementNodeOptionsRequest,
     GetWorkflowNodeOptionsRequest,
     Option,
     OptionsDataSource,
@@ -124,6 +128,24 @@ const PropertyComboBox = ({
         [lookupDependsOnPaths, lookupDependsOnValuesKey, path, workflowId, workflowNodeName]
     );
 
+    const clusterElementQueryOptions: {
+        loadDependencyValueKey: string;
+        request: GetClusterElementNodeOptionsRequest;
+    } = useMemo(
+        () => ({
+            loadDependencyValueKey: lookupDependsOnValuesKey,
+            request: {
+                clusterElement: currentNode!.clusterElementName!,
+                clusterElementType: currentNode!.clusterElementType!,
+                id: workflowId,
+                lookupDependsOnPaths,
+                propertyName: path!,
+                workflowNodeName,
+            },
+        }),
+        [lookupDependsOnPaths, lookupDependsOnValuesKey, path, workflowId, workflowNodeName, currentNode]
+    );
+
     const queryEnabled = useMemo(
         () =>
             !!currentNode &&
@@ -132,6 +154,7 @@ const PropertyComboBox = ({
                 : true) &&
             !!connectionRequirementMet &&
             optionsDataSource,
+
         [connectionRequirementMet, currentNode, lookupDependsOnPaths?.length, lookupDependsOnValues, optionsDataSource]
     );
 
@@ -139,7 +162,24 @@ const PropertyComboBox = ({
         data: optionsData,
         isLoading,
         isRefetching,
-    } = useGetWorkflowNodeOptionsQuery(queryOptions, Boolean(queryEnabled));
+    } = useGetWorkflowNodeOptionsQuery(queryOptions, Boolean(queryEnabled && !currentNode?.clusterElementType));
+
+    const {
+        data: clusterElementNodeOptionsData,
+        isLoading: isClusterElementNodeOptionsLoading,
+        isRefetching: isClusterElementNodeOptionsRefetching,
+    } = useGetClusterElementNodeOptionsQuery(
+        clusterElementQueryOptions,
+        Boolean(queryEnabled && currentNode?.clusterElementType)
+    );
+    // console.log('clusterElementNodeOptionsData', clusterElementNodeOptionsData);
+    // console.log('isLoading', isLoading);
+    // console.log('isrefetching', isRefetching);
+    // console.log('current node', currentNode);
+    // console.log('queryEnabled', queryEnabled);
+    // console.log('lookupDependsOnValues', lookupDependsOnValues);
+    // console.log('connectionRequirementMet', connectionRequirementMet);
+    // console.log('optionsDataSource', optionsDataSource);
 
     const options = useMemo(() => {
         if (optionsData) {
diff --git a/client/src/shared/queries/platform/workflowNodeOptions.queries.ts b/client/src/shared/queries/platform/workflowNodeOptions.queries.ts
index f282c7797fa..4a5e1e18585 100644
--- a/client/src/shared/queries/platform/workflowNodeOptions.queries.ts
+++ b/client/src/shared/queries/platform/workflowNodeOptions.queries.ts
@@ -1,5 +1,6 @@
 /* eslint-disable sort-keys */
 import {
+    GetClusterElementNodeOptionsRequest,
     GetWorkflowNodeOptionsRequest,
     type Option,
     WorkflowNodeOptionApi,
@@ -16,6 +17,21 @@ export const WorkflowNodeOptionKeys = {
         loadDependencyValueKey,
     ],
     workflowNodeOptions: ['workflowNodeOptions'] as const,
+
+    propertyClusterElementNodeOptions: (
+        request: GetClusterElementNodeOptionsRequest,
+        loadDependencyValueKey: string
+    ) => [
+        ...WorkflowNodeOptionKeys.clusterElementNodeOptions,
+        request.id,
+        request.workflowNodeName,
+        request.clusterElementType,
+        request.clusterElement,
+        request.propertyName,
+        request.searchText,
+        loadDependencyValueKey,
+    ],
+    clusterElementNodeOptions: ['clusterElementNodeOptions'] as const,
 };
 
 export const useGetWorkflowNodeOptionsQuery = (
@@ -28,3 +44,14 @@ export const useGetWorkflowNodeOptionsQuery = (
         enabled: enabled === undefined ? true : enabled,
         staleTime: 60000,
     });
+
+export const useGetClusterElementNodeOptionsQuery = (
+    {loadDependencyValueKey, request}: {loadDependencyValueKey: string; request: GetClusterElementNodeOptionsRequest},
+    enabled?: boolean
+) =>
+    useQuery<Array<Option>, Error>({
+        queryKey: WorkflowNodeOptionKeys.propertyClusterElementNodeOptions(request, loadDependencyValueKey),
+        queryFn: () => new WorkflowNodeOptionApi().getClusterElementNodeOptions(request),
+        enabled: enabled === undefined ? true : enabled,
+        staleTime: 60000,
+    });

From 021c296d4ba6ab0fee9e824fdd0990f9a589a640 Mon Sep 17 00:00:00 2001
From: Ivica Cardic <ivica.cardic@gmail.com>
Date: Tue, 15 Jul 2025 09:31:10 +0200
Subject: [PATCH 2/2] 1652 - client - Refactor: update property name to
 `clusterElementWorkflowNodeName` in `PropertyComboBox` for consistency with
 workflow node naming conventions.

---
 .../components/properties/components/PropertyComboBox.tsx     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/client/src/pages/platform/workflow-editor/components/properties/components/PropertyComboBox.tsx b/client/src/pages/platform/workflow-editor/components/properties/components/PropertyComboBox.tsx
index d0f65d62c1c..f896e58ef3c 100644
--- a/client/src/pages/platform/workflow-editor/components/properties/components/PropertyComboBox.tsx
+++ b/client/src/pages/platform/workflow-editor/components/properties/components/PropertyComboBox.tsx
@@ -135,12 +135,12 @@ const PropertyComboBox = ({
         () => ({
             loadDependencyValueKey: lookupDependsOnValuesKey,
             request: {
-                clusterElement: currentNode!.clusterElementName!,
                 clusterElementType: currentNode!.clusterElementType!,
+                clusterElementWorkflowNodeName: currentNode!.name!,
                 id: workflowId,
                 lookupDependsOnPaths,
                 propertyName: path!,
-                workflowNodeName,
+                workflowNodeName, // Mora biti ime od cluster element root node-a, npr. aiAgent_1
             },
         }),
         [lookupDependsOnPaths, lookupDependsOnValuesKey, path, workflowId, workflowNodeName, currentNode]
