120 Commits

Author SHA1 Message Date
Kasper Nilsson
581c1b957e Modify draft comment tooltip text
Bug: Issue 9452
Change-Id: Ie22fa838553c98a2a34b613cc7afb5b9a5688e00
2018-07-26 10:21:10 -07:00
Wyatt Allen
25ef4dd952 Set focus in confirm dialog when discarding draft
Change-Id: I6d221c2ca4494586c06e87732f9d8de2434fd599
2018-07-10 18:04:44 -07:00
Kasper Nilsson
86b28f498b Change minimum body font size to 1em
13px (1em in PG) should be the minimum body font size for a11y reasons.
Some other CSS is modified in this change in order to accomodate the
implications for the layout (mostly in the change actions).

Bug: Issue 9171
Change-Id: I7a7baa58bf5599888bd75e4b329fb4f75f198dc5
2018-06-25 20:44:19 -07:00
Wyatt Allen
18f0354a33 Report time between draft comment actions
Report the time between create, update or discard flows are initiated on
diff draft comments.

Change-Id: I71b2f955bfa65dde57307d67fda45069bffa02c0
2018-06-23 00:45:53 +00:00
Wyatt Allen
8635c8effb Make awaiting draft save feel even less blocking
When creating, updating or deleting draft comments, the diff containing
the draft does not need to be kept open for the underlying requests to
succeed. However, in a number of ways, the draft UI suggests that it
does. This results in the draft writing process feeling like a blocking
experience when it need not be.

Change the draft UI to feel less blocking:
- Instead of merely disabling the textarea when saving, the textarea is
  hidden and the presentation form of the message is shown immediately.
- Instead of disabling a draft as its being discarded, the draft
  disappears immediately.
- The `_savingMessage` is removed.

Bug: Issue 6970
Change-Id: Ia396f0f1780571def84be0d20f19c98bdb0b0cde
2018-06-22 09:37:43 -07:00
Wyatt Allen
261917281e Optionally log timing baselines with timer object
The gr-reporting "time" and "timeEnd" methods provide a convenient
mechanism for PolyGerrit components to record timings. However, because
they record the start time in a global dictionary keyed by the timing
name, they do not work well when multiple timers with the same key may
be reported simultaneously.

This multiple-timer scenario can come about when creating diff drafts,
which uses the CreateDraftComment timing key to time each draft,
potentially overwriting timers for earlier requests.

      Create      Create       Draft 1     Draft 2
      Draft 1     Draft 2      Created     Created
         |           |            |           |
         +------------------------+           |
         |           |            |           |
         |           +------------------------+
         |           |            |           |
Time ----+-----------+------------+-----------+---------------->
         |           |            |           |
        Save        Save        Timer    Timer attempts
        Timer       Timer       Ended    to end, but no
       Baseline    Baseline             timer is running!
                 (Overwrite!)

Provide a new method to record timing using timer objects that do not
store start times statefully. This gives a simple tool for the
concurrent timer cases, while preserving the convenient interface for
the timers for which concurrency is not an issue.

Change-Id: Ia5c030a16c87537700928df71a175821770e6814
2018-06-18 16:21:34 -07:00
Kasper Nilsson
429a3a1b40 Increase diff comment expand click target
Uses padding and negative margin to increase the click target for
expanding/collapsing diff comments.

Also listens for tap events instead of click events.

Bug: Issue 8896
Change-Id: I1e54fb703795f5e153da5bc2ccfd5dc575a6e03a
2018-06-15 09:13:59 -07:00
Wyatt Allen
846ac2fa99 Report timing for updating diff comment drafts
Record the time it takes to save, update and delete comments starting
with the handlers for user corresponding interactions.

Change-Id: I9f22dc2e015fa46afcd5d531a3c0d4906e0bec89
2018-06-05 16:20:34 +00:00
Kasper Nilsson
4313467582 Replace more CSS vars with constants
Swaps out various shades of red and black with --error-text-color and
--deemphasized-text-color, respectively.

Also removes some vestigial CSS that was never applied, and a hard-coded
check for a specific color in gr-autocomplete_test.

Change-Id: Ideee67300d8bbaa8e86fb1a2991492fa22a2ac43
2018-05-09 20:54:39 -07:00
viktard
9ca5ae2cbd Merge "Add robot svg to robot comment details" 2018-04-27 18:32:38 +00:00
Becky Siegel
891d60c3ef Add robot svg to robot comment details
Bug: Issue 8514
Change-Id: Iefc5d12986f62faa30f23c578b5261ab2bb1a703
2018-04-27 10:34:45 -07:00
Kasper Nilsson
7c394e06e4 Use variables in dialog and comment styling
Also cleans up some inconsistent styling in the various subcomponents of
the settings view.

