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() {
let milestone = this.props.milestone;
// Skip charts that have nothing to show.
if (milestone.stats.isEmpty) return;
let issues = milestone.issues;
// Total number of points in the milestone.
let total = issues.open.size + issues.closed.size;

View File

@ -22,10 +22,12 @@ export default (milestone) => {
// Progress in points.
a = milestone.issues.closed.size;
b = milestone.issues.open.size;
if (a + b > 0) {
if (a) {
isEmpty = false;
points = progress(a, b);
if (points === 100) isDone = true;
if (a + b > 0) {
points = progress(a, b);
if (points === 100) isDone = true;
}
}
// 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 (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.
notify(stats) {
if (stats.isEmpty) {
return actions.emit('system.notify', {
'text': 'This milestone has no issues',
'type': 'warn',
'system': true,
'ttl': null
});
notify(milestone) {
if (milestone.stats.isEmpty) {
let left;
if (left = milestone.issues.open.size) {
return actions.emit('system.notify', {
'text': `No progress has been made, ${left} point${(left > 1) ? 's' : ''} left`,
'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', {
'text': 'This milestone is complete',
'type': 'success'
});
}
if (stats.isOverdue) {
if (milestone.stats.isOverdue) {
actions.emit('system.notify', {
'text': 'This milestone is overdue',
'type': 'warn'
@ -273,7 +282,7 @@ class ProjectsStore extends Store {
_.extend(milestone, { 'stats': stats(milestone) });
// Notify?
if (say) this.notify(milestone.stats);
if (say) this.notify(milestone);
// We are supposed to exist already.
if ((i = this.findIndex(project)) < 0) { throw 500; }

View File

@ -26,6 +26,23 @@ export default {
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) => {
let milestone = {
'issues': {