35 Commits

Author SHA1 Message Date
Wyatt Allen
43ddaf6b1c Set line number hash using replaceState
When clicking a line number in the diff view, set the URL hash using
`history.replaceState` rather than `history.pushState` to avoid an
additional history entry.

Bug: Issue 4820
Change-Id: If2101508a49ac15e955d2981f7c7f93f22d5b9f9
2016-10-27 10:51:07 -07:00
Wyatt Allen
4e1d1b8427 Accept base patch line links
PolyGerrit uses the format b<line number> in URLs to indicate a specific
line number in the base patch, but the GWT UI would use the format of
a<line number>. Update PolyGerrit to understand both.

Bug: Issue 4792
Change-Id: I8d09be9cb952c66e085d3a4777c04e6d79eab518
2016-10-20 16:53:34 +00:00
Andrew Bonventre
a8e4332ba0 Remove extra network call to get change detail on diff view
An observer was causing an extra call to grab the change detail
when it wasn’t needed since it’s already called in _paramsChanged.

Change-Id: I9a9904145e5d88c377cd9d130a7f9a4be67454e3
2016-10-16 13:32:19 -07:00
Logan Hanks
610f80d3ec Add namespacing for keyboard shortcut disabling
The gr-overlay element attempts to manage disabling and enabling
keyboard shortcuts. When multiple gr-overlay elements are available
on a page and one of them opens immediately, that overlay tries to
disable keyboard shortcuts, but the other elements initialize as
closed and enable them.

This change offers a new method for disabling keyboard shortcuts.
The caller can pass in an identifier to enable or disable. If keyboard
shortcuts are disabled by one or more identifiers, then they are
suppressed.

Change-Id: I82fe6efd922f09279e76a2f2c8cb5781f3afe395
2016-10-14 14:05:43 -07:00
Becky Siegel
6c06e78cf6 Fix horizontal scrolling in file dropdown, comments, and gr diff view
Previously, long file names would display outside of the window size,
causing a horizontal scroll on mobile browsers.

With this change:
* In the file list on the change view, the rightControls are adjusted so
that they wrap on a new line on smaller/mobile screens.
* In the comment list, word-wrapping is used for long file paths
displayed above each comment.
* In the diff view, instead of displaying full paths in the dropdown,
the path is truncated to include an ellipsis, a slash and the file name
so that it can be seen both in the dropdown and also the native browser
select.

Bug: Issue 4722
Change-Id: Icd4644a45db71bc6666c21d62c864d91e9874654
2016-10-13 15:44:59 -07:00
Andrew Bonventre
99642e348e Merge "Default to unified view on small screen sizes" 2016-10-13 00:20:32 +00:00
Becky Siegel
74f531c6a6 Default to unified view on small screen sizes
Previously, the default view type was displayed for all screen sizes.
If side by side was the user's preference, and they viewed polygerrit
on mobile, side by side was displayed.

This change ignores user preference for small screen sizes (under 900
px wide). The user can still toggle to a split view, but unified will
be the first view shown.

Bug: Issue 4682
Change-Id: Id4e1cab17de433033e103c3cca582b7e9c656acf
2016-10-12 14:51:09 -07:00
Kasper Nilsson
624b070db7 Add dropdown for selecting diff view mode to file list
Setting persists for the duration of viewing a change. When a user
selects a new change, their default view mode is set.

Bug: Issue 4670
Change-Id: I4eade0e42c13bf2b3079ef38fb07239f98a243d8
2016-10-07 14:07:41 -07:00
Kasper Nilsson
76aaa8cb33 Check for modifiers before creating comment
In some cases, the "press c to comment" feature was overriding default
browser copy behavior. This change checks for modifiers before creating
comments. This functionality is factored out into a function for future
use.

Bug: Issue 3989
Change-Id: I3ebe0dec2f5436b8339d81d99d1287799ff3568b
2016-09-27 16:10:09 -07:00
beckysiegel
c47410c816 Focus and tab between diff preferences inputs
Previously, the diff preferences form did not automatically focus to the
first textfield and did not allow tabbing between input fields. This
change adds autofocus when the overlay is opened and allows for tabbing
between the other input fields in the modal.

