Enable Desktop Notifications
Review Request #7660 — Created Sept. 25, 2015 and submitted
This task created a desktop notification to send to users when an update has been made to a review request. This involved adding a JSON column to the user profile called settings to represent user settings such as their preference on recieving desktop notifications. Users can enable or disable the desktop notifications using an option in the account setting form.
Tested on Chrome, Firefox, Internet Explorer and Safari.
Test Cases
1. Notifications enabled both in permissions and in account settings, and browser supported
expected: notification is shows
2. Notifications enabled in permissions but not in account settings, and browser supported
expected: updates bubble displayed
3. Notifications disabled in permissions but enabled in account settings, and browser supported
expected: updates bubble displayed
4. Notifications not supported by browser (Internet Explorer)
expected: updates bubble displayedThe JS Unit tests were also run during the testing for this task.
Description | From | Last Updated |
---|---|---|
Col: 80 E501 line too long (90 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (86 > 79 characters) |
reviewbot | |
Col: 72 W291 trailing whitespace |
reviewbot | |
Col: 80 E501 line too long (101 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (89 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (90 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (86 > 79 characters) |
reviewbot | |
Col: 72 W291 trailing whitespace |
reviewbot | |
Col: 80 E501 line too long (101 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (89 > 79 characters) |
reviewbot | |
Missing semicolon. |
brennie | |
Needs doc comment. |
brennie | |
Single quotes. |
brennie | |
We can do this in initialize() and then set e.g., this._shouldUseDesktopNotifications so we only have to do it once. |
brennie | |
No blank line here. |
brennie | |
No blank line here. |
brennie | |
We try not to go over 80 characters. We should use gettext() for the string with a %s-interpolation e.g. (gettext("Review … |
brennie | |
This should be a constant on the object. |
brennie | |
No blank line here. |
brennie | |
Single quotes. |
brennie | |
Can we reformat this as follows: 'enable_desktop_notifications': self.profile.settings.get( 'enable_desktop_notifications', True), If not, can we pull this out into a variable … |
brennie | |
Col: 45 E502 the backslash is redundant between brackets |
reviewbot | |
Col: 17 E131 continuation line unaligned for hanging indent |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
This should go with the first var statement at the beginning, e.g. var x = ..., y = ...; Also, … |
brennie | |
This conditional should be wrapped in parentheses. |
brennie | |
There should be a space between ) and {. |
brennie | |
This expression should be wrapped in parentheses. Also, the second and third conditions need to be indented four spaces, not … |
brennie | |
This will overwrite window.Notification. Can we set this as a method on the object? |
brennie | |
Blank line between statement and beginning of block. |
brennie | |
Update this docstring to refer to the fact that it also can use web notifications. |
brennie | |
Can you document the arguments to this function? We document them like: /* * ... * * Args: * info … |
brennie | |
receive |
brennie | |
Missing space between ) and { |
brennie | |
Missing a period. Also, can you document the args as above? |
brennie | |
Missing a period. Also, can you document the args as above? |
brennie | |
So this overrides window.Notification again. We should use a method on the object. We should only check for it once … |
brennie | |
This checking should be done in receiveNotification. |
brennie | |
These need to be declared at the top of the function. |
brennie | |
Missing a space between ) and { |
brennie | |
You can use _.delay(_.bind(...), ...) |
brennie | |
This should be formatted as: } else if (Notification.permission === 'denied' || Notificaiton.permission === 'default') { Also, this can be … |
brennie | |
We don't enforce line ending limits for HTML templates. This can be written as enableDesktopNotifications: {{user_profile.settings.enable_desktop_notifications|yesno:'true,false'}} |
brennie | |
Needs a trailing comma. This is to prevent having to modify this line later when adding a new line. |
chipx86 | |
This is missing: from __future__ import unicode_literals which must appear before the other imports, with a blank line in-between. |
chipx86 | |
Needs a trailing comma. |
chipx86 | |
Should be "Show desktop notifications ..." |
chipx86 | |
This should use the property you defined above (self.profile.should_enable_desktop_notifications) |
david | |
This should reuse the convenience function provided on the profile, so that we don't have two places determining a default … |
chipx86 | |
"Return", not "Get". "Get" implies that the function is going to get something from somewhere. "Return" implies it's going to … |
chipx86 | |
This also needs a "Returns" block, like: Returns: bool: <description of the return value here> |
chipx86 | |
Because settings defaults to null, we need to check here that it's not None before calling .get() |
david | |
This should be formatted more like: this._shouldUseDesktopNotifications = ( 'Notification' in window && RB.UserSession.instance.get(....)); |
chipx86 | |
Probably you can skip the first half of this and just see if this._notificationType is undefined. |
david | |
So right now, we have all this code, and some code below, that deals with cross-browser setup and requests for … |
chipx86 | |
Can we align the || with the opening (? We also tend to put operators on the previous line. this._notificationType … |
david | |
These two checks could be combined into the same if statement. Also make sure there's a space before opening {s. |
david | |
First line of function docs should be a summary fitting on one line without wrapping. You can then expand on … |
chipx86 | |
Space between if and (. It might also be nice to switch the order of the conditional: if (this._shouldUseDesktopNotifications && … |
david | |
We always want to show the in-page bubble. If I get a popup on my screen, I need to be … |
chipx86 | |
Same as above. The first line should be a summary fitting on a single line. |
chipx86 | |
Same as above. |
chipx86 | |
This can be simplified using JavaScript's || operator: var username = info.user.fullname || info.user.username; |
david | |
We generally combine var definitions into a single statement: var username = ..., notificationText = ...; |
david | |
Extra trailing whitespace should be removed. |
chipx86 | |
Space between the , and { |
david | |
Please indent these two lines one more level. |
david | |
As I mention below, if you have a local var for this._notification you can skip the extra bind. |
david | |
This could be formatted much more nicely: _.delay( _.bind(function() { this._notification.close(); }, this), RB.ReviewablePageView.NOTIFICATION_LIFETIME_MSECS); Even better, if you keep a … |
david | |
Col: 44 W291 trailing whitespace |
reviewbot | |
This should be indented 4 spaces. |
brennie | |
No parens needed. |
brennie | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
Remove this whitespace. |
brennie | |
"the user's browser" |
CH chronicleyu | |
Reformat this as: this._canNotify = ( this.notificationType !== undefined && RB.UserSession.instance.get('...')); Also, missing a semi-colon and there is trailing whitespace. |
brennie | |
Capital 'F' for the false. |
CH chronicleyu | |
Unindent these. |
brennie | |
No blank line here. |
brennie | |
Unindent. |
brennie | |
You don't have to wrap notification.close() in a function, e.g.: _.delay(notification.close, RB.NotificationManager.NOTIFICATION_LIFETIME_MSECS); |
brennie | |
Col: 44 W291 trailing whitespace |
reviewbot | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
There's an extra ' in here. |
david | |
Should be a lower-case 'true' |
david | |
Actually, the way you had it before was correct (since this is JavaScript, not Python). However, this should end in … |
david | |
I don't think this works (since notification.close() will call immediately). However, you probably can do: _.delay(_.bind(notification.close, notification), RB.NotificationManager.NOTIFICATION_LIFETIME_MSECS); |
david | |
I think this should be _showUpdatesBubble |
brennie | |
Fix indentation |
brennie | |
Fix indentation |
brennie | |
This file uses tabs instead of spaces. We use 4 spaces for all our JS. |
brennie | |
Register |
brennie | |
Catch |
brennie | |
Create |
brennie | |
Show |
brennie | |
will create. |
brennie | |
Missing period. |
brennie | |
Remove this line. |
brennie | |
"Set up" |
brennie | |
Dedent by 4 |
brennie | |
Return. Missing period. |
brennie | |
"Send" The first sentence of a doccomment should be a single line. |
brennie | |
Missing period. |
brennie | |
Missing a period. Also doesnt tell us that the following list is a list of keys. |
brennie | |
Backquotes, not single quotes. |
brennie | |
"Create" First sentence of a doc comment should fit on a single line. Also, minor typos: ``RB.notificationManager.notifiy |
brennie | |
second line should be indented one more space |
brennie | |
should be indented one more space. |
brennie | |
backquotes, not single quotes. |
brennie | |
"Call" |
brennie | |
Call. shouldNotify. |
brennie | |
"Call". Needs args. |
brennie | |
"Return" Needs args. |
brennie | |
API |
brennie | |
"Otherwise," |
brennie | |
"then use their preference" "Otherwise," |
brennie | |
Missing a period. Also this should be: `:py:data:`True` |
brennie | |
No need for an else clause. We can just have return True. |
brennie | |
The bubble will always be displayed, no? |
brennie | |
Missing a period. |
brennie | |
"This function will handle the review updated ..." |
brennie | |
Missing a period. |
brennie | |
Missing period. |
brennie | |
Missing period. |
brennie | |
Missing period. |
brennie | |
Missing period. |
brennie | |
"This function will create ..." "notification" |
brennie | |
", then we will send" |
brennie | |
Missing period. |
brennie | |
"This function will tell. |
brennie | |
It, not This. |
brennie | |
``true`` |
brennie | |
"Otherwise, ``false`` will be returned. |
brennie | |
``title`` (``String``) Note the space. Also, missing a period. Capitalization of the. |
brennie | |
Same as above. |
brennie | |
Same as above. |
brennie | |
Same as above. |
brennie | |
Capitilizaiton and missing period. |
brennie | |
Same as above. |
brennie | |
Same as above. |
brennie | |
Same as above. |
brennie | |
See my comments in the other doc-comment. |
brennie | |
Capitilzation and missing period. |
brennie | |
Same as above. |
brennie | |
Same as above. |
brennie | |
Same as ahove. |
brennie | |
See my comments on the other doc comment. |
brennie | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
This should be in sentence casing, like the other options. |
chipx86 | |
This can be: return (not self.settings or self.settings.get('enable_desktop_notifications', True)) |
chipx86 | |
The function name would be better as _onReviewRequestUpdated. |
chipx86 | |
The /* is indented one space too far. |
chipx86 | |
"and send", no "s". |
chipx86 | |
This isn't true anymore, right? We're always sending the bubble now. |
chipx86 | |
Blank line between these. |
chipx86 | |
No need to capitalize "Updates Bubble." |
chipx86 | |
Indentation is wonky here. Make sure you run jshint to catch these. |
chipx86 | |
"review request update," or just "update." |
chipx86 | |
I'm having a hard time parsing that sentence. I think it's the "used" bit and maybe "the notification." |
chipx86 | |
Indenation here and below all looks wrong, too. Go through everything and make sure every indentation level is an even … |
chipx86 | |
Most of this looks like stuff that could easily be inline in the call below. |
chipx86 | |
This should go into more detail on what this is responsible for, requirements, etc. |
chipx86 | |
The entire purpose of what this class does is express visual notifications based off data, so this by definition should … |
chipx86 | |
"for the user browser" doesn't make sense. "user's browser" ? |
chipx86 | |
Should be sentence casing. Also, this sentence is a bit confusing. I don't think there's a notification telling us about … |
chipx86 | |
Most of the stuff in here should be in initialize. Any variable state defaults should be there. The only thing … |
chipx86 | |
This should just be a constant on the model. |
chipx86 | |
4 space indentation on everything. |
chipx86 | |
Too many parens. They're not needed here. |
chipx86 | |
Indentation is off here as well. Same with ones below. Make sure to check every comment. |
chipx86 | |
Indentation is off here as well. |
chipx86 | |
Blank line between these. |
chipx86 | |
No backticks for the types. |
chipx86 | |
"URL String" isn't a type. It's just a String. |
chipx86 | |
the /* is indented one space too far. |
chipx86 | |
Blank line between each argument. |
chipx86 | |
Blank line between these. |
chipx86 | |
I'm not sure this is useful. This function is just taking positional arguments and turning it into an object of … |
chipx86 | |
Space before {. |
chipx86 | |
This is only needed by the prototype implementation above, so I'd move it there. Then, update call sites to use … |
chipx86 | |
We shouldn't have a copy of every single function, since those can all just access the instance. A wrapper function … |
chipx86 | |
The test suite needs a unit test for every function available to it, under every condition, simulating the ability to … |
chipx86 | |
Sentence casing. |
chipx86 | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
I've been informed in my work that this should just be: ``True`` |
brennie | |
Remove this blank line. |
brennie | |
The indentation here is a little off. It should be: NOTIFICATION_TYPE: (window.Notification || window.mozNotification || window.webkitNotification) |
brennie | |
Single quotes. |
brennie | |
Single quotes. |
brennie | |
Can you move this function definition inline into the notify call? |
brennie | |
There is no var statement for this variable. |
brennie | |
I'd rather have this all inline: RB.Notificationmanager.instance.notify({ ... }); |
brennie | |
You don't need quotes around JS object keys. |
brennie | |
Undo this. |
brennie | |
Should be at top of function. |
brennie |
- Description:
-
~ - Created a desktop notification to send to users on update
~ - Added a column to the user profile(enableDeskopNotifications) representing their preference on recieving desktop notifications
~ - (WIP) Created an option in the account setting form to enable/disable desktop notifications
~ - Created a desktop notification to send to users on update
~ - Added a column to the user profile(enableDeskopNotifications) representing their preference on recieving desktop notifications ~ - Created an option in the account setting form to enable/disable desktop notifications - Diff:
-
Revision 2 (+87 -9)
-
Tool: Pyflakes Processed Files: reviewboard/accounts/evolutions/profile_enable_desktop_notifications.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/models.py reviewboard/accounts/forms/pages.py Ignored Files: reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/accounts/evolutions/profile_enable_desktop_notifications.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/models.py reviewboard/accounts/forms/pages.py Ignored Files: reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
-
-
-
-
-
- Description:
-
~ - Created a desktop notification to send to users on update
~ - Added a column to the user profile(enableDeskopNotifications) representing their preference on recieving desktop notifications ~ - Created an option in the account setting form to enable/disable desktop notifications ~ - Created a desktop notification to send to users on update
~ - Added a column to the user profile(enableDeskopNotifications) representing their preference on recieving desktop notifications
~ - Created an option in the account setting form to enable/disable desktop notifications
+ + TODO: Clean up and move enableDesktopNotifications into settings JSON field
-
-
-
-
-
We can do this in
initialize()
and then set e.g.,this._shouldUseDesktopNotifications
so we only have to do it once. -
-
-
We try not to go over 80 characters.
We should use
gettext()
for the string with a%s
-interpolatione.g. (
gettext("Review request submitted by %s", username)
)Also, can we rip out the ternary into its own variable to make the
new Notification
simpler? -
-
-
-
Tool: Pyflakes Processed Files: reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
-
-
-
- Summary:
-
WIP: Enable Desktop NotificationsEnable Desktop Notifications
- Description:
-
~ - Created a desktop notification to send to users on update
~ - Added a column to the user profile(enableDeskopNotifications) representing their preference on recieving desktop notifications
~ - Created an option in the account setting form to enable/disable desktop notifications
~ - Created a desktop notification to send to users on update
~ - Added a JSON column to the user profile(settings) to represent users settings such as their preference on recieving desktop notifications ~ - Created an option in the account setting form to enable/disable desktop notifications - - TODO: Clean up and move enableDesktopNotifications into settings JSON field
- Testing Done:
-
+ Tested on Chrome, Firefox, Internet Explorer and Safari.
+ + Test Cases
+ 1. Notifications enabled both in permissions and in account settings, and browser supported + expected: notification is shows + 2. Notifications enabled in permissions but not in account settings, and browser supported + expected: updates bubble displayed + 3. Notifications disabled in permissions but enabled in account settings, and browser supported + expected: updates bubble displayed + 4. Notifications not supported by browser (Internet Explorer) + expected: updates bubble displayed
-
This looks really good! Most things are just style issues.
-
Can we reformat this as follows:
'enable_desktop_notifications': self.profile.settings.get( 'enable_desktop_notifications', True),
If not, can we pull this out into a variable first?
-
This should go with the first
var
statement at the beginning, e.g.var x = ..., y = ...;
Also, since
window
's scope is implicit in JS, the real notification (window.Notification
) can be accessed asNotification
anywhere. We should call this something else to avoid any confusion. -
-
-
This expression should be wrapped in parentheses.
Also, the second and third conditions need to be indented four spaces, not two.
-
-
-
-
Can you document the arguments to this function?
We document them like:
/* * ... * * Args: * info (info's type): * A brief description of info */
Also this first line is indented by one extra space.
-
-
-
-
-
So this overrides
window.Notification
again. We should use a method on the object. We should only check for it once and store it.This expression should be wrapped in parentheses and the second & third lines need to be indented at 4 spaces each.
-
-
-
-
-
This should be formatted as:
} else if (Notification.permission === 'denied' || Notificaiton.permission === 'default') {
Also, this can be written as
Notification.permission !== 'granted'
. -
-
We don't enforce line ending limits for HTML templates.
This can be written as
enableDesktopNotifications: {{user_profile.settings.enable_desktop_notifications|yesno:'true,false'}}
-
Tool: Pyflakes Processed Files: reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
-
-
-
-
-
Can we align the || with the opening (? We also tend to put operators on the previous line.
this._notificationType = (window.Notification || window.mozNotification || window.webkitNotification)
-
These two checks could be combined into the same if statement. Also make sure there's a space before opening {s.
-
Space between
if
and(
.It might also be nice to switch the order of the conditional:
if (this._shouldUseDesktopNotifications && this._notificationType.permission === 'granted') { this._sendDesktopNotification(info); } else { this._sendUpdatesBubble(info); }
-
This can be simplified using JavaScript's || operator:
var username = info.user.fullname || info.user.username;
-
We generally combine
var
definitions into a single statement:var username = ..., notificationText = ...;
-
-
-
-
This could be formatted much more nicely:
_.delay( _.bind(function() { this._notification.close(); }, this), RB.ReviewablePageView.NOTIFICATION_LIFETIME_MSECS);
Even better, if you keep a local var that points to the same thing as
this._notification
, you can skip the bind entirely.
-
<p>I'm going to recommend an additional set of changes to the design here.</p>
<p>Right now, we have a bunch of new code in ReviewablePageView for figuring out the</p> -
-
This is missing:
from __future__ import unicode_literals
which must appear before the other imports, with a blank line in-between.
-
-
-
This should reuse the convenience function provided on the profile, so that we don't have two places determining a default value.
-
"Return", not "Get".
"Get" implies that the function is going to get something from somewhere. "Return" implies it's going to return a value.
-
-
This should be formatted more like:
this._shouldUseDesktopNotifications = ( 'Notification' in window && RB.UserSession.instance.get(....));
-
So right now, we have all this code, and some code below, that deals with cross-browser setup and requests for desktop notifications, along with the checks for whether we can use these notifications.
If we later have a new view not based on ReviewablePageView that wants to do the same thing, we're going to have to repeat this.
Instead, I suggest we have a new wrapper object,
ui/managers/notificationManager.js
, that manages all this. Callers should be able to simply do:RB.NotificationManager.setup(); ... if (RB.NotificationManager.canNotify) { RB.NotificationManager.notify({ ... // data on the notification }); }
The manager would, in
setup
, figure out the type of object and request permission if needed. It would only do this once, allowingsetup
to be called by any class expecting to do notifications.This makes for a nice, reusable interface around notifications that we can later extend, and more easily unit test.
(Also, there should be unit tests for these changes.)
-
First line of function docs should be a summary fitting on one line without wrapping. You can then expand on a description.
-
We always want to show the in-page bubble. If I get a popup on my screen, I need to be able to find out what page had the update. If it's not on the page as well, I'll have to guess.
-
-
-
- Diff:
-
Revision 5 (+286 -10)
-
Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
-
-
-
-
-
-
-
Reformat this as:
this._canNotify = ( this.notificationType !== undefined && RB.UserSession.instance.get('...'));
Also, missing a semi-colon and there is trailing whitespace.
-
-
-
-
You don't have to wrap
notification.close()
in a function, e.g.:_.delay(notification.close, RB.NotificationManager.NOTIFICATION_LIFETIME_MSECS);
- Diff:
-
Revision 6 (+299 -10)
-
Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
-
-
- Diff:
-
Revision 7 (+296 -10)
-
Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
-
-
-
-
Actually, the way you had it before was correct (since this is JavaScript, not Python). However, this should end in a period.
-
I don't think this works (since
notification.close()
will call immediately). However, you probably can do:_.delay(_.bind(notification.close, notification), RB.NotificationManager.NOTIFICATION_LIFETIME_MSECS);
- Diff:
-
Revision 8 (+290 -10)
-
Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
- Diff:
-
Revision 9 (+329 -11)
-
Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
-
The only comments I have have to do with grammar and word choice. Otherwise, I am fine with this landing.
Could you also rewrite the summary into paragraph form and mention in the testing done that you ran the JS unit tests?
Thanks!
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Diff:
-
Revision 10 (+330 -11)
-
Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
-
- Description:
-
~ - Created a desktop notification to send to users on update
~ This task created a desktop notification to send to users when an update has been made to a review request. This involved adding a JSON column to the user profile called settings to represent user settings such as their preference on recieving desktop notifications. Users can enable or disable the desktop notifications using an option in the account setting form.
- - Added a JSON column to the user profile(settings) to represent users settings such as their preference on recieving desktop notifications - - Created an option in the account setting form to enable/disable desktop notifications - Testing Done:
-
Tested on Chrome, Firefox, Internet Explorer and Safari.
Test Cases
1. Notifications enabled both in permissions and in account settings, and browser supported expected: notification is shows 2. Notifications enabled in permissions but not in account settings, and browser supported expected: updates bubble displayed 3. Notifications disabled in permissions but enabled in account settings, and browser supported expected: updates bubble displayed 4. Notifications not supported by browser (Internet Explorer) expected: updates bubble displayed + + The JS Unit tests were also run during the testing for this task.
- Diff:
-
Revision 11 (+330 -11)
-
Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
-
Overall, this is looking very good. There's a few things missing, and a few things you don't need, which I've covered below.
The biggest issue that stands out to me, though, is a lack of consistency with indentation levels. This sort of thing must be absolutely consistent, and it feels like maybe your editor just isn't set right to enforce or help notice indentation differences.
We use 4 space indentation, both for JavaScript statements and within documentation. I've highlighted a number of places where I noticed inconsistencies, but please go through and make sure everything is consistent throughout the change.
-
-
-
-
-
-
-
-
-
-
-
I'm having a hard time parsing that sentence. I think it's the "used" bit and maybe "the notification."
-
Indenation here and below all looks wrong, too.
Go through everything and make sure every indentation level is an even multiple of 4.
-
-
-
The entire purpose of what this class does is express visual notifications based off data, so this by definition should be a
View
and not aModel
. -
-
Should be sentence casing.
Also, this sentence is a bit confusing. I don't think there's a notification telling us about notifications.
-
Most of the stuff in here should be in
initialize
. Any variable state defaults should be there. The only thing that should belong in a special setup function would be the part that requests permission. -
-
-
-
-
-
-
-
-
-
-
-
I'm not sure this is useful.
This function is just taking positional arguments and turning it into an object of keys/values. Thing is, when you have a function as complicated as this in JavaScript, argument-wise, it's often better to instead have it take
options
and to pull from that, emulating Python keyword arguments.However, that'd defeat the whole point of this function. So, given that, it's probably best not to have this function at all.
-
-
This is only needed by the prototype implementation above, so I'd move it there. Then, update call sites to use
this.NOTIFICATION_LIFETIME_MSECS
. -
We shouldn't have a copy of every single function, since those can all just access the instance. A wrapper function like these are only useful if they're doing additional work, like instantiating things.
Same below.
shouldNotify
doesn't even do the right thing, as the wrapped function returns a value. -
The test suite needs a unit test for every function available to it, under every condition, simulating the ability to use notifications, inability to use them, different sorts of arguments and interaction, etc.
-
- Diff:
-
Revision 12 (+257 -25)
-
Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
-
-
- Diff:
-
Revision 13 (+257 -25)
-
Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
-
- Diff:
-
Revision 14 (+257 -25)
-
Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
- Diff:
-
Revision 15 (+258 -25)
-
Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
- Diff:
-
Revision 16 (+309 -26)
-
Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/pages/views/tests/reviewablePageViewTests.js reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/pages/views/tests/reviewablePageViewTests.js reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
- Diff:
-
Revision 17 (+315 -26)
-
Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/pages/views/tests/reviewablePageViewTests.js reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/pages/views/tests/reviewablePageViewTests.js reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js
- Diff:
-
Revision 18 (+315 -26)
-
Tool: Pyflakes Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/pages/views/tests/reviewablePageViewTests.js reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js Tool: PEP8 Style Checker Processed Files: reviewboard/staticbundles.py reviewboard/accounts/evolutions/__init__.py reviewboard/accounts/forms/pages.py reviewboard/accounts/evolutions/profile_settings.py reviewboard/accounts/models.py Ignored Files: reviewboard/static/rb/js/pages/views/tests/reviewablePageViewTests.js reviewboard/static/rb/js/ui/managers/tests/notificationManagerModelTests.js reviewboard/static/rb/js/ui/managers/notificationManagerModel.js reviewboard/templates/base.html reviewboard/static/rb/js/pages/views/reviewablePageView.js