Change-Id: I7b4487f84717cadd82c790785c3a83cf68eb8ce8
2018-04-27 12:00:26 +02:00
Kasper Nilsson
6fa20d3b3d Major refactor of button styles
Declares several CSS variables for styling buttons throughout the app
and uses them.

Removes the concept of a 'tertiary' button -- primary and secondary have
the exact same styling, so all tertiary buttons are changed to secondary
buttons and the existing secondary button (only replyBtn) is changed to
a primary button.

Also removes some of the many ways to modify a button color and
background -- there is no need for mixins to specifically style various
attributes of the paper-button when the ability to apply any styles
directly to it (via @apply --gr-button) is already supported.

Change-Id: I19a4114764df80b06175032b228a6ec63b414089
2018-04-20 14:02:59 +02:00
Kasper Nilsson
b0d03d047a Introduce deemphasized-text-color
Introduces and standardizes the various shades of medium dark gray used
throughout the app to #616161, or Material Gray 600.

Change-Id: I311155cfdba4381643451233dfafbfbdacd55e90
2018-04-19 08:21:49 +00:00
Kasper Nilsson
92ad99f345 Use the same text color throughout the app
Change-Id: I55f83e0dbdd83efcbe179683b87060440908e789
2018-04-16 10:15:33 +02:00
Wyatt Allen
ed22566dfe Guard comment textarea and overlays behind dom-if templates
Until the thread list was added, we rarely rendered a large number of
diff comments at once. A diff would add them incrementally in an
asynchronous loop, and even then, their number was reduced by being
filtered to to the given path and patch range.

Rendering all comments at once in the thread list exposed inefficiencies
in instantiating gr-diff-comments, and, for changes with many comments,
could temporarily lockup the browser.

The biggest cause of slowness in comment instantiation was the textarea
for editing. Because existing comments are not in an edit state by
default (...and because only the final comment in a thread can be edited
anyway ... assuming the user even chooses to edit ... assuming there
even is an authenticated user...) it's more efficient to put the
textarea in a dom-if until it's needed.

The overlays are also expensive but infrequently used. These are put
inside a dom-if as well.

Change-Id: I50702afe2b178221110ad3200c5e3862a7722c5d
2018-04-05 18:11:35 -07:00
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
Becky Siegel
07c44918f2 Robot comment styling updates
- Removes the blue background color
- Moves the robot comment specific buttons to be left aligned
- Makes the robot run ID selectable
- Displays the run ID as plain text if there's not a link

Bug: Issue 8514
Change-Id: Ic72caaf76977f5485655ef9ed45b4a7350397a9b
2018-03-15 16:59:13 +00:00
Becky Siegel
fc18085eeb Update gr-diff-comment unresolved toggle
This changes updates the unresolved toggle so that it only attempts to
save when explicitly tapped (as opposed to the value of resolved
changing on its own).

This was causing issues with comment synchronization between
gr-thread-view and diff comments, and also re-rendering the order of
comments in gr-thread-list within the dom-repeat.

This change also lets the resolved checkbox get selected via the enter
key.

Change-Id: I6065c745a0eabcf19df38f3cd6fd2c0d7e7434f3
2018-03-11 20:59:54 +00:00
Quinten Yearsley
9c056b7e73 Put robot comment actions inside a dom-if template
Change-Id: I3f971bf1001c9bf137670705efbd589d3bda1ec0
2018-02-20 11:18:33 -08: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
Kasper Nilsson
8f86afc906 Merge "Rename robot-comments-controls to robot-comment-controls" 2018-02-06 00:41:47 +00: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
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
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
3969b31414 Fix typo in element ID
Change-Id: I01a0fd76c0a0fc9f1f36857bb6982203fba0cbc8
2017-12-27 13:18:41 -08:00
Wyatt Allen
4f09a3f50c Merge "Restore confirm discard dialog for draft comments" 2017-12-08 20:04:56 +00:00
Kasper Nilsson
7f4e9d1762 Merge "Create a robot-comment-controls plugin endpoint" 2017-12-06 23:34:52 +00:00
Viktar Donich
3a12ebf262 Create a robot-comment-controls plugin endpoint
This is needed to add "Not important" link by a plugin.

Change-Id: Id8ef0a372e7111c12631cf41aafce9ac6a33e7f0
2017-12-06 14:02:52 -08:00
Kasper Nilsson
ed4e5f1f88 Modify resolved checkbox to call save()
Previously, the resolved checkbox called _saveDraft(). Using save()
instead disables the comment while waiting for the save request to
return.

Bug: Issue 7933
Change-Id: I44ce88094b271aa46a726a75aa4eb283b29f1a35
2017-12-06 13:39:52 -08:00
Kasper Nilsson
bc6f579528 Restore confirm discard dialog for draft comments
Draft comments with message text should have a confirm dialog when
discarded to prevent accidental data loss.

