100 Commits

Author SHA1 Message Date
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
Wyatt Allen
3d8dc2edda Merge "Render inline diffs sequentially" 2017-02-08 00:42:09 +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
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
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
Wyatt Allen
1e3cd47707 Highlight add/remove diff lines more consistently
Diffs in PolyGerrit apply two shades of highlight to changed lines
(light and dark) to indicate the granularity of modifications and to
distinguish intraline edits. However, the logic for choosing the
background shade for diff lines would differ from that of GWT UI diffs
subtly.

 +----------------------------------+----------------------------------+
 |       GWT UI Shading Logic       |   PG Shading Logic (incorrect)   |
 +----------------------------------+----------------------------------+
 | Diff lines get a dark background | Diff lines get a dark background |
 | IFF they appear in a delta chunk | IFF they do NOT contain any      |
 | that is empty on the left OR     | intraline differences.           |
 | empty on the right.              |                                  |
 +----------------------------------+----------------------------------+
 |            Diff lines get a light background otherwise.             |
 +---------------------------------------------------------------------+

With this change, the shading logic in PolyGerrit is modified to match
that of the GWT UI.

Bug: Issue 4219
Bug: Issue 5117
Change-Id: Ice24292df777118c08c3e73f771720f8a186a183
2016-12-22 10:41:39 -08:00
Wyatt Allen
f362d246d1 Merge "Add robot comments to PolyGerrit" 2016-12-16 17:23:00 +00:00
Becky Siegel
35a7682262 Add robot comments to PolyGerrit
This change adds an API request to get robot comments for displaying
inline in the diff view. They are styled in a different color, contain
build and robotId information, and a "please fix" action rather than the
standard set of actions.

Feature: Issue 5089
Change-Id: I1f5954a2ed01920bb7c3dc897e3285687ff7d3ca
2016-12-15 11:20:25 -08:00
Aaron Gable
d5d9a13ec8 Ensure side-by-side diff lines don't collapse to 0px height
Bug: Issue 5091
Change-Id: I647205b2d1c05ddc0c871647331fbe3f773c04b5
2016-12-10 00:42:09 +00:00
Wyatt Allen
d970500d62 Annotate trailing whitespace per user preference
Add a simple annotation layer that marks trailing whitespace in diffs
(guarded by the `show_whitespace_errors` diff preference). The newly
supported diff preference is added to both diff preference controls. The
requirement that all annotation layers must implement `addListener` is
relaxed as the trailing whitespace layer is the third layer that doesn't
use it.

Adds tests for the layer and the diff preference.

Feature: Issue 4836
Change-Id: Ifba05216bf0bc3c0a8a094f5ef392b983091d59f
2016-11-20 13:31:30 -08:00
Wyatt Allen
603d03c669 Cleanup test format
Change-Id: I8606412953d507b877a67c816d3e7a059265cc77
2016-11-07 13:19:47 -08:00
Wyatt Allen
7d82244218 Merge "Make line marker more distinguished" 2016-11-07 21:17:12 +00:00
Becky Siegel
6a7085e5ab Make line marker more distinguished
Previously, the line marker was only subtly visible by the highlighted
line number. This change adds a bottom border to the selected line if
the user is using keycodes (j, k, up, down) to more the cursor. When
the escape key is pressed, the distinguished line marker will dissapear.

Feature: Issue 4739
Change-Id: If8c751efc137ef87cfdad1c8bf7d905de1219107
2016-11-03 13:34:07 -07:00
Becky Siegel
dc46218284 Fix for issue where line wraps incorrectly on fixed width diff view
A css rule that was added for the full width diff caused lines to wrap
incorrectly. I've adjusted the style so that it is only present with
the full-width class.

Bug: Issue 4870
Change-Id: Ie94d0a06a125efb9fe7fa25ff7f2d45f54331d64
2016-11-03 01:07:03 +00:00
Viktar Donich
bcab19889b Revert "Make horizontal scrolling visible on diff page"
This reverts commit 52c943d88e088894e61e054964ec91ffe410a0bc.

Change-Id: I63f4aa2efd386300c070521c5bccf1c6ac5c594e
2016-11-02 19:10:30 +00:00
Wyatt Allen
c2bea1cc81 Merge "Add preference for line wrapping in diff preferences" 2016-11-01 16:40:03 +00:00
Becky Siegel
e7d19a9976 Add preference for line wrapping in diff preferences
Previously in Polygerrit, diff views were always displayed in the width
specified in diff preferences. This change gives the option to wrap
lines instead, which takes precedence over column width (the column
width option is hidden when line wrapping is selected), and fits the
diff view to screen.

