2016-03-04 17:48:22 -05:00
<!--
2018-03-26 10:04:27 -04:00
@license
2016-03-04 17:48:22 -05:00
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
< link rel = "import" href = "../../../bower_components/polymer/polymer.html" >
2017-06-19 11:27:22 -07:00
< link rel = "import" href = "../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.html" >
2016-03-04 17:48:22 -05:00
< link rel = "import" href = "../../../bower_components/iron-autogrow-textarea/iron-autogrow-textarea.html" >
2017-12-06 13:59:46 -08:00
< link rel = "import" href = "../../../styles/shared-styles.html" >
2018-05-14 12:59:23 -07:00
< link rel = "import" href = "../../core/gr-reporting/gr-reporting.html" >
2017-12-06 13:59:46 -08:00
< link rel = "import" href = "../../plugins/gr-endpoint-decorator/gr-endpoint-decorator.html" >
< link rel = "import" href = "../../plugins/gr-endpoint-param/gr-endpoint-param.html" >
2016-03-04 17:48:22 -05:00
< link rel = "import" href = "../../shared/gr-button/gr-button.html" >
2017-10-18 13:22:43 -07:00
< link rel = "import" href = "../../shared/gr-confirm-dialog/gr-confirm-dialog.html" >
2016-03-04 17:48:22 -05:00
< link rel = "import" href = "../../shared/gr-date-formatter/gr-date-formatter.html" >
2016-11-08 15:49:05 -08:00
< link rel = "import" href = "../../shared/gr-formatted-text/gr-formatted-text.html" >
2018-04-27 10:33:14 -07:00
< link rel = "import" href = "../../shared/gr-icons/gr-icons.html" >
2017-05-08 10:40:06 -07:00
< link rel = "import" href = "../../shared/gr-overlay/gr-overlay.html" >
2016-05-03 15:14:57 -04:00
< link rel = "import" href = "../../shared/gr-rest-api-interface/gr-rest-api-interface.html" >
2017-05-08 10:40:06 -07:00
< link rel = "import" href = "../../shared/gr-storage/gr-storage.html" >
2017-12-06 13:59:46 -08:00
< link rel = "import" href = "../../shared/gr-textarea/gr-textarea.html" >
2017-03-10 16:37:17 -08:00
< link rel = "import" href = "../../shared/gr-tooltip-content/gr-tooltip-content.html" >
2017-05-08 10:40:06 -07:00
< link rel = "import" href = "../gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog.html" >
< script src = "../../../scripts/rootElement.js" > < / script >
2016-03-04 17:48:22 -05:00
< dom-module id = "gr-diff-comment" >
< template >
2017-06-01 15:31:55 -07:00
< style include = "shared-styles" >
2016-03-04 17:48:22 -05:00
:host {
display: block;
2016-11-08 15:49:05 -08:00
font-family: var(--font-family);
2016-12-07 13:36:49 -08:00
padding: .7em .7em;
2016-03-04 17:48:22 -05:00
--iron-autogrow-textarea: {
2017-07-24 10:27:27 -07:00
box-sizing: border-box;
2016-03-04 17:48:22 -05:00
padding: 2px;
};
}
2017-06-05 14:40:54 -07:00
:host([disabled]) {
2016-03-04 17:48:22 -05:00
pointer-events: none;
}
2018-06-12 16:18:34 -07:00
:host([disabled]) .actions,
:host([disabled]) .robotActions,
2017-11-02 18:17:52 -07:00
:host([disabled]) .date {
2016-03-04 17:48:22 -05:00
opacity: .5;
}
2018-06-12 16:18:34 -07:00
:host([discarding]) {
display: none;
}
2016-03-04 17:48:22 -05:00
.header {
2017-11-20 13:54:11 -08:00
align-items: baseline;
2016-10-06 10:18:32 -07:00
cursor: pointer;
2016-03-04 17:48:22 -05:00
display: flex;
font-family: 'Open Sans', sans-serif;
2018-06-15 09:13:59 -07:00
margin: -.7em -.7em 0 -.7em;
padding: .7em;
2016-03-04 17:48:22 -05:00
}
2016-11-08 15:49:05 -08:00
.container.collapsed .header {
2018-06-15 09:13:59 -07:00
margin-bottom: -.7em;
2016-11-08 15:49:05 -08:00
}
2016-10-06 10:18:32 -07:00
.headerMiddle {
2018-04-16 17:04:22 +02:00
color: var(--deemphasized-text-color);
2016-03-04 17:48:22 -05:00
flex: 1;
2016-10-06 10:18:32 -07:00
overflow: hidden;
2016-03-04 17:48:22 -05:00
}
.authorName,
2017-07-06 13:32:40 -07:00
.draftLabel,
.draftTooltip {
2017-09-08 13:12:41 -07:00
font-family: var(--font-family-bold);
2016-03-04 17:48:22 -05:00
}
2017-07-06 13:32:40 -07:00
.draftLabel,
.draftTooltip {
2018-04-17 16:23:08 +02:00
color: var(--deemphasized-text-color);
2016-03-04 17:48:22 -05:00
display: none;
}
.date {
justify-content: flex-end;
margin-left: 5px;
2017-05-08 10:40:06 -07:00
min-width: 4.5em;
text-align: right;
2016-10-06 10:18:32 -07:00
white-space: nowrap;
2016-03-04 17:48:22 -05:00
}
a.date:link,
a.date:visited {
2018-04-16 17:04:22 +02:00
color: var(--deemphasized-text-color);
2016-03-04 17:48:22 -05:00
}
.actions {
display: flex;
2017-09-22 10:51:56 -07:00
justify-content: flex-end;
2016-03-04 17:48:22 -05:00
padding-top: 0;
}
.action {
2017-10-11 17:27:11 -07:00
margin-left: 1em;
2017-09-22 10:51:56 -07:00
}
2018-03-14 15:26:45 -07:00
.robotActions {
display: flex;
justify-content: flex-start;
padding-top: 0;
}
.robotActions .action {
/* Keep button text lined up with output text */
margin-left: -.3rem;
margin-right: 1em;
}
2017-09-22 10:51:56 -07:00
.rightActions {
display: flex;
justify-content: flex-end;
2016-03-04 17:48:22 -05:00
}
.editMessage {
display: none;
2017-01-11 09:55:59 -08:00
margin: .5em 0;
width: 100%;
2016-03-04 17:48:22 -05:00
}
2016-12-07 13:36:49 -08:00
.container:not(.draft) .actions .hideOnPublished {
2016-03-04 17:48:22 -05:00
display: none;
}
.draft .reply,
.draft .quote,
2016-11-29 16:46:12 -08:00
.draft .ack,
2016-03-04 17:48:22 -05:00
.draft .done {
display: none;
}
2017-07-06 13:32:40 -07:00
.draft .draftLabel,
.draft .draftTooltip {
2016-03-04 17:48:22 -05:00
display: inline;
}
.draft:not(.editing) .save,
2017-12-05 11:03:52 -08:00
.draft:not(.editing) .cancel {
2016-03-04 17:48:22 -05:00
display: none;
}
.editing .message,
.editing .reply,
.editing .quote,
2016-11-29 16:46:12 -08:00
.editing .ack,
2016-03-04 17:48:22 -05:00
.editing .done,
2017-02-22 17:05:05 -08:00
.editing .edit,
2017-11-01 12:15:19 -07:00
.editing .discard,
2017-02-22 17:05:05 -08:00
.editing .unresolved {
2016-03-04 17:48:22 -05:00
display: none;
}
.editing .editMessage {
display: block;
}
2016-10-06 10:18:32 -07:00
.show-hide {
margin-left: .4em;
}
2016-12-07 13:36:49 -08:00
.robotId {
2018-04-17 16:23:08 +02:00
color: var(--deemphasized-text-color);
2016-12-07 13:36:49 -08:00
margin-bottom: .8em;
margin-top: -.4em;
}
2018-04-27 10:33:14 -07:00
.robotIcon {
margin-right: .2em;
/* because of the antenna of the robot, it looks off center even when it
is centered. artificially adjust margin to account for this. */
margin-top: -.3em;
}
2016-12-07 13:36:49 -08:00
.runIdInformation {
2018-03-14 15:26:45 -07:00
margin: .7em 0;
2016-12-07 13:36:49 -08:00
}
.robotRun {
margin-left: .5em;
}
.robotRunLink {
margin-left: .5em;
}
2016-10-06 10:18:32 -07:00
input.show-hide {
display: none;
}
label.show-hide {
2018-04-17 16:23:08 +02:00
color: var(--comment-text-color);
2016-10-06 10:18:32 -07:00
cursor: pointer;
display: block;
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-26 13:49:01 -08:00
font-size: .8rem;
2016-10-06 10:18:32 -07:00
height: 1.1em;
margin-top: .1em;
}
#container .collapsedContent {
display: none;
}
#container.collapsed {
padding-bottom: 3px;
}
#container.collapsed .collapsedContent {
display: block;
overflow: hidden;
padding-left: 5px;
text-overflow: ellipsis;
white-space: nowrap;
}
#container.collapsed .actions,
2016-11-08 15:49:05 -08:00
#container.collapsed gr-formatted-text,
2017-05-03 10:03:35 -07:00
#container.collapsed gr-textarea {
2016-10-06 10:18:32 -07:00
display: none;
}
2017-02-22 17:05:05 -08:00
.resolve,
.unresolved {
align-items: center;
display: flex;
flex: 1;
2017-09-22 10:51:56 -07:00
margin: 0;
2017-01-04 16:45:21 -08:00
}
.resolve label {
2018-04-17 16:23:08 +02:00
color: var(--comment-text-color);
2017-01-04 16:45:21 -08:00
}
2017-05-08 10:40:06 -07:00
gr-confirm-dialog .main {
display: flex;
flex-direction: column;
width: 100%;
}
#deleteBtn {
2017-05-18 16:34:17 -07:00
display: none;
2017-11-09 09:18:16 -08:00
--gr-button: {
2018-04-16 17:04:22 +02:00
color: var(--deemphasized-text-color);
2017-11-09 09:18:16 -08:00
padding: 0;
}
2017-05-08 10:40:06 -07:00
}
2017-05-18 16:34:17 -07:00
#deleteBtn.showDeleteButtons {
display: block;
}
2016-03-04 17:48:22 -05:00
< / style >
2016-06-09 16:08:04 -07:00
< div id = "container"
class="container"
on-mouseenter="_handleMouseEnter"
on-mouseleave="_handleMouseLeave">
2018-06-15 09:13:59 -07:00
< div class = "header" id = "header" on-tap = "_handleToggleCollapsed" >
2016-03-04 17:48:22 -05:00
< div class = "headerLeft" >
< span class = "authorName" > [[comment.author.name]]< / span >
2017-07-06 13:32:40 -07:00
< span class = "draftLabel" > DRAFT< / span >
< gr-tooltip-content class = "draftTooltip"
2017-03-10 16:37:17 -08:00
has-tooltip
2018-07-26 10:21:10 -07:00
title="This draft is only visible to you. To publish drafts, click the 'Reply' or 'Start review' button at the top of the change or press the 'A' key."
2017-03-10 16:37:17 -08:00
max-width="20em"
2017-07-06 13:32:40 -07:00
show-icon>< / gr-tooltip-content >
2016-03-04 17:48:22 -05:00
< / div >
2016-10-06 10:18:32 -07:00
< div class = "headerMiddle" >
< span class = "collapsedContent" > [[comment.message]]< / span >
< / div >
2017-09-22 11:17:57 -07:00
< gr-button
id="deleteBtn"
link
2018-04-17 09:08:47 +02:00
secondary
2017-09-22 11:17:57 -07:00
class$="action delete [[_computeDeleteButtonClass(_isAdmin, draft)]]"
on-tap="_handleCommentDelete">
(Delete)
< / gr-button >
2016-03-04 17:48:22 -05:00
< a class = "date" href $ = " [ [ _computeLinkToComment ( comment ) ] ] " on-tap = "_handleLinkTap" >
2017-02-28 14:58:20 -08:00
< gr-date-formatter
has-tooltip
date-str="[[comment.updated]]">< / gr-date-formatter >
2016-03-04 17:48:22 -05:00
< / a >
2016-10-06 10:18:32 -07:00
< div class = "show-hide" >
< label class = "show-hide" >
< input type = "checkbox" class = "show-hide"
2016-10-10 17:31:56 -07:00
checked$="[[collapsed]]"
2016-10-06 10:18:32 -07:00
on-change="_handleToggleCollapsed">
2016-10-10 17:31:56 -07:00
[[_computeShowHideText(collapsed)]]
2016-10-06 10:18:32 -07:00
< / label >
< / div >
2016-03-04 17:48:22 -05:00
< / div >
2017-11-02 18:17:52 -07:00
< div class = "body" >
< template is = "dom-if" if = "[[comment.robot_id]]" >
< div class = "robotId" hidden $ = " [ [ collapsed ] ] " >
2018-04-27 10:33:14 -07:00
< iron-icon class = "robotIcon" icon = "gr-icons:robot" > < / iron-icon >
2017-11-02 18:17:52 -07:00
[[comment.robot_id]]
< / div >
< / template >
2018-04-05 10:48:03 -07:00
< template is = "dom-if" if = "[[editing]]" >
< gr-textarea
id="editTextarea"
class="editMessage"
autocomplete="on"
monospace
disabled="{{disabled}}"
rows="4"
text="{{_messageText}}">< / gr-textarea >
< / template >
2018-03-14 15:26:45 -07:00
<!-- The message class is needed to ensure selectability from
gr-diff-selection.-->
2017-11-02 18:17:52 -07:00
< gr-formatted-text class = "message"
content="[[comment.message]]"
no-trailing-margin="[[!comment.__draft]]"
collapsed="[[collapsed]]"
config="[[projectConfig.commentlinks]]">< / gr-formatted-text >
2018-03-14 15:26:45 -07:00
< div hidden $ = " [ [ ! comment . robot_run_id ] ] " class = "message" >
2017-11-02 18:17:52 -07:00
< div class = "runIdInformation" hidden $ = " [ [ collapsed ] ] " >
Run ID:
2018-03-14 15:26:45 -07:00
< template is = "dom-if" if = "[[comment.url]]" >
< a class = "robotRunLink" href $ = " [ [ comment . url ] ] " >
< span class = "robotRun link" > [[comment.robot_run_id]]< / span >
< / a >
< / template >
< template is = "dom-if" if = "[[!comment.url]]" >
< span class = "robotRun text" > [[comment.robot_run_id]]< / span >
< / template >
2017-11-02 18:17:52 -07:00
< / div >
2017-01-04 16:45:21 -08:00
< / div >
2017-11-02 18:17:52 -07:00
< div class = "actions humanActions" hidden $ = " [ [ ! _showHumanActions ] ] " >
< div class = "action resolve hideOnPublished" >
< label >
< input type = "checkbox"
2018-03-08 17:29:09 -08:00
id="resolvedCheckbox"
checked="[[resolved]]"
2017-11-02 18:17:52 -07:00
on-change="_handleToggleResolved">
Resolved
< / label >
< / div >
< div class = "rightActions" >
2018-04-17 09:08:47 +02:00
< gr-button
link
secondary
class="action cancel hideOnPublished"
2017-11-06 17:02:06 -08:00
on-tap="_handleCancel">Cancel< / gr-button >
2018-04-17 09:08:47 +02:00
< gr-button
link
secondary
class="action discard hideOnPublished"
2017-11-02 18:17:52 -07:00
on-tap="_handleDiscard">Discard< / gr-button >
2018-04-17 09:08:47 +02:00
< gr-button
link
secondary
class="action edit hideOnPublished"
2017-11-02 18:17:52 -07:00
on-tap="_handleEdit">Edit< / gr-button >
2018-04-17 09:08:47 +02:00
< gr-button
link
secondary
disabled$="[[_computeSaveDisabled(_messageText, comment, resolved)]]"
class="action save hideOnPublished"
on-tap="_handleSave">Save< / gr-button >
2017-11-02 18:17:52 -07:00
< / div >
2016-03-04 17:48:22 -05:00
< / div >
2018-03-14 15:26:45 -07:00
< div class = "robotActions" hidden $ = " [ [ ! _showRobotActions ] ] " >
2018-02-14 10:41:24 -08:00
< template is = "dom-if" if = "[[isRobotComment]]" >
2018-04-17 09:08:47 +02:00
< gr-button
link
secondary
class="action fix"
2018-02-14 10:41:24 -08:00
on-tap="_handleFix"
disabled="[[robotButtonDisabled]]">
Please Fix
< / gr-button >
2018-03-14 15:26:45 -07:00
< gr-endpoint-decorator name = "robot-comment-controls" >
< gr-endpoint-param name = "comment" value = "[[comment]]" >
< / gr-endpoint-param >
< / gr-endpoint-decorator >
2018-02-14 10:41:24 -08:00
< / template >
2017-09-22 10:51:56 -07:00
< / div >
2016-03-04 17:48:22 -05:00
< / div >
< / div >
2018-04-05 10:48:03 -07:00
< template is = "dom-if" if = "[[_enableOverlay]]" >
< gr-overlay id = "confirmDeleteOverlay" with-backdrop >
< gr-confirm-delete-comment-dialog id = "confirmDeleteComment"
on-confirm="_handleConfirmDeleteComment"
on-cancel="_handleCancelDeleteComment">
< / gr-confirm-delete-comment-dialog >
< / gr-overlay >
< gr-overlay id = "confirmDiscardOverlay" with-backdrop >
< gr-confirm-dialog
id="confirmDiscardDialog"
confirm-label="Discard"
confirm-on-enter
on-confirm="_handleConfirmDiscard"
on-cancel="_closeConfirmDiscardOverlay">
< div class = "header" slot = "header" >
Discard comment
< / div >
< div class = "main" slot = "main" >
Are you sure you want to discard this draft comment?
< / div >
< / gr-confirm-dialog >
< / gr-overlay >
< / template >
2016-05-03 15:14:57 -04:00
< gr-rest-api-interface id = "restAPI" > < / gr-rest-api-interface >
2016-05-23 13:53:10 -07:00
< gr-storage id = "storage" > < / gr-storage >
2018-05-14 12:59:23 -07:00
< gr-reporting id = "reporting" > < / gr-reporting >
2016-03-04 17:48:22 -05:00
< / template >
< script src = "gr-diff-comment.js" > < / script >
< / dom-module >