347 Commits

Author SHA1 Message Date
Becky Siegel
6cd5590a15 Fix local storage with PARENT revision
Previously, if a PARENT revision was getting compared to a patchset,
the local storage key would be the same for both, and there were issues
if a user was trying to write drafts on the same line on either side.

This addresses the issue by storing 'PARENT' as the patch number in the
local storage key, so that each key is unique.

Bug: Issue 5412
Change-Id: Ia8b2f0abe1d24a3849628fe335c931f07bcaff52
2017-03-13 15:03:09 -07:00
Wyatt Allen
6a96c8b248 Normalize some invalid comment ranges
Formerly, nonsensical comment ranges would prevent comments from
appearing in diffs. With this change, ranges are normalized by the
ranged comment layer so that they can be translated into valid
annotations.

See also
* Ibcab6e537abe8b81e764b09982a2581ae81463f8 should reject such ranges.
* I019e00063ab5c45c99379f3f9fb74eda0408d63f should avoid this error when
  constructing comment emails.

Bug: Issue 5744
Change-Id: Ib5834017f81f81a877b32264ee57d72302911a6c
2017-03-10 12:21:03 -08:00
Wyatt Allen
aa8a7ab071 Merge "Revert timezone in timestamp" 2017-03-10 00:59:15 +00:00
Becky Siegel
ef950faaab Scroll to target if the bottom is not visible and meets condition
Previously, we did not scroll to target in the cursor manager if the top
was visible. However, there were times where the bottom content was
not visible, and it could have moved up into view.

This change passes an optional function for calcuating target height to
the cursor manager. If it is passed, the function is used to calculate
height instead of targetHeight. Height is ultimately used to determine
if the bottom is visible.

If the top is visible, but the bottom is not, scroll to the target if
the scroll position is farther down than the current position. Don't
scroll if the condition is not met because more content related to the
target is actually visible without scrolling, and do not want to reduce
it.

Bug: Issue 5498
Change-Id: I1708c921093b6e8b1916ae68fb468816f7c67633
2017-03-09 14:37:21 -08:00
Kasper Nilsson
bdf4390476 Revert timezone in timestamp
Removes the timezone from the timestamps, as the tooltip shows UTC
offset on mouseover.

Also upgrades most instances of gr-date-formatter to use gr-tooltip.

Bug: Issue 5587
Change-Id: I57c7dcacf0618ffd967eff3cb4ff37a5e1876180
2017-03-09 11:35:22 -08:00
Becky Siegel
e76c79bc05 Fix problem where gr-formatted-text would sometimes not display
There was an issue where gr-formatted-text would not display when the
config was not loaded yet.  This change adds a function to display text
as is, in the event that the config is not yet loaded. It also refactors
the existing functions to make it more clear where config is needed.

Bug: Issue 5690
Change-Id: I74896bd59793b26b2b8fe289c13e5762c60fe8df
2017-03-06 09:38:05 -08:00
Wyatt Allen
8fd847fb77 Initialize diff cursors as soon as diffs render content
Previously diff cursors initialized when their diffs completely finished
rendering. This means waiting longer than needed because the diff render
process includes processing and rendering syntax highlights whereas the
diff cursor only needs to wait on the content of the diff.

With this change diffs fire an event when they've finished with their
content only, and diff cursors await this event instead of the full
render.

Bug: Issue 5681
Change-Id: Ida9da83a20fe4c2dcd8920304504ec7e1185eb5d
2017-03-01 17:19:00 -08:00
Wyatt Allen
e6bd7d7b47 Merge "Allow async recursion for syntax on zeroth diff section" 2017-02-28 23:01:38 +00:00
Wyatt Allen
437dc44709 Allow async recursion for syntax on zeroth diff section
The logic inside the syntax layer that decides whether the next step of
the processing is done synchronously or after a timeout would not choose
to use a timeout if it is processing the zeroth section of the diff.

