Refactor RB.UploadAttachmentView to extend RB.DialogView

Review Request #10884 — Created Feb. 5, 2020 and submitted

hxqlin
Review Board
release-3.0.x
10820
4a89476...
reviewboard

This review request refactors RB.UploadAttachmentView to extend RB.DialogView
as opposed to calling the RB.DialogView constructor and modalBox directly.
The change involves extending the RB.DialogView prototype for initialization,
rendering, and events with the necessary properties in RB.UploadAttachmentView.
RB.UploadAttachmentView also uses the button map provided by RB.DialogView to
render its upload and cancel buttons, removing the need to create DOM nodes for
them directly in the class.

The 'path' id is also removed and replaced with a 'js-path' class to reduce the
chance of conflicting elements.

  • dialogView unit tests still pass

Manual testing:
- opening the dialog, uploading a file, and submitting it (without editing the caption)
- opening the dialog, uploading a file, editing the caption, and submitting it
- opening the dialog, editing the caption, uploading a file, and submitting it
- opening the dialog, uploading a file, then cancelling the dialog
- opening the dialog, editing the caption, then cancelling the dialog
- opening the dialog, then cancelling the dialog without uploading anything
- verified the 'Upload' button is disabled unless a file is actually uploaded

Description From Last Updated

This looks pretty solid, but there's one thing that's going to be important to address. The uploadAttachmentView.js file is a ...

chipx86chipx86

Can you flesh out the summary, description, and testing a bit? What I'd like to see is a bit more ...

chipx86chipx86

Looks good, but I realized the new filename isn't in staticbundles.py, which means the new version isn't being used. Can ...

chipx86chipx86

We've found a handful of quirky issues with _super(), so we're trying to move away from it. It can get ...

chipx86chipx86

Single quotes should be used where possible. (Old code may be using double quotes still, but any new/moved code should ...

chipx86chipx86

These should also be using single quotes.

chipx86chipx86

This method needs to return this. It should also document that in the docstring. The docstring should also be using ...

chipx86chipx86

This should have a trailing comma

daviddavid

Since we've changed this to be es6 now, this should have a trailing comma.

daviddavid

Trailing comma

daviddavid

Trailing comma

daviddavid

Since this is now a new-style doc comment, it should be written in the imperative mood ("Render the dialog" rather ...

daviddavid
chipx86
  1. 
      
  2. This looks pretty solid, but there's one thing that's going to be important to address.

    The uploadAttachmentView.js file is a plain ES5 JavaScript file, but in it you're using some ES6 conventions (trailing commas on the last item in an array/dictionary), which isn't safe to include. So we either need to remove those or rename this to uploadAttachmentView.es6.js.

    I'd prefer the latter, so we can more easily maintain this going forward. Now this normally would also involve ES6ifying the file more, changing to newer-style function declarations (render() { ... } instead of render: function() { ... }) and using newer-style dedented templates, but I think even without those it's worth doing the rename.

    (And those changes should all probably happen as another change, rather than cluttering up this change -- you don't have to do that work, just saying.)

  3. We've found a handful of quirky issues with _super(), so we're trying to move away from it. It can get into infinite loops, depending on aspects of the parent classes. Can you update this to directly reference the parent prototype's render method?

  4. 
      
hxqlin
chipx86
  1. 
      
  2. Can you flesh out the summary, description, and testing a bit?

    What I'd like to see is a bit more in the summary and in the description on what this change does.

    Summary

    "Refactoring" can mean so many things, and is kind of generic, but the first line of the description is a good initial summary. "Refactor RB.UploadAttachmentView to extend RB.DialogView."

    Description

    The description should then elaborate on that, explaining the why of this. What does this refactor get us.

    The part about 'path' is a secondary detail, so it should be in its own paragraph. Use the first paragraph to tell the story of the reason for this change.

    Testing

    Testing should then provide enough information for the reviewer (and someone down the road potentially reproducing a bug) to know exactly what your testing process was. What were those manual tests? What did you do?

    I like to list one thing per paragraph, saying what I tested and what the conditions were.

    This is important, because it's easy to say something was tested but hard for a reviewer to know if that testing was sufficient, and they might have areas they're aware of to test that you may have missed.

  3. Single quotes should be used where possible.

    (Old code may be using double quotes still, but any new/moved code should use single quotes.)

  4. These should also be using single quotes.

  5. This method needs to return this. It should also document that in the docstring.

    The docstring should also be using /** instead of /*, which will tell doc generators about it.

    This is old code from before we adopted any modern doc conventions, which is why it wasn't doing this already, but since you're making changes to it, it's a good time to move that over.

  6. 
      
hxqlin
david
  1. 
      
  2. This should have a trailing comma

  3. Since we've changed this to be es6 now, this should have a trailing comma.

  4. Since this is now a new-style doc comment, it should be written in the imperative mood ("Render the dialog" rather than "Renders")

  5. 
      
hxqlin
mike_conley
  1. This looks great to me, thanks!

  2. 
      
chipx86
  1. 
      
  2. Looks good, but I realized the new filename isn't in staticbundles.py, which means the new version isn't being used. Can you add it there and do a new round of testing, make 100% sure it's all working and that your new code is being executed?

  3. 
      
hxqlin
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.0.x (e94bac0)
Loading...