-
Notifications
You must be signed in to change notification settings - Fork 6
/
tree.js
44 lines (34 loc) · 1.11 KB
/
tree.js
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
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { setCommandsCurrentCommandName } from './data/actions';
import Tree from '../components/tree/tree';
import NavBox from '../components/navbox';
class CommandTree extends Component {
constructor( props ) {
super( props );
this.handleTreeClick = this.handleTreeClick.bind( this );
}
handleTreeClick( evt, currentCommandName ) {
evt.persist();
evt.stopPropagation();
this.props.setCommandsCurrentCommandName( currentCommandName );
}
render() {
return <NavBox>
<Tree
definition={this.props.treeDefinition}
onClick={this.handleTreeClick}
activeNode={this.props.currentCommandName}
/>
</NavBox>;
}
}
const mapStateToProps = ( { commands: { treeDefinition, currentCommandName } } ) => {
return { treeDefinition, currentCommandName };
};
const mapDispatchToProps = { setCommandsCurrentCommandName };
export default connect( mapStateToProps, mapDispatchToProps )( CommandTree );