Bug: Issue 4140
Change-Id: If15812bb4404ca4061597755eeaf68d4cae23b3f
2016-09-20 18:30:29 -07:00
Andrew Bonventre
04e57d6361 Add next/prev links to the diff view
Bug: Issue 4514
Change-Id: I39927b397fda8d6bb80b7e3a9144e5cfe620fb5a
2016-09-07 18:28:47 -04:00
Kasper Nilsson
0deb7e3fb7 Blur dropdowns after selection
Blurring dropdowns after selection enables a more shortcut-based
workflow.

Bug: Issue 3868
Change-Id: Ie35e5458f10540d0498b32d9bf03f5a6888c2232
2016-08-31 11:42:34 -07:00
Logan Hanks
78ad03c542 Fix diff mode selector initial state
When gr-diff-view attaches, it may need the user's preferences in order
to set the diff mode selector to the correct state.

In the course of testing this change, I realized that an overriding
diff mode selection wasn't sticking across pages, especially when moving
back and forth in history. Modified gr-change-view to also update the
diff mode from the user's preferences when it notices a different change
is being loaded.

Bug: Issue 4434
Change-Id: Id2041b55bf66d7de66f74d7765ed0db717caeebf
2016-08-25 15:29:29 -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
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
bdd4e3498c Move the diff cursor to line number specified by the URL hash
If the gr-diff-view is loaded with a line number address in the URL
hash, moves the diff cursor to that line.

Bug: Issue 4206
Change-Id: I359a29d7a3fd97b0ce72228aec3f49ae2295bfee
2016-06-21 08:47:36 -07:00
Wyatt Allen
a68b48e1f5 Update the URL hash with the selected diff line
Sets the URL hash to the address of the cursor when a user selects a
diff line (either by clicking the line number or using the 'c' hotkey).
If the cursor is on a line of the revision, the address is the line
number. If the cursor is on a line of the base patch, the address is the
letter 'b' followed by the line number. Otherwise the address is the
empty string.

Bug: Issue 4206
Change-Id: Ic85da197eb6264ea1111cc34e781dccbc24d4d40
2016-06-20 14:14:55 -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
5008b4491f Add a checkbox to hide ranged comments behind
Also adds concept of locally stored preferences.

Change-Id: Ib074a682228d5360a932af696e18967e8e3473be
2016-06-08 15:29:11 -07:00
Wyatt Allen
82ba696dd6 Update the diff mode switcher to use gr-select
Change-Id: I8cdbd4954be759a2fd3901e987b4d73c50983443
2016-06-08 10:29:06 -07:00
Urs Wolfer
c047fcd09d Fix usage of property '_projectConfig'
- gr-change-view: access with wrong name
- gr-diff-view: missing property declaration

Change-Id: I6751e16d80698fa86029d93a45ee54fc5a7b9b5d
2016-05-29 18:12:56 +02:00
Wyatt Allen
88678da403 Add support for images in diffs
If gr-diff recognizes that the file difference it's representing is
between images, it uses a different diff-builder that displays images
in a side-by-side-manner. In this case gr-diff will also make requests
for the image data itself, which it can pass down into the image-based
diff-builder.

Adds methods to gr-rest-api-interface to support rendering the data
relevant to image diffs. For images that are revisions of the current
change, provides "getChangeFileContents". For images that come from the
parent tree (i.e. if the basePatchNum is "PARENT") the interface
provides "getCommitInfo" to determine the SHA of the parent commit, and
"getCommitFileContents" which can get file contents for a given commit.

Bug: Issue 3822
Change-Id: I9be025b4e549fca97c87cdbeede6cb64dea5eac0
2016-05-26 12:02:29 -07:00
Wyatt Allen
0b6fe19256 Add keyboard shortcuts to diff-view and change-view's inline diffs
Includes the gr-diff-cursor in the relevant views and wires up the
relevant keyboard commands to move the cursor around. Adds the new
keyboard commands to the keyboard shortcuts dialog.