For diffs with very large initial shared chunks (for example a chunk of
more than 20,000 lines as linked in the bug) this results in the syntax
layer processing the entire chunk using synchronous recursion.

As a result, the (1) UI would lock up while processing the syntax for
this chunk, and (2) when rendering all diffs on the change, the call
stack would be exceeded.

With this change, the syntax layer allows asynchrony when processing the
zeroth chunk of the diff.

Bug: Issue 5654
Change-Id: I0e60479b2c59c9c626199e7a6b8d63ccb55ebaa7
2017-02-28 13:13:22 -08:00
Viktar Donich
a2cfc65301 Save comments on Ctrl+Enter and Meta+Enter
Feature: Issue 4997
Change-Id: Ia1887b3ee558b96182e3ea987370c9f555c90502
2017-02-28 11:16:39 -08:00
Kasper Nilsson
c617573db7 Add unresolved label to draft comments
Feature: Issue 5619
Change-Id: I5c053d37c51d71324ef7151f180cf7c8ad366c51
2017-02-22 17:05:05 -08:00
Viktar Donich
c6894439c6 Take tab size into account for line-wrapping
Previously, the logic was only checking exact line wrap boundaries and
missed tabs advancing over the boundary.

Also, line breaks were added inside span elements wrapping tabs, which
prevented correct rendering.

Bug: Issue 5597
Change-Id: I750547cb574c02965d5a30ba57f791841779297a
2017-02-22 14:56:22 -08:00
Viktar Donich
cd0c147cfc Merge "Label resolved state in comment threads" 2017-02-17 18:13:00 +00:00
Kasper Nilsson
56961e7039 Purge copy/paste cache when diff changes
Bug: Issue 5441
Change-Id: Ifa180dbb4acedce17bc7b75186386d539de5b80e
2017-02-17 00:31:07 +00:00
Wyatt Allen
e9b9d8d101 Remove color from "params" syntax class
HLJS emits a syntax class for function parameters which the PolyGerrit
syntax stylesheet would color blue. However, HLJS did not always apply
this class accurately, for example, in the C++ case described in the
linked issue.

Because the class was not very informative anyway, and the HLJS default
stylesheet does not style it either, this change removes it from the
PolyGerrit syntax styles.

Bug: Issue 4975
Change-Id: I26ed0b8f745ac6add994a5d1cfc8eb1303dac8cf
2017-02-16 14:51:56 -08:00
Kasper Nilsson
b5a681c75b Make 'Ack' mark thread as resolved
Bug: Issue 5568
Change-Id: Id8dba066766b5cc8d943bcb5df877c6b66b73ec1
2017-02-16 11:05:30 -08:00
Kasper Nilsson
6127a38646 Label resolved state in comment threads
Unresolved state is only shown when the comment actions (reply/Ack/etc)
are shown AND when the thread is unresolved.

Feature: Issue 5442
Change-Id: I7e0859530198fa17172e9f9efa73a20c7aa03975
2017-02-16 18:42:43 +00:00
Wyatt Allen
c5b184977d Merge "Fix corner case where storage gets duplicated for patchsets" 2017-02-13 22:54:57 +00:00
Wyatt Allen
1333e30bd7 Remove loading state from the diff view earlier
In a recent change (Ib83ff5157), the promise strategy for processing and
rendering diffs changed so that they resolve after all the work (i.e.
processing, diff content, and syntax highlighting) had completed.

Beforehand the promise would actually resolve after the diff processing
had finished. The diff view would wait for this promise to resolve
(along with the resolution of network calls) before removing the
`_loading` flag.

Because the promise resolution now represents all of the diff rendering
work being complete, rather than the first step only, this use of the
promise was outdated.

With this change, the diff view sets `_loading` to `false` immediately
before starting the diff processing/content/syntax pipeline.

