From e00650891d6390ad79fba75e1aec8c4e83c58fa0 Mon Sep 17 00:00:00 2001 From: profjellybean Date: Fri, 23 Dec 2022 13:29:24 +0100 Subject: [PATCH] #59: Made list of changings in config, fixed bug with tree Bug: Filetree creation was false --- .../file-tree-comparison/chart/chart.js | 4 +- .../file-tree-comparison/chart/index.js | 12 +++-- .../file-tree-comparison/components/tree.css | 2 - .../file-tree-comparison/components/tree.js | 3 +- .../legacy/file-tree-comparison/config.css | 19 +++++++ .../legacy/file-tree-comparison/config.js | 54 +++++++++++++++---- .../file-tree-comparison/reducers/config.js | 17 ++++++ .../file-tree-comparison/reducers/data.js | 5 ++ .../file-tree-comparison/sagas/index.js | 17 +++--- 9 files changed, 105 insertions(+), 28 deletions(-) diff --git a/ui/src/visualizations/legacy/file-tree-comparison/chart/chart.js b/ui/src/visualizations/legacy/file-tree-comparison/chart/chart.js index 17ab9c73..477a2ad1 100644 --- a/ui/src/visualizations/legacy/file-tree-comparison/chart/chart.js +++ b/ui/src/visualizations/legacy/file-tree-comparison/chart/chart.js @@ -147,6 +147,7 @@ export default class Changes extends React.Component { }); const changed = { add: additions, edit: edited, delete: deletions }; this.setState({ tree1: tree1H, tree2: tree2H, changed: changed }); + this.props.onSetChanged(changed); } } function getEdits(fromSha, toSha, commits) { @@ -178,10 +179,9 @@ function getTreeCommitspan(toSha, commits) { } const fileTree = []; const commitRadius = commits.slice(0, commits.findIndex((e) => e.sha === toSha) + 1); - commitRadius.forEach((commit) => { commit.files.data.forEach((f) => { - if (f.stats.additions === f.lineCount) { + if (f.stats.additions > f.stats.deletions) { if (!fileTree.includes(f.file.path)) { fileTree.push(f.file.path); } diff --git a/ui/src/visualizations/legacy/file-tree-comparison/chart/index.js b/ui/src/visualizations/legacy/file-tree-comparison/chart/index.js index b645df25..e64e7dde 100644 --- a/ui/src/visualizations/legacy/file-tree-comparison/chart/index.js +++ b/ui/src/visualizations/legacy/file-tree-comparison/chart/index.js @@ -2,6 +2,7 @@ import { connect } from 'react-redux'; import Chart from './chart.js'; +import { setCommit1, setCommit2, setTree1, setTree2, setChanged } from '/ui/src/visualizations/legacy/file-tree-comparison/sagas'; const mapStateToProps = (state /*, ownProps*/) => { const corState = state.visualizations.fileTreeComparison.state; @@ -14,9 +15,12 @@ const mapStateToProps = (state /*, ownProps*/) => { }; }; -const mapDispatchToProps = (dispatch) => { - return { - }; -}; +const mapDispatchToProps = (dispatch) => ({ + onSetCommit1: (commit) => dispatch(setCommit1(commit)), + onSetCommit2: (commit) => dispatch(setCommit2(commit)), + onSetTree1: (tree) => dispatch(setTree1(tree)), + onSetTree2: (tree) => dispatch(setTree2(tree)), + onSetChanged: (changes) => dispatch(setChanged(changes)), +}); export default connect(mapStateToProps, mapDispatchToProps)(Chart); diff --git a/ui/src/visualizations/legacy/file-tree-comparison/components/tree.css b/ui/src/visualizations/legacy/file-tree-comparison/components/tree.css index 85758d85..a0fd3811 100644 --- a/ui/src/visualizations/legacy/file-tree-comparison/components/tree.css +++ b/ui/src/visualizations/legacy/file-tree-comparison/components/tree.css @@ -17,13 +17,11 @@ } li:not(:last-child) { - margin-bottom: 5px; margin-left: 5px; width: fit-content; padding: 2px; } li:last-child { - margin-bottom: 5px; margin-left: 5px; width: fit-content; padding: 2px; diff --git a/ui/src/visualizations/legacy/file-tree-comparison/components/tree.js b/ui/src/visualizations/legacy/file-tree-comparison/components/tree.js index 7b7f4085..85206fcb 100644 --- a/ui/src/visualizations/legacy/file-tree-comparison/components/tree.js +++ b/ui/src/visualizations/legacy/file-tree-comparison/components/tree.js @@ -10,6 +10,7 @@ export default class Tree extends React.PureComponent { } componentWillReceiveProps(nextProps, nextContext) { + console.log(nextProps); this.setState({ tree: nextProps.files, }); @@ -50,7 +51,7 @@ class TreeNode extends React.PureComponent { if (x.mark === 'Addition' || x.mark === 'Deletion' || x.mark === 'Edit') { return (
-