63 Commits

Author SHA1 Message Date
Urs Wolfer
a010547eef Fix issues detected by 'JSHint' and 'JSCS'
Change-Id: Id16d7abe53d5f65c97bf778dc532e404b41283d8
2016-10-20 20:41:00 +02:00
Becky Siegel
eb4ea184f7 Keyboard shortcuts to expand and collapse all comments
This change adds keyboard shortcuts to the "gr-diff-comment-thread"
expand all comments when 'e' is pressed and collapse all comments when
'shift + e' is pressed. Note that the keyboard event is detected on the
thread instead of the comment to minimize the number of events getting
triggered.

Feature: Issue 4738
Change-Id: Iab77349bd1527d7af5e05a827919a78a86909835
2016-10-12 11:13:56 -07:00
Becky Siegel
6bf4e4f14e Allow for comments to be collapsible
Previously in Polygerrit, comments were always expanded. You could
always see the full comment (if multiline) and any applicable actions.

This change creates a collapsed comment view.  It adds a preview of the
text to the header row when collapsed, and can be toggled open when any
part of the header is clicked.

Bug: Issue 4698
Change-Id: Idca5caf92eb32518b6737dbb5a3380d227513996
2016-10-06 15:28:42 -07:00
Kasper Nilsson
b852326209 Add ctrl+s as keyboard shortcut to save comment draft
Shortcut only functions while editing the actual text area of the
comment. This makes sense, as one should have to save each individual
comment as a draft. This also mimics the current behavior of GWT UI.

Bug: Issue 3848
Change-Id: I7037d3dbdc5dae3048fcae580ed09c41e54f0669
2016-08-24 09:58:42 -07:00
Viktar Donich
bed05854a7 Cancel comment updates on discard
Fixes race condition triggering re-rendering of a deleted comment by
canceling debounced updates for `comment.editing` changes.

Bug: Issue 4319
Change-Id: I2a7578443783360088d6f65decd7dcb8be5e636b
2016-08-05 15:45:22 -07:00
Wyatt Allen
d0dd392794 Establish annotation pipeline
Apply diff annotations (intraline differences and comment ranges) by
executing the annotation layers in order to each line. The diff builder
maintains an ordered array of annotation layers which are communicated
to GrDiffBuilder subclass instances. The builder also listens to each
layer for notifications that annotations have changed for some line
range and re-renders (i.e. re-applies the pipeline on DIV.contentText
elements) accordingly.

Change-Id: Iea0599d4869cafaadc0974158153a91d927913e8
2016-07-20 12:25:40 -07:00
Viktar Donich
b2198e8233 Ranged comments integration
- gr-file-list recognizes local preferences (for hasRangedComments flag)
- gr-file-list reacts to cursor hotkey only if there is no range
  selected (currently always false).
- Remove dead code from GrDiffBuilderSideBySide, GrDiffBuilder,
  gr-diff-builder.html
- Bugfix: GrDiffBuilder.prototype.getGroupsByLineRange handles one-line
  BOTH code sections correctly. Test updated as well.
- Added utitily methods added to gr-diff-builder.html to reduce
  dependency on DOM structure and reduce amount of code copy-pasting:
  - renderLineRange, getContentByLine, etc
- For gr-diff.js and gr-diff-comment-thread.js addDraft renamed to
  addOrEditDraft because that's what it does.
- For both, addDraft method always creates a draft comment.
- Added support for ranged comments in gr-diff, gr-diff-comment-thread.
- Added mouseenter and mouseout events to gr-comment.js
- Refactored gr-comment.js to reduce code copy-paste, unify event
  payload, and to eliminate need of accessing component instance for
  patchNum. Tests updated as well.
- Refactored gr-diff.js UI data model update using gr-diff-builder.html
  utility methods to make code more readable.
- Added support for creating ranged comments to gr-diff.js.
- gr-selection-action-box now reacts to click and tap to create a 
  comment.

Change-Id: I01480a4c6f460774a8b2826915702800b3f81d25
2016-06-13 22:44:47 +00:00
Urs Wolfer
9b8b237431 Fix 'gr-diff-comment' test when run multiple times
The test worked fine on CI since they are run with a clean profile.
When tests were run in a normal browser profile manually, tests
'draft creation/cancelation' and 'draft saving/editing' failed
alternately because of local storage use for saving draft comments.

Since these tests do not test local storage (yet), we can just create
a stub for 'gr-storage#getDraftComment' which simulates a clean state.

Change-Id: Ibb63be4f1c395d47e0022f63d0d2ba0a7c87b137
2016-06-05 12:20:11 +02:00
Viktar Donich
7ad28920e9 Gr-diff retrofit: store comment state
Fixing UI data pipe line, re-rendering:
 - side, draft text and editing status in UI comment objects
 - update gr-diff UI model on comment save/update

Feature: Issue 3910
Change-Id: I96f714c7de9add6e316dcf64bb7d566690b9d3ae
2016-05-27 10:46:54 -07:00
Wyatt Allen
035c74f508 Cleanup of diff comment draft saving work
- Refactors the _editDraft property of gr-diff-comment to _messageText.
- Renames the gr-storage element as instantiated in gr-diff-comment from
  "localStorage" to "storage".
- The gr-storage diff comment functions are refactored to include
  "comment" in their names and to accept a location object rather than 4
  separate arguments.
- Added a comment describing the use of a promise in the _loadLocalDraft
  method of gr-diff-comment.
- Throttled the invocation of the _cleanupDrafts method of gr-storage to
  avoid potentially expensive crawls over all localStorage entries.
- Various other smaller fixes.

Bug: Issue 3787
Change-Id: Idf96051c0d56d6ce8b15f55ca2680363bd1ca805
2016-05-23 14:12:19 -07:00
Andrew Bonventre
180693c180 gr-request/gr-ajax cleanup (gr-diff-comment)
Bug: Issue 3988
Change-Id: I0c100a0b77a256c1eb34f94e8fff0515add5dea1
2016-05-04 12:25:15 -04:00
Andrew Bonventre
6a9312f7b1 Properly remove discarded comments from model in gr-new-diff
Change-Id: Icb5d3ba1edd2cd3a75aa6568a152bacc5e0babda
2016-03-25 16:17:06 +00:00
Andrew Bonventre
78792e8e98 Refactor directory structure of components
There is no change in functionality. Only moving things around.

+ Separate html from the js.
+ Place the unit test for a component within the same folder.
+ Organize the components in subfolders.

Change-Id: I51fdc510db75fc1b33f040ca63decbbdfd4d5513
2016-03-04 18:02:24 -05:00