Avoid a page reload on the review request UI.
Review Request #3389 — Created Oct. 1, 2012 and discarded
The idea here is to have both discard and draft banners on the window so that by using jQuery we can hide/show the appropriate banner instead of fully re-loading the page.
Note- Testing pertains banners only and it was performed as follows: -Analyse expected behaviour of a review request's state in demo.reviewboard. -Reproduce the review request's state locally making sure it behaves as expected(minus the page reload). * Brand new, not yet published: Discard-Review-Request button: draft-banner and "close" option in the nav bar hide. Discard-banner shows Discard-Review-Request link: draft-banner and "close" option in the nav bar hide. Discard-banner shows. Publish button: draft-banner hides and review-request gets published as expected. * Published and unchanged None of the banners are displayed- as expected. * Published with a change causing a draft Draft-banner is displayed as expected. "ok" button: saves description entered as expected "cancel" button: description entered is discarded as expected "publish changes" button: draft banner hides and request is published as expected. "discard changes" button: draft banner hides and request is discarded as expected. * Discarded discard-banner is displayed as expected. "ok" button: saves description entered as expected "cancel" button: description entered is discarded as expected * Reopened after discarded "reopen for review" button: discard-banner hides, draft-banner is displayed and request becomes a draft. * Submitted submitted-banner is displayed as expected. "ok" button: saves description entered as expected "cancel" button: description entered is discarded as expected * Reopened after submitted -submitted request was previously a draft: "reopen" button hides submitted-banner and displays draft-banner -submitted request was previously public: "reopen" button hides submitted-banner.
Description | From | Last Updated |
---|---|---|
Can you combine these two lines? |
david | |
Please combine these too. |
david | |
This change isn't correct--we already were hiding it using CSS. We don't want it to be present in the case … |
david | |
You removed the spaces inside the {%. Please don't |
david | |
Please put the spaces back before the else. |
david | |
There's no reason for this change. |
david | |
This still isn't correct. It's still including the draft banner in the page for users who should never be able … |
david | |
What happens if you pass this success function to gReviewRequest.close on line ~2619 in reviews.js, where we attach the click … |
mike_conley | |
This semicolon is breaking reviews.js - you need to remove it. |
mike_conley | |
This isn't needed. Keep it as it was. You only really care about hasOwnProperty when you want to be sure … |
chipx86 | |
You need to put the other id "#discard-review-request-link" back into this query. |
mike_conley | |
Space before "{" |
chipx86 | |
Should use gDraftBanner. |
chipx86 | |
It'd be nice to have a variable at the top like gDraftBanner for this. |
chipx86 | |
This seems wrong. Note that there's two conditions for showing this form: 1) It has a pending draft. 2) The … |
chipx86 | |
The first conditional is checking against 'P', so I don't see how the newly added check against 'D' can ever … |
chipx86 | |
nits - space before the equals signs here. |
mike_conley | |
The style is a bit off here - should look like: gReviewRequest.publish({ buttons: gDraftBannerButtons, success: function() { gDraftBanner.hide(); } }); |
mike_conley | |
space before = |
mike_conley | |
Spaces after the ifs, and on either side of the =='s, and before the open braces. Also, I think you … |
mike_conley | |
In an effort to prepare for our eventual localization, we probably want to abstract the English text into some constants … |
mike_conley | |
So, instead of hiding each editicon, how about shutting down their editable-fieldness? This would mean changing inlineEditor so that it … |
mike_conley | |
Same as above. |
mike_conley | |
Same comments as above - only in this case, we'd be enabling the inlineEditor. |
mike_conley | |
Instead of changing the ID and adding this, let's just keep the old ID. |
mike_conley | |
What is this element? I can't find any elements with this ID anywhere... |
mike_conley | |
Not entirely sure this is necessary - see below. |
mike_conley | |
Why is this ID changing? |
mike_conley | |
Please remove this extra line. |
mike_conley | |
Hm, so I'm afraid how how fragile this structure is for l10n. Not sure how important that is at this … |
mike_conley | |
This looks really, really wrong. That's three things named the same ID, with tiny variations. That's just plain confusing. If … |
mike_conley | |
Style is a bit off here. success: function() { gDraftBanner.hide(); } |
mike_conley | |
I think I'd feel better if we didn't depend so much on whether the banners were visible, and just checked … |
mike_conley | |
This is really confusing - why are we still creating a client-side timestamp here? Why can't we retrieve this information … |
mike_conley | |
This can be condensed to: $("span.status").text(newState ? newState : "updated"); |
mike_conley | |
Whoa - hold it...why are you passing "disable" as a string? I thought disable was a function that we'd call … |
mike_conley | |
Same as above. Also, this function looks *extremely* similar to the one on line 2503. We might want to DRY* … |
mike_conley | |
I really don't think this is how we want to be enabling and disabling inlineEditors... |
mike_conley | |
Why was this ID changed? |
mike_conley | |
Swap these. var should go first. Blank line after the var. |
chipx86 | |
loaded should be last. It signifies that we've finished loading. |
chipx86 | |
I believe this can possibly fetch fields that aren't on the review request. I think what you want is .review-request … |
chipx86 | |
I'm certain this doesn't work. You're never terminating the publish() command. That makes me think that this code path was … |
chipx86 | |
There's no way any of this was ever tested. You're using Django template tags in here, but we never go … |
chipx86 | |
Indentation problems. |
chipx86 | |
Should be alphabetical. |
chipx86 | |
Space after the "," |
chipx86 | |
You have indentation problems here. We only call this once, so I don't think it's worth having a function for … |
chipx86 | |
Same comments here. |
chipx86 | |
You can chain this: $('time.timesince') .attr('datetime', gReviewRequest.last_updated) .timesince(); |
chipx86 | |
We're not actually closing it. I'd call this "onReviewRequestClosed" instead, since it's really the handler after we've closed. |
chipx86 | |
Can you keep the queries grouped and the non-queries grouped? |
chipx86 | |
No need for ".editable" |
chipx86 | |
onReviewRequestReopened |
chipx86 | |
What's the "updated" all about? |
chipx86 | |
There can only be one element with a given ID. This query is not reliable. You may need to change … |
chipx86 | |
You're missing a ; |
chipx86 | |
Same comment as above. |
chipx86 | |
Space before "(" |
chipx86 | |
The ID is the most specific. No need to append the class names. Needs to wrap to < 80 chars. … |
chipx86 | |
I think what you really want is: $('.review-request .editable').reviewRequestFieldEditor(); |
chipx86 | |
Keep the blank line. |
chipx86 | |
You're defining this button ID multiple times, which won't work. You need to switch to classes and update call sites. |
chipx86 | |
Levels of indentation look wrong. The last endif should only have one space, and the first here should have two. … |
chipx86 | |
One space before "if" |
chipx86 |
- Change Summary:
-
-Fixed the indentation -Changed the logic of the template -Got rid of the trailing whitespace
- Change Summary:
-
-Modified logic of draft-banner in review_header.html. -Modified handler for the case when review-request-discard button is clicked.
-
I think you may have found a bug in datastore.js - at this line: https://github.com/reviewboard/reviewboard/blob/master/reviewboard/static/rb/js/datastore.js#L660 if (!options.success) is evaluating to true, even if a function is passed. We can fix that by using hasOwnProperty. So change that line to be: if (!options.hasOwnProperty("success")) { // ... } That makes the banner go away for me.
-
- Change Summary:
-
- draft-banner and discard-banner now show/hide properly. - Changed the template to address points raised by David. Note: There's a server error message that appears and quickly goes away. It also disappers from the console so i don't get to see what is causing the error message.
- Change Summary:
-
-Fixed server error message. -Page still reloading:success member inside the click handler does not prevent the page reload request in _apiCall()
- Change Summary:
-
-Page reloading is successfully avoided for the discard-draft button. -I've also cleaned up review_header.html
- Summary:
-
Changed a bit of the logic in review_header.htmlAvoided a page reload for discard-draft button.
- Description:
-
~ This is work in progress.i've cleaned up the template and changed the logic of the discard-banner and draft
~ The idea here is to have both boxes on the window so that by using jQuery we can hide/show the appropriate banner instead of fully re-loading the page.
- banner boxes.The idea here is to have both boxes on the window so that by using jQuery we can hide/show - the appropriate box instead of fully re-loading the page. - Testing Done:
-
+ Manual testing done locally.
- Description:
-
~ The idea here is to have both boxes on the window so that by using jQuery we can hide/show the appropriate banner instead of fully re-loading the page.
~ The idea here is to have both discard and draft banners on the window so that by using jQuery we can hide/show the appropriate banner instead of fully re-loading the page.
-
Hi Jesus, I'd like to see a complete, detailed, step-by-step set of tests in Testing Done that describes every permutation of states you're working with. We need to know what testing and that testing needs to occur with every draft, since this is something very core that we can't get wrong.
-
This isn't needed. Keep it as it was. You only really care about hasOwnProperty when you want to be sure that this specific base-level instance has it and not a prototype backing it.
-
-
-
-
This seems wrong. Note that there's two conditions for showing this form: 1) It has a pending draft. 2) The user viewing it has permissions to edit this review request. #1 is dynamic. That state will change when there's an edit or when a review request is reopened from a discarded state. #2 is not dynamic. This will never change while the page is open. So that original check should remain, and if the user doesn't have permission to edit the review request, this form should never be in the HTML.
-
The first conditional is checking against 'P', so I don't see how the newly added check against 'D' can ever be false.
- Change Summary:
-
Modifications: -Addressed Christian's comments. -"close" option in the nav bar now hides when discard-review request is clicked. Current issues: -Discard-banner: The draft shows two pencil icons instead of one. Also, the "reopen for review" button is broken. Console does not capture anything when the button is clicked.
-
I'd also like to see detailed testing showing things are working for when the review request is in the following states: * Brand new, not yet published * Published and unchanged * Published with a change causing a draft * Discarded * Roepened after discarded * Submitted * Reopened after submitted
- Change Summary:
-
Banners show/hide when appropriate. Next Step: -Resolve issue of multiple pencil icons showing on discard-banner and submitted banner. -Keep functionality the same as before: i.e: a user should lose the ability to edit the request's fields once it's discarded.
- Testing Done:
-
~ Discard-Review-Request button:
~ -Pre-condition: Review request is not yet public. ~ -Post-condition(on click): Draft-banner and "close" option in the nav bar hide. Discard-banner shows. ~ Note- Testing pertains banners only and it was performed as follows:
~ -Analyse expected behaviour of a review request's state in demo.reviewboard. ~ -Reproduce the review request's state locally making sure it behaves as expected(minus the page reload). + + -
Brand new, not yet published:
Discard-Review-Request button: draft-banner and "close" option in the nav bar hide. Discard-banner shows
Discard-Review-Request link: draft-banner and "close" option in the nav bar hide. Discard-banner shows.
Publish button: draft-banner hides and review-request gets published as expected.
+ -
Published and unchanged
None of the banners are displayed- as expected.
+ -
Published with a change causing a draft
Draft-banner is displayed as expected.
"ok" button: saves description entered as expected
"cancel" button: description entered is discarded as expected
"publish changes" button: draft banner hides and request is published as expected.
"discard changes" button: draft banner hides and request is discarded as expected.
+ -
Discarded
discard-banner is displayed as expected.
"ok" button: saves description entered as expected
"cancel" button: description entered is discarded as expected
+ -
Reopened after discarded
"reopen for review" button: discard-banner hides, draft-banner is displayed and request becomes a draft.
+ -
Submitted
submitted-banner is displayed as expected.
"ok" button: saves description entered as expected
"cancel" button: description entered is discarded as expected
+ -
Reopened after submitted
-submitted request was previously a draft: "reopen" button hides submitted-banner and displays draft-banner
-submitted request was previously public: "reopen" button hides submitted-banner.
-
- Change Summary:
-
-Hide editable fields when user discards a review request. -Review request status is updated accordingly. current issues: -Testing-done/description fields are still editable when request is discarded. -Two pencil icons on discard-banner/submitted-banner -Can't figure out how to check if a review request is a draft using RB.ReviewRequest
- Summary:
-
Avoided a page reload for discard-draft button.WIP: Avoid a page reload on the review request UI.
-
-
-
The style is a bit off here - should look like: gReviewRequest.publish({ buttons: gDraftBannerButtons, success: function() { gDraftBanner.hide(); } });
-
Maybe I missed something, but why are we generating this updated timestamp on the client side, instead of reading it from the returned object once the API call is successful?
-
-
Spaces after the ifs, and on either side of the =='s, and before the open braces. Also, I think you can simplify your replacements here like this: if (newState) { $("span.status").text(newState); } else { $("span.status").text("updated"); }
-
In an effort to prepare for our eventual localization, we probably want to abstract the English text into some constants that can be easily flipped.
-
So, instead of hiding each editicon, how about shutting down their editable-fieldness? This would mean changing inlineEditor so that it can be disabled.
-
-
-
-
-
-
-
-
-
Hm, so I'm afraid how how fragile this structure is for l10n. Not sure how important that is at this stage... David or Christian?
- Change Summary:
-
-Fixed issue of multiple pencil icons on the banners. Next Step: -Add a field to RB.ReviewRequest to check if a review request is public/draft.
- Diff:
-
Revision 12 (+175 -71)
- Change Summary:
-
Changed reviews.js so all '.editable' fields are bound to the inlineEditor() and enabled/disabled when appropriate.
- Diff:
-
Revision 13 (+152 -72)
- Change Summary:
-
-RB.ReviewRequest now pulls in data from the API about the status of a review request. -This solves the issue of showing draft-banner/no banner when a previosuly submitted review request is re-opened
- Diff:
-
Revision 14 (+151 -80)
-
-
This looks really, really wrong. That's three things named the same ID, with tiny variations. That's just plain confusing. If you really need these things to share these styles, you should use a class - not a series of IDs.
-
-
I think I'd feel better if we didn't depend so much on whether the banners were visible, and just checked the review request object to see if it was in a state that allowed for editable fields.
-
This is really confusing - why are we still creating a client-side timestamp here? Why can't we retrieve this information from the review request instead?
-
-
Whoa - hold it...why are you passing "disable" as a string? I thought disable was a function that we'd call on inlineEditor widgets.
-
Same as above. Also, this function looks *extremely* similar to the one on line 2503. We might want to DRY* it up. * Don't repeat yourself.
-
-
- Change Summary:
-
Addressed issues from previous review request: -Better IDs for elements that take care of changing description on the banners. -Avoid code repetition.
- Diff:
-
Revision 15 (+162 -78)
- Change Summary:
-
-Original data from the review request is pulled when a draft review request is discarded/submitted. -Avoid code repetition. TODO: -More thorough testing. -A banner at the bottom of the page should appear when a review request is updated(discarded/changed/submitted etc).
- Diff:
-
Revision 16 (+177 -83)
- Change Summary:
-
TODO: -Display draft-banner properly when a public review request is modified needs work still. -More thorough testing. -A banner at the bottom of the page should appear when a review request is updated(discarded/changed/submitted etc).
- Summary:
-
WIP: Avoid a page reload on the review request UI.Avoid a page reload on the review request UI.
- Diff:
-
Revision 17 (+186 -84)
-
-
-
-
I believe this can possibly fetch fields that aren't on the review request. I think what you want is .review-request .main
-
I'm certain this doesn't work. You're never terminating the publish() command. That makes me think that this code path was never tested.
-
There's no way any of this was ever tested. You're using Django template tags in here, but we never go through Django. That clearly can never work. What are you attempting to do here? Why can't we reuse the banner we'd otherwise have? That should just be in the HTML and shown.
-
-
-
-
You have indentation problems here. We only call this once, so I don't think it's worth having a function for it. Just do this logic where it's needed.
-
-
You can chain this: $('time.timesince') .attr('datetime', gReviewRequest.last_updated) .timesince();
-
We're not actually closing it. I'd call this "onReviewRequestClosed" instead, since it's really the handler after we've closed.
-
-
-
-
-
There can only be one element with a given ID. This query is not reliable. You may need to change button IDs to classes and make sure nothing breaks.
-
-
-
-
The ID is the most specific. No need to append the class names. Needs to wrap to < 80 chars. Do: $('#submitted-description') .reviewCloseCommentEditor(...);
-
-
-
You're defining this button ID multiple times, which won't work. You need to switch to classes and update call sites.
-
Levels of indentation look wrong. The last endif should only have one space, and the first here should have two. Make sure the template tags above only indent by 1 space each time and that they're all correct.
-