174 Commits

Author SHA1 Message Date
Wyatt Allen
8b45290ed2 Report proportion of due_to_rebase chunks in loaded diffs
Change-Id: If48e4194352456d25e99e9f4d9df331226a3af4a
2018-02-14 13:06:32 -08:00
Becky Siegel
a638c38bce Merge "Update comment thread creation/removal to no longer use locationRange" 2018-02-13 17:27:54 +00: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
8f9664b7b7 Disallow commenting on an edit base
Bug: Issue 8289
Change-Id: I934f8b4ac2a6f1993ddb1ad55c3c05f9fd0182f9
2018-02-08 11:28:52 -08: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
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
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
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
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
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
Jeremy Roman
b4f32f7fee Use the basic multiplication sign for image dimensions.
The present symbol is "n-ary times operator" (U+2A09), from
the supplemental mathematical operators block, which renders
a much larger glyph than typical for basic multiplication.

This change replaces it with "multiplication sign" (U+00D7),
from the Latin-1 supplement block. It is the symbol ordinarily
used for multiplication (including dimensions), and is also
likely present in more fonts.

Change-Id: Id0e168bc61e25924e6b651587dc6b19a06c185f7
2018-01-02 18:29:48 +00:00
Becky Siegel
721361e16c Fix diff flashing when expand inline diffs
There was an issue where when a diff was expanded that had previously
been expanded, its old content was displayed, then cleared, then
reloaded.

Fix this by clearing diffs when they are collapsed.

Bug: Issue 7986
Change-Id: I3dc6460ff6fba4ff9f2cbd4b004b1e50d4b75814
2017-12-20 16:12:41 -08:00
Viktar Donich
a28dee069f Weblinks API for embedded scenario using Gerrit.Nav interface
Gerrit.Nav.setup() now takes a weblinks generator function as a third
parameter. Here's the function signature:

``` js
Gerrit.Nav.setup(navigate, generateUrl, generateWeblinks)
```

Weblinks generator function takes single payload parameter with
`type` property that determines which part of the UI is the consumer of
the weblinks. `type` property can be one of `file`, `change`, or
`patchset`.

For `file` type, payload will also contain string properties:
`repo`, `commit`, `file`.

For `pachset` type, payload will also contain string properties:
`repo`, `commit`.

For `change` type, payload will also contain string properties:
`repo`, `commit`.

If server provides weblinks, those will be passed as `options.weblinks`
property on the main payload object.

Change-Id: I0d9de3a295435304e2b6aad551112440075cf098
2017-12-08 20:20:10 -08:00
Wyatt Allen
617adb42a6 Merge "Add ability to add annotation layers from plugins" 2017-12-01 17:46:24 +00:00
Ravi Mistry
af1e0f8bf6 Add ability to add annotation layers from plugins
Highlights:
* Adds a new getDiffLayers function to gr-js-api-interface.js. This is
  invoked by gr-diff-builder.html when gathering annotation layers.
* New annotationApi function in gr-public-js-api.js for plugins to call.
* The annotationApi function returns an instance of the new
  GrAnnotationActionsInterface in gr-annotation-actions-js-api.js
* GrAnnotationActionsInterface has an API for the plugin to register an
  addLayerFunction and an optional method to call to get a notify callback.
* The new samples/coverage-plugin.html is an end-to-end example of how
  to invoke the new APIs to annotate lines.

Bug: Issue 7339
Change-Id: Ie51845e0b3564953aba5d7d41986cedce0337073
2017-11-29 12:27:51 -05:00
Becky Siegel
7fc7762ca0 Remove double line, padding, and drop shadow from inline diff view
Bug: Issue 7859
Change-Id: I56bae94e11e57dd4126518f29d5b2d08777f8a8e
2017-11-28 15:49:20 -08:00
Wyatt Allen
bde59814e6 Merge "Introduce diff builder for binary files" 2017-11-28 00:47:27 +00:00
Wyatt Allen
c56ece73e2 Support creating comments on merge parents
Bug: Issue 4760
Change-Id: I66ced578819b6f48d7d1535a54f1debf0e35374e
2017-11-27 11:09:58 -08:00
Wyatt Allen
bae435c7a6 Introduce diff builder for binary files
Binary files cannot be diffed like text, but for some binary changes,
the diff algorithm does yield binary differences as text. With this
change, the diff builder and processor are taught to render a special
message for (non-image) binary diffs, and will ignore the text
representation of the delta.