This is a regression introduced by I0dae814.

Bug: Issue 7900
Change-Id: Ibd9829ccf36a551445282e5cb0d37c1a6df46ab9
2017-12-05 14:33:13 -08:00
Kasper Nilsson
46a6c8eca2 Allow toggling resolved outside editing state
A recent change modified some comment editing UX. As a consequence, the
save button disabled state was erroneously based entirely on whether or
not the comment message had changed.

With this change:
- Save disabled state on a comment takes into account resolved state
- The resolved checkbox is always visible on an expanded draft comment
- When the resolved checkbox is modified on a non-`editing` draft
  comment, it is saved immediately

Bug: Issue 6023
Change-Id: I40b0b280129e5a76c13e38c97525f91a8e56482d
2017-12-05 13:20:22 -08:00
Becky Siegel
6de1489147 Refactor gr-button styling
A few changes:
- Utilize mixins within gr-button internally, so less styles have to be
  overridden by elements implementing their own button styles.
- All buttons have a hover background color, which is 12% black
  overlayed on top of its current background color.

Bug: Issue 7894
Change-Id: I4f2879aa0232912267bbf1290a1c800d024099a6
2017-12-01 16:15:19 -08:00
Kasper Nilsson
80ca288da5 Delete draft comment when saved with empty text
Recently, the comment editing UX was changed (the discard button was
removed from the editing view). This (obviously) made it impossible to
discard a draft comment whilst editing it.

Editing a comment, clearing the text, and saving now removes the
comment.

Bug: Issue 7832
Change-Id: I0dae814b9ce2e7a5b57530f839c708e59c215341
2017-11-27 16:37:11 -08:00
Kasper Nilsson
d66fb88099 Fix bad vertical align in collapsed comments
Bug: Issue 7762
Change-Id: I3b79b054a99b7ba5caf6b0ec9f48abdf6cdee0b7
2017-11-20 13:54:11 -08:00
Paladox none
1b3ea22cf5 PolyGerrit: Replace content with slot part 2
This change makes the following replacement:

<content select=".header"> replace it with
the slot equivalent.

Change-Id: Icc68576a3b44559775103163febd429194802981
2017-11-15 17:36:37 +00:00
Kasper Nilsson
6a25b28830 Merge "Clean up comment editing UX" 2017-11-09 21:50:01 +00:00
Kasper Nilsson
998e4cf5b7 Clean up comment editing UX
The removal of the 'Discard' button from comments in the editing state
complicated the UX of the 'Cancel' button a bit.

Previously:
- Discard deleted the draft completely.
- Cancel cancelled whatever edits were made, and reverted to the prior
  draft state. Cancel was also hidden on new drafts.

Currently:
- Cancel cancels whatever edits were made, and reverts to whatever edit
  was last stored.

This behavior is problematic, for a few reasons:
- Due to some vestigial code, the actual value of the comment's message
  (not just the buffer value '_messageText') was updated any time the
  draft comment was edited. This was done to prevent multiple drafts
  from being created on the same thread -- that issue was made obsolete
  by the removal of buttons from individual comments, and their
  consolidation to the thread level.
- If a user cancels a draft, then restarts it (having their text
  repopulated from localstorage), then cancels it again, the draft is
  rendered as a saved draft comment with the localstorage value, despite
  having never been saved at all.

So, with this change:
- Cancel cancels whatever edits were made.
- If a user tries to add a draft in the same place...
  - ...and the draft has been saved on the server, the textarea is
    prepopulated with the value from the comment received from the
    server.
  - ...and the draft has NOT been saved on the server, the textarea is
    rehydrated from localstorage.

This UX makes sense because...
- Case 1 occurs when a user clicks "Edit" on an existing draft comment -
  thus expecting to edit the content shown in the UI.
- Case 2 occurs when a user cancels a draft that they started
  constructing, but did not save -- thus there is no suggestion of any
  prepopulated value by the UI, _and_ the case in which a draft was
  erroneously cancelled during editing can be solved.

Bug: Issue 7709
Change-Id: Iacf9a91fbb0226aba3a518f56edd61f28c15a8ef
2017-11-09 11:38:59 -08:00
Kasper Nilsson
786438b7a6 Re-style comment removal button on diff comments
Some modifications to the styling of paper-button within gr-button
overrode a few deliberate styling decisions made in the delete comment
button (namely, color and padding). This change moves those CSS props
inside a styling mixin so that they are properly applied, and overload
the defaults from inside gr-button.

Change-Id: Ifdfc0a3959f4131e1bb86e8b66d70db2fde79077
2017-11-09 09:18:16 -08:00
Kasper Nilsson
060b612810 Remove hidden attribute from cancel button
The hidden attribute was erroneously left on the cancel button in diff
comments, causing it to not show up by default.

