Redesign file attachment boxes.

Review Request #7189 — Created April 9, 2015 and submitted

Information

Review Board
release-2.5.x
7d6496d...

Reviewers

As we've added features, the design of the file attachment boxes has gotten a
little bit crusty. We ended up in a situation where we had an icon, a
thumbnail, a caption, a filename, some buttons, and a drop-down menu. This was
way overly complicated, and managed to stuff a bunch of UI into a small area,
making even the thumbnails pretty useless.

This change re-imagines the file attachment boxes with simplicity as the
primary goal. When looking at the page, the only visible information is the
thumbnail and the caption. The thumbnail is a new "HD" thumbnail which is the
full width of the file attachment box. Hovering the mouse over a file box will
trigger an animation that will scroll across the full thumbnail, which makes it
possible to get a lot more information out of it.

Additionally, other commands (such as updating, downloading, adding a comment,
or deleting) are all shown in a menu on the left which is shown while hovering
over the file attachment.

Internally, this changes file attachments to always render via the javascript
views. We previously had a wacky scenario where the initial page load would
render the HTML in a django template, and then the javascript code would
"import" existing file attachments. Newly-created file attachments would be
rendered from javascript. This resulted in a duplication of the template data
between django templates and the backbone view, except there wasn't an exact
1:1 parity between the two. Rendering entirely from javascript cleans up the
code significantly.

I've posted a video of the animation at
https://www.dropbox.com/s/lyohd4firvby0th/new-file-attachments.mov?dl=0

  • Added, deleted, and updated file attachments.
  • Tested that animation started and stopped when I expected it to, and that
    various edge conditions and mouse trickery didn't result in wacky animation.
  • Checked links for every command.
  • Ran unit tests.
  • Ran js-tests.

Description From Last Updated

Can you switch this to the #: format, so it'll get picked up by Sphinx when we start doing codebase …

chipx86chipx86

Can we make this a constant?

chipx86chipx86

So, we have .opacity() for this, which other places use. However, we may want to consider at some point nuking …

chipx86chipx86

Can you stick these back in alphabetical order?

chipx86chipx86

What's the 2px?

chipx86chipx86

We should have a new top-level @z-index-... variable for any new value, so we can make sure the order exists …

chipx86chipx86

Just as an optimization, this could be: fileAttachments = _.map(this.options.editorData.fileAttachments, (this.options.editorData.mutableByUser ? this.reviewRequest.draft.createFileAttachment : this.reviewRequest.createFileAttachment)); Since the value isn't going …

chipx86chipx86

No need for that trailing space, since the next line has some spaces anyway.

chipx86chipx86

The original "spaceless" stuff was to prevent the inline elements from having spaces between tags manifesting in the caption editor, …

chipx86chipx86

These lines are a big too long. Can you wrap them?

chipx86chipx86

These too.

chipx86chipx86

This can be consolidated: '<% if (!loaded) { %>', '<span ...></span>', '<% } else { %>', '<% if (reviewURL) { …

chipx86chipx86

Missing a doc block.

chipx86chipx86

This is over 79 chars.

chipx86chipx86

Indentation mismatch.

chipx86chipx86

Trailing blank line.

chipx86chipx86

Missing a space at the end of the first line.

chipx86chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/base_file_attachment.py
        reviewboard/attachments/mimetypes.py
        reviewboard/reviews/models/file_attachment_comment.py
        reviewboard/reviews/builtin_fields.py
        reviewboard/attachments/tests.py
        reviewboard/reviews/ui/base.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/tests/reviewRequestModelTests.js
        reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js
        reviewboard/static/rb/js/models/tests/reviewRequestEditorModelTests.js
        reviewboard/static/rb/js/resources/models/tests/fileAttachmentModelTests.js
        reviewboard/static/rb/js/views/tests/fileAttachmentThumbnailViewTests.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.js
        reviewboard/static/rb/css/pages/reviews.less
        reviewboard/templates/reviews/reviewable_page_data.js
        reviewboard/templates/reviews/parts/file_attachment_thumbnail.html
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/changedesc_file_attachment.html
        reviewboard/templates/reviews/review_request_box.html
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/tests/reviewRequestEditorViewTests.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/base_file_attachment.py
        reviewboard/attachments/mimetypes.py
        reviewboard/reviews/models/file_attachment_comment.py
        reviewboard/reviews/builtin_fields.py
        reviewboard/attachments/tests.py
        reviewboard/reviews/ui/base.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/tests/reviewRequestModelTests.js
        reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js
        reviewboard/static/rb/js/models/tests/reviewRequestEditorModelTests.js
        reviewboard/static/rb/js/resources/models/tests/fileAttachmentModelTests.js
        reviewboard/static/rb/js/views/tests/fileAttachmentThumbnailViewTests.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.js
        reviewboard/static/rb/css/pages/reviews.less
        reviewboard/templates/reviews/reviewable_page_data.js
        reviewboard/templates/reviews/parts/file_attachment_thumbnail.html
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/changedesc_file_attachment.html
        reviewboard/templates/reviews/review_request_box.html
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/tests/reviewRequestEditorViewTests.js
    
    
  2. 
      