Bug: Issue 4033
Change-Id: If9f63c11d28c7864c64ce8c9cfed6da4fcf4666a
2016-05-18 11:11:02 -07:00
Andrew Bonventre
73d85d7545 Small cleanup within gr-diff and gr-diff-view
+ There is no longer a window resize handler needed in gr-diff.
+ The “show preferences” keyboard shortcut is now fixed.

Change-Id: I22b2ff358d345cff9ef40ade0bdcbb5cb71ba7f4
2016-05-15 13:16:52 -04:00
Andrew Bonventre
91c6293e3a Support “diff against” in the file list
Bug: Issue 3936
Change-Id: I07f242a8cb7be063a2d56dbe3f4b6a28143588c0
2016-05-11 19:23:01 -04:00
Wyatt Allen
f93f1c24ee Add toggle to PolyGerrit diff view to switch between diff styles
The gr-diff element was already capable of rendering diffs in either
side-by-side or unified style, but was configured by default to use
side-by-side. The GWT diff UI included an icon button toggle to switch
between these two styles above and to the right of the diff near the
"Diff View Preferences" button. This change introduces a selector in the
PolyGerrit UI to allow similar switching behavior.

Previously, the diff mode was encoded as a private property of the
gr-diff element. Now that the switcher is introduced at the same level
as the "Diff View Preferences" button (one level up from the gr-diff
element) it is changed to be a public property of the element so that it
can be changed through the parent view (in this case the gr-diff-view
element).

A dropdown is added to the gr-diff-view based in style on the
gr-patch-range-select element (which plays a similar role). This
dropdown has options for either of the two diff modes and controls the
diff display through a property on the view.

The view gets a new, computed property called _diffMode which encodes
which diff state should be displayed based on the changeViewState and
the user's preferences. The user's choice of diff view is persisted
across diff views, but is reverted to the preference when the change
view is visited.

A test is added to the gr-diff-view element.

Bug: Issue 3909
Change-Id: I00d93500f8d210394acc9c8f3398c9406ae74276
2016-05-09 15:56:23 -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
61bcdbc3db gr-ajax cleanup (gr-change-list-view)
Bug: Issue 3988
Change-Id: I1f312eba0e561f0c04296f42e8f8da5779077402
2016-05-04 16:26:08 +00:00
Andrew Bonventre
c80291ca05 Move gr-diff controls into gr-diff-view
This will allow for an easier time in implementing expanding
inline diffs by having gr-diff only responsible for rendering the
diff itself and not other controls.

Change-Id: I254ad5900091c731e2197590d6043c103216785e
2016-04-23 23:28:55 -04:00
Andrew Bonventre
2c6e16282a Refine sorting within the file list
+ Always place the Commit message at the top.
+ Put {.h|.hxx|.hpp} files before others with the same base name.

Bug: Issue 3852
Bug: Issue 4065
Change-Id: I5295a19734711516c69831fd8250f13f962cbba2
2016-04-15 18:27:01 +00:00
Andrew Bonventre
30344cc9a3 Remove gr-ajax/gr-request from gr-diff-view
Bug: Issue 3988
Change-Id: Ia34d881e7eb12904971c3cc47cac5aa1dbe08a3f
2016-04-05 16:49:13 -04:00
Andrew Bonventre
cfacb80095 Remove final uses of app.accountReady
Change-Id: I9ed0591d3c0fa673a7bcadbbee0b998b0a57eb05
2016-03-29 14:21: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
3509f8144f Fix failing gr-diff-view test
iron-a11y-keys-behavior doesn’t like commas apparently.

The keyboard shortcuts should call preventDefault() anyway, so
this is a proper fix that prevents the test key event from bubbling
up to the iron-a11y-keys-behavior logic.

Change-Id: I4b8120556db9146aa5eb9669db26e1737b031b51
2016-03-11 12:35:48 -05: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