33 Commits

Author SHA1 Message Date
Sadrul Habib Chowdhury
974bedb38f Show timestamp in the patchset picker
BUG: Issue 6933

Change-Id: I84627763c9979c08246d0ff592a2c2800af4a742
2017-12-12 18:54:09 -05:00
Wyatt Allen
a744e2303f Support for parent diff bases in merge changes
With this change, in merge changes, patch ranges can diff against a
specific parent (as indicated by a negative parent index) similarly to
the GWT UI.
- Parent options appear in patch range selectors when available.
- The router no longer redirects parent indexed patch ranges now that
  they are supported.
- The RevisionInfo class is added to house revision related functions in
  a form that's easily passed between components.
- On merge changes the default patch range base is labeled as
  "AutoMerge" rather than "Base".

Feature: Issue 4760
Change-Id: I221ba97e28be52f225f7d90f5f8c5a0f17ddb8c2
2017-11-21 17:41:15 -08:00
Becky Siegel
0853fd04b5 Use comment API to determine comment strings in patch range select
Change-Id: Ic81175fe428c550504e2ecf20026547e71db03fc
2017-11-13 16:41:42 -08:00
Becky Siegel
09e28e9cb7 Update patch range select to use changeComments
In a follow-up change it will fetch comment counts from gr-comment-api.

Change-Id: I4d98652d3f4efad723f18f4b4dc984ca52e40970
2017-11-13 20:30:58 +00:00
Becky Siegel
fde2da6dc2 Use gr-dropdown-list for diff view file select
The diff view file select used its own implementation of a dropdown,
which also had two versions, a native select for mobile and a custom
design for desktop.

gr-autocomplete-dropdown was designed so that it could be used in this
scenario as well, as it also has a native select built in.

This will also allow us to add comments in the dropdown (follow-up
change) and use Gerrit.Nav instead of generated URLs.

Change-Id: I5613bb8e327a3f6ae227bf69e64bfafbbfe09b6c
2017-11-08 14:28:36 -08:00
Kasper Nilsson
743845aa00 Remove unnecessary param from observer
Observing both revisions and _sortedRevisions in <gr-patch-range-select>
is unnecessary.

This change does not fix any bugs, but does simplify the code.

Change-Id: I01e5562e3ca40ba5f0be1d73036bbeb70313c7cf
2017-11-06 16:55:37 -08:00
Kasper Nilsson
05b2f914c0 Reverse the order of patchsets in range select
As discussed with UX (and as exists in GWTUI), highest-first order is a
more convenient ordering for patchset dropdowns.

Bug: Issue 7551
Change-Id: I6212d293accbee3772c2765f1e20e951f110d4d2
2017-11-03 15:07:54 -07:00
Becky Siegel
3a90cd92c2 Fix comments sometimes not showing up in patch set select
Previously, comments were not used as a parameter in the computed
function that calculated patch range values. Instead, it just used the
value of 'comments' when the patch dropdown was computed.

However, if comments were loaded after the dropdown values were
calculated, it was not updated to display the comment counts.

This change fixes the problem by using comments as a parameter in the
value calculations, and includes a default empty object in the case that
comments are not used as an input for the patch range selector
(currently the diff view).

Bug: Issue 7444
Change-Id: I2646800afc1632bf39b3c6a451c848669007ca18
2017-10-16 17:20:01 -07:00
Kasper Nilsson
1598e0e5ba Merge "Update patchset selector styles" 2017-10-03 16:55:05 +00:00
Becky Siegel
4c3fa09766 Update patchset selector styles
Also fixed patchset dropdown so that 'edit' does not display as
'Patchset edit'

Change-Id: I14f02f878d0e459644511cebfd3a2208cfd2e053
2017-10-03 15:58:16 +01:00
Kasper Nilsson
a7f7f3bf47 Remove two-way databinding from patch range select
Two-way databinding was causing some cyclical UI updating, resulting in
an incorrect redirect URL. Instead of binding to the patchNum and
basePatchNum in both directions, the patch-range-select fires an event
when it notices a change in the selected patchsets.

