/
StandardNode.jsx
executable file
·110 lines (102 loc) · 3.52 KB
/
StandardNode.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import React, { Component, Fragment } from 'react'
import { Tabs, Tab, Badge, Panel } from 'react-bootstrap'
import EditableInput from '../common/EditableInput'
import ActionSection from './ActionSection'
import TransitionSection from './TransitionSection'
const style = require('./style.scss')
export default class StandardNodePropertiesPanel extends Component {
renameNode = text => {
if (text) {
let nodes = this.props.flow.nodes;
for (let i = 0; i < nodes.length; i++) {
if (text === nodes[i].name) {
return;
}
}
this.props.updateNode({ name: text })
}
}
transformText(text) {
return text.replace(/[^a-z0-9-_\.]/gi, '_')
}
render() {
const { node, readOnly } = this.props
return (
<div className={style.node}>
<Panel>
<EditableInput
readOnly={readOnly}
value={node.name}
className={style.name}
onChanged={this.renameNode}
transform={this.transformText}
/>
</Panel>
<Tabs animation={false} id="node-props-modal-standard-node-tabs">
{!this.props.transitionOnly && (
<Tab
eventKey="on_enter"
title={
<Fragment>
<Badge>{(node.onEnter && node.onEnter.length) || 0}</Badge> On Enter
</Fragment>
}
>
<ActionSection
readOnly={readOnly}
items={node.onEnter}
header="On Enter"
onItemsUpdated={items => this.props.updateNode({ onEnter: items })}
copyItem={item => this.props.copyFlowNodeElement({ action: item })}
pasteItem={() => this.props.pasteFlowNodeElement('onEnter')}
canPaste={Boolean(this.props.buffer.action)}
/>
</Tab>
)}
{!this.props.transitionOnly && (
<Tab
eventKey="on_receive"
title={
<Fragment>
<Badge>{(node.onReceive && node.onReceive.length) || 0}</Badge> On Receive
</Fragment>
}
>
<ActionSection
readOnly={readOnly}
items={node.onReceive}
header="On Receive"
waitable={true}
onItemsUpdated={items => this.props.updateNode({ onReceive: items })}
copyItem={item => this.props.copyFlowNodeElement({ action: item })}
pasteItem={() => this.props.pasteFlowNodeElement('onReceive')}
canPaste={Boolean(this.props.buffer.action)}
/>
</Tab>
)}
<Tab
eventKey="transitions"
title={
<Fragment>
<Badge>{(node.next && node.next.length) || 0}</Badge> Transitions
</Fragment>
}
>
<TransitionSection
readOnly={readOnly}
items={node.next}
header="Transitions"
currentFlow={this.props.flow}
currentNodeName={node.name}
subflows={this.props.subflows}
onItemsUpdated={items => this.props.updateNode({ next: items })}
copyItem={item => this.props.copyFlowNodeElement({ transition: item })}
pasteItem={() => this.props.pasteFlowNodeElement('next')}
canPaste={Boolean(this.props.buffer.transition)}
/>
</Tab>
</Tabs>
</div>
)
}
}