Add confirmation dialog for post-commit review requests on web UI
Review Request #10148 — Created Sept. 17, 2018 and submitted
When a user is scrolling through the changeset (post commit review) to
make a new review request on the web UI, clicking on the row of a
commit makes a new review request, which can be done accidentally very
easily.I added a confirmation dialog when creating post-commit review requests
on web UI so the user can confirm that they want to create a new review
request from that commit. Clicking 'cancel' closes the dialog and takes
no further action, clicking 'create' creates a new review request.
Ran JS tests (all of which pass).
Tested behaviour in Chrome, Safari, and Firefox with the following
scenarios:
- Click on commit, click cancel on confirmation dialog
- Click on commit with no diff with master, click confirm, see error
message- Click on commit with diff with master, click confirm, see review
request created
Description | From | Last Updated |
---|---|---|
Can you wrap your summary at 72 characters, but ideally 52 characters. Commit summaries needn't end in a period. |
brennie | |
You can have your testing done render a list using: Tested behaviour in Chrome, Safari in Firefox: 1. Something 2. … |
brennie | |
The issue was originally filed against reviewboard 2.5.x. Can you apply your patch on that branch, test, and re-post? Note: … |
brennie | |
Could you add a screen shot of your work? |
brennie | |
Can you wrap your description at 72 characters? |
brennie | |
One more request to add to the design of this: can we include the commit summary in the text of … |
david | |
Tiny nit: summaries don't need a period. |
brennie | |
Also your summary should be in the imperitive mood as if it were an order. If you substitute your sumamry … |
brennie | |
Ideally this long message would be in the body of the dialog instead of the title |
brennie | |
How about: "The confirmation dialog will allow the user to cancel the creation of the review request." |
brennie | |
We may want to add more context to the message here, something like: You are creating a new review request … |
brennie | |
This string needs to be marked for translation with gettext(). |
brennie | |
This string needs to be marked for translation with gettext(). Missing trailing comma. |
brennie | |
This string needs to be marked for translation with gettext(). |
brennie | |
Unfortunately, we can't use ES6 arrow functions here. We'll have to do _.bind(this._createNewReviewRequest, this) instead. This is because we have … |
brennie | |
Instead of doing this, lets define a subclass that will display this content. We can refactor it out into a … |
brennie | |
Can you add body and title here? The title should be something like "Are you sure?" or "Create review request?" |
brennie | |
This should really be in the default impl of render above. Also, doing _.result twice may result in us calling … |
brennie | |
Title case: Create Review Request? |
brennie | |
While you're here, would you mind updating the doc comment to take the following format: /** * Initialze the view. … |
brennie | |
Need a var body statement at the top of the function. |
brennie | |
if (body) { |
brennie | |
Instead of duplicating this I would just do See the :js:class:`class-level documentation <RB.DialogView>` for the keys that this object accepts. |
brennie | |
Let's sort these alphabetically. |
david | |
Please put a blank line between these two. |
david | |
Instead of <b>, let's just use <span> and then put font-weight: bold in the CSS. |
david | |
Because this is an ES5 file, no trailing comma on the last item in an object. |
david | |
Because this is an ES5 file, no trailing comma on the last item in an object. |
david | |
A few things here. Wrapping everything in gettext wont work. gettext() requires the value to a be a string literal, … |
brennie | |
While you're here, can you change this to /**? Otherwise it doesn't get picked up by the documentation generation tool |
brennie | |
And this? |
brennie | |
This is only used once, so instead of defining a variable, you could do it inline: body: this._dialogBodyTemplate({ prefixText: gettext('...'), … |
david | |
In ES5, all variables need to be defined at the top of the function. So: var commitID = this.model.get('id'), dialogView; … |
david | |
Wrap to 79 columns. |
david |
Status: Discarded
Change Summary:
When I did the rbt post command I didn't realize that I should pass in the branch name as an argument and changing it in the Branch section under Information did not update the diff (it was trying to compare it against master instead of release-4.0.x). After closing and reopening it for review the diff was deleted entirely so I will make a new review request. Sorry!
Status: Re-opened
Summary: |
|
||||
---|---|---|---|---|---|
Commit: |
|
||||
Diff: |
Revision 1 (+23 -1) |
Checks run (2 succeeded)
-
-
Can you wrap your summary at 72 characters, but ideally 52 characters. Commit summaries needn't end in a period.
-
You can have your testing done render a list using:
Tested behaviour in Chrome, Safari in Firefox: 1. Something 2. Another thing 3. Yet another thing.
-
The issue was originally filed against reviewboard 2.5.x.
Can you apply your patch on that branch, test, and re-post?
Note:
To get Reviewboard 2.5.x to work, you will need a new virtual environment with Review Board at
release-2.5.x
and Djblets atrelease-0.9.x
. You do not need another source checkout of RB or Djblets -- another virtualenv will suffice. -
-
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 1) How about:
"The confirmation dialog will allow the user to cancel the creation of the review request."
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 1) We may want to add more context to the message here, something like:
You are creating a new review request from a commit that has already been published. Are you sure you want to continue?
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 1) This string needs to be marked for translation with
gettext()
. -
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 1) This string needs to be marked for translation with
gettext()
.Missing trailing comma.
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 1) This string needs to be marked for translation with
gettext()
. -
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 1) Unfortunately, we can't use ES6 arrow functions here. We'll have to do
_.bind(this._createNewReviewRequest, this)
instead.This is because we have customers on older versions of IE (I know :( ). We do allow arrow functions in
.es6.js
files, which are transpiled with Babel to ES5 that can run on all these browsers.However, since this patch will be backported to 2.5.x, we don't be able to use that. Sorry.
Summary: |
|
||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: |
|
||||||||||||||||||||||||||||||||||||||||||
Testing Done: |
|
||||||||||||||||||||||||||||||||||||||||||
Branch: |
|
||||||||||||||||||||||||||||||||||||||||||
Commit: |
|
||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 2 (+23 -1) |
||||||||||||||||||||||||||||||||||||||||||
Added Files: |
Checks run (2 succeeded)
Testing Done: |
|
---|
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Testing Done: |
|
-
-
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 2) Instead of doing this, lets define a subclass that will display this content. We can refactor it out into a generic class at a later date.
If you wrap the contents of the file in an IIFE, we can have it local to the file.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+38 -2) |
||||
Removed Files: |
|||||
Added Files: |
Checks run (2 succeeded)
-
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revisions 2 - 3) Can you add body and title here?
The title should be something like "Are you sure?" or "Create review request?"
-
reviewboard/static/rb/js/ui/views/dialogView.js (Diff revision 3) This should really be in the default impl of render above. Also, doing
_.result
twice may result in us calling an expensive function twice. Lets do:var body; /* snip */ body = _.result(this, 'body'); if (body !== undefined) { this.$el.append($('<p>').text(body)); }
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+41 -2) |
Checks run (2 succeeded)
-
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 4) Title case:
Create Review Request?
-
reviewboard/static/rb/js/ui/views/dialogView.js (Diff revision 4) While you're here, would you mind updating the doc comment to take the following format:
/** * Initialze the view. * * Args: * options (object): * Options for the view. * * Option Args: * body (string or function, optional): * <Description of body.> * * title (string, optional): * <Description of title.> * * buttons (object, optional): * <Description of buttons.> */
-
reviewboard/static/rb/js/ui/views/dialogView.js (Diff revision 4) Need a
var body
statement at the top of the function. -
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 5 (+64 -6) |
||||
Added Files: |
Checks run (2 succeeded)
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 6 (+75 -6) |
Checks run (2 succeeded)
-
-
reviewboard/static/rb/js/ui/views/dialogView.js (Diff revision 6) Instead of duplicating this I would just do
See the :js:class:`class-level documentation <RB.DialogView>` for the keys that this object accepts.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 7 (+65 -6) |
Checks run (2 succeeded)
-
Just a few tiny nits left.
-
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 7) Please put a blank line between these two.
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 7) Instead of
<b>
, let's just use<span>
and then putfont-weight: bold
in the CSS. -
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 7) Because this is an ES5 file, no trailing comma on the last item in an object.
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 7) Because this is an ES5 file, no trailing comma on the last item in an object.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 8 (+66 -6) |
Checks run (2 succeeded)
-
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 8) A few things here. Wrapping everything in gettext wont work.
gettext()
requires the value to a be a string literal, otherwise the code that looks for things to translate won't be able to parse this.Also, we want to avoid using inline styles when possible. This should be included in the rules for
.summary
in the LESS file.Instead, lets use a template on the class:
{ _dialogTemplate: _.template([ '<p><%- prefixText %></p>', '<p class="summary">', ' <%- commitID %>: <%- summary %>', '</p>', '<p><%- suffixText %></p>', ].join('')), }
For more details on
_.template
, check out the docs.Then we can use it like so:
var dialogView = new RB.DialogView({ title: gettext('Create Review Request?'), body: this._dialogTemplate({ prefixText: gettext('You are creating a new review request from the following published commit:'), suffixText: gettext('Are you sure you want to continue?'), }), buttons: [ /* ... */ ] });
This allows us to only mark the string literals for translation. Additionally, lets use
<p>
tags for content separation instead of<br>
, as that is what they exist for.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 9 (+82 -6) |
Checks run (2 succeeded)
-
Two minor nits, but otherwise looks good to me!
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 9) While you're here, can you change this to
/**
? Otherwise it doesn't get picked up by the documentation generation tool -
Summary: |
|
||||
---|---|---|---|---|---|
Commit: |
|
||||
Diff: |
Revision 10 (+84 -8) |
Checks run (2 succeeded)
-
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 10) This is only used once, so instead of defining a variable, you could do it inline:
body: this._dialogBodyTemplate({ prefixText: gettext('...'), commitID: commitID, summary: this.model.get('summary'), suffixText: ... }),
-
reviewboard/static/rb/js/newReviewRequest/views/commitView.js (Diff revision 10) In ES5, all variables need to be defined at the top of the function. So:
var commitID = this.model.get('id'), dialogView; if (commitID.length > 7) { commitID = commitID.slice(0, 7); } dialogView = new RB.DialogView({ ...
-
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 11 (+85 -8) |