Bug: Issue 5533
Change-Id: I24fafe4d55166e2acbf1849e6a75fbcba122b997
2017-02-10 15:29:36 -08:00
Becky Siegel
a88f8c82d4 Fix corner case where storage gets duplicated for patchsets
Previously, there was an issue where if you create a draft comment in
side by side view and switch to unified view, the comment thinks it's in
the later patch set rather than the earlier one and a second copy gets
added to local storage with the later patchset as a component of the
key.

This was because the the thread group assumed all threads inside of it
had the same patch number. This change fixes that, so in the event that
a user switches from side by side to unified, the patch number will get
taken from the comment rather than the thread group.

Bug: Issue 5493
Change-Id: I7f00997bcb2e6f1001a5d58ac206acf5af3367d2
2017-02-10 14:52:57 -08:00
Becky Siegel
2c602323e1 Move reply buttons to comment thread
Move all buttons that generate a reply of some sort (done, ack, reply,
quote) to the comment thread instead of the comment [1].

When there is a draft for a particular comment thread, all reply buttons
are hidden [2].  For example, if you click reply, you cannot click done
on the same thread, unless you remove the draft.

Each thread can have up to 1 draft. It's also worth noting that if a
thread has a draft, and the user clicks on the line or 'c' at the same
range, the existing draft will switch to 'editing' form.

[1] With the exception of "please fix" for robot comments.
[2] In this case, The please fix button will be disabled when other
reply buttons are hidden.

Feature: Issue 5410
Change-Id: Id847ee0cba0d0ce4e5b6476f58141866d41ffdad
2017-02-09 16:07:32 -08:00
Becky Siegel
1074e868b7 Get unresolved state from thread when it exists for new reply
Currently, when a response is created via keyboard shortcut 'c' or
clicking a line number, the comment is not created with the unresolved
state of the last comment in the thread.

This change checks for the previous state and adds that to the new
draft.

Bug: Issue 5408
Change-Id: I20eb039864120d5175cc016bfc695da564bc174d
2017-02-09 08:02:22 -08:00
Viktar Donich
b8f4484815 Ignore triple clicks for other gr-diff-highlight instances
At the moment, gr-diff-highlight react to selection change event, so if
there are multiple instances on the page, for example in gr-change-view,
all instances react to selection.
This change makes gr-diff-highlight to ignore selections for other
instances, thus reacting only its own selection.

Bug: Issue 5504
Change-Id: I9f0e1dc7fe9f316400d9c96fb0c8c5f7ff78d779
2017-02-08 14:05:31 -08:00
Wyatt Allen
23929fc5ff Add null/undefined checks for comment ranges
Change-Id: Ia66529e44b047ca8938708110d75e7bf910e73ae
2017-02-08 10:29:04 -08:00
Wyatt Allen
c4817a446c Merge "Fix race between comment saving and reply dialog" 2017-02-08 00:55:38 +00:00
Wyatt Allen
3d8dc2edda Merge "Render inline diffs sequentially" 2017-02-08 00:42:09 +00:00
Kasper Nilsson
6cff0e60d6 Fix race between comment saving and reply dialog
In some cases, the reply dialog could be opened before all comment
drafts have been saved, causing the draft to not appear in the dialog.

This change maintains an array corresponding to each draft request and
refers to it before opening the reply dialog. If the array is populated,
a non-blocking alert is shown with the text 'Try again when all comments
have saved.'

Bug: Issue 5369
Change-Id: Ieb73e7d7b4f66daff6cc2278a84c2195b7d0e541
2017-02-07 16:41:50 -08:00
Wyatt Allen
4a9de6fa4d Merge "Don't merge threads on same line left/right" 2017-02-08 00:30:57 +00:00
Wyatt Allen
206966a5ae Render inline diffs sequentially
Changes with large numbers of files could overwhelm PolyGerrit when a
user selects [Expand all] for inline diffs. This was because the
asynchronous processing/rendering/annotating process would be kicked off
for all unexpanded diffs simultaneously, resulting in browser lock-up
and general slowness even after rendering had completed.

With this change, inline diffs are rendered in serial rather than
parallel. In this way the benefits of the async features of diff
rendering extend to the file list, even for changes with many large
diffs (such as the one in the linked issue).

