Skip to content

Commit

Permalink
updated ScriptInput.js
Browse files Browse the repository at this point in the history
  • Loading branch information
shaun210 committed Nov 24, 2023
1 parent 884056a commit bd75241
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ui/src/components/PipelineEditor/PipelineEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,15 +460,15 @@ export default function PipelineEditor(props) {
nodeId: getStepNodeId(outputNodeId),
outputId: getStepOutput(outputNodeId),
file: sourceNode.data.descriptionFile,
type: input.type
}
newPipelineOutputs.push(newNode);
}

else if (sourceNode.type === 'constant') { // change this to 'else if'
else if (sourceNode.type === 'constant') {
newNode = {
description: 'A constant has no description',
label: 'a constant has no label',
type: sourceNode.data.type,
example: sourceNode.data.value,
nodeId: getStepNodeId(outputNodeId),
outputId: getStepOutput(outputNodeId),
Expand Down Expand Up @@ -514,7 +514,7 @@ export default function PipelineEditor(props) {
: newOutput;
})
);
}, [edges, reactFlowInstance, setOutputList, inputList]);
}, [edges, reactFlowInstance, setOutputList, inputList, onConstantValueChange]);


const refreshOutputListOnInputNodeChange = useCallback(() => {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/form/AutoResizeTextArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function AutoResizeTextArea({ defaultValue, keepWidth, className,
const [value, setValue] = useState(defaultValue || ''); // Initialize with defaultValue prop

useEffect(() => {
setValue(defaultValue || ''); // Update value when defaultValue prop changes
setValue(defaultValue || '');
}, [defaultValue]);

useEffect(() => {
Expand Down
11 changes: 10 additions & 1 deletion ui/src/components/form/ScriptInput.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import React, { useEffect, useState } from 'react';
import AutoResizeTextArea from './AutoResizeTextArea'

export const ARRAY_PLACEHOLDER = 'Array (comma-separated)';
export const CONSTANT_PLACEHOLDER = 'Constant';

export default function ScriptInput({ type, value, options, onValueUpdated, cols, ...passedProps }) {

const [fieldValue, setFieldValue] = useState(value)

useEffect(() => {
setFieldValue(value || '')
}, [value])

if(type.endsWith('[]')) {
return <AutoResizeTextArea {...passedProps}
defaultValue={value && typeof value.join === 'function' ? value.join(', ') : value}
Expand Down Expand Up @@ -43,8 +50,10 @@ export default function ScriptInput({ type, value, options, onValueUpdated, cols
onChange={e => onValueUpdated(e.target.checked)} />

case 'int':
return <input type='text' {...passedProps} defaultValue={value}
console.log('ScriptInput', value, fieldValue)
return <input type='text' {...passedProps} value={fieldValue}
placeholder={CONSTANT_PLACEHOLDER}
onChange={e => setFieldValue(e.target.value)}
onKeyDown={e => { if (e.key === "Enter") onValueUpdated(parseInt(e.target.value)) }}
onBlur={e => onValueUpdated(parseInt(e.target.value))} />

Expand Down

0 comments on commit bd75241

Please sign in to comment.