17 Commits

Author SHA1 Message Date
Dave Borowitz
8cdc76ba4c Add @license tags to PG HTML and JS assets
These tags are preserved by the Closure compiler and vulcanize in order
to serve the license notices embedded in the outputs. In a standalone
Gerrit server, these license are also covered in the LICENSES.txt served
with the documentation. When serving PG assets from a CDN, it's less
obvious what the corresponding LICENSES.txt file is, since the CDN is
not directly linked to a running Gerrit server. Safer to embed the
licenses in the assets themselves.

Change-Id: Id1add1451fad1baa7916882a6bda02c326ccc988
2018-03-26 10:47:55 -04:00
Wyatt Allen
7e6519f5c3 Upgrade REST API interface methods for parent indices
To support diffing against individual parents of merge changes, teach
the get-diff and get-change-files API methods to understand parent index
base patches, as indicated by negative numbers.

Feature: Issue 4760
Change-Id: I54225e93d05e64ca223944cf3c93b09ee0a7fd70
2017-11-13 18:32:43 +00:00
Viktar Donich
d8d91278b2 Remove gapi-auth and consolidate it with default one
This change removes gr-gapi-auth and merge gr-gerrit-auth into one
gr-auth static API, exposed as Gerrit.Auth to enable cross-domain
configuration for embedded scenario.

Apparently, Google Platform JS library shares state across instances,
and as a result for embedded use case PolyGerrit requesting OAuth
sequence breaks other instances. To mitigate that, this change provides
an interface similar to Gerrit.Nav for setting OAuth access tokens.

``` js
Gerrit.Auth.setup(getToken, defaultOptions)
```

Gerrit.Auth.setup takes following parameters:
- getToken takes a function that returns Promise resolving to full token
object (including `access_token` and `expires_at` properties)
- defaultOptions may contain `credentials` fetch option that will be
used for all HTTP requests if provided

With the access_token PolyGerrit uses Gerrit's "faster CORS":
- REST API endpoints are prefixed with /a/ (after base url)
- access_token is added as URL param
- all but GET requests are made as POST
- POST requests have Content-Type as text/plain
- $ct URL param presents actual Content-Type
- $m URL param presents actual Cotnent-Type

Change-Id: I860bb84b30a2259d750a2239b7713c019b89b0e0
2017-08-08 13:16:59 -07:00
Viktar Donich
ade2e11a75 Use ETag and If-None-Match for GET /change/detail
This prevents regenerating JSON response if nothing changed.

Feature: Issue 6639
Change-Id: I1d542928d7b48a049cd4328f1a2ac1dcd1017cd6
2017-07-19 11:21:46 -07:00
Viktar Donich
e351535b27 Use BaseUrlBehavior when fetching OAuth config
Change-Id: I2a845758ef7671089c52672f80d8f43779eabb01
2017-06-29 10:28:11 -07:00
Viktar Donich
464ed4b886 Add auth provider for GAPI OAUTH2 and tests
The auth provider can be enabled with window.USE_GAPI_AUTH flag, which
is disabled by default.

gr-gapi-auth depends on oauthconfig plugin to provide auth config info.

https://developers.google.com/api-client-library/javascript/start/start-js

Feature: Issue 6489
Change-Id: I6d6da5231a766ac241b2a931076e2ae04aab03a6
2017-06-20 14:27:34 -07:00
Viktar Donich
cc58d5ae39 Extract auth logic from gr-rest-api-interface
First step for adding more auth provides (eg OAuth)

Feature: Issue 6489
Change-Id: I6c88e9fd92b67ae50a816bce12ed2412a9ec8c2d
2017-06-15 16:10:12 -07:00
Kasper Nilsson
73a04170a0 Refactor gr-rest-api-interface to use rest-client-behavior
Significant unnecessary code duplication existed between the two
files, most importantly an enum that existed and was mirrored in both
places. This change removes all duplicate code from the interface,
preferring the publicly accessible nature of the behavior, and changes
private function calls within the interface accordingly.

Change-Id: Ifbe10e445c03f13044b8ae07e0d3cd24cfb3284e
2017-05-31 18:40:07 +00:00
Paladox none
8b0d046dfb Fix PolyGerrit URLs to support prefixed URL
This updates most of polygerrit links to use the implementation added in
I2b2d704fe33c90ea2f2a2183fc79897642a48175 .

Change-Id: Ib3bb694969e903fd76a1dad13cfb642bde086142
2017-04-13 23:44:31 +01:00
Viktar Donich
7b6c299141 Group reviewer updates in the UI (integrate)
Picks up grouped reviewer updates and shows them in gr-message-list.

Bug: Issue 4383, Issue 5256
Change-Id: If799717294e806eccad4087b19566fd15618c600
2017-02-01 09:56:34 -08:00
Viktar Donich
ba69a1e192 Coalesce requests within change view
Fetch more data with GET /change/detail instead of multiple separate
GET requests. Fetch independent resources in parallel. Fixed change
actions jumping around.

First page load to full page down by ~25% (1050ms vs 1400ms on localhost,
expect even more on prod server)

Timeline before and after:
http://imgur.com/a/oEFdD

Bug: Issue 4406
Change-Id: Ib7c3c160513cbb29aad89fedabfacbfd271abf22
2016-11-16 20:25:14 -08:00
Kasper Nilsson
6eb9a84be9 Add handling for files with no extension to special sort
Due to substring logic, files with no extension were treated as files
with no path. This change ensures that these files are properly
alphabetized in the file-list.

Also adds a behavior test to the suite.

Bug: Issue 4697
Change-Id: I41df0db4ca981919d9e435e850737115fc97b8d9
2016-10-10 14:42:09 -07:00
Kasper Nilsson
028d382a5c Apply special file sorting to gr-comment-list
Files in the file list are sorted specially so that header files appear
before their corresponding source files. This change applies this same
sorting algorithm to the comment list.

In order to achieve this, the special file sort function was exposed
publicly -- removed from gr-rest-api-interface and put in a new file,
gr-file-path-behavior.

Bug: Issue 4586
Change-Id: I31079dcef0c3c2421b2561cedf69f68aaf653af4
2016-09-28 15:41:14 -07:00
Paladox none
f27498bd78 Update es6-promise polyfill to 3.3.0
Per https://gerrit-review.googlesource.com/#/c/86130/4/lib/js/BUCK

by @Andrew Bonventre

Change-Id: I6f4b6d16074ee0f2d948519cae81bed423b76db2
2016-09-13 22:19:23 +00:00
Paladox
914cf06b27 Add es6-promise for Internet Explorer
Plus it is required by the fetch polyfill, see
https://github.com/github/fetch#installation

Also see https://github.com/github/fetch/issues/114

This fixes the undefined Promise error in internet explorer 11, due to
Promises not being supported in Internet explorer and other browsers.

See http://caniuse.com/#feat=promises

Bug: Issue 4308
Change-Id: I93df9c89a9a98059292038dffe1655c3f4d503c5
2016-09-13 15:14:32 +00: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
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