Bug: Issue 4031
Change-Id: I2dcdbe9def006de827a37c35c42606bc1c9cf4fc
2017-11-27 11:00:08 -08:00
Becky Siegel
6ca31cac3a Revert "Weblinks API for embedded scenario"
This reverts commit 253d1faa9ef7ac18116ba7493e4ae2e76df34388.

Reason for revert: breaks diff views

Change-Id: Iaeadcdca1156e4f7a3bb2a118a766a24f808348c
2017-11-22 01:15:23 +00:00
Viktar Donich
253d1faa9e Weblinks API for embedded scenario
In embedded scenario, Gerrit.Weblinks.setup may be called to set a
weblinks generator function.

Weblinks generator function takes single payload parameter with
`type` property that determines which part of the UI is the consumer of
the weblinks. `type` property can be one of `file`, `change`, or
`patchset`.

For `file` type, payload will also contain string properties:
`repo`, `commit`, `file`.

For `pachset` type, payload will also contain string properties:
`repo`, `commit`.

For `change` type, payload will also contain string properties:
`repo`, `commit`.

If server provides weblinks, those will be passed as `options.weblinks`
property on the main payload object.

Change-Id: Ie0f9edf959365869aa6eac6413d1efe29b61c9cb
2017-11-17 11:52:19 -08:00
Wyatt Allen
0309756d48 Fix column width styles for blame when fit-to-screen is enabled
Change-Id: I073658de061f1512b16e08b4540f23b864698a60
2017-09-30 14:54:01 +01:00
Wyatt Allen
ed628d7f37 Show blame in diff
With this change a blame column is added to the left side of diff
tables. The column is empty and hidden until blame is loaded. A button
is added to the change view to trigger a load of the blame for that
diff, as well as a unload it if already loaded. In this stage, the blame
information is non-interactive and only displays the SHA, date and
commit author.

Feature: Issue 6075
Change-Id: Ifcb951265d0e6339094e6b7c9574ec9c69e60b51
2017-09-27 18:55:42 -04:00
Becky Siegel
273b7ee2a2 Fix inability to leave multiple comments on line of code
This appears to have broke in I0428fead7a9d1f1dc5d6aa9efc3d81ecbe6b5c64

The computation to get the comment thread used to pass the range object,
but stopped doing so in the above change. This change adds it back in
and also separates the range string computation so that additional
unit tests can be added.

Bug: Issue 7081
Change-Id: I846d0c24b894fa0577f4fefaf8dcf4fc751daa15
2017-08-28 15:38:41 -07:00
Wyatt Allen
cf830b86b0 Remove test.only
Originally added by I0428fead7a9d1f

Change-Id: I663b667b6f05a4458288316517701938df0fb832
2017-08-18 22:29:18 +00:00
Becky Siegel
8d92d53db5 Annotation updates
Change-Id: I146f76b9dcc1a92e18acec01481ad280fb431868
2017-08-12 11:49:52 -07:00
Kasper Nilsson
380bf8ba6b Disable diff comments on edit patchsets
Includes a minor refactor of gr-diff comment construction logic.

Bug: Issue 4437
Change-Id: I0428fead7a9d1f1dc5d6aa9efc3d81ecbe6b5c64
2017-08-09 21:17:31 +00:00
Wyatt Allen
f0eb4bbf53 Harden gr-formatted-text agains slow/failed project configs
Formerly, if a formatted text component tried to render without the
project config (used by inner linked text components) it would
temporarily fall-back to rendering the unformatted (and un-linkified)
text via `.textContent` -- mirroring the behavior of gr-linked-text.

The result is formatted text elements (when rendered without a project
config) appear as one long line of text. Unlike linkification, however,
text can be accurately formatted with or without the project config --
so this disruptive, poor UX is unnecessary.

The formatted text component is updated to format text when the project
config has not provided, and to re-render when the config has been
provided.

In order to propagate project config loads to the formatted text
components hosted by diff comments, the REST calls must be made by the
diff thread component. To make this call, the thread must have the
project's name, so gr-diff-builder is updated to provide this name to
thread components.

