From 9214a645c7468b73d26ea5d8894613307980925d Mon Sep 17 00:00:00 2001 From: Miriam Date: Thu, 24 Feb 2022 11:47:19 +0100 Subject: [PATCH] #35 Add new Filter for Branch \n\n Add Filter sort by Branch and show Branch Information in the Box --- .../File-Evolution/chart/chart.js | 127 ++++++++++++++---- .../File-Evolution/chart/index.js | 4 +- .../visualizations/File-Evolution/config.js | 39 ++++-- .../File-Evolution/reducers/config.js | 12 +- .../File-Evolution/sagas/index.js | 2 + .../visualizations/File-Evolution/styles.scss | 4 +- 6 files changed, 145 insertions(+), 43 deletions(-) diff --git a/ui/src/visualizations/File-Evolution/chart/chart.js b/ui/src/visualizations/File-Evolution/chart/chart.js index e3fbbc71..1d1bbaae 100644 --- a/ui/src/visualizations/File-Evolution/chart/chart.js +++ b/ui/src/visualizations/File-Evolution/chart/chart.js @@ -18,7 +18,8 @@ export default class FileEvolution extends React.Component { const space = 50; const commitBoxes = this.getCommitsDraw(space); //const svgHeight = (commitRects.length / 2 + 1) * this.props.commitBoxHeight + (commitRects.length / 2) * space; - const svgHeight = this.props.commitBoxHeight + space; + // const svgHeight = this.props.commitBoxHeight + space; + const svgHeight = (this.props.commitBoxHeight + space) * 25; //TODO anzahl branch const svgWidth = (commitBoxes.length / 2 + 1) * this.props.commitBoxHeight + commitBoxes.length / 2 * space; return (
@@ -64,6 +65,8 @@ export default class FileEvolution extends React.Component { commitInfo.push(

+ Commit +
{commit.messageHeader}

); @@ -71,44 +74,66 @@ export default class FileEvolution extends React.Component { if (props.showCommitMessage) { commitInfo.push( - Message: {commit.message} + Message: {commit.message} ); + commitInfo.push(
); } if (props.showCommitSha === 'short') { commitInfo.push( - Short SHA: {commit.shortSha} + Short SHA: {commit.shortSha} ); + commitInfo.push(
); } else if (props.showCommitSha === 'all') { - commitInfo.push(SHA: {commit.sha}); + commitInfo.push( + + SHA: {commit.sha} + + ); + commitInfo.push(
); } if (props.showCommitDate) { commitInfo.push( - Date: {commit.date} + Date: {commit.date} ); + commitInfo.push(
); } if (props.showCommitAuthor) { commitInfo.push( - Author: {commit.signature} + Author: {commit.signature} ); + commitInfo.push(
); + } + if (props.showCommitBranch) { + commitInfo.push( + + Branch: {getBranch(props, commit)} + + ); + commitInfo.push(
); } if (props.showCommitWeblink) { commitInfo.push( - URL: {commit.webUrl} + URL: {commit.webUrl} ); + commitInfo.push(
); } if (props.showCommitFiles) { - commitInfo.push(Files:); + commitInfo.push( + + Files: + + ); commitInfo.push(
); const files = props.commitFiles[commit.sha]; for (const f in files) { @@ -156,37 +181,85 @@ export default class FileEvolution extends React.Component { arrow.push(); return arrow; } + function getBranchCommitPosition(props, space, y, x, height) { + let newY = y; + const pos = {}; + for (const b in props.branches) { + const branchName = props.branches[b].branch; + // console.log(this.props.selectedBranches.indexOf(branchName)); + // if (this.props.selectedBranches.indexOf(branchName) > -1) { + const xy = {}; + xy['x'] = x; + xy['y'] = newY; + pos[branchName] = xy; + newY = newY + space + height; + //} + } + console.log(pos); + return pos; + } const commitData = this.props.commits; const width = this.props.commitBoxWidth; const height = this.props.commitBoxHeight; const commitRects = []; let x = 20; - const y = 20; + let y = space; + const commitBoxPosition = getBranchCommitPosition(this.props, space, y, x, height); + console.log(commitBoxPosition); for (const i in commitData) { const commit = commitData[i]; + if (this.props.selectedAuthors.indexOf(commit.signature) > -1) { if (this.props.selectedBranches.indexOf(getBranch(this.props, commit)) > -1) { - const color = getBoxColor(this.props, commit); - commitRects.push( - - - - {getCommitInfo(this.props, commit)} - - - ); + if (this.props.commitBoxSort === 'date') { + const color = getBoxColor(this.props, commit); + commitRects.push( + + + + {getCommitInfo(this.props, commit)} + + + ); - commitRects.push( - - {getArrow(x, y, height, width)} - - ); + commitRects.push( + + {getArrow(x, y, height, width)} + + ); - x = x + width + space; - //y = y + height + space; //TODO auskommentieren - } - } + x = x + width + space; + //y = y + height + space; //TODO auskommentieren + } else if (this.props.commitBoxSort === 'branch') { + if (commitBoxPosition[getBranch(this.props, commit)] !== undefined) { + console.log(getBranch(this.props, commit)); + console.log(commitBoxPosition[getBranch(this.props, commit)]['x']); + console.log(commitBoxPosition[getBranch(this.props, commit)]['y']); + x = commitBoxPosition[getBranch(this.props, commit)]['x']; + y = commitBoxPosition[getBranch(this.props, commit)]['y']; + + commitRects.push( + + + + {getCommitInfo(this.props, commit)} + + + ); + + commitRects.push( + + {getArrow(x, y, height, width)} + + ); + + commitBoxPosition[getBranch(this.props, commit)]['x'] = x + width + space; + //y = y + height + space; //TODO auskommentieren + } + } //sortbranch + } //selected Branches + } //selected Authors } commitRects.pop(); //remove last arrow return commitRects; diff --git a/ui/src/visualizations/File-Evolution/chart/index.js b/ui/src/visualizations/File-Evolution/chart/index.js index 495d16d7..ae5fbb10 100644 --- a/ui/src/visualizations/File-Evolution/chart/index.js +++ b/ui/src/visualizations/File-Evolution/chart/index.js @@ -20,12 +20,14 @@ const mapStateToProps = (state /*, ownProps*/) => { commitBoxHeight: FileEvolutionState.config.commitBoxHeight, commitBoxWidth: FileEvolutionState.config.commitBoxWidth, commitBoxColor: FileEvolutionState.config.commitBoxColor, + commitBoxSort: FileEvolutionState.config.commitBoxSort, showCommitDate: FileEvolutionState.config.showCommitDate, showCommitAuthor: FileEvolutionState.config.showCommitAuthor, showCommitMessage: FileEvolutionState.config.showCommitMessage, showCommitWeblink: FileEvolutionState.config.showCommitWeblink, showCommitSha: FileEvolutionState.config.showCommitSha, - showCommitFiles: FileEvolutionState.config.showCommitFiles + showCommitFiles: FileEvolutionState.config.showCommitFiles, + showCommitBranch: FileEvolutionState.config.showCommitBranch }; }; diff --git a/ui/src/visualizations/File-Evolution/config.js b/ui/src/visualizations/File-Evolution/config.js index 14c3dd8a..cacde8e7 100644 --- a/ui/src/visualizations/File-Evolution/config.js +++ b/ui/src/visualizations/File-Evolution/config.js @@ -13,7 +13,10 @@ import { setShowCommitMessage, setShowCommitAuthor, setShowCommitFiles, - setShowCommitSha, setShowCommitWeblink + setShowCommitSha, + setShowCommitWeblink, + setCommitBoxSort, + setShowCommitBranch } from './sagas'; import React from 'react'; @@ -21,9 +24,7 @@ import CheckboxLegend from '../../components/CheckboxLegend'; import TabCombo from '../../components/TabCombo'; const mapStateToProps = (state /*, ownProps*/) => { - //console.log(state); const FileEvolutionState = state.visualizations.fileEvolution.state; - console.log(FileEvolutionState); return { branches: FileEvolutionState.data.data.branches, committers: FileEvolutionState.data.data.committers, @@ -39,7 +40,8 @@ const mapStateToProps = (state /*, ownProps*/) => { showCommitAuthor: FileEvolutionState.config.showCommitAuthor, showCommitMessage: FileEvolutionState.config.showCommitMessage, showCommitSha: FileEvolutionState.config.showCommitSha, - showCommitFiles: FileEvolutionState.config.showCommitFiles + showCommitFiles: FileEvolutionState.config.showCommitFiles, + showCommitBranch: FileEvolutionState.config.showCommitBranch }; }; @@ -54,8 +56,10 @@ const mapDispatchToProps = (dispatch /*, ownProps*/) => { onClickShowCommitBoxFiles: showCommitFiles => dispatch(setShowCommitFiles(showCommitFiles)), onClickShowCommitBoxMessage: showCommitMessage => dispatch(setShowCommitMessage(showCommitMessage)), onClickShowCommitBoxWeblink: showCommitWeblink => dispatch(setShowCommitWeblink(showCommitWeblink)), + onClickShowCommitBoxBranch: showCommitBranch => dispatch(setShowCommitBranch(showCommitBranch)), onSetShowCommitSha: showCommitSha => dispatch(setShowCommitSha(showCommitSha)), - onClickCommitBoxColor: commitBoxColor => dispatch(setCommitBoxColor(commitBoxColor)) + onClickCommitBoxColor: commitBoxColor => dispatch(setCommitBoxColor(commitBoxColor)), + onClickCommitBoxSortBy: commitBoxSort => dispatch(setCommitBoxSort(commitBoxSort)) }; }; @@ -96,7 +100,6 @@ const FileEvolutionConfigComponent = props => { />
- { ]} onChange={value => props.onClickCommitBoxColor(value)} /> + + props.onClickCommitBoxSortBy(value)} + />
@@ -117,7 +126,7 @@ const FileEvolutionConfigComponent = props => { />{' '} Show Author{' '} -
+
-
+
+ +
-
+
-
+