Skip to content

Commit

Permalink
#35 Show Headline for Branches \n\n show Headline and Info-Box if the…
Browse files Browse the repository at this point in the history
…re are no Commits in this Branch
  • Loading branch information
miriamgehbauer committed Feb 28, 2022
1 parent 9214a64 commit bc914c2
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 20 deletions.
94 changes: 77 additions & 17 deletions ui/src/visualizations/File-Evolution/chart/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class FileEvolution extends React.Component {
//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) * 25; //TODO anzahl branch
//console.log(this.props.branches.size())
const svgWidth = (commitBoxes.length / 2 + 1) * this.props.commitBoxHeight + commitBoxes.length / 2 * space;
return (
<div className={styles.chartContainer}>
Expand Down Expand Up @@ -181,6 +182,55 @@ export default class FileEvolution extends React.Component {
arrow.push(<polyline points={pointsForArrowHead} fill="none" stroke="black" />);
return arrow;
}

function getBranchNoCommitInfo(props, xStart, height, width, branchCommitPosition) {
const branchNoCommitInfo = [];
const xPosStart = 20;
for (const b in props.branches) {
const branchName = props.branches[b].branch;
const xPos = branchCommitPosition[branchName]['x'];
const yPos = branchCommitPosition[branchName]['y'];
if (xPos === xStart) {
branchNoCommitInfo.push(
<g width={width} height={height}>
<rect x={xPos} y={yPos} width={width} height={height} fill={props.branchesColorPalette[branchName]} />
<foreignObject x={xPos} y={yPos} width={width} height={height} class="branchInfo">
<h1>There are no Commits in this Branch or this Branch ist not selected</h1>
</foreignObject>
</g>
);
console.log(branchNoCommitInfo);
}
}
return branchNoCommitInfo;
}

function getBranchHeadline(props, space, yStart, xStart, height) {
const branchHeadline = [];
const namePrints = [];
const branchPos = getBranchCommitPosition(props, space, yStart, xStart, height);
const xPos = 20;
for (const b in props.branches) {
const branchName = props.branches[b].branch;
const yPos = commitBoxPosition[branchName]['y'] - space / 2;
const widthHeadline = 200;
const heightHeadline = space;
branchHeadline.push(
<g width={widthHeadline} height={heightHeadline}>
<foreignObject x={xPos} y={yPos} width={widthHeadline} height={heightHeadline} class="branchName">
<h1>
<b>
Branch: {branchName}
</b>
</h1>
</foreignObject>
</g>
);
console.log(branchHeadline);
}
return branchHeadline;
}

function getBranchCommitPosition(props, space, y, x, height) {
let newY = y;
const pos = {};
Expand All @@ -195,40 +245,44 @@ export default class FileEvolution extends React.Component {
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 xStart = 20;
let x = xStart;
let y = space;
const commitBoxPosition = getBranchCommitPosition(this.props, space, y, x, height);
console.log(commitBoxPosition);
if (this.props.commitBoxSort === 'branch') {
commitRects.push(getBranchHeadline(this.props, space, y, x, height));
}
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) {
if (this.props.commitBoxSort === 'date') {
const color = getBoxColor(this.props, commit);
if (x !== xStart) {
commitRects.push(
<g width={width} height={height}>
{getArrow(x - width - space, y, height, width)}
</g>
);
}
commitRects.push(
<g width={width} height={height}>
<rect x={x} y={y} width={width} height={height} fill={color} />
<foreignObject x={x} y={y} width={width} height={height}>
<foreignObject x={x} y={y} width={width} height={height} class="commitInfo">
{getCommitInfo(this.props, commit)}
</foreignObject>
</g>
);

commitRects.push(
<g width={width} height={height}>
{getArrow(x, y, height, width)}
</g>
);

x = x + width + space;
//y = y + height + space; //TODO auskommentieren
} else if (this.props.commitBoxSort === 'branch') {
Expand All @@ -239,29 +293,35 @@ export default class FileEvolution extends React.Component {
x = commitBoxPosition[getBranch(this.props, commit)]['x'];
y = commitBoxPosition[getBranch(this.props, commit)]['y'];

if (x !== xStart) {
commitRects.push(
<g width={width} height={height}>
{getArrow(x - width - space, y, height, width)}
</g>
);
}

commitRects.push(
<g width={width} height={height}>
<rect x={x} y={y} width={width} height={height} fill={getBoxColor(this.props, commit)} />
<foreignObject x={x} y={y} width={width} height={height}>
<foreignObject x={x} y={y} width={width} height={height} class="commitInfo">
{getCommitInfo(this.props, commit)}
</foreignObject>
</g>
);

commitRects.push(
<g width={width} height={height}>
{getArrow(x, y, height, width)}
</g>
);

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

if (this.props.commitBoxSort === 'branch') {
commitRects.push(getBranchNoCommitInfo(this.props, xStart, height, 500, commitBoxPosition));
}
//commitRects.pop(); //remove last arrow
return commitRects;
}
}
9 changes: 6 additions & 3 deletions ui/src/visualizations/File-Evolution/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const mapDispatchToProps = (dispatch /*, ownProps*/) => {
onClickShowCommitBoxBranch: showCommitBranch => dispatch(setShowCommitBranch(showCommitBranch)),
onSetShowCommitSha: showCommitSha => dispatch(setShowCommitSha(showCommitSha)),
onClickCommitBoxColor: commitBoxColor => dispatch(setCommitBoxColor(commitBoxColor)),
onClickCommitBoxSortBy: commitBoxSort => dispatch(setCommitBoxSort(commitBoxSort))
onClickCommitBoxSort: commitBoxSort => dispatch(setCommitBoxSort(commitBoxSort))
};
};

Expand Down Expand Up @@ -111,8 +111,11 @@ const FileEvolutionConfigComponent = props => {
<label className={styles.label}>Sort by</label>
<TabCombo
value={props.commitBoxSort}
options={[{ label: 'Date', icon: 'file-alt', value: 'date' }, { label: 'Branch', icon: 'cloud-upload-alt', value: 'branch' }]}
onChange={value => props.onClickCommitBoxSortBy(value)}
options={[
{ label: 'Date', icon: 'file-alt', value: 'date' },
{ label: 'Branch', icon: 'cloud-upload-alt', value: 'branch' }
]}
onChange={value => props.onClickCommitBoxSort(value)}
/>
</div>
<div className="control">
Expand Down
5 changes: 5 additions & 0 deletions ui/src/visualizations/File-Evolution/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@
foreignObject{
overflow: scroll;
}

.branchName{
overflow: hidden;
}

}

0 comments on commit bc914c2

Please sign in to comment.