show no progress message; closes #93

This commit is contained in:
Radek Stepan 2016-01-26 20:43:15 +01:00
parent 58a2e80f10
commit 687a32e7de
6 changed files with 92 additions and 44 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -33,6 +33,10 @@ export default React.createClass({
componentDidMount() { componentDidMount() {
let milestone = this.props.milestone; let milestone = this.props.milestone;
// Skip charts that have nothing to show.
if (milestone.stats.isEmpty) return;
let issues = milestone.issues; let issues = milestone.issues;
// Total number of points in the milestone. // Total number of points in the milestone.
let total = issues.open.size + issues.closed.size; let total = issues.open.size + issues.closed.size;

View File

@ -22,10 +22,12 @@ export default (milestone) => {
// Progress in points. // Progress in points.
a = milestone.issues.closed.size; a = milestone.issues.closed.size;
b = milestone.issues.open.size; b = milestone.issues.open.size;
if (a + b > 0) { if (a) {
isEmpty = false; isEmpty = false;
points = progress(a, b); if (a + b > 0) {
if (points === 100) isDone = true; points = progress(a, b);
if (points === 100) isDone = true;
}
} }
// Check that milestone hasn't been created after issue close; #100. // Check that milestone hasn't been created after issue close; #100.
@ -60,5 +62,5 @@ export default (milestone) => {
// If we have closed all issues, we are "on time". // If we have closed all issues, we are "on time".
if (isDone) isOnTime = true; if (isDone) isOnTime = true;
return { isDone, days, isOnTime, isOverdue, 'progress': { points, time } }; return { isOverdue, isOnTime, isDone, isEmpty, days, 'progress': { points, time } };
}; };

View File

@ -241,24 +241,33 @@ class ProjectsStore extends Store {
} }
// Talk about the stats of a milestone. // Talk about the stats of a milestone.
notify(stats) { notify(milestone) {
if (stats.isEmpty) { if (milestone.stats.isEmpty) {
return actions.emit('system.notify', { let left;
'text': 'This milestone has no issues', if (left = milestone.issues.open.size) {
'type': 'warn', return actions.emit('system.notify', {
'system': true, 'text': `No progress has been made, ${left} point${(left > 1) ? 's' : ''} left`,
'ttl': null 'system': true,
}); 'ttl': null
});
} else {
return actions.emit('system.notify', {
'text': 'This milestone has no issues',
'type': 'warn',
'system': true,
'ttl': null
});
}
} }
if (stats.isDone) { if (milestone.stats.isDone) {
actions.emit('system.notify', { actions.emit('system.notify', {
'text': 'This milestone is complete', 'text': 'This milestone is complete',
'type': 'success' 'type': 'success'
}); });
} }
if (stats.isOverdue) { if (milestone.stats.isOverdue) {
actions.emit('system.notify', { actions.emit('system.notify', {
'text': 'This milestone is overdue', 'text': 'This milestone is overdue',
'type': 'warn' 'type': 'warn'
@ -273,7 +282,7 @@ class ProjectsStore extends Store {
_.extend(milestone, { 'stats': stats(milestone) }); _.extend(milestone, { 'stats': stats(milestone) });
// Notify? // Notify?
if (say) this.notify(milestone.stats); if (say) this.notify(milestone);
// We are supposed to exist already. // We are supposed to exist already.
if ((i = this.findIndex(project)) < 0) { throw 500; } if ((i = this.findIndex(project)) < 0) { throw 500; }

View File

@ -26,6 +26,23 @@ export default {
done(); done();
}, },
'stats - has no progress been made?': (done) => {
let milestone = {
'issues': {
'open': {
'size': 1
},
'closed': {
'size': 0
}
}
};
assert.isTrue(stats(milestone).isEmpty);
done();
},
'stats - is milestone done?': (done) => { 'stats - is milestone done?': (done) => {
let milestone = { let milestone = {
'issues': { 'issues': {