feat(xod-client): special UI for tweak nodes

This commit is contained in:
Evgeny Kochetkov
2019-02-06 18:42:39 +03:00
parent 28e598dac1
commit e763931397
3 changed files with 28 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ import { isPinSelected } from '../../editor/utils';
import RegularNodeBody from './nodeParts/RegularNodeBody';
import WatchNodeBody from './nodeParts/WatchNodeBody';
import TweakNodeBody from './nodeParts/TweakNodeBody';
import TerminalNodeBody from './nodeParts/TerminalNodeBody';
import ConstantNodeBody from './nodeParts/ConstantNodeBody';
import BusNodeBody from './nodeParts/BusNodeBody';
@@ -114,6 +115,7 @@ class Node extends React.Component {
[XP.isTerminalPatchPath, () => <TerminalNodeBody {...this.props} />],
[XP.isWatchPatchPath, () => <WatchNodeBody {...this.props} />],
[XP.isConstantNodeType, () => <ConstantNodeBody {...this.props} />],
[XP.isTweakPath, () => <TweakNodeBody {...this.props} />],
[isBusNodeType, () => <BusNodeBody {...this.props} />],
[XP.isJumperPatchPath, () => <JumperNodeBody {...this.props} />],
[R.T, () => <RegularNodeBody {...this.props} />],

View File

@@ -6,7 +6,7 @@ import { noop } from 'xod-func-tools';
import RegularNodeBody from './RegularNodeBody';
const getConstantValue = ({ pins }) =>
export const getConstantValue = ({ pins }) =>
R.compose(R.prop('value'), R.head, R.values)(pins);
const ConstantNodeBody = props => (

View File

@@ -0,0 +1,25 @@
import * as R from 'ramda';
import React from 'react';
import PropTypes from 'prop-types';
import * as XP from 'xod-project';
import { noop } from 'xod-func-tools';
import WatchNodeBody from './WatchNodeBody';
import { getConstantValue } from './ConstantNodeBody';
const TweakNodeBody = props => (
<WatchNodeBody
{...props}
label={props.label || getConstantValue(props) || XP.getBaseName(props.type)}
/>
);
TweakNodeBody.defaultProps = {
onVariadicHandleDown: noop,
};
TweakNodeBody.propTypes = R.merge(WatchNodeBody.propTypes, {
pins: PropTypes.any,
});
export default TweakNodeBody;