-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathindex.js
More file actions
85 lines (74 loc) · 2.26 KB
/
index.js
File metadata and controls
85 lines (74 loc) · 2.26 KB
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
import React from 'react';
import { connect } from 'react-redux';
import {
getSource,
getSourceLayout,
getCodeCrumbsUserChoice,
getNamespacesList
} from 'core/dataBus/selectors';
import { selectCodeCrumb, selectNodeToOpenInEditor, selectCcFlowEdge } from 'core/dataBus/actions';
import { getCheckedState } from 'core/controlsBus/selectors';
import Tree from './Tree';
import FlowEdges from './FlowEdge';
const mapStateToProps = (state, props) => {
const { codeCrumbsMinimize, codeCrumbsLineNumbers } = getCheckedState(state);
const namespacesList = getNamespacesList(state);
const { namespace } = props;
const namespaceProps = { namespace };
const { filesMap } = getSource(state, namespaceProps);
const { codecrumbsLayoutMap, ccAlightPoint } = getSourceLayout(state, { namespace });
const {
selectedCrumbedFlowKey: currentSelectedCrumbedFlowKey,
selectedCcFlowEdgeNodes
} = getCodeCrumbsUserChoice(state, {
namespace
});
return {
codecrumbsLayoutMap,
ccAlightPoint,
filesMap,
currentSelectedCrumbedFlowKey,
codeCrumbsLineNumbers,
namespacesList,
codeCrumbsMinimize,
selectedCcFlowEdgeNodes
};
};
const mapDispatchToProps = (dispatch, props) => {
const { namespace } = props;
return {
onCodeCrumbSelect: (event, options) => {
return event.metaKey || event.altKey
? dispatch(
selectNodeToOpenInEditor(
{ path: options.fileNode.path, line: options.codeCrumb.crumbNodeLines[0] },
namespace
)
)
: dispatch(selectCodeCrumb(options, namespace));
},
onFlowEdgeClick: (source, target, ccNamespacesKeys) => {
dispatch(selectCcFlowEdge({ source, target }, source.namespace));
// case with external edge
if (source.namespace !== target.namespace) {
dispatch(selectCcFlowEdge({ source, target }, target.namespace));
}
ccNamespacesKeys.forEach(ns => {
if (ns !== source.namespace && ns !== target.namespace) {
dispatch(selectCcFlowEdge(undefined, ns));
}
});
}
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(props => {
return (
<React.Fragment>
<FlowEdges {...props} />
<Tree {...props} />
</React.Fragment>
);
});