Skip to content

Commit

Permalink
Differentiate between CLs without reviewers and WIPs
Browse files Browse the repository at this point in the history
There should be a distinction between CLs that have been sent out for
review but that do not have assigned reviewers, and those that are
published to Gerrit with the "work in progress" label attached.

This change splits these distinct states into separate categories with
different labels, but they still use the same grey icon as before (now
renamed to "not_ready").
  • Loading branch information
adg committed Apr 16, 2020
1 parent e4ff25c commit 9be4f36
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
15 changes: 13 additions & 2 deletions src/gerrit.js
Expand Up @@ -89,6 +89,11 @@ export class Changelist {
return this.json_.unresolved_comment_count !== 0;
}

// Returns whether the CL is labeled 'work in progress'.
isWorkInProgress() {
return this.json_.work_in_progress === true;
}

// Returns the number of lines changed by this CL.
getDeltaSize() {
return this.json_.insertions + this.json_.deletions;
Expand Down Expand Up @@ -164,8 +169,11 @@ export class Changelist {
if (this.isSubmittable() && !this.hasUnresolvedComments())
return Changelist.READY_TO_SUBMIT;

if (this.isWorkInProgress())
return Changelist.WIP;

if (this.getReviewers().length == 0)
return Changelist.NOT_MAILED;
return Changelist.NO_REVIEWERS;

if (this.hasUnresolvedComments())
return Changelist.OUTGOING_NEEDS_ATTENTION;
Expand Down Expand Up @@ -249,7 +257,10 @@ Changelist.NONE = 'none';
Changelist.STALE = 'stale';

// The CL has not been sent for review yet.
Changelist.NOT_MAILED = 'not_mailed';
Changelist.NO_REVIEWERS = 'no_reviewers';

// The CL is labeled 'work in progress'.
Changelist.WIP = 'work_in_progress';

// Someone else is waiting for this user to review the CL.
Changelist.INCOMING_NEEDS_ATTENTION = 'incoming_needs_attention';
Expand Down
41 changes: 30 additions & 11 deletions src/messages.js
Expand Up @@ -44,10 +44,17 @@ POPUP_SECTION_DATA[gerrit.Changelist.READY_TO_SUBMIT] = {
},
};

POPUP_SECTION_DATA[gerrit.Changelist.NOT_MAILED] = {
className: 'notMailed',
POPUP_SECTION_DATA[gerrit.Changelist.WIP] = {
className: 'workInProgress',
formatHeader: function(count) {
return 'Your ' + pluralizedCl(count) + ' not mailed for review';
return 'Your work in progress ' + pluralizedCl(count);
},
};

POPUP_SECTION_DATA[gerrit.Changelist.NO_REVIEWERS] = {
className: 'noReviewers',
formatHeader: function(count) {
return 'Your ' + pluralizedCl(count) + ' with no assigned reviewers';
},
};

Expand Down Expand Up @@ -80,7 +87,7 @@ BADGE_DATA[gerrit.Changelist.OUTGOING_NEEDS_ATTENTION] = {
},
color: '#4d2c91',
formatTitle: function(count) {
return count + ' of your CLs requiring your attention';
return count + ' of your ' + pluralizedCl(count) + ' requiring your attention';
},
};

Expand All @@ -91,7 +98,7 @@ BADGE_DATA[gerrit.Changelist.READY_TO_SUBMIT] = {
},
color: '#004c40',
formatTitle: function(count) {
return count + ' of your CLs ready to submit';
return count + ' of your ' + pluralizedCl(count) + ' ready to submit';
},
};

Expand All @@ -102,18 +109,29 @@ BADGE_DATA[gerrit.Changelist.STALE] = {
},
color: '#004ba0',
formatTitle: function(count) {
return count + ' of your stale CLs';
return count + ' of your stale ' + pluralizedCl(count);
},
};

BADGE_DATA[gerrit.Changelist.NO_REVIEWERS] = {
icon: {
'24': 'img/ic_assignment_not_ready_24dp_1x.png',
'48': 'img/ic_assignment_not_ready_24dp_2x.png',
},
color: '#8d8d8d',
formatTitle: function(count) {
return count + ' of your ' + pluralizedCl(count) + ' not assigned reviewers';
},
};

BADGE_DATA[gerrit.Changelist.NOT_MAILED] = {
BADGE_DATA[gerrit.Changelist.WIP] = {
icon: {
'24': 'img/ic_assignment_not_mailed_24dp_1x.png',
'48': 'img/ic_assignment_not_mailed_24dp_2x.png',
'24': 'img/ic_assignment_not_ready_24dp_1x.png',
'48': 'img/ic_assignment_not_ready_24dp_2x.png',
},
color: '#8d8d8d',
formatTitle: function(count) {
return count + ' of your CLs not sent for review';
return count + ' of your work in progress ' + pluralizedCl(count);
},
};

Expand Down Expand Up @@ -144,5 +162,6 @@ export const SECTION_ORDERING = [
gerrit.Changelist.OUTGOING_NEEDS_ATTENTION,
gerrit.Changelist.READY_TO_SUBMIT,
gerrit.Changelist.STALE,
gerrit.Changelist.NOT_MAILED,
gerrit.Changelist.NO_REVIEWERS,
gerrit.Changelist.WIP,
];

0 comments on commit 9be4f36

Please sign in to comment.