Skip to content

Commit

Permalink
#59: Began writing search function, search box in config, made action…
Browse files Browse the repository at this point in the history
… set_filter
  • Loading branch information
profjellybean committed Jan 6, 2023
1 parent e006508 commit 44b4a3c
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 19 deletions.
20 changes: 19 additions & 1 deletion ui/src/visualizations/legacy/file-tree-comparison/chart/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,22 @@ export default class Changes extends React.Component {
componentWillReceiveProps(nextProps) {
if (nextProps.commits.length !== 0) {
const commits = this.buildingSelect(nextProps.commits, null);
this.setState({ commits: nextProps.commits, commitsToChoose1: commits, commitsToChoose2: commits });
this.setState({ commits: nextProps.commits, commitsToChoose1: commits, commitsToChoose2: commits, filter: nextProps.filter });
if (this.state.tree2.length !== 0 && this.state.tree1.length !== 0) {
this.filterTrees(nextProps.filter);
}
}
}

filterTrees(f) {
if (f === '' || f === null) {
return;
}
let t1 = this.state.tree1;
let t2 = this.state.tree2;

console.log(t1);
}
compareTrees(c1, c2) {
console.log('compareTrees');
const tree1 = getTreeCommitspan(c1.sha, this.state.commits);
Expand Down Expand Up @@ -212,6 +225,11 @@ function markChild(tree, path, mode) {
}
return tree;
}

function filterTree(tree, filter) {

return tree;
}
function makeHierarchyFileTree(fileTree) {
if (fileTree === null || fileTree === undefined) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +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';
import { setFilter, setChanged } from '/ui/src/visualizations/legacy/file-tree-comparison/sagas';

const mapStateToProps = (state /*, ownProps*/) => {
const corState = state.visualizations.fileTreeComparison.state;
Expand All @@ -12,14 +12,12 @@ const mapStateToProps = (state /*, ownProps*/) => {
commit2: corState.config.commit2,
tree1: corState.config.tree1,
tree2: corState.config.tree2,
filter: corState.config.filter,
};
};

const mapDispatchToProps = (dispatch) => ({
onSetCommit1: (commit) => dispatch(setCommit1(commit)),
onSetCommit2: (commit) => dispatch(setCommit2(commit)),
onSetTree1: (tree) => dispatch(setTree1(tree)),
onSetTree2: (tree) => dispatch(setTree2(tree)),
onSetFilter: (f) => dispatch(setFilter(f)),
onSetChanged: (changes) => dispatch(setChanged(changes)),
});

Expand Down
25 changes: 18 additions & 7 deletions ui/src/visualizations/legacy/file-tree-comparison/config.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,25 @@
align-content: center;
display: flex;
flex-flow: wrap;
margin-bottom: auto;
}
.search {
padding-top: 1em;
}
.files{
font-size: smaller;
overflow-y: auto;
max-height: 30em;
overflow-x: auto;
}
.info {
align-self: flex-end;
max-width: 400px;
height: 40em;
display: flex;
flex-direction: row;
flex-flow: wrap;
justify-content: space-between;
align-content: space-between;
}
hr {
flex-basis: 100%;
Expand Down Expand Up @@ -38,12 +53,7 @@ hr {
width: 25px;
margin-right: 10px;
}
.files{
font-size: smaller;
overflow-y: auto;
max-height: 25em;
overflow-x: auto;
}

.listStyle {
list-style-type: disc;
margin-left: 15px;
Expand All @@ -53,3 +63,4 @@ hr {
word-wrap: break-word;
width: auto !important;
}

37 changes: 31 additions & 6 deletions ui/src/visualizations/legacy/file-tree-comparison/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,37 @@

import { connect } from 'react-redux';
import style from './config.css';
import { setFilter } from './sagas';
const mapStateToProps = (state /*, ownProps*/) => {
const fileTreeState = state.visualizations.fileTreeComparison.state;
return {
changed: fileTreeState.config.changed,
};
};

const mapDispatchToProps = (dispatch) => {};
const mapDispatchToProps = (dispatch, ownProps) => {
return Object.assign({
onSetFilter: (c) => dispatch(setFilter(c)),
},
ownProps
);
};

const ChangesConfigComponent = (props) => {
return (
<div className={style.info}>
<div className={style.search}>
<input
placeholder="Highlight issue..."
onChange={(e) => {
if (e.target.value === null) {
props.onSetFilter('');
} else {
props.onSetFilter(e.target.value);
}
}}
/>
</div>
<div className={style.files}>
<div hidden={props.changed.add.length === 0}>
<div>
Expand Down Expand Up @@ -53,11 +72,17 @@ const ChangesConfigComponent = (props) => {
</div>
</div>
<div className={style.legend}>
<hr />
<div className={style.add}></div><div className={style.flexGrow}> Additions</div><hr/>
<div className={style.delete}></div><div className={style.flexGrow}> Deletions</div><hr/>
<div className={style.edit}></div><div className={style.flexGrow}> Modifications</div><hr/>
</div>
<hr />
<div className={style.add}></div>
<div className={style.flexGrow}> Additions</div>
<hr />
<div className={style.delete}></div>
<div className={style.flexGrow}> Deletions</div>
<hr />
<div className={style.edit}></div>
<div className={style.flexGrow}> Modifications</div>
<hr />
</div>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export default handleActions(
_.assign({}, state, {
changed: action.payload ? action.payload : null,
}),
SET_FILTER: (state, action) =>
_.assign({}, state, {
filter: action.payload ? action.payload : null,
}),
},
{
commit1: [],
Expand All @@ -36,5 +40,6 @@ export default handleActions(
delete: [],
edit: [],
},
filter: '',
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const setCommit2 = createAction('SET_COMMIT_2', (f) => f);
export const setTree1 = createAction('SET_TREE_1', (f) => f);
export const setTree2 = createAction('SET_TREE_2', (f) => f);
export const setChanged = createAction('SET_CHANGED', (f) => f);
export const setFilter = createAction('SET_FILTER', (f) => f);

export default function* () {
// fetch data once on entry
Expand Down

0 comments on commit 44b4a3c

Please sign in to comment.