fix(xod-client): fix deducing of types in Jumper node body

This commit is contained in:
Kirill Shumilov
2019-02-08 14:40:31 +03:00
parent 6b57300a5a
commit 94f8ae4e94
2 changed files with 15 additions and 16 deletions

View File

@@ -104,6 +104,9 @@
&.error {
stroke: $color-datatype-dead;
}
&.generic {
stroke: $color-node-outline;
}
}
.nodeLabelContainer {

View File

@@ -2,32 +2,28 @@ import R from 'ramda';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { foldEither } from 'xod-func-tools';
import { foldEither, foldMaybe, maybePath } from 'xod-func-tools';
import { NODE_CORNER_RADIUS } from '../../nodeLayout';
const INPUT_PINKEY = '__in__';
const OUTPUT_PINKEY = '__out__';
const getDeducedTypeOfPin = R.curry((pinkey, pins) =>
R.compose(
foldMaybe('generic', R.identity),
R.map(foldEither('error', R.identity)),
maybePath([INPUT_PINKEY, 'deducedType'])
)(pins)
);
const JumperNodeBody = ({ pins }) => {
const inConnected = R.path([INPUT_PINKEY, 'isConnected'], pins);
const outConnected = R.path([OUTPUT_PINKEY, 'isConnected'], pins);
const type = R.cond([
[
() => inConnected,
R.compose(
foldEither('error', R.identity),
R.path([INPUT_PINKEY, 'deducedType'])
),
],
[
() => outConnected,
R.compose(
foldEither('error', R.identity),
R.path([OUTPUT_PINKEY, 'deducedType'])
),
],
[R.T, R.always('')],
[() => inConnected, getDeducedTypeOfPin(INPUT_PINKEY)],
[() => outConnected, getDeducedTypeOfPin(OUTPUT_PINKEY)],
[R.T, R.always('generic')],
])(pins);
const isConnected =