Bug: Issue 7336, Issue 7315, Issue 7316
Change-Id: Ifdf476dcf4fa1353d0b280d7e6dd25e4ef40865a
2017-10-03 12:41:30 +00:00
Becky Siegel
f24e030695 Fix file list header on mobile
- Fix CSS rules that were overridden for hiding elements
- Use padding rather than height to achieve desired height so that on a
  small screen when items wrap the header can grow

Bug: Issue 7317
Change-Id: I00b03bb1df4627d7f8a57b48fcccbb43d5b10284
2017-10-02 09:30:42 +01:00
Becky Siegel
4486c95b37 Further modify file-list CSS
Change-Id: I3dc96446ea307f4d6ae5bf60c00c290aa59e290e
2017-10-01 16:46:07 +01:00
Becky Siegel
fd7c71f1db Implement gr-dropdown-list in patch range select
This also moves the change reloading logic back to the change view,
where it gets updated patch ranges via a two-way data binding.

Change-Id: Ib09ad1a176ba96bac77a513d344226df029aef7b
2017-10-01 12:27:44 +01:00
Becky Siegel
89fe0501e1 Utilize gr-patch-range-select in the change view
Slight refactoring required in order to satisfy both use cases:
- Fire an event when patch range changes and let parent element
  handle it.
- Support comment strings
- availablePatches becomes an array of objects instead of an
  array of integers.

Change-Id: Ia8da9296f41eb2d45c9358d03fbec3940273ad9d
2017-09-14 13:47:38 -07:00
Becky Siegel
8d92d53db5 Annotation updates
Change-Id: I146f76b9dcc1a92e18acec01481ad280fb431868
2017-08-12 11:49:52 -07:00
David Ostrovsky
e6a6f44f8c Render change edits on change and diff screens
ORIGINALLY: Iafd4b80af53624027c347f0f443b4cdfde292e29

This change makes the change view and the diff view change edit aware.
Mutation operations on edit itself, like editing files in editor, are
beyond the scope of this change.

Change edits must be fetched with a separate change edit endpoint and
merged into the change.revisions object. The _number of an editInfo is
'edit'. It has a special property called 'basePatchNum' that marks
which patch set the edit is based on. In patch set selectors, the edit
is sorted right after its basePatchNum.

Alternative implementation considerations:

It could be easier to handle edits on the Polygerrit UI, if

  GET /changes/<id>/detail endpoint

would optionally include the change edit in the resulting
change.revsions map.

TODOs:
* Overwrite change.current_revision with change edit commit in some
  use cases
* Mark the change edit as Change Edit in the header of the change view
* Allow for modification of the edit in the change/diff view
* Disable commenting on files in edit patchsets
* Modify file list rows to have appropriate actions when edit is
  selected (e.g. allow revert, disable marking as reviewed)
* Identify and whitelist valid change/revision actions for an edit 

Bug: Issue 4437
Change-Id: Ia4690d20954de730cd625ac76920e849beb12f7c
2017-08-08 13:44:50 -07:00
Becky Siegel
8e174ab23a Update gr-select for Polymer 2
Polymer2 does not support type extension. As such, elements that rely on
it are  updated.

Instead of
<select is="gr-select"><select>

This will now be..
<gr-select>
  <select></select>
</gr-select>

This is similar to the implementation of iron-input, except that is more
complex, as it is supporting both type extention and non-type extension.
https://github.com/PolymerElements/iron-input/blob/master/iron-input.html

Bug: Issue 6371
Change-Id: I31091ff24791a9dc073b3325c7b0daa1580b69ef
2017-07-05 14:12:44 -07: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
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
Mike Samuel
0895052c01 Polygerrit now loads polymer-resin
polymer-resin intercepts polymer property assignments
before they reach XSS-vulnerable sinks like `href="..."`
and text nodes in `<script>` elements.