With this change, the `__expanded` property is removed from file objects
in GR-FILE-LIST. Instead, that element maintains a list
(`_expandedFilePaths`) which records the same information. Because the
expanded files are recorded in a list, however, splices on the list can
be observed, batch diff expansion can be handled sequentially.

Tests are updated to respect the new expanded paths list.

Bug: Issue 5396
Change-Id: Ib83ff5157177e1c890db8a82fbc25df8fecbe065
2017-02-07 16:17:56 -08:00
Viktar Donich
5b4d7b30e0 Merge "Handle triple click selection" 2017-02-07 22:55:52 +00:00
Viktar Donich
cb2d12770d Handle triple click selection
Double-clicking selects the word underneath it on OS X and Linux text
editors. Triple-clicking selects the whole line.

Selected line can be copied or commented on.

Feature: Issue 5375
Change-Id: I79fff57e7dbfde18ab741a3a67b61869fb52cecf
2017-02-07 14:40:48 -08:00
Wyatt Allen
049a045247 Merge "Get tests passing in safari/firefox" 2017-02-07 21:18:31 +00:00
Becky Siegel
41bdc04cb8 Don't merge threads on same line left/right
Goes along with c/95273/. Adds commentSide attribute to comments to see
which side of the diff view they belong on. This is also used as part
of the locationRange for the gr-diff-comment-thread-group, so that two
thread groups can be on the same line or range for the unified group (
one for the right, one for the left).

Note: there is already a 'side' attribute on the gr-diff-comment, which
is confusing. This side actually references 'PARENT' or 'REVISION', to
identify whether the comment belongs to the parent or any revision. On
diffs where two revisions are compared to each other, this cannot be
used to determine left/right. However, because 'side' is part of
the CommentInfo entity[1], it is difficult to change the name and make
more sense out of that.

[1] https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#comment-info

Bug: Issue 5114
Change-Id: I5cc4c17d4bb134e31e5cc07ff9b08ed349488c97
2017-02-07 21:00:52 +00:00
Becky Siegel
41e811942d Get tests passing in safari/firefox
Change-Id: I1d85a24ce12bcd2f556abc14e028d9926180b978
2017-02-06 18:15:14 -08:00
Becky Siegel
8c19a02e67 Fix range issue with comment replies
- Adds range when parent exists when comment POSTed
- Finds range via filtering comments for backfill

Bug: Issue 5459
Change-Id: Ied19cc4b33749ba81fad6d1a5030abab419b1e6f
2017-02-06 17:03:57 -08:00
Wyatt Allen
e153473446 Merge "Fix lint errors" 2017-02-02 01:45:00 +00:00
Wyatt Allen
455c91c88b Merge "Allow multiple threads per line, with different ranges" 2017-02-02 00:39:40 +00:00
Becky Siegel
562a30493e Allow multiple threads per line, with different ranges
- Add concept of diff comment thread groups, which are all of the
  threads at a particular line number.

- The thread group is responsible for breaking up comments into threads
  based on the range of the comment.

- Thread groups are ordered by the updated time of the first comment in
  the group.

- Thread groups are given a key, based on comment range, which is used
  to determine what thread group a new comment should go in (or if it
  needs a new one).

Feature: Issue 5292
Change-Id: If544e8bb879262de3ce5397e86124837b66ada04
2017-02-01 16:10:08 -08:00
Becky Siegel
90c8d2742a Fix lint errors
Change-Id: I455c266868738903400c031194fbfe22e5f41fdf
2017-02-01 14:55:24 -08:00
Wyatt Allen
07a2bd77e9 Merge "Store/retrieve unsaved drafts by range when available" 2017-02-01 17:40:06 +00:00
Becky Siegel
64ce59f48a Store/retrieve unsaved drafts by range when available
Previously, drafts were only based on line number and not patch range.
This adds range to the key in localstorage so that multiple drafts can
be stored for a line range. It also prevents the wrong draft from
surfacing in the incorrect context.