chipx86
  1. Awesome! Looking great. Can't wait to land this.

  2. reviewboard/attachments/mimetypes.py (Diff revision 1)
     
     
     
    Show all issues

    Can you switch this to the #: format, so it'll get picked up by Sphinx when we start doing codebase docs?

  3. Show all issues

    Can we make this a constant?

  4. Show all issues

    So, we have .opacity() for this, which other places use. However, we may want to consider at some point nuking a bunch of those macros, considering most are pretty supported in the browsers we otherwise support.. No strong opinion on whether it's worth fixing up here.

  5. Show all issues

    Can you stick these back in alphabetical order?

  6. Show all issues

    What's the 2px?

    1. It's to make it fit within the border of the parent element.

    2. Maybe add a comment, just to help make that clear down the road when we forget. Or constants.

  7. Show all issues

    We should have a new top-level @z-index-... variable for any new value, so we can make sure the order exists in one location.

  8. reviewboard/static/rb/js/pages/views/reviewablePageView.js (Diff revision 1)
     
     
     
     
     
     
     
     
    Show all issues

    Just as an optimization, this could be:

    fileAttachments = _.map(this.options.editorData.fileAttachments,
                            (this.options.editorData.mutableByUser
                             ? this.reviewRequest.draft.createFileAttachment
                             : this.reviewRequest.createFileAttachment));
    

    Since the value isn't going to change within the loop, we can just pre-calculate the function to call.

  9. reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js (Diff revision 1)
     
     
     
     
     
     
     
    Show all issues

    The original "spaceless" stuff was to prevent the inline elements from having spaces between tags manifesting in the caption editor, since it threw off editing and I think spacing a bit. Worth verifying that nothing is broken here in Chrome, Firefox, or IE.

  10. Show all issues

    These lines are a big too long. Can you wrap them?

  11. reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js (Diff revision 1)
     
     
     
     
     
     
     
    Show all issues

    These too.

  12. reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    This can be consolidated:

    '<% if (!loaded) { %>',
    '<span ...></span>',
    '<% } else { %>',
    '<%   if (reviewURL) { %>',
    '<a href="..."></a>',
    '<%   } %>',
    '<%= thumbnailHTML %>',
    '<% } %>'
    
  13. Show all issues

    Missing a doc block.

  14. Show all issues

    This is over 79 chars.

  15. Show all issues

    Indentation mismatch.

  16. Show all issues

    Trailing blank line.

  17. Show all issues

    Missing a space at the end of the first line.

  18. 
      
david
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/base_file_attachment.py
        reviewboard/attachments/mimetypes.py
        reviewboard/reviews/models/file_attachment_comment.py
        reviewboard/reviews/builtin_fields.py
        reviewboard/attachments/tests.py
        reviewboard/reviews/ui/base.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/tests/reviewRequestModelTests.js
        reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js
        reviewboard/static/rb/js/models/tests/reviewRequestEditorModelTests.js
        reviewboard/static/rb/js/resources/models/tests/fileAttachmentModelTests.js
        reviewboard/static/rb/js/views/tests/fileAttachmentThumbnailViewTests.js
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.js
        reviewboard/static/rb/css/pages/reviews.less
        reviewboard/templates/reviews/reviewable_page_data.js
        reviewboard/templates/reviews/parts/file_attachment_thumbnail.html
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/changedesc_file_attachment.html
        reviewboard/templates/reviews/review_request_box.html
        reviewboard/static/rb/css/defs.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/tests/reviewRequestEditorViewTests.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/base_file_attachment.py
        reviewboard/attachments/mimetypes.py
        reviewboard/reviews/models/file_attachment_comment.py
        reviewboard/reviews/builtin_fields.py
        reviewboard/attachments/tests.py
        reviewboard/reviews/ui/base.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/tests/reviewRequestModelTests.js
        reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js
        reviewboard/static/rb/js/models/tests/reviewRequestEditorModelTests.js
        reviewboard/static/rb/js/resources/models/tests/fileAttachmentModelTests.js
        reviewboard/static/rb/js/views/tests/fileAttachmentThumbnailViewTests.js
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.js
        reviewboard/static/rb/css/pages/reviews.less
        reviewboard/templates/reviews/reviewable_page_data.js
        reviewboard/templates/reviews/parts/file_attachment_thumbnail.html
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/changedesc_file_attachment.html
        reviewboard/templates/reviews/review_request_box.html
        reviewboard/static/rb/css/defs.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/tests/reviewRequestEditorViewTests.js
    
    
  2. 
      
chipx86
  1. 
      
  2. Show all issues

    No need for that trailing space, since the next line has some spaces anyway.

  3. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.5.x (a4e85e5)
Loading...