It showed up upon editing an existing draft because the hideOnPublished
CSS overrode the hack for the [hidden] attribute.

In addition, the buggy behavior was actually enforced by a buggy test --
it asserted that the button was not visible, but was labelled as "Cancel
is visible".

Bug: Issue 7664
Change-Id: I9e08c33fc4adf0f1465a52055a3308210625ffde
2017-11-06 17:08:02 -08:00
Wyatt Allen
5eab49acc0 Show comment saving progress indicator inside comments themselves
Bug: Issue 7596
Change-Id: I194bce633c8d746c24f71fc7f4bbdf2b87e5b883
2017-11-03 21:00:56 +00:00
Kasper Nilsson
9725fac3b7 Hide "Discard" button while editing comment
Bug: Issue 7491
Change-Id: I3514fd3f2ba63f138cd6eb52d32034d1ec8e47b0
2017-11-01 12:15:19 -07:00
Wyatt Allen
d563a713d6 Only erase unsaved drafts after save request succeeds
Unsaved diff drafts are kept in localstorage so they are not lost if
they do not get saved (for example, if the browser crashes). However,
this stored copy of the comment is cleared when the save request is
started, not after it succeeds. As such, if the save request fails (for
example, if the user credentials are invalid), the comment can be truly
lost.

With this change, the localstorage copy is only cleared after save
success. If the request fails, it allows the error message to appear
rather than showing a misleading "All comments saved" toast.

Bug: issue 7289
Change-Id: Id5c8144ecccec50de35f83af616b4e4915b62b5c
2017-10-27 12:56:04 -07:00
Wyatt Allen
fb3733ccb9 Prevent save while disabled
The [Save] button cannot be clicked when the comment is disabled (via
`pointer-events: disabled;` in the CSS), and clicking the [Save] button
results in setting disabled to true. However, it is possible to click
save again before the style is applied. It's also possible to trigger
the button using a non-pointer-event (such as a key). With this change,
an extra check is added to the [Save] button's click handler to prevent
clicks when the component is disabled.

Bug: Issue 6972
Change-Id: I16117af31c5e7b5d7d49a025eebb690d8802b64b
2017-10-24 16:34:10 -07:00
Wyatt Allen
489e2680a7 Show confirmation dialog before destructively discarding draft comments
The discard confirm dialog is added alongside the delete confirm dialog
and the dialog opening/closing code is refactored to work on either. The
confirm discard dialog only appears if the draft message is savable.

Feature: Issue 6984
Change-Id: I6d88a8734fa7736f685796790e02437b10c81f00
2017-10-19 13:11:54 -07:00
Becky Siegel
7eb2707811 Update order of buttons in gr-diff-comment
Because the order of buttons switched on most modals (cancel on left,
save on right) this updates the button order in gr-diff-comment for
consistency. Discard is moved to the left of 'save' and 'edit'.'

Change-Id: Ifa08976b77d99bb32fb1d6388f38843ad9e065fa
2017-10-16 09:43:23 -07:00
Becky Siegel
d1f95e97ae Update a few gr-button styles
- Diff preferences
  - Use link button, align right
- diff comment
  - use link button, modify colors

Change-Id: Ibdd232b1f30d2d0d3e36ce708afbd35470f6da44
2017-10-12 00:52:20 +00:00
Kasper Nilsson
aafba229bb Make comment removal element less obtrusive
This change moves the admin-only commment up above the comment next to
the date and styles it more subtly, saving vertical space.

Bug: Issue 7274
Change-Id: Id3095a5439e33055eec3191f6e31d17bb8640615
2017-09-23 00:48:28 +00:00
Kasper Nilsson
15cdbd4bd1 Invert comment action alignments
It makes the most sense (at least for left-to-right language speaking
locales) to have the most final and most destructive UI elements read
last, as interacting with those is the most permanent, and requires the
full context of the information in the element.

In diff comments, actions like 'Save' and 'Discard' (which affect the
entire comment) were on the left, whereas toggling the resolved state
was on the right. This change flips these alignments.

Bug: Issue 5924
Change-Id: Id00e19d662a983fad071df0fb866052b2001beb4
2017-09-22 13:39:47 -07:00
Wyatt Allen
494e7d42b7 Show toast messages for storing diff comment drafts
With this change, toast messages show when diff comments are being saved
and notify when saving is complete, even when the diff view is no-longer
loaded. This signal is intended to encourage users to write diff
comments and feel free to navigate away to view other parts of a change.

With this change, new toast messages are able to replace existing toast
messages.

Feature: Issue 6970
Change-Id: I5973673d85c73b14794cb5e5b21327dd0c27ec1d
2017-09-17 15:53:32 -07:00