The gerrit API already supports the 'lineWrapping' preference so this
change uses that already existing option.

Feature: Issue 4809
Change-Id: I0d9e292739b5910abfd04af63ec4c745bf06e446
2016-10-31 17:35:21 -07:00
Viktar Donich
52c943d88e Make horizontal scrolling visible on diff page
Diff header scrolls with content and sticks to the top.
Implemented custom gr-header wrapper to accomodate this.

Bug: Issue 4491
Change-Id: I451ecd4f6c454fd9ab3085ad8f9c5bdd27cb9269
2016-10-28 12:31:58 -07:00
Viktar Donich
74975da15e Merge "Revert "Fix app size to make scrollbars visible"" 2016-10-24 20:53:42 +00:00
Viktar Donich
cc6b8300d1 Revert "Fix app size to make scrollbars visible"
This reverts commit a7b89441bda7a1ea7e98969462c2def989bd68c2.

Reason for revert: Got a better idea for app layout, will send follow-up change.

Change-Id: I7b7c86288fb070114e76dd68701e05c539089eab
2016-10-24 20:53:30 +00:00
Viktar Donich
e2d1c6307f Revert "Layout fixes (mostly for Safari)"
This reverts commit 37ef1672f9133b605c5e14f8fbcc241d4c40eb50.

Reason for revert: Got a better idea for app layout, will send follow-up change.

Change-Id: I7bfddcef416d44c7af88d74da6b39c2a93565d32
2016-10-24 20:52:59 +00:00
Viktar Donich
37ef1672f9 Layout fixes (mostly for Safari)
Follow-up for c/89172 for the Safari.

Change-Id: Ifa85f42217f6020991b6644d95d490eb9a8d7b52
2016-10-23 21:28:00 -07:00
Wyatt Allen
85c9b30f75 Merge "Fix table render hinting" 2016-10-21 17:51:20 +00:00
Wyatt Allen
4254ca3f64 Fix table render hinting
Formerly, GPU rendering was hinted for diff tables on TBODY elements for
scrolling performance on large diffs. This would cause the right border
of the table appear inconsistently in Chrome -- likely as a fluke of
GPU layer compositing. With this change, the entire TABLE is hinted
rather than the TBODIES inside it, allowing them to be composited
together.

Bug: Issue 4801
Change-Id: I952a2d71a2ebd2d92b326b565b85fb55b52927cf
2016-10-21 10:43:44 -07:00
Viktar Donich
642c4ac19e Merge "Fix app size to make scrollbars visible" 2016-10-20 22:38:36 +00:00
Viktar Donich
a7b89441bd Fix app size to make scrollbars visible
Fixes footer at the bottom of the page for all pages and changes
scrolling behavior for diff page.

On the diff page:
- horizontal scrolling is right above footer when required
- all headers stay in place when scrolling

Bug: Issue 4491
Change-Id: I62fdf130376b210c26fadcadc90bf452361ac15d
2016-10-20 12:09:57 -07:00
Urs Wolfer
a010547eef Fix issues detected by 'JSHint' and 'JSCS'
Change-Id: Id16d7abe53d5f65c97bf778dc532e404b41283d8
2016-10-20 20:41:00 +02:00
Wyatt Allen
3894bb9f2a Use semi-transparent intraline highlight color
Because code comments are rendered using italics, and because italics
can sometimes draw text outside of their bounding boxes, some characters
may be visually obscured when they are adjacent to an annotation with a
background color -- particularly intraline difference annotations. With
this change, intraline difference background is given an alpha channel
so that such characters are not obscured.

Bug: Issue 4785
Change-Id: I5372e6f4def5e69126288965eb9829e5680c2102
2016-10-18 18:18:00 -07:00
Andrew Bonventre
fd434afe59 First round cleanup of network requests & errors from tests
+ These were slowing down tests in cases where it would actually hit a
  live server, potentially adding the latency from the network to the
  test.
+ Other fixes involve removing unused imports of util.js amongst other
  small tweaks/fixes.

Bug: Issue 4016
Change-Id: I442deefebeffc6a701e4922faccfe1c74b3a35b6
2016-10-16 06:56:37 +00:00
Becky Siegel
1f5a8510b7 Safeguard for font preferences if server has skew
Added temporary safeguard for the font preferences change so that inputs
are hidden and custom styles are not set if font-size was not part of
the preferneces response.