Bug: Issue 6686
Change-Id: I8d09c740930500e99cb5f87b92f4d72f3f50a9ce
2017-08-01 16:14:45 -07:00
Wyatt Allen
dc8782d762 Centralized comment requests
Formerly, gr-diff would make its own REST calls for diff comments in the
patch range and path being viewed. However, these calls by the diff view
were redundant to the more general comment requests made by either
gr-diff-view (which requests all comments to support skipping to the
next file with comments) or gr-change-view (which requests comments
individually for each inline diff).

With this change, the diff component no longer loads comments for
itself, but is rather provided the comments from its host view via a
public property. In this way the host view can load the more-general
comment data, and filter it down for the diff view's params.

Introduces the gr-comment-api component to simplify loading and
filtering diff comments for use by diff views. By using this new
component:
* The diff view makes only one request for comments (including drafts
  and robot comments) to support skipping to the next comment and
  displaying comments in the diff view.
* The change view makes only one request for comments for all inline
  diffs.

Bug: Issue 5299
Change-Id: Ia14a01619f1f9881aa0d253fd3f49af9a17f3dce
2017-08-01 14:15:38 -07:00
Wyatt Allen
f07c69ce99 Merge "Revert "Remove styles for dueToRebase chunks"" 2017-07-20 18:08:49 +00:00
Alice Kober-Sotzek
4cb04e13cd Revert "Remove styles for dueToRebase chunks"
This reverts commit e048852365d1c7fc92bea2f597f117c13140f9a0.

Reason for revert: Highlighting which hunks were introduced by a rebase
is done as best-effort and will be clearly stated as such when we
announce this feature. Hence, we expect at least some false-negatives
at the moment (which we intend to get rid off over time). There aren't
any false-positives which we know of at the moment.

Change-Id: I103dbe8bea98d0bb7a417c02d371c2864dca015d
2017-07-20 16:32:58 +00:00
Becky Siegel
27a376907b Use updateStyles instead of customStyle
customStyle was removed in Polymer 2. Use updateStyles instead.

https://www.polymer-project.org/2.0/docs/upgrade#use-updatestyles-instead-of-customstyle

Change-Id: If89441dda76c39ed3b1db89a123100c06d5c3532
2017-07-17 11:11:27 -07:00
Becky Siegel
08ca826bce Fix the target row highlight on Firefox
Previiously, when pressing j/k on a change view and a horizontal line
appeared, in firefox, the rows jumped around a bit, as the bottom
border added an additional pixel of height.

Instead, this change uses a box shadow to simulate a bottom border.
The box shadow approach did not work on the table row, but instead had
to be applied to the table cell itself (in the target row)

Bug: Issue 6079
Change-Id: I7b80ef119f5ef0c8ad6cad51858edf2ac9c325da
2017-06-29 17:14:38 +00:00
Wyatt Allen
e048852365 Remove styles for dueToRebase chunks
While the due_to_rebase signal gives false-positives and false-negatives
(Issue 6583) do not style the marked chunks differently.

Change-Id: Ic716dcf259c4f4f0ef09510e37ce744c1d4082e0
2017-06-27 09:32:34 -07:00
Wyatt Allen
6df3f492b9 Confirmation for rendering large diffs with whole file
If the user views a very large diff while "Whole file" is enabled in
their preferences, rendering may lock up their browser. With this
change, instead of rendering, users are warned and allowed to bypass the
warning (risking browser lock up) or render with a context that is less
than whole file.

Bug: Issue 6402
Change-Id: I6e97c06598fb5f6900c925127ab6a99693b8aa7f
2017-06-15 12:02:35 -07:00
Wyatt Allen
380ad8210b Remove GPU acceleration hinting for diff scroll
Bug: Issue 6378
Change-Id: I5550bd6a0bad95b0c113c3b75fafe2c25c038b0d
2017-06-13 09:12:24 -07:00
Alice Kober-Sotzek
d1a2e07e4f Merge changes from topic 'improve-diff-for-rebase'
* changes:
  Highlight hunks which are due to rebase on PolyGerrit
  Copy due_to_rebase to subgroups in gr-diff-processor
  Move diff tests from RevisionIT to RevisionDiffIT
  Mark hunks which are present due to a rebase when diffing patch sets
