Skip to content

Commit 9578b2f

Browse files
Fix m statte
1 parent 873c435 commit 9578b2f

9 files changed

Lines changed: 218 additions & 68 deletions

File tree

src/public/dist/bundle.js

Lines changed: 96 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85805,6 +85805,7 @@ var CONTROLS_KEYS = exports.CONTROLS_KEYS = {
8580585805
SOURCE_EXPAND_ALL: 'sourceExpandAll',
8580685806
DEPENDENCIES: 'dependencies',
8580785807
DEPENDENCIES_SHOW_ALL: 'dependenciesShowAll',
85808+
DEPENDENCIES_SHOW_ONE_MODULE: 'dependenciesShowOneModule',
8580885809
CODE_CRUMBS: 'codeCrumbs',
8580985810
CODE_CRUMBS_MINIMIZE: 'codeCrumbsMinimize',
8581085811
CODE_CRUMBS_DETAILS: 'codeCrumbsDetails'
@@ -85861,6 +85862,10 @@ var DefaultState = {
8586185862
title: 'Show All dependencies',
8586285863
key: _constants.CONTROLS_KEYS.DEPENDENCIES_SHOW_ALL,
8586385864
type: _constants.VIEW_TYPES.BUTTON
85865+
}, {
85866+
name: 'M',
85867+
title: 'Show One module dependencies',
85868+
key: _constants.CONTROLS_KEYS.DEPENDENCIES_SHOW_ONE_MODULE
8586485869
}]
8586585870
}, {
8586685871
name: 'CodeCrumbs',
@@ -86182,6 +86187,7 @@ exports.default = function () {
8618286187
switch (action.type) {
8618386188
case _constants2.ACTIONS.SET_INITIAL_SOURCE_DATA:
8618486189
return _extends({}, state, action.payload, {
86190+
dependenciesRootEntryPoint: action.payload.dependenciesList[0],
8618586191
firstLevelFolders: (0, _get2.default)(action.payload, 'filesTree.children', []).filter(function (item) {
8618686192
return item.type === _constants.DIR_NODE_TYPE;
8618786193
}).reduce(function (res, item) {
@@ -86512,6 +86518,7 @@ var mapStateToProps = function mapStateToProps(state) {
8651286518
return {
8651386519
sourceDiagramOn: checkedState.source,
8651486520
dependenciesDiagramOn: checkedState.dependencies,
86521+
dependenciesShowOneModule: checkedState.dependenciesShowOneModule,
8651586522
codeCrumbsDiagramOn: checkedState.codeCrumbs,
8651686523
codeCrumbsMinimize: checkedState.codeCrumbsMinimize,
8651786524
codeCrumbsDetails: checkedState.codeCrumbsDetails,
@@ -86935,29 +86942,66 @@ var DependenciesTree = function (_React$Component) {
8693586942
//move to utils
8693686943

8693786944
}, {
86938-
key: 'drawTree',
86939-
value: function drawTree() {
86940-
var _this2 = this;
86941-
86945+
key: 'getFilteredDependenciesList',
86946+
value: function getFilteredDependenciesList() {
8694286947
var _props = this.props,
86943-
primaryDraw = _props.primaryDraw,
86944-
filesTreeLayoutNodes = _props.filesTreeLayoutNodes,
8694586948
dependenciesList = _props.dependenciesList,
8694686949
dependenciesEntryPoint = _props.dependenciesEntryPoint,
86947-
shiftToCenterPoint = _props.shiftToCenterPoint,
86948-
sourceDiagramOn = _props.sourceDiagramOn;
86950+
dependenciesShowOneModule = _props.dependenciesShowOneModule;
8694986951

8695086952

86951-
var moduleFilesList = (0, _treeLayout.getFilesList)(filesTreeLayoutNodes);
86952-
var filteredList = !dependenciesEntryPoint ? dependenciesList : dependenciesList.filter(function (d) {
86953-
return d.moduleName === dependenciesEntryPoint.path;
86953+
var entryPoint = dependenciesEntryPoint || {
86954+
path: dependenciesList[0].moduleName
86955+
};
86956+
86957+
if (dependenciesShowOneModule) {
86958+
var entryModule = dependenciesList.find(function (d) {
86959+
return d.moduleName === entryPoint.path;
86960+
});
86961+
return [entryModule];
86962+
}
86963+
86964+
var dependenciesStore = [];
86965+
this.collectDependencies(entryPoint.path, dependenciesList, dependenciesStore);
86966+
return dependenciesStore;
86967+
}
86968+
}, {
86969+
key: 'collectDependencies',
86970+
value: function collectDependencies(entryModuleName, dependenciesList) {
86971+
var _this2 = this;
86972+
86973+
var store = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
86974+
86975+
var entryModule = dependenciesList.find(function (d) {
86976+
return d.moduleName === entryModuleName;
86977+
});
86978+
86979+
store.push(entryModule);
86980+
86981+
entryModule.importedModuleNames.forEach(function (name) {
86982+
return _this2.collectDependencies(name, dependenciesList, store);
8695486983
});
86984+
}
86985+
}, {
86986+
key: 'drawTree',
86987+
value: function drawTree() {
86988+
var _this3 = this;
86989+
86990+
var _props2 = this.props,
86991+
primaryDraw = _props2.primaryDraw,
86992+
filesTreeLayoutNodes = _props2.filesTreeLayoutNodes,
86993+
shiftToCenterPoint = _props2.shiftToCenterPoint,
86994+
sourceDiagramOn = _props2.sourceDiagramOn;
86995+
86996+
86997+
var moduleFilesList = (0, _treeLayout.getFilesList)(filesTreeLayoutNodes);
86998+
var filteredDependenciesList = this.getFilteredDependenciesList();
8695586999

86956-
filteredList.forEach(function (_ref2) {
87000+
filteredDependenciesList.forEach(function (_ref2) {
8695787001
var moduleName = _ref2.moduleName,
8695887002
importedModuleNames = _ref2.importedModuleNames;
8695987003

86960-
var moduleNode = _this2.findNodeByPathName(moduleFilesList, moduleName);
87004+
var moduleNode = _this3.findNodeByPathName(moduleFilesList, moduleName);
8696187005

8696287006
if (!moduleNode) return;
8696387007

@@ -86972,11 +87016,14 @@ var DependenciesTree = function (_React$Component) {
8697287016
y: mY,
8697387017
name: moduleNode.data.name
8697487018
});
86975-
(0, _drawHelpers2.drawFileIcon)(primaryDraw, shiftToCenterPoint, { x: mX, y: mY });
87019+
(0, _drawHelpers2.drawFileIcon)(primaryDraw, shiftToCenterPoint, {
87020+
x: mX,
87021+
y: mY
87022+
});
8697687023
}
8697787024

8697887025
importedModuleNames.reduce(function (prevSource, name) {
86979-
var importedNode = _this2.findNodeByPathName(moduleFilesList, name);
87026+
var importedNode = _this3.findNodeByPathName(moduleFilesList, name);
8698087027

8698187028
if (!importedNode) return;
8698287029

@@ -87602,6 +87649,7 @@ var TreeDiagram = function (_React$Component) {
8760287649
dependenciesEntryPoint = _props.dependenciesEntryPoint,
8760387650
sourceDiagramOn = _props.sourceDiagramOn,
8760487651
dependenciesDiagramOn = _props.dependenciesDiagramOn,
87652+
dependenciesShowOneModule = _props.dependenciesShowOneModule,
8760587653
codeCrumbsDiagramOn = _props.codeCrumbsDiagramOn,
8760687654
codeCrumbsMinimize = _props.codeCrumbsMinimize,
8760787655
codeCrumbsDetails = _props.codeCrumbsDetails,
@@ -87635,6 +87683,7 @@ var TreeDiagram = function (_React$Component) {
8763587683
dependenciesList: dependenciesList,
8763687684
filesTreeLayoutNodes: filesTreeLayoutNodes,
8763787685
dependenciesEntryPoint: dependenciesEntryPoint,
87686+
dependenciesShowOneModule: dependenciesShowOneModule,
8763887687
primaryLayer: this.dependenciesEdgesLayer
8763987688
}, sharedProps)),
8764087689
filesTreeLayoutNodes && codeCrumbsDiagramOn && _react2.default.createElement(_CodeCrumbsTree2.default, _extends({
@@ -88068,7 +88117,7 @@ function reactOnButtonAction(action) {
8806888117
}
8806988118

8807088119
_context2.next = 12;
88071-
return (0, _effects.put)((0, _actions.setDependenciesEntryPoint)(null));
88120+
return (0, _effects.all)([(0, _effects.put)((0, _actions2.toggleSwitch)(_constants2.CONTROLS_KEYS.DEPENDENCIES_SHOW_ONE_MODULE)), (0, _effects.put)((0, _actions.setDependenciesEntryPoint)(null))]);
8807288121

8807388122
case 12:
8807488123
return _context2.abrupt('return', _context2.sent);
@@ -88115,14 +88164,42 @@ function reactOnToggledFolder(action) {
8811588164
}
8811688165

8811788166
function reactDependenciesEntryPointChange(action) {
88167+
var dependenciesRootEntryPoint, dependenciesShowOneModule, isRootPoint;
8811888168
return regeneratorRuntime.wrap(function reactDependenciesEntryPointChange$(_context4) {
8811988169
while (1) {
8812088170
switch (_context4.prev = _context4.next) {
8812188171
case 0:
88122-
_context4.next = 2;
88123-
return (0, _effects.put)((0, _actions2.setHiddenControl)(_constants2.CONTROLS_KEYS.DEPENDENCIES_SHOW_ALL, !action.payload));
88172+
if (action.payload) {
88173+
_context4.next = 4;
88174+
break;
88175+
}
8812488176

88125-
case 2:
88177+
_context4.next = 3;
88178+
return (0, _effects.put)((0, _actions2.setHiddenControl)(_constants2.CONTROLS_KEYS.DEPENDENCIES_SHOW_ALL, true));
88179+
88180+
case 3:
88181+
return _context4.abrupt('return', _context4.sent);
88182+
88183+
case 4:
88184+
_context4.next = 6;
88185+
return (0, _effects.select)(function (state) {
88186+
return state.dataBus.dependenciesRootEntryPoint;
88187+
});
88188+
88189+
case 6:
88190+
dependenciesRootEntryPoint = _context4.sent;
88191+
_context4.next = 9;
88192+
return (0, _effects.select)(function (state) {
88193+
return state.viewSwitches.checkedState.dependenciesShowOneModule;
88194+
});
88195+
88196+
case 9:
88197+
dependenciesShowOneModule = _context4.sent;
88198+
isRootPoint = action.payload.path === dependenciesRootEntryPoint.moduleName;
88199+
_context4.next = 13;
88200+
return (0, _effects.put)((0, _actions2.setHiddenControl)(_constants2.CONTROLS_KEYS.DEPENDENCIES_SHOW_ALL, isRootPoint && !dependenciesShowOneModule));
88201+
88202+
case 13:
8812688203
case 'end':
8812788204
return _context4.stop();
8812888205
}

src/public/dist/bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/public/js/components/controls/ViewSwitches/store/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const CONTROLS_KEYS = {
1010
SOURCE_EXPAND_ALL: 'sourceExpandAll',
1111
DEPENDENCIES: 'dependencies',
1212
DEPENDENCIES_SHOW_ALL: 'dependenciesShowAll',
13+
DEPENDENCIES_SHOW_ONE_MODULE: 'dependenciesShowOneModule',
1314
CODE_CRUMBS: 'codeCrumbs',
1415
CODE_CRUMBS_MINIMIZE: 'codeCrumbsMinimize',
1516
CODE_CRUMBS_DETAILS: 'codeCrumbsDetails'

src/public/js/components/controls/ViewSwitches/store/reducer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ const DefaultState = {
2929
title: 'Show All dependencies',
3030
key: CONTROLS_KEYS.DEPENDENCIES_SHOW_ALL,
3131
type: VIEW_TYPES.BUTTON
32+
},
33+
{
34+
name: 'M',
35+
title: 'Show One module dependencies',
36+
key: CONTROLS_KEYS.DEPENDENCIES_SHOW_ONE_MODULE
3237
}
3338
]
3439
},

src/public/js/components/data-bus/store/reducer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default (state = DefaultState, action) => {
1818
return {
1919
...state,
2020
...action.payload,
21+
dependenciesRootEntryPoint: action.payload.dependenciesList[0],
2122
firstLevelFolders: safeGet(
2223
action.payload,
2324
'filesTree.children',

src/public/js/components/tree-diagram/TreeDiagramContainer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const mapStateToProps = state => {
1919
return {
2020
sourceDiagramOn: checkedState.source,
2121
dependenciesDiagramOn: checkedState.dependencies,
22+
dependenciesShowOneModule: checkedState.dependenciesShowOneModule,
2223
codeCrumbsDiagramOn: checkedState.codeCrumbs,
2324
codeCrumbsMinimize: checkedState.codeCrumbsMinimize,
2425
codeCrumbsDetails: checkedState.codeCrumbsDetails,

src/public/js/components/tree-diagram/component/DependenciesTree/DependenciesTree.js

Lines changed: 83 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,65 +20,103 @@ class DependenciesTree extends React.Component {
2020
return list.find(l => l.data.path === pathName);
2121
};
2222

23+
getFilteredDependenciesList() {
24+
const {
25+
dependenciesList,
26+
dependenciesEntryPoint,
27+
dependenciesShowOneModule
28+
} = this.props;
29+
30+
const entryPoint = dependenciesEntryPoint || {
31+
path: dependenciesList[0].moduleName
32+
};
33+
34+
if (dependenciesShowOneModule) {
35+
const entryModule = dependenciesList.find(
36+
d => d.moduleName === entryPoint.path
37+
);
38+
return [entryModule];
39+
}
40+
41+
const dependenciesStore = [];
42+
this.collectDependencies(
43+
entryPoint.path,
44+
dependenciesList,
45+
dependenciesStore
46+
);
47+
return dependenciesStore;
48+
}
49+
50+
collectDependencies(entryModuleName, dependenciesList, store = []) {
51+
const entryModule = dependenciesList.find(
52+
d => d.moduleName === entryModuleName
53+
);
54+
55+
store.push(entryModule);
56+
57+
entryModule.importedModuleNames.forEach(name =>
58+
this.collectDependencies(name, dependenciesList, store)
59+
);
60+
}
61+
2362
drawTree() {
2463
const {
2564
primaryDraw,
2665
filesTreeLayoutNodes,
27-
dependenciesList,
28-
dependenciesEntryPoint,
2966
shiftToCenterPoint,
3067
sourceDiagramOn
3168
} = this.props;
3269

3370
const moduleFilesList = getFilesList(filesTreeLayoutNodes);
34-
let filteredList = !dependenciesEntryPoint
35-
? dependenciesList
36-
: dependenciesList.filter(
37-
d => d.moduleName === dependenciesEntryPoint.path
38-
);
39-
40-
filteredList.forEach(({ moduleName, importedModuleNames }) => {
41-
const moduleNode = this.findNodeByPathName(
42-
moduleFilesList,
43-
moduleName
44-
);
71+
const filteredDependenciesList = this.getFilteredDependenciesList();
4572

46-
if (!moduleNode) return;
73+
filteredDependenciesList.forEach(
74+
({ moduleName, importedModuleNames }) => {
75+
const moduleNode = this.findNodeByPathName(
76+
moduleFilesList,
77+
moduleName
78+
);
4779

48-
const [mX, mY] = [moduleNode.y, moduleNode.x];
80+
if (!moduleNode) return;
4981

50-
if (!sourceDiagramOn) {
51-
drawFileText(primaryDraw, shiftToCenterPoint, {
52-
x: mX,
53-
y: mY,
54-
name: moduleNode.data.name
55-
});
56-
drawFileIcon(primaryDraw, shiftToCenterPoint, { x: mX, y: mY });
57-
}
82+
const [mX, mY] = [moduleNode.y, moduleNode.x];
5883

59-
importedModuleNames.reduce((prevSource, name) => {
60-
const importedNode = this.findNodeByPathName(
61-
moduleFilesList,
62-
name
63-
);
84+
if (!sourceDiagramOn) {
85+
drawFileText(primaryDraw, shiftToCenterPoint, {
86+
x: mX,
87+
y: mY,
88+
name: moduleNode.data.name
89+
});
90+
drawFileIcon(primaryDraw, shiftToCenterPoint, {
91+
x: mX,
92+
y: mY
93+
});
94+
}
95+
96+
importedModuleNames.reduce((prevSource, name) => {
97+
const importedNode = this.findNodeByPathName(
98+
moduleFilesList,
99+
name
100+
);
64101

65-
if (!importedNode) return;
66-
67-
const [iX, iY] = [importedNode.y, importedNode.x];
68-
//TODO: implementation iterations:
69-
//1) done: first with sharp angles + overlay
70-
//2) done: without overlaying, not fot all cases
71-
//3) rounded angles
72-
const source = { x: iX, y: iY };
73-
drawDependenciesEdge(primaryDraw, shiftToCenterPoint, {
74-
source,
75-
target: { x: mX, y: mY },
76-
prevSource
77-
});
78-
79-
return source;
80-
}, null);
81-
});
102+
if (!importedNode) return;
103+
104+
const [iX, iY] = [importedNode.y, importedNode.x];
105+
//TODO: implementation iterations:
106+
//1) done: first with sharp angles + overlay
107+
//2) done: without overlaying, not fot all cases
108+
//3) rounded angles
109+
const source = { x: iX, y: iY };
110+
drawDependenciesEdge(primaryDraw, shiftToCenterPoint, {
111+
source,
112+
target: { x: mX, y: mY },
113+
prevSource
114+
});
115+
116+
return source;
117+
}, null);
118+
}
119+
);
82120
}
83121

84122
render() {

0 commit comments

Comments
 (0)