Change-Id: I5b34b317bf953591889fa25e1c351d4f490d989e
2016-10-14 14:13:36 -07:00
Andrew Bonventre
0c03db348c Merge "Add a diff preference for font size" 2016-10-14 17:53:05 +00:00
Wyatt Allen
1be7c31e66 Gracefully handle HTTP 409 for diff API
If a file is too large for the server to deliver the diff, the API will
respond with HTTP 409. PolyGerrit interprets th this as a network error
and covers the entire page with an error message. Furthermore, the
handler for loading the diff is not written for this kind of failure and
tries to dereference the diff object -- null in that case.

With this change, the 409 message does not block use of the whole page
and the handler does not break when the diff is null.

Issue: Bug 4770
Change-Id: I68fe50c474fc03d4217e969649f62df38ca5b632
2016-10-13 11:50:14 -07:00
Becky Siegel
d7dbed640c Add a diff preference for font size
This change adds a font size field in diff preferences in both the
generic preferences page and also the preferences modal from the diff
view. The new field allows users to update their preferred font size
for the diff view to be displayed. This updates both the line number
font size as well as the diff font size.

Feature: Issue 4417
Change-Id: I0fb75fd2186d2ff63b3627e8b0f15f2b3cddbfa3
2016-10-12 16:31:24 -07:00
Wyatt Allen
056e40c01c Fix diff expanded/collapsed binding
Refactors bindings in file lists to change the expanded state of a diff
using a property name that does not collide with the hidden attribute.

Change-Id: I7f7e38a910a8d4dd19be2d591033be6f6d3cb7a1
2016-10-05 21:49:33 -07:00
Kasper Nilsson
bf457dd412 Fix data binding in gr-file-list, introduced in 86117
In https://gerrit-review.googlesource.com/c/86117/ the data binding
between the _files array and the dom-repeat in gr-file-list was not
properly enforced. This change fixes that, and also properly
references a static file-list property.

In addition, tests were implemented to ensure this regression is caught
in the future.

Bug: Issue 4575
Change-Id: I32a5645ec47d953ee6a7a71f4b14fc8c9483df3d
2016-09-30 13:04:15 -07:00
Wyatt Allen
9fcec7437f Generate clipboard data via diff rather than DOM reconstruction
This change uses a new method of generating the clipboard data that
circumvents several strange issues caused by shadow/shady DOM. This
new method is much more legible and abstracts more logic away from the
DOM.

Bug: Issue 4494
Change-Id: I8c186d6cbbe9536548d934f734856b1f9ced1a26
2016-09-13 14:24:57 -07:00
Andrew Bonventre
cca7fb3df1 Merge "Fix copy/paste in diff view" 2016-09-01 23:37:17 +00:00
Kasper Nilsson
613b49c64e Fix copy/paste in diff view
The addition of syntax highlighting silently broke copy/paste
functionality due to the addition of another layer of div nesting.

Related to this bug are some issues with correct text selection in
unified diff view, so this patch addresses them as well.

Bug: Issue 4317
Change-Id: Iac7379de4131ab4e44905a54218d42fcfe67ce62
2016-08-29 16:18:47 -07:00
Kasper Nilsson
93b0ad4964 Add expand inline functionality to diffs
This commit enables the user to manually expand individual diffs
inline in the file list of the change view.

Bug: Issue 4382
Change-Id: I87d5af9971fed3aa5e1eb64523f4623a5ff2ac8d
2016-08-26 10:36:30 -07:00
Wyatt Allen
be0142ca03 Improves visible tabs rendering
This change reverts visible tabs to use the » character. A few different
approaches have been used for rendering these tab indicators:

I:  Before the Annotation Pipeline, tab indicators were configured by a
    class that was optionally applied to tab elements by the diff
    builder. The class was guarded by the show_tabs preference and a CSS
    rule created a `::before` pseudo element to insert the character.
    (Thus also preventing the » from being copyable text.)

II: When the Annotation Pipeline was implemented, the ordering of layers
    called for intraline difference elements being rendered *inside* tab
    indicators. As a result, the » indicator would sometimes have a
    different background than the intraline difference, looking sloppy.

    To solve this, the pseudo element was positioned using absolute,
    allowing the pseudo element to consume no horizontal space and and
    the intraline background to extend across the entire tab.

III:When performance tuning, it was discovered that the
    absolute-positioned tab indicators were positioned incorrectly when
    GPU acceleration was hinted for the diff, so the containing tab
    elements were made relative.