This follows the instructions in WORKSPACE for adding a new bower
dependency with kaspern's tweak to use the dependency in a rule so
that it's found.  //lib/js/bower_components.bzl has already been
rolled-back per those instructions.

The license is the polymer license as can be seen at
https://github.com/Polymer/polymer-resin/blob/master/LICENSE though
I'm not sure that //tools/js/bower2bazel.py recognizes it as such.

Docs for the added component are available at
https://github.com/Polymer/polymer-resin/blob/master/README.md
https://github.com/Polymer/polymer-resin/blob/master/getting-started.md

With this change, when I introduce an XSS vulnerability as below,
polymer-resin intercepts and stops it.

Patch that introduces a strawman vulnerability.

--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js
@@ -55,6 +55,10 @@
         url: '/q/status:abandoned',
         name: 'Abandoned',
       },
+      {
+        url: location.hash.replace(/^#/, '') || 'http://example.com/#fragment_echoed_here',
+        name: 'XSS Me',
+      },
     ],
   }];

---

Address kaspern's and paladox's comments.

---

Undo version bumps for bower dependencies.

---

Change Soy index template to parallel app/index.html.

---

update polymer-resin to version 1.1.1-beta

----

Load polymer-resin into polygerrit-ui/**/*_test.html

After this, I ran the tests with
  -l chrome
  -l firefox

I ran a handful of tests with -p and observed that the
console shows "initResin" is called before test cases start
executing.

These changes were done programmaticly by running the script below
(approximately) thus:
```
gerrit/ $ cd polygerrit-ui/app
app/ $ find . -name \*test.html | xargs perl hack-tests.pl
```

```
use strict;

sub removeResin($) {
  my $s = $_[0];
  $s =~ s@<link rel="import" href="[^"]*/polymer-resin/[^"]*"[^>]*>\n?@@;
  $s =~ s@<script src="[^"]*/polymer-resin/[^"]*"></script>\n?@@;
  $s =~ s@<script>\s*security\.polymer_resin.*?</script>\n?@@s;
  return $s;
}

for my $f (@ARGV) {
  next if $f =~ m@/bower_components/|/node_modules/@;

  system('git', 'checkout', $f);
  print "$f\n";

  my @lines = ();
  open(IN, "<$f") or die "$f: $!";
  my $maxLineOfMatch = 0;
  while (<IN>) {
    push(@lines, $_);
    # Put a marker after core loading directives.
    $maxLineOfMatch = scalar(@lines)
      if m@/webcomponentsjs/|/polymer[.]html\b|/browser[.]js@;
  }
  close(IN) or die "$f: $!";

  die "$f missing loading directives" unless $maxLineOfMatch;

  # Given ./a/b/c/my_test.html, $pathToRoot is "../../.."
  # assuming no non-leading . or .. components in the path from find.
  my $pathToRoot = $f;
  $pathToRoot =~ s@^\.\/@@;
  $pathToRoot =~ s@^(.*?/)?app/@@;
  $pathToRoot =~ s@\/[^\/]*$@@;
  $pathToRoot =~ s@[^/]+@..@g;

  my $nLines = scalar(@lines);
  open(OUT, ">$f") or die "$f: $!";

  # Output the lines up to the last polymer-resin dependency
  # loaded explicitly by this test.
  my $before = join '', @lines[0..($maxLineOfMatch - 1)];
  $before = removeResin($before);
  print OUT "$before";

  # Dump out the lines that load polymer-resin and configure it for
  # polygerrit.
  if (1) {
      print OUT qq'<link rel="import" href="$pathToRoot/bower_components/polymer-resin/standalone/polymer-resin-debug.html"/>
<script>
security.polymer_resin.install({allowedIdentifierPrefixes: [\'\']});
</script>
    ';
  }

  # Emit any remaining lines.
  my $after = join '', @lines[$maxLineOfMatch..$#lines];
  $after = removeResin($after);
  $after =~ s/^\n*//;
  print OUT "$after";

  close(OUT) or die "$f: $!";
}
```

