697 Commits

Author SHA1 Message Date
Becky Siegel
99990d7fc8 Add optional file link to gr-comment-thread
This will be used by gr-thread-view so that comment threads can have
context. In order to generate URLs, comment threads will also need a
line and change property.

Change-Id: I35d405c8af9f10b4e0c89dd5fcb9e48b7b373534
2018-02-27 10:48:32 -08:00
Becky Siegel
3eac40a5e9 Merge "Add rough component for viewing comment threads in the change view" 2018-02-22 18:32:59 +00:00
Becky Siegel
a7b81d2de5 Add rough component for viewing comment threads in the change view
Future changes will enhance the aesthetics of this component and insert
it as a tab by the messages list

Bug: Issue 8241
Change-Id: Ia68519ba67aa0fa07d1687e731e1ed82e9979369
2018-02-22 01:55:29 +00:00
Wyatt Allen
83b5d542ab Merge "Correct logic for matching a new comment to its thread in a group" 2018-02-21 23:14:37 +00:00
Wyatt Allen
659f15110f Correct logic for matching a new comment to its thread in a group
When a new comment is being added to a line, Gerrit checks to see if
there is an existing thread on the same line (and same range, if any) so
that the comment can be appended to it if so. Otherwise, a new thread is
created.

However, following I4f7804ac02, the logic to identify the appropriate
thread by range was refactored to not use range location strings, but
use range objects instead. Problematically, there were two flaws in this
code:
1)  The range object references were compared rather than their values.
2)  Only new threads were being rendered with their corresponding ranges
    whereas existing threads were not.

