refactor: type renderers
This commit is contained in:
parent
faea819945
commit
3664828331
|
@ -81,8 +81,6 @@ const makeTabSelector = (context, type) => createSelector(
|
|||
<Component
|
||||
context={context}
|
||||
key={key}
|
||||
label={label}
|
||||
name={key}
|
||||
options={options}
|
||||
value={values[key]}
|
||||
/>
|
||||
|
|
|
@ -13,9 +13,6 @@ const decorate = compose(
|
|||
|
||||
const Actions = ({
|
||||
context,
|
||||
name,
|
||||
label,
|
||||
options,
|
||||
value,
|
||||
}) => (
|
||||
<div className="actions">
|
||||
|
|
|
@ -4,8 +4,6 @@ import React from 'react';
|
|||
import propertyPropTypes from './property-prop-types';
|
||||
|
||||
const Bool = ({
|
||||
name,
|
||||
label,
|
||||
value,
|
||||
}) => (
|
||||
<select value={value}>
|
||||
|
|
|
@ -27,9 +27,6 @@ const decorate = compose(
|
|||
|
||||
const Condition = ({
|
||||
context,
|
||||
name,
|
||||
label,
|
||||
options,
|
||||
value,
|
||||
}) => (
|
||||
<span className="condition">
|
||||
|
|
|
@ -4,8 +4,6 @@ import React from 'react';
|
|||
import propertyPropTypes from './property-prop-types';
|
||||
|
||||
const Number = ({
|
||||
name,
|
||||
label,
|
||||
options,
|
||||
value,
|
||||
}) => (
|
||||
|
@ -13,13 +11,13 @@ const Number = ({
|
|||
{
|
||||
options
|
||||
? (
|
||||
<select name={name} value={value}>
|
||||
<select value={value}>
|
||||
{Object.entries(options).map(([optionValue, optionLabel]) => (
|
||||
<option value={optionValue}>{optionLabel}</option>
|
||||
))}
|
||||
</select>
|
||||
)
|
||||
: <input name={name} type="text" value={value} />
|
||||
: <input type="text" value={value} />
|
||||
}
|
||||
</span>
|
||||
);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
export default {
|
||||
name: PropTypes.string.isRequired,
|
||||
label: PropTypes.string,
|
||||
options: PropTypes.shape({}),
|
||||
};
|
||||
|
|
|
@ -13,9 +13,6 @@ const decorate = compose(
|
|||
|
||||
const Routines = ({
|
||||
context,
|
||||
name,
|
||||
label,
|
||||
options,
|
||||
value,
|
||||
}) => {
|
||||
const entries = Object.entries(value.routines);
|
||||
|
@ -25,7 +22,7 @@ const Routines = ({
|
|||
{
|
||||
entries.length > 0 && (
|
||||
entries.map(
|
||||
([name, routine]) => (
|
||||
([, routine]) => (
|
||||
<li className="routine">
|
||||
<Actions.component context={context} value={routine.routine} />
|
||||
</li>
|
||||
|
|
|
@ -4,8 +4,6 @@ import React from 'react';
|
|||
import propertyPropTypes from './property-prop-types';
|
||||
|
||||
const String = ({
|
||||
name,
|
||||
label,
|
||||
options,
|
||||
value,
|
||||
}) => (
|
||||
|
@ -13,13 +11,13 @@ const String = ({
|
|||
{
|
||||
options
|
||||
? (
|
||||
<select name={name} value={value}>
|
||||
<select value={value}>
|
||||
{Object.entries(options).map(([optionValue, optionLabel]) => (
|
||||
<option value={optionValue}>{optionLabel}</option>
|
||||
))}
|
||||
</select>
|
||||
)
|
||||
: <input name={name} type="text" value={value} />
|
||||
: <input type="text" value={value} />
|
||||
}
|
||||
</span>
|
||||
);
|
||||
|
|
|
@ -5,8 +5,10 @@ import PropTypes from 'prop-types';
|
|||
import React from 'react';
|
||||
|
||||
import Bool from './bool.type-renderer';
|
||||
import Number from './number.type-renderer';
|
||||
import propertyPropTypes from './property-prop-types';
|
||||
import Steps from './steps';
|
||||
import String from './string.type-renderer';
|
||||
import {contextStepsList} from './steps-lists';
|
||||
import {typeFits, typeFromSteps} from './typing';
|
||||
|
||||
|
@ -40,8 +42,9 @@ const renderValue = (context, type, value) => {
|
|||
case 'bool':
|
||||
return <Bool.component value={value.value} />;
|
||||
case 'number':
|
||||
return <Number.component value={value.value} />;
|
||||
case 'string':
|
||||
return <span className="wrapper"><input value={value.value} /></span>;
|
||||
return <String.component value={value.value} />;
|
||||
case 'object':
|
||||
return (
|
||||
<div className="object">
|
||||
|
|
Loading…
Reference in New Issue
Block a user