mirror of
https://github.com/xodio/xod.git
synced 2026-03-24 17:46:56 +01:00
fix(xod-client): fix deducing of types in Jumper node body
This commit is contained in:
@@ -104,6 +104,9 @@
|
||||
&.error {
|
||||
stroke: $color-datatype-dead;
|
||||
}
|
||||
&.generic {
|
||||
stroke: $color-node-outline;
|
||||
}
|
||||
}
|
||||
|
||||
.nodeLabelContainer {
|
||||
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user