Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
show chart for all milestones; radekstepan#67
Browse files Browse the repository at this point in the history
  • Loading branch information
radekstepan committed Mar 25, 2016
1 parent 34e75a3 commit c86affc
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 24 deletions.
74 changes: 62 additions & 12 deletions public/js/bundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public/js/bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/js/components/Chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default React.createClass({
displayName: 'Chart.jsx',

render() {
return <div id="chart" ref="el" />;
return <div id="chart" ref="el" style={this.props.style} />;
},

componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/pages/ChartPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default React.createClass({

render() {
let content;
if (!this.state.app.loading) {
if (!this.state.app.system.loading) {
let projects = this.state.projects;
// Find the milestone.
let milestone;
Expand Down
51 changes: 45 additions & 6 deletions src/js/components/pages/MilestonesPage.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import _ from 'lodash';

import Page from '../../lib/PageMixin.js';

Expand All @@ -16,13 +17,51 @@ export default React.createClass({

render() {
let content;
if (!this.state.app.loading) {
if (!this.state.app.system.loading) {
let projects = this.state.projects;
content = (
<div>
<Milestones projects={projects} project={this.props} />
</div>
);

// Create the all milestones payload.
let data;
_.find(projects.list, (obj) => {
if (obj.owner == this.props.owner && obj.name == this.props.name) {
if (obj.milestones) {
let created_at = 'Z',
due_on = '0',
issues = {
'closed': { 'list': [], 'size': 0 },
'open': { 'list': [], 'size': 0 }
};
// Merge all the milestone issues together.
_(obj.milestones).filter((m) => !m.stats.isEmpty).each((m) => {
if (m.created_at < created_at) created_at = m.created_at;
if (m.due_on > due_on) due_on = m.due_on;
_.each([ 'closed', 'open' ], (k) => {
issues[k].list = issues[k].list.concat(m.issues[k].list);
issues[k].size += m.issues[k].size;
});
}).value();

issues.closed.list = _.sortBy(issues.closed.list, 'closed_at');

// A meta milestone.
data = { issues, created_at, 'stats': { 'isEmpty': false } };

if (due_on != '0') data.due_on = due_on;
}
return true;
}
});

if (data) {
content = (
<div>
<Chart data={data} style={{ 'marginBottom': '40px' }} />
<Milestones projects={projects} project={this.props} />
</div>
);
} else {
content = <Milestones projects={projects} project={this.props} />
}
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/pages/ProjectsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default React.createClass({

render() {
let content;
if (!this.state.app.loading) {
if (!this.state.app.system.loading) {
let projects = this.state.projects;
if (projects.list.length) {
if (!this.state.edit) {
Expand Down

0 comments on commit c86affc

Please sign in to comment.