fix(ui): Send number input as number JSON not string (#130)
* fix(ui): Submit number fields as numbers not text * fix(ui): Remove some debug messages
This commit is contained in:
committed by
GitHub
parent
1eee5b5a32
commit
a569e37a34
@@ -28,7 +28,10 @@ const AgentForm = ({
|
|||||||
|
|
||||||
// Handle input changes
|
// Handle input changes
|
||||||
const handleInputChange = (e) => {
|
const handleInputChange = (e) => {
|
||||||
const { name, value, type, checked } = e.target;
|
const { name, value, type, checked } = e.target.name.target;
|
||||||
|
|
||||||
|
// Convert value to number if it's a number input
|
||||||
|
const processedValue = type === 'number' ? Number(value) : value;
|
||||||
|
|
||||||
if (name.includes('.')) {
|
if (name.includes('.')) {
|
||||||
const [parent, child] = name.split('.');
|
const [parent, child] = name.split('.');
|
||||||
@@ -36,13 +39,13 @@ const AgentForm = ({
|
|||||||
...formData,
|
...formData,
|
||||||
[parent]: {
|
[parent]: {
|
||||||
...formData[parent],
|
...formData[parent],
|
||||||
[child]: type === 'checkbox' ? checked : value
|
[child]: type === 'checkbox' ? checked : processedValue
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setFormData({
|
setFormData({
|
||||||
...formData,
|
...formData,
|
||||||
[name]: type === 'checkbox' ? checked : value
|
[name]: type === 'checkbox' ? checked : processedValue
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -57,7 +60,6 @@ const AgentForm = ({
|
|||||||
|
|
||||||
// Handle navigation between sections
|
// Handle navigation between sections
|
||||||
const handleSectionChange = (section) => {
|
const handleSectionChange = (section) => {
|
||||||
console.log('Changing section to:', section);
|
|
||||||
setActiveSection(section);
|
setActiveSection(section);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -94,7 +96,6 @@ const AgentForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleAddDynamicPrompt = () => {
|
const handleAddDynamicPrompt = () => {
|
||||||
console.log('Adding dynamic prompt');
|
|
||||||
setFormData({
|
setFormData({
|
||||||
...formData,
|
...formData,
|
||||||
dynamicPrompts: [
|
dynamicPrompts: [
|
||||||
|
|||||||
@@ -57,10 +57,15 @@ const ConfigForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handle config field change
|
// Handle config field change
|
||||||
const handleConfigChange = (index, key, value) => {
|
const handleConfigChange = (index, e) => {
|
||||||
|
const { name: key, value, type, checked } = e.target;
|
||||||
const item = items[index];
|
const item = items[index];
|
||||||
const config = parseConfig(item);
|
const config = parseConfig(item);
|
||||||
config[key] = value;
|
|
||||||
|
// Convert value to number if it's a number input
|
||||||
|
const processedValue = type === 'number' ? Number(value) : value;
|
||||||
|
|
||||||
|
config[key] = type === 'checkbox' ? checked : processedValue;
|
||||||
|
|
||||||
onChange(index, {
|
onChange(index, {
|
||||||
...item,
|
...item,
|
||||||
@@ -112,7 +117,7 @@ const ConfigForm = ({
|
|||||||
<FormFieldDefinition
|
<FormFieldDefinition
|
||||||
fields={fieldGroup.fields}
|
fields={fieldGroup.fields}
|
||||||
values={parseConfig(item)}
|
values={parseConfig(item)}
|
||||||
onChange={(key, value) => handleConfigChange(index, key, value)}
|
onChange={(e) => handleConfigChange(index, e)}
|
||||||
idPrefix={`${itemType}-${index}-`}
|
idPrefix={`${itemType}-${index}-`}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -28,8 +28,13 @@ const MCPServersSection = ({
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Handle field value changes for a specific server
|
// Handle field value changes for a specific server
|
||||||
const handleFieldChange = (index, name, value) => {
|
const handleFieldChange = (index, e) => {
|
||||||
handleMCPServerChange(index, name, value);
|
const { name, value, type, checked } = e.target;
|
||||||
|
|
||||||
|
// Convert value to number if it's a number input
|
||||||
|
const processedValue = type === 'number' ? Number(value) : value;
|
||||||
|
|
||||||
|
handleMCPServerChange(index, name, type === 'checkbox' ? checked : processedValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -56,7 +61,7 @@ const MCPServersSection = ({
|
|||||||
<FormFieldDefinition
|
<FormFieldDefinition
|
||||||
fields={getServerFields()}
|
fields={getServerFields()}
|
||||||
values={server}
|
values={server}
|
||||||
onChange={(name, value) => handleFieldChange(index, name, value)}
|
onChange={(e) => handleFieldChange(index, e)}
|
||||||
idPrefix={`mcp_server_${index}_`}
|
idPrefix={`mcp_server_${index}_`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import React from 'react';
|
|||||||
*/
|
*/
|
||||||
const FormField = ({
|
const FormField = ({
|
||||||
id,
|
id,
|
||||||
|
name,
|
||||||
label,
|
label,
|
||||||
type = 'text',
|
type = 'text',
|
||||||
value,
|
value,
|
||||||
@@ -45,8 +46,9 @@ const FormField = ({
|
|||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id={id}
|
id={id}
|
||||||
|
name={name}
|
||||||
checked={value === true || value === 'true'}
|
checked={value === true || value === 'true'}
|
||||||
onChange={(e) => onChange(e.target.checked ? 'true' : 'false')}
|
onChange={onChange}
|
||||||
/>
|
/>
|
||||||
{labelWithIndicator}
|
{labelWithIndicator}
|
||||||
</label>
|
</label>
|
||||||
@@ -59,8 +61,9 @@ const FormField = ({
|
|||||||
<label htmlFor={id}>{labelWithIndicator}</label>
|
<label htmlFor={id}>{labelWithIndicator}</label>
|
||||||
<select
|
<select
|
||||||
id={id}
|
id={id}
|
||||||
|
name={name}
|
||||||
value={value || ''}
|
value={value || ''}
|
||||||
onChange={(e) => onChange(e.target.value)}
|
onChange={onChange}
|
||||||
className="form-control"
|
className="form-control"
|
||||||
required={required}
|
required={required}
|
||||||
>
|
>
|
||||||
@@ -79,8 +82,9 @@ const FormField = ({
|
|||||||
<label htmlFor={id}>{labelWithIndicator}</label>
|
<label htmlFor={id}>{labelWithIndicator}</label>
|
||||||
<textarea
|
<textarea
|
||||||
id={id}
|
id={id}
|
||||||
|
name={name}
|
||||||
value={value || ''}
|
value={value || ''}
|
||||||
onChange={(e) => onChange(e.target.value)}
|
onChange={onChange}
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
required={required}
|
required={required}
|
||||||
@@ -96,8 +100,9 @@ const FormField = ({
|
|||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
id={id}
|
id={id}
|
||||||
|
name={name}
|
||||||
value={value || ''}
|
value={value || ''}
|
||||||
onChange={(e) => onChange(e.target.value)}
|
onChange={onChange}
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
required={required}
|
required={required}
|
||||||
@@ -115,8 +120,9 @@ const FormField = ({
|
|||||||
<input
|
<input
|
||||||
type={type}
|
type={type}
|
||||||
id={id}
|
id={id}
|
||||||
|
name={name}
|
||||||
value={value || ''}
|
value={value || ''}
|
||||||
onChange={(e) => onChange(e.target.value)}
|
onChange={onChange}
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
required={required}
|
required={required}
|
||||||
|
|||||||
@@ -25,10 +25,11 @@ const FormFieldDefinition = ({
|
|||||||
<div key={field.name} style={{ marginBottom: '16px' }}>
|
<div key={field.name} style={{ marginBottom: '16px' }}>
|
||||||
<FormField
|
<FormField
|
||||||
id={`${idPrefix}${field.name}`}
|
id={`${idPrefix}${field.name}`}
|
||||||
|
name={field.name}
|
||||||
label={field.label}
|
label={field.label}
|
||||||
type={field.type}
|
type={field.type}
|
||||||
value={safeValues[field.name] !== undefined ? safeValues[field.name] : field.defaultValue}
|
value={safeValues[field.name] !== undefined ? safeValues[field.name] : field.defaultValue}
|
||||||
onChange={(value) => onChange(field.name, value)}
|
onChange={onChange}
|
||||||
placeholder={field.placeholder || ''}
|
placeholder={field.placeholder || ''}
|
||||||
helpText={field.helpText || ''}
|
helpText={field.helpText || ''}
|
||||||
options={field.options || []}
|
options={field.options || []}
|
||||||
|
|||||||
Reference in New Issue
Block a user