---

update polymer-resin to version 1.2.1-beta

---

update Soy index template to new style polymer-resin initialization

----

fix lint warnings

----

Load test/common-test-setup.html into *_test.html

Instead of inserting instructions to load and initialize polymer-resin into
every test file, add a common-test-setup.html that does that and also fold
iron-test-helpers loading into it.

----

imported files do not need to load webcomponentsjs

Change-Id: I71221c36ed8a0fe7f8720c1064a2fcc9555bb8df
2017-05-30 23:16:09 -04:00
Kasper Nilsson
a59b9c587d ES6ify /gr-patch-range-select/*
Bug: Issue 6179
Change-Id: I9285ea11f9ff63244f1321cc5a3ba8466db56ae8
2017-05-16 14:41:17 -07:00
Viktar Donich
29e1ce5e84 Collection of prospective test flake fixes
Potentially related:
https://github.com/Polymer/web-component-tester/issues/505

Bug: Issue 5792
Change-Id: I9ab6e8e40d9811dd52906335426764c052907609
2017-03-30 13:46:58 -07:00
Becky Siegel
82ac09fdd9 Add rel="noopener" to external links
It is recommended to open external links using rel=noopener for both
security and performance reasons.

https://developers.google.com/web/tools/lighthouse/audits/noopener

Change-Id: Ic8fadadbf16f876231345dfdd300a0d2f6a658f2
2016-12-27 13:51:24 -08:00
Kasper Nilsson
111a46fd78 Hotfix for browser bug
Some browsers crash when allowed to have extremely long options in a
dropdown. This change truncates the user-supplied field of patch set
descriptions to 500 chars to prevent these crashes.

Bug: Issue 5085
Change-Id: I1fa5df3badb4ceca90519dfcd89369376992c432
2016-12-22 14:41:10 -05:00
Becky Siegel
a2ea634774 Changes to diff view for mobile
- Hide download link and file web links from patchsets.
- Add a full file path.
- Change next/prev buttons to be arrows on either side of full path
- Change subheader to flex/wrap so that the display mode wraps to the
next line instead of the second patch set item.

Bug: Issue 5114
Change-Id: Iefb8afe9d7e2417f8aa2070e52073708c052fa4f
2016-12-19 14:44:20 -08:00
Kasper Nilsson
f081d7236f UI side of patchset descriptions
Adds an editable label allowing the change owner to edit patchset
descriptions within the UI.

Also re-styles the dropdowns pertaining to patchsets for better UX.

Feature: Issue 4544
Change-Id: I15c0f8ab6a60c3a06482fe152539615d31eeae0f
2016-12-07 14:37:13 -08:00
Kasper Nilsson
3ea4311f66 Utilize patch set description in PG
This change adds the patch set description, if it exists, in every patch
set select in the change view and the diff view. Also includes
refactoring of an existing function into a behavior for use in other
files, and removes some unnecessary DOM nodes from the change-view.

http://imgur.com/a/rEhOF

Feature: Issue 4544
Change-Id: Id5f8d2d5750f3f7afc677e16c411327f53487b19
2016-11-11 10:47:37 -08:00
Becky Siegel
7416b235e4 Sync patch set dropdowns on navigation
Previously, on a changelist or file view, if you change the patchset
to a lower number and then click the back button, dropdown value did not
change properly. The issue was related to how the selected option was
rendered in a dom-if. This change refactors the gr-select element to fit this
use case.

Bug: Issue 4800
Change-Id: I66ee5b7aba5421a01ca79f9e72a853a73c32e589
2016-11-02 18:11:24 -07: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
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
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