As a result, if the user attempted to add a line comment on a line with
an existing ranged comment, the ranged comment's thread would be
identified as the destination (because the new comment has no range and
the existing thread's range was not being set). Appending the range-less
comment to a ranged thread resulted in incoherent data and the draft
would be unsavable.

With this change, the logic uses value equality to match ranges and the
`gr-diff-comment-thread-group#_getThreads` method is updated to set the
range on existing threads.

Bug: Issue 8410
Change-Id: If34e0d46a5c1af81bec82125217088fb574a2f61
2018-02-21 21:51:56 +00:00
Kasper Nilsson
1fc8edf5c9 Fix some styles with diff mode selector
Change-Id: I06642afcba42deee9590eae96b146401ea1d7220
2018-02-21 10:28:59 -08:00
Kasper Nilsson
2b3fa4ed95 Merge "Add "Mark reviewed" shortcut for diff view" 2018-02-21 17:58:55 +00:00
Kasper Nilsson
5b7e0af8e4 Add "Mark reviewed" shortcut for diff view
Bug: Issue 8393
Change-Id: Ie131f9a0a75fe2c0204cd36c0a03e9640fe1e915
2018-02-20 13:16:20 -08:00
Quinten Yearsley
9c056b7e73 Put robot comment actions inside a dom-if template
Change-Id: I3f971bf1001c9bf137670705efbd589d3bda1ec0
2018-02-20 11:18:33 -08:00
Wyatt Allen
d034002446 Merge "Save diff mode preference when toggled" 2018-02-16 21:58:48 +00:00
Wyatt Allen
ffae724134 Save diff mode preference when toggled
Introduce the gr-diff-mode-selector which componentizes the diff mode
buttons already used in the file list and adds them to the diff view.
With this new component, when authenticated users change their diff
preference using the new selector (or by the 'm' keyboard shortcut), the
new mode is saved to their preferences. Unauthenticated users see no
change in diff mode preference persistence.

The diff selector is now consistently labeled as "Diff view" rather than
as "Diff views".

Bug: Issue 8144
Change-Id: I4b30714deb9a466e707b3d4ae90c1d4c60222c64
2018-02-15 11:43:10 -08:00
Wyatt Allen
0191eae697 Merge "Report proportion of due_to_rebase chunks in loaded diffs" 2018-02-14 22:09:33 +00:00
Wyatt Allen
8b45290ed2 Report proportion of due_to_rebase chunks in loaded diffs
Change-Id: If48e4194352456d25e99e9f4d9df331226a3af4a
2018-02-14 13:06:32 -08:00
Kasper Nilsson
74fa14c3bc Merge "Add confirmOnEnter prop to confirm dialog" 2018-02-14 00:43:05 +00:00
Becky Siegel
a638c38bce Merge "Update comment thread creation/removal to no longer use locationRange" 2018-02-13 17:27:54 +00:00
Kasper Nilsson
7d50910d77 Add confirmOnEnter prop to confirm dialog
For some dialogs, the confirm event should fire on enter. This change
adds this optional property.

Checking the disabled property before firing the confirm event should
prevent unintended side effects throughout the app.

Change-Id: I5603065b37bf87b1c4b36ff54376fb4066869afe
2018-02-12 18:23:25 -08:00
Wyatt Allen
f5f6899752 Simplify CSS for diff line numbers
Line numbers in diffs had been specified in data-attributes and CSS to
avoid including them in pasteboard selections. However, we have since
moved to a different system that avoids including non diff content in
selections, and this CSS needlessly complicates style application.

With this change, diff line numbers show content, and the relevant CSS
is simplified. This provides a small, but measurable diff render
performance improvement.

Change-Id: Iad062553be533ead1dd29eaaacd5af8867249a16
2018-02-13 01:40:22 +00:00
Becky Siegel
bbde672af0 Update comment thread creation/removal to no longer use locationRange
Follow-up to https://gerrit-review.googlesource.com/c/gerrit/+/157590
which no longer used locationRange to group comments together into
threads. However, locationRange was still used for a few other things
including thread removal, which could result in a bug if there were
two threads that had the same locationRange and the wrong one was
found first.

Things included in this change:
1. Determine whether a thread group exists
   - This is identified as it was before. The thread group now gets a
     commentSide attribute, as it can pass it to all of its children
     (the same for all).
2. Determine if a thread exists within the group for a given range in a
   group
   - The range object is now included as an attribute on the comment
     thread instead of the locationRange string.
3. Be able to remove a thread group
   - A rootId attribute is now stored on the comment thread, which is
     data bound to each comment. When a comment is removed, it finds the
     thread with the rootId within the thread group to remove.
   - In the event that a thread group only contains a single draft,
     there is no roottId.

Change-Id: I4f7804ac02f4259b4964c6333d258f0fc3b29d24
2018-02-12 17:36:33 -08:00
Kasper Nilsson
3f631f9329 Merge "Add manual_review section to diff prefs" 2018-02-10 00:05:08 +00:00
Kasper Nilsson
75f467566a Add manual_review section to diff prefs
Bug: Issue 4676
Change-Id: Iecef2b7bc1d506b960b32f92bb1b8870c5b96c65
2018-02-09 22:21:00 +00:00
Wyatt Allen
61e414c9a3 Toggle diff view mode with 'm' key
Ieae237f9bb1 adds a keyboard shortcut to switch diff view modes in the
diff view. With this change, the key is changed from 'v' to 'm', support
is added to the change view as well as the diff view, and tests are
added.

Bug: Issue 8269
Change-Id: Ifeaa26bc1d6256809d58673232cf982b6faac400
2018-02-09 10:17:50 -08:00
Kasper Nilsson
8f9664b7b7 Disallow commenting on an edit base
Bug: Issue 8289
Change-Id: I934f8b4ac2a6f1993ddb1ad55c3c05f9fd0182f9
2018-02-08 11:28:52 -08:00
Kasper Nilsson
2206c8511e Merge "Cancel diff rendering when diffs are collapsed or detached" 2018-02-08 03:55:07 +00:00
Wyatt Allen
fcc3cf8c1d Cancel diff rendering when diffs are collapsed or detached
Formerly, if diff rendering is started, but then unloaded or navigated
away from, the rendering work would needlessly continue in the
background. Cancel rendering when a diff will not be used.

Bug: Issue 6061
Change-Id: I695281229335e84f2d5c802c1fa971842c588330
2018-02-07 17:02:07 -08:00
Kasper Nilsson
f428a236a6 Respect manual_review preference in diff view
The ability to modify the preference in the diff settings will be added
in a later change.

Bug: Issue 4676
Change-Id: I8c335acd9c50344714e56901f82c09327e7f4366
2018-02-07 11:38:03 -08:00
Wyatt Allen
fdf0db7a2b Compute threads with in_reply_to rather than location
The UI does not allow creating multiple comments at the same diff
location, but instead encourages contributing to the comment threads
already at a location. The uniqueness of thread locations was leveraged
to simplify the collection of comments into threads by mapping their
locations to keys.

However, the REST API does permit multiple threads starting from the
same diff location, so this expectation in the key-based UI threading
logic can be wrong. In such scenarios, an unresolved thread may be
mistakenly inserted into a resolved thread, resulting in a comment that
is not resolvable through the UI.

With this change, the `getCommentThreads` method is updated to associate
comments into threads via the `in_reply_to` graph rather than location
map in the same way that the `unresolved_comment_count` detail property
is determined server-side.

Although this corrects the issue in the `getCommentThreads` method, as
of this change, the diffs do not yet use it to thread comments.
Migrating diffs over to use it will be done in follow-up.

Bug: Issue 6779
Change-Id: I9427ccc716acdf7ef4c63eba48d2287875fa5534
2018-02-06 19:22:31 +00:00
Becky Siegel
dd0b031184 Merge "Prepare gr-diff-comment-thread for use in comment thread view" 2018-02-06 18:49:16 +00:00
Wyatt Allen
f78a45c7eb Associate threads with in_reply_to in gr-diff-comment-thread-group
The UI does not allow creating multiple comments at the same diff
location, but instead encourages contributing to the comment threads
already at a location. The uniqueness of thread locations was leveraged
to simplify the collection of comments into threads by mapping their
locations to keys.

However, the REST API does permit multiple threads starting from the
same diff location, so this expectation in the key-based UI threading
logic can be wrong. In such scenarios, an unresolved thread may be
mistakenly inserted into a resolved thread, resulting in a comment that
is not resolvable through the UI.

With this change, the threading logic in gr-diff-comment-thread-group is
updated to associate comments into threads via the `in_reply_to` graph
rather than location map in the same way that the
`unresolved_comment_count` detail property is determined server-side.

Bug: Issue 6779
Change-Id: Ibb29d4ba5c5de9e92dfbfba8ac7ac8037c332028
2018-02-05 18:12:32 -08:00
Becky Siegel
428ec67a7d Prepare gr-diff-comment-thread for use in comment thread view
- Updaotes the unresolved property to be public, and reflects the
  attribute. This will be used for the toggle to show unresolved threads
  or all threads.
- Update logic to always show drafts at the end of sorted comments.
  Without this, the thread could get in a weird state where you can
  still add another draft, but since they are not threaded, and once the
  comment is published, its date changes to the published date anyway,
  so its ordering will be at the end.
- This change also adds the __draft attribute in gr-diff-comment-api so
  that draft comments will render correctly in the new view.

Change-Id: Icacc46ab5fd643b061ecfac8dcd313f815d17199
2018-02-05 17:16:30 -08:00
Kasper Nilsson
8f86afc906 Merge "Rename robot-comments-controls to robot-comment-controls" 2018-02-06 00:41:47 +00:00
viktard
dfa58ce16c Merge "Support implicit PARENT parameter when calculating commitRange" 2018-02-05 23:27:46 +00:00
Thomas Shafer
849c446243 Support implicit PARENT parameter when calculating commitRange
When there isn't an explicit revision, the view defaults the base patch num to
PARENT. When the base patch num is PARENT, baseCommit should be set to the
parent commit.

Change-Id: I2c5291f67356111ef4562f36636647f0cb98bea6
2018-02-05 12:58:09 -08:00
Viktar Donich
c5069b1cd2 Show "File X of Y" next to file navigation links in diff view
Bug: Issue 4917
Change-Id: Ie993504fe80034da0e3d3ddee99687ba09ebc2ff
2018-02-05 10:54:17 -08:00
Thomas Shafer
fbeb8c929a Swap baseCommit and commit for weblinks
The baseCommit should be used to generate the left side of the weblinks.

Change-Id: I9ab3aaae5a13acb6b581713308b38beddcd7750a
2018-02-05 10:11:49 -08:00
Becky Siegel
21ad8d38c7 Update gr-comment-api to get comments grouped by thread
Change-Id: Id6f1ca24b17137ea89a7f6ba24f62179f0aecb30
2018-02-02 11:07:07 -08:00
Wyatt Allen
117e449efb Move descendedFromClass into a behavior
Change-Id: Ie592a1b2d22cfc0ba32514fa4a48f68f7ed9eeb6
2018-01-31 18:25:42 -08:00
Quinten Yearsley
b27908d897 Rename robot-comments-controls to robot-comment-controls
This would make the actual name consistent with the documentation
(https://gerrit-review.googlesource.com/Documentation/pg-plugin-endpoints.html)
and it also makes sense for comment to be singular in the context
of one comment.

Change-Id: I62d3f247c7b9a8356d5188cc4d6754d8efe0f8ca
2018-01-31 23:34:03 +00:00
Becky Siegel
e64a1c9958 Change font sizes from em to rem
Change-Id: Ib97c05836bcf1a19959bb1bed8ee30897b663de7
2018-01-26 17:24:05 -08:00
Becky Siegel
d450a9eb57 Respect default font size preference from browsers
We encountered an issue where PolyGerrit was not respecting browser
font preferences. Browser font preferences include both a default font
size and a minimum font size.

In the event that a font declared in px is smaller than the minimum font
size, the size is increased to equal the minimum font size. However,
if the font is declared in px and greater than the minimum, the
preferred font size is not taken into account.

Browsers' default font size is 16px [1], So instead of declaring the
base font in px (previously 13px), this change makes it a percentage
of the default font size. If the user has changed their default, this
is taken into account.

From this point, all other fonts will be declared in rems, which makes
it easier to base the new size off of the base font size of the <html>
tag, rather than ems which bases it on the container[2]. This allows us
to declare font sizes in a way more similar to pixels, yet relative.

A follow-up change will change all font size declaration to use rem from
em for consistency.

[1] https://stackoverflow.com/questions/29511983/is-the-default-font-size-of-every-browser-16px-why
[2] https://webdesign.tutsplus.com/tutorials/comprehensive-guide-when-to-use-em-vs-rem--cms-23984

Bug: Issue 8157
Change-Id: I04ec2c861b2fb288ec7556dfb655d7feea9c9157
2018-01-27 00:29:32 +00:00
kaspern
3d8223a3cd Merge changes I8ccca824,I184f3a57,I05432b20
* changes:
  Add `doneEdit` change action
  Refactor edit change action logic
  Replace `editLoaded` with `editMode`
2018-01-25 00:51:26 +00:00
Kasper Nilsson
808838e915 Replace editLoaded with editMode
Done for clarity and differentiation with `editPatchsetLoaded`.

Bug: Issue 4437
Change-Id: I05432b202921cad7f906a1cbe9ed68aaeac164cb
2018-01-24 15:45:28 -08:00
Luís Oliveira
40eb3f47cc Avoid spurious newlines in diffs with CRLF line endings
Commit d5d9a13ec8fa62f0c36df7b75a2231663056668f fixed Issue 5091 by
adding a newline to the end of each diff line. In files with CRLF line
endings, this causes spurious newlines as described in Issue 7164.

This tweaks the aforementioned fix to specifically target empty lines
thereby still ensuring that (empty) diff lines don't collapse to 0px
height while avoiding inserting spurious newlines elsewhere.

Bug: Issue 7164
Change-Id: Iafbbf004cfb588fc123988674bbce8dfabf4d2b8
2018-01-24 11:22:30 +00:00
Kasper Nilsson
b1e2307fda Fix review checkbox behavior in diff view
The saveReviewedState observer observes params.*, but should not set
reviewed state when view !== Gerrit.Nav.View.DIFF. This can (and did)
happen when the Gerrit.Nav API is used to change the view -- the
observer is triggered before the view is detached.

Bug: Issue 8192
Change-Id: I06c1875f6f515c0d001277e63eb7724728c85cba
2018-01-23 10:33:44 -08:00
Martin Fick
a0cc7845ea Merge "Add a keyboard shortcut [v] for toggling side-by-side / unified view." 2018-01-23 15:31:28 +00:00
Wyatt Allen
e515ff6c12 Do not collapse line numbers that are indicated in the URL
When users navigate to the diff view with a line number specified at the
end, depending on their context preference, the line might be in a
shared region that gets collapsed when the diff renders. With this
change, the location specified in the URL is prevented from being
collapsed by marking it as a "key" location.

Bug: Issue 5247
Change-Id: Ifd5827cd922b022cddb1601911a9ecea6a054f35
2018-01-22 14:03:24 -08:00
Wyatt Allen
0b2144b367 Allow convergent comment saves
Formerly, the save button would be disabled when attempting to edit a
comment to have the same content as what's already been saved. This can
be a confusing UX where it isn't clear why a comment cannot be saved.

Allow saving comments even when the text has not been changed.

Bug: Issue 8128
Change-Id: I615c38e0cc109ea87f58c9b8a9b7de28ec459b88
2018-01-18 14:51:41 -08:00
Kasper Nilsson
75bf5b9357 Add getFileContent to rest API interface
Change edits must be able to get file content from non edit patch sets.
This new function gets the file content and type, regardless of what
patch set is being referenced (edit or otherwise).

This change also uses the new function in gr-editor-view.

Bug: Issue 4437
Change-Id: Id0e395df42aa5c635d126573814cb4fdd61486cb
2018-01-16 18:05:46 -08:00
James Putman
376b5e9720 Add a keyboard shortcut [v] for toggling side-by-side / unified view.
Bug: Issue 7557
Change-Id: Ieae237f9bb1d2d614147d362f1b3478c0968ff2f
2018-01-13 22:44:20 -07:00
Paladox none
313e605fc6 Fix html syntax in gr-diff-preferences
Change-Id: Iaa5da5607b9ec90e0d80a7c906e316b6ef1b9687
2018-01-11 23:21:18 +00:00
Kasper Nilsson
6f3dd7b1ef Use separator in diff view
Replaces the plaintext forward slash separator.

Change-Id: I2828e2287551ae3c40b4f310ff72f97807f14aa9
2018-01-11 10:23:36 -08:00