IV: Continuing performance tuning, the tab indicators seemed to slow
    scrolling on very large diffs with tabs. It was mistakenly assumed
    (by me) that this was related to the pseudo-elements when it was
    actually caused by the thousands of positioning contexts they
    created using relative and absolute.

    Instead they were modified to use strike-through instead of a pseudo
    element, which was more-performant, but less-usable (it looked bad).

With this change, we roll-back the clock a little and solve a core
problem: namely that tab indicators were not annotated inside the
intraline differences. Fixing that, positioning tricks are no-longer
needed to make the background look right.

To do this, we decouple the tab elements (which control tab width) from
the tab indicators (which optionally make tabs visible). This is done
using an annotation layer that inserts tab indicator elements wherever
a tab character is used in the source content, and it does so after
intraline differences have been applied.

Bug: Issue 4441
Change-Id: I4fea2a3a20a7039bfeb746bd1e1c1004e43c4801
2016-08-25 11:47:17 -07:00
Andrew Bonventre
87d7d86a3d Merge "Applies optimizations to diff comment DOM attachment" 2016-08-11 20:30:20 +00:00
Wyatt Allen
32b03fc76f Applies optimizations to diff comment DOM attachment
A source of latency when creating diff comments in large diffs is the
work needed to reflow the diff DOM to make room for the new comment.
This is particularly evident when adding comments to new files because
the diff is built as an addition group representing the entire file, so
the comment causes a reflow on every subsequent line.

This change optimizes this process in three ways.

* **Limit the size of ADD & REMOVE groups:** The diff processor will now
  break an add or a remove chunk into a series of smaller chunks of the
  same kind. This is controlled by the MAX_GROUP_SIZE constant. In this
  way the number of nodes that need to be reflowed when a comment is
  added to an add or remove group is limited to the number of subsequent
  lines in that group plus the subsequent number of groups.
* **GPU optimize group in general:** Adds CSS properties to diff TBODY
  elements (which correspond to groups, for the most part) that trigger
  GPU acceleration when available.
* **Apply `table-layout: fixed;`** This style speeds up table reflow in
  general.

Change-Id: Ie0e3665b7752fec67f7123cfae70ae99e6f67521
2016-08-11 12:35:31 -07:00
Andrew Bonventre
a51f78b1b2 Merge "Reduces the cost of Diff Reflow" 2016-08-11 18:06:18 +00:00
Wyatt Allen
a04b5c1ae6 Reduces the cost of Diff Reflow
Improves the speed of diff (particularly when scrolling in a large diff)
by removing the hover state for line numbers and by removing the pseudo
elements used in visible tabs.

Change-Id: I3c8687ec282696842b51f8f43b76aa267a1506b1
2016-08-11 10:55:02 -07:00
Viktar Donich
7706e9cff9 Hide gaps from right diff when hiding left diff
When a change contains removal of large block of text, in left diff side
it is highlighted with red, and in right side there's a corresponding
empty space. Hiding left diff side leaves gaps in the code.

This change hides those gaps when left diff side is hidden by Shift+A.
Feature: Issue 3926

Change-Id: I11c6574c098a9ecfe58d1804ba57c5c4f97e4d1a
2016-08-10 14:55:22 -07:00
Viktar Donich
c282d7b282 Toggle left diff on Shift+A
Feature: Issue 3926
Change-Id: Ia52334f2aefeae4b3f115e5779da3b61af25ba11
2016-08-10 12:54:49 -07:00
Wyatt Allen
9f7e37cbf7 Fixes an if-else chain
Change-Id: I5181644364a959461a4ad5fdc23e24a57ffe5052
2016-08-08 14:36:24 -07:00
Viktar Donich
9187269b56 Prevent empty diff content lines from collapsing
Bug: Issue 4330
Change-Id: I506be8ab6c9cc0e14c41abd78e87736da9f470a1
2016-08-05 16:28:00 -07:00
Viktar Donich
b34d1f87c7 Show file weblinks (e.g. gitles) in diff view
Bug: Issue 4205
Change-Id: Ib5c832bb29453aa51ebe73732c7b8e6885e7e12f
2016-08-03 14:52:13 -07:00
Wyatt Allen
ec4d6a28a4 Modularize syntax theme
Change-Id: I682bdbeb6b8bd4dbb4b389c52043db4b6c19286e
2016-07-26 10:38:15 -07:00