Enhance FieldWithHelp and NodeConfiguration components with nodeType support

- Added nodeType prop to FieldWithHelp for dynamic field configuration based on node type.
- Updated getFieldConfig function to retrieve node-specific field configurations.
- Integrated nodeType in NodeConfiguration to pass relevant type to input fields, improving flexibility for different operations.
This commit is contained in:
Nikhil-Doye
2025-10-23 16:03:14 -04:00
parent 80f7d2f600
commit 24f687191f
3 changed files with 39 additions and 3 deletions
+3 -1
View File
@@ -23,6 +23,7 @@ interface FieldWithHelpProps {
max?: number;
step?: number;
className?: string;
nodeType?: string;
}
export const FieldWithHelp: React.FC<FieldWithHelpProps> = ({
@@ -37,9 +38,10 @@ export const FieldWithHelp: React.FC<FieldWithHelpProps> = ({
max,
step,
className = "",
nodeType,
}) => {
const [showHelp, setShowHelp] = useState(false);
const fieldConfig = getFieldConfig(fieldName);
const fieldConfig = getFieldConfig(fieldName, nodeType);
if (!fieldConfig) {
// Fallback for unknown fields
+2
View File
@@ -526,6 +526,7 @@ Return only the optimized prompt:`,
min={field.min}
max={field.max}
step={field.step}
nodeType={data.type}
/>
{data.type === "llmTask" && field.key === "prompt" && (
<div className="flex items-center space-x-2">
@@ -577,6 +578,7 @@ Return only the optimized prompt:`,
onChange={handleLabelChange}
type="text"
placeholder="Enter node label"
nodeType={data.type}
/>
{config.fields.map((field) => (
+34 -2
View File
@@ -220,7 +220,8 @@ export const fieldConfigs: Record<string, FieldConfig> = {
required: true,
},
},
operation: {
// Database operation field
"database.operation": {
technicalName: "operation",
userFriendlyName: "Database operation",
description: "Choose what type of database operation to perform",
@@ -238,6 +239,25 @@ export const fieldConfigs: Record<string, FieldConfig> = {
required: true,
},
},
// Slack operation field
"slack.operation": {
technicalName: "operation",
userFriendlyName: "Slack operation",
description: "Choose what type of Slack operation to perform",
helpText:
"Select the type of Slack operation you want to perform. Each operation has different configuration options.",
examples: [
"Message - Send messages to channels or users",
"Channel - Create, archive, or manage channels",
"User - Invite, remove, or manage users",
"File - Upload and manage files",
"Reaction - Add/remove reactions to messages",
"Reminder - Set reminders for users",
],
validation: {
required: true,
},
},
// Output Fields
format: {
@@ -350,7 +370,19 @@ export const fieldConfigs: Record<string, FieldConfig> = {
},
};
export const getFieldConfig = (fieldName: string): FieldConfig | null => {
export const getFieldConfig = (
fieldName: string,
nodeType?: string
): FieldConfig | null => {
// First try to get node-specific field config
if (nodeType) {
const nodeSpecificKey = `${nodeType}.${fieldName}`;
if (fieldConfigs[nodeSpecificKey]) {
return fieldConfigs[nodeSpecificKey];
}
}
// Fallback to generic field config
return fieldConfigs[fieldName] || null;
};