63 Commits

Author SHA1 Message Date
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
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
Andrew Bonventre
a12d3cdfe8 Fix bugs due to non-idiomatic use of property values in ready
+ dom-repeat reuses elements for the sake of efficiency, and
  according to [1], it’s considered an anti-pattern to do one-shot
  state setup by inspecting attributes/properties in ready/attached.
+ Move state management to be more explicit instead of one-time
  setup in ready().

[1] https://github.com/Polymer/polymer/issues/1713

Bug: Issue 3979
Change-Id: I5a7d2ae222223cf1ac8703cd30c66f004b606cfc
2016-05-24 14:50:13 -04: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
Wyatt Allen
7a4aa8cc81 Save comment drafts locally if they are abandoned
If the user starts writing a diff comment, but discards it or navigates
away before saving it as a draft, then the text that had been entered
re-appears if the user starts a comment on the same line of the same
file of the same patch-set of the same change.

Achieves this by storing the comment text in localStorage along with a
timestamp whenever the textarea is edited by the user. The entry is
cleared from localStorage if the user saves the comment as a draft. When
a new comment is started, the gr-diff-comment checks localStorage to see
whether a relevant entry exists to use as the initial text.

Adds the gr-storage element as an interface for localStorage. This
element clears away stored comment drafts if they are more than a day
old.

Bug: Issue 3787
Change-Id: I11327a69d463a6a84a0cd8d59f4662a6a4c296a6
2016-05-23 11:04:25 -07:00
Andrew Bonventre
28165262dc Update reply counter when adding drafts to inline diffs
Also do a small cleanup of _boundScrollHandler in favor of
Polymer.{listen|unlisten}

Bug: Issue 4119
Change-Id: I16e0f74dd3f480f99b837cdf6664603a94dcc06f
2016-05-20 13:09:53 -07:00
Andrew Bonventre
8f2310717b Show network and server errors in a toast 🍞 notification
gr-error-manager is introduced to deal with error events
fired from gr-rest-api-interface. Currently it will display
the first error it sees for 5 seconds, ignoring others during
that time. If a response comes back as a 403, it prompts the
user to refresh the page and the alert remains on the screen
indefinitely.

Bug: Issue 3992
Bug: Issue 3953
Change-Id: I4a54eb1e865b88f9a5531e864e0b1d58d638a4cd
2016-05-05 11:37:31 -04: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
2aa22125b6 Move gr-diff-new to gr-diff
Change-Id: Ifaad016f806c31f3df43143b3238b757faa18b20
2016-03-25 17:56:08 -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