diff --git a/src/core/json-schema-components.jsx b/src/core/json-schema-components.jsx index 50a3b729f00..f44f0e933b7 100644 --- a/src/core/json-schema-components.jsx +++ b/src/core/json-schema-components.jsx @@ -47,6 +47,7 @@ export class JsonSchemaForm extends Component { let { schema, errors, value, onChange, getComponent, fn, disabled } = this.props const format = schema && schema.get ? schema.get("format") : null const type = schema && schema.get ? schema.get("type") : null + let getComponentSilently = (name) => getComponent(name, false, { failSilently: true }) let Comp = type ? format ? getComponentSilently(`JsonSchema_${type}_${format}`) : @@ -63,7 +64,7 @@ export class JsonSchema_string extends Component { static propTypes = JsonSchemaPropShape static defaultProps = JsonSchemaDefaultProps onChange = (e) => { - const value = this.props.schema && this.props.schema["type"] === "file" ? e.target.files[0] : e.target.value + const value = this.props.schema && this.props.schema.get("type") === "file" ? e.target.files[0] : e.target.value this.props.onChange(value, this.props.keyName) } onEnumChange = (val) => this.props.onChange(val) @@ -92,23 +93,27 @@ export class JsonSchema_string extends Component { const isDisabled = disabled || (schemaIn && schemaIn === "formData" && !("FormData" in window)) const Input = getComponent("Input") if (type && type === "file") { - return () + return ( + + ) } else { - return () + return ( + + ) } } } @@ -170,6 +175,7 @@ export class JsonSchema_array extends PureComponent { const schemaItemsSchema = schema.getIn(["items", "schema"]) let ArrayItemsComponent let isArrayItemText = false + let isArrayItemFile = schemaItemsType === "file" ? true : false if (schemaItemsType && schemaItemsFormat) { ArrayItemsComponent = getComponent(`JsonSchema_${schemaItemsType}_${schemaItemsFormat}`) } else if (schemaItemsType === "boolean" || schemaItemsType === "array" || schemaItemsType === "object") { @@ -177,7 +183,7 @@ export class JsonSchema_array extends PureComponent { } // if ArrayItemsComponent not assigned or does not exist, // use default schemaItemsType === "string" & JsonSchemaArrayItemText component - if (!ArrayItemsComponent) { + if (!ArrayItemsComponent && !isArrayItemFile) { isArrayItemText = true } @@ -205,22 +211,30 @@ export class JsonSchema_array extends PureComponent { return (
{ - isArrayItemText ? - this.onItemChange(val, i)} - disabled={disabled} - errors={errors} - /> - : this.onItemChange(val, i)} - disabled={disabled} - errors={errors} - schema={schemaItemsSchema} - getComponent={getComponent} - fn={fn} + isArrayItemFile ? + this.onItemChange(val, i)} + disabled={disabled} + errors={errors} + getComponent={getComponent} /> + : isArrayItemText ? + this.onItemChange(val, i)} + disabled={disabled} + errors={errors} + /> + : this.onItemChange(val, i)} + disabled={disabled} + errors={errors} + schema={schemaItemsSchema} + getComponent={getComponent} + fn={fn} + /> } {!disabled ? (