2017-06-12 13:20:22 +00:00
Becky Siegel
0f3ef15b8c Merge "Fix line numbers in shadow-dom" 2017-06-09 21:41:07 +00:00
Alice Kober-Sotzek
ec44e83877 Highlight hunks which are due to rebase on PolyGerrit
Change-Id: Ifd31c8b2d31d71ff19060da56d81b64954f4fdb7
2017-06-09 13:38:50 +02:00
Becky Siegel
cb9afdc18b Fix line numbers in shadow-dom
Another border-box issue, this time with .lineNum:before.

Bug: Issue 6372
Change-Id: Ic6521090775f2a990b4fa7b7f36c5989151ce2ac
2017-06-09 00:12:43 +00:00
Kasper Nilsson
3e3c79646a Add a11ySuite call to gr-diff_test
a11ySuite is a wct function that tests for basic a11y features. For
more, see https://goo.gl/P15eE6

Bug: Issue 6435
Change-Id: I6bb3852de43838b9d3009578cb42dfdfb02e9bff
2017-06-07 11:07:36 -07:00
Kasper Nilsson
40ea3ade99 Improve a11y for diff viewing
Adds an aria-label to added and removed rows marking the row as "added"
or "removed" for screen readers. As part of this change, the <tr>
elements that make up the diff are now focusable.

Test plan:
- Somewhat included as a part of testing this functionality is the use
of WCT's a11ySuite function[1]. This will be introduced in a later
change.

[1] https://goo.gl/P15eE6

Bug: Issue 6435
Change-Id: I676fc171d404ca6e8e9276965192b1452595fa61
2017-06-06 17:25:32 -07:00
Wyatt Allen
27a7a367b1 Merge "Add polygerrit-ui/app/test/common-test-setup.html" 2017-06-06 00:40:15 +00:00
Becky Siegel
a4fc6de235 Fix various selectors for shadow dom
https://www.polymer-project.org/2.0/docs/devguide/style-shadow-dom

Bug: Issue 6372
Change-Id: I1918e86b31d4fa02b67d1b0e5ef9ae8f48877257
2017-06-05 22:42:22 +00:00
Mike Samuel
e07c4b2ea1 Add polygerrit-ui/app/test/common-test-setup.html
This is a partial roll-forward of c/106190

This replaces all loads of iron-test-helpers with a load of a file
that wraps it, and adds that file to test files that do not currently
load iron-test-helpers.

A future CL will also install polymer-resin via common-test-helpers.html.

I tested by running

$ WCT_ARGS="-l chrome" ./polygerrit-ui/app/run_test.sh

Change-Id: Ifb3cd2c8db13d724f57e56e7e78045470d103a43
2017-06-05 22:10:12 +00:00
Wyatt Allen
21e6b7f207 Close race condition that mixed content from other diffs
Previously, when a diff was reloaded, it would clear the diff content
(the previous diff) and open requests for the data regarding the new
diff. When the requests finished, it would cancel async processing and
start it again on the new data. In this arrangement, a narrow race
condition was present where the async rendering could emit a diff from
the previous diff after the diff table had been cleared, but before the
network requests resolved -- resulting is content form the previous diff
appearing in the new one.

With this change, the async processing is cancelled at the same time
that the diff content is cleared.

Bug: Issue 6170
Change-Id: Ie5a807082ab51156595f9eeb9ba6c958d41e890a
2017-06-05 09:19:00 -07:00
Becky Siegel
b159a7f5cc Update styles for shadow dom
- Create a shared style module that is included in every custom element
- Add the shared style module to each existing element

Change-Id: I1ee382955afe4ff630548a6640e7c4d03688849d
2017-06-02 14:54:03 -07:00
Wyatt Allen
c601abccc3 Revert "Polygerrit now loads polymer-resin"
This reverts commit 0895052c01ac5ac657a9763d2ad9967d9ae55c18.

Reason for revert: issue 6387

Change-Id: I14e00addeab53606952aa3ea2d45a74eac7a9d8a
2017-06-02 09:37:37 -07:00
Wyatt Allen
2f0df3d255 Merge "Polygerrit now loads polymer-resin" 2017-06-01 18:36:38 +00:00