flow: fixes
This commit is contained in:
parent
34e795afaf
commit
c8c1f1ea2b
|
@ -9,18 +9,16 @@ const decorate = compose(
|
||||||
contempo(require('./entity.raw.scss')),
|
contempo(require('./entity.raw.scss')),
|
||||||
);
|
);
|
||||||
|
|
||||||
const json = require('~/../fixtures/kitty.entity.json');
|
const json = require('~/../fixtures/watering-can.entity.json');
|
||||||
|
|
||||||
const EntityComponent = (props) => {
|
const EntityComponent = (props) => {
|
||||||
const {context} = props;
|
|
||||||
const entity = new Entity(json);
|
const entity = new Entity(json);
|
||||||
context.add('entity', entity, 'entity');
|
|
||||||
const {traits} = json;
|
const {traits} = json;
|
||||||
return (
|
return (
|
||||||
<div className="entity">
|
<div className="entity">
|
||||||
<div className="document-pane" />
|
<div className="document-pane" />
|
||||||
<div className="settings-pane">
|
<div className="settings-pane">
|
||||||
<Traits context={context} traits={traits} />
|
<Traits context={entity.context} traits={traits} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
import {Context} from '@avocado/behavior';
|
|
||||||
import {hot} from 'react-hot-loader';
|
import {hot} from 'react-hot-loader';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import Entity from './entity';
|
import Entity from './entity';
|
||||||
|
|
||||||
const context = new Context();
|
|
||||||
|
|
||||||
const Persea = () => (
|
const Persea = () => (
|
||||||
<Entity context={context} />
|
<Entity />
|
||||||
);
|
);
|
||||||
|
|
||||||
export default hot(module)(Persea);
|
export default hot(module)(Persea);
|
||||||
|
|
|
@ -15,7 +15,7 @@ const Routines = ({
|
||||||
context,
|
context,
|
||||||
value,
|
value,
|
||||||
}) => {
|
}) => {
|
||||||
const entries = Object.entries(value.routines);
|
const entries = value.routines ? Object.entries(value.routines) : [];
|
||||||
return (
|
return (
|
||||||
<div className="routines">
|
<div className="routines">
|
||||||
<ol>
|
<ol>
|
||||||
|
|
|
@ -20,12 +20,16 @@ export const variableStepsList = (context, previousSteps, key, variable, variabl
|
||||||
steps.push({type: 'invoke', args: []});
|
steps.push({type: 'invoke', args: []});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!variable) {
|
|
||||||
return [steps];
|
|
||||||
}
|
|
||||||
const sublists = Object.entries(description)
|
const sublists = Object.entries(description)
|
||||||
.map(([key, description]) => (
|
.map(([key, description]) => (
|
||||||
variableStepsList(context, previousSteps.concat(steps), key, variable[key], description.type, type)
|
variableStepsList(
|
||||||
|
context,
|
||||||
|
previousSteps.concat(steps),
|
||||||
|
key,
|
||||||
|
'undefined' === typeof variable ? undefined : variable[key],
|
||||||
|
description.type,
|
||||||
|
type
|
||||||
|
)
|
||||||
))
|
))
|
||||||
.map((childLists) => (
|
.map((childLists) => (
|
||||||
childLists.map((stepsList) => (
|
childLists.map((stepsList) => (
|
||||||
|
@ -34,7 +38,7 @@ export const variableStepsList = (context, previousSteps, key, variable, variabl
|
||||||
: []
|
: []
|
||||||
))
|
))
|
||||||
))
|
))
|
||||||
return sublists.length > 0 ? flatten(sublists) : [steps];
|
return sublists.length > 0 ? [steps].concat(flatten(sublists)) : [steps];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const contextStepsList = (context, type) => (
|
export const contextStepsList = (context, type) => (
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.invoke {
|
.invoke {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,10 @@ export function typeFromSteps(context, steps) {
|
||||||
const {key} = step;
|
const {key} = step;
|
||||||
if (key) {
|
if (key) {
|
||||||
const description = Context.typeDescription(type, v);
|
const description = Context.typeDescription(type, v);
|
||||||
return [v[key], description[key] ? description[key].type : type];
|
return [
|
||||||
|
'object' === typeof v ? v[key] : undefined,
|
||||||
|
description[key] ? description[key].type : type
|
||||||
|
];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return [v, type];
|
return [v, type];
|
||||||
|
|
|
@ -44,6 +44,7 @@ const renderValue = (context, type, value) => {
|
||||||
return <Bool.component value={value.value} />;
|
return <Bool.component value={value.value} />;
|
||||||
case 'number':
|
case 'number':
|
||||||
return <Number.component value={value.value} />;
|
return <Number.component value={value.value} />;
|
||||||
|
case 'any':
|
||||||
case 'string':
|
case 'string':
|
||||||
return <String.component value={value.value} />;
|
return <String.component value={value.value} />;
|
||||||
case 'object':
|
case 'object':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user