This change is also important for the multi-thread changes that are
currently in development as well, because it is possible to have
separate threads for these ranges, each of which can have its own draft
saved in storage.

Bug: Issue 3548
Change-Id: Id4c1beb5d73a47a1f98b0b169091905c80f8c64a
2017-01-31 18:46:34 -08:00
Wyatt Allen
3b824c577d Remove unnecessary HTML escaping
Because the `_computeAccountTitle` method was only used in a binding to
an HTML attribute, the manual HTML escaping performed in that method was
in not needed.

Since removing this, the only use-site for the `util.escapeHTML`
function is the `GrDiffBuilder`. To discourage general use of manual
HTML escaping (in favor of default escaping in Polymer bindings) -- as
well as to lighten util.js -- the escapeHTML function is moved into
`GrDiffBuilder`, its regex is made a constant, and is given a unit test.

Change-Id: I28c9f546cf50461e96995ecd6da8653e75554023
2017-01-30 17:28:57 -08:00
Kasper Nilsson
ee1ce06064 Wrap resolved checkbox in label tag
Increases the click surface for resolving comments.

Change-Id: Ibce18001426a3c283cd5df13482853a2185c2ab9
2017-01-24 14:46:31 -08:00
Kasper Nilsson
13ab50938a Fix copy/paste edge case
In some cases, even though the copy selection was a valid one, the
target is something existing outside the content element. One specific
instance of this is when selecting lines by clicking/dragging along line
numbers.

Bug: Issue 5325
Change-Id: I3496a9d2432201aae6ef43a63ccca601a3bcd309
2017-01-24 09:50:18 -08:00
Wyatt Allen
1bc4f2f565 Support jumping to next/previous file with comments via shortcut
Adds keyboard shortcuts to the diff view to navigate to the next or
previous file in the change's file list that has comments in the current
patch range.

Feature: Issue 5235
Change-Id: I1ad39089c1ac227e335093f25b72311f7e98b3f7
2017-01-19 12:18:52 -08:00
Wyatt Allen
709bd685ef Fix intermittent border issue
Occasionally comment threads would render in such a way that the bottom
border is covered by the following diff line. Giving 1px of margin below
the thread elements makes the border consistent generally.

Bug: Issue 5083
Change-Id: I3f29905d1dc388d2d160444c16f09ddeaaec36b5
2017-01-12 13:36:50 -08:00
Kasper Nilsson
06c374d500 Add resolvable comments checkbox
Adds the 'resolved' checkbox to the front end. Unresolved comment
threads are indicated by #fcfaa6 as background-color, whereas resolved
threads have the background #fcfad6.

Feature: Issue 4879
Change-Id: Ie1eeba61ccba559f89b707542acab2198c99b8a7
2017-01-11 12:57:56 -08:00
Wyatt Allen
0a2250ee18 Tighten padding around inline comment editing
Bug: Issue 5243
Change-Id: I9e47c18b9352ca3b0a6f985640a2326875cfbc7f
2017-01-11 10:11:28 -08:00
Wyatt Allen
4704d2dd69 Include workarounds for character literal syntax bugs
Include workarounds with bug references for a pair of simple HLJS bugs
related to parsing character literals.
* In Go, HLJS misunderstands backslash character literals.
* In C++, HLJS misunderstands wchar_t character literals.

Bug: Issue 5007
Bug: Issue 5242
Change-Id: I4c92b254062198dbf043ccd401e3224961a84a33
2017-01-10 17:05:23 -08:00
Kasper Nilsson
87cb82f5a1 Expand unresolved comment threads in diff view by default
This change leverages the unresolved flag to automatically expand only
the last UNRESOLVED_EXPAND_COUNT comments in unresolved threads.

Feature: Issue 4752
Change-Id: Ia23920e1a210246838645d56a6bc81d0dff7da07
2017-01-10 18:42:37 +00:00