summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/elements/diff/gr-diff-comment/gr-diff-comment.html
blob: d58b6be4aecfa428f8319ee946beff42b90694e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!--
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">
<link rel="import" href="../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.html">
<link rel="import" href="../../../bower_components/iron-autogrow-textarea/iron-autogrow-textarea.html">
<link rel="import" href="../../shared/gr-textarea/gr-textarea.html">
<link rel="import" href="../../shared/gr-button/gr-button.html">
<link rel="import" href="../../shared/gr-confirm-dialog/gr-confirm-dialog.html">
<link rel="import" href="../../shared/gr-date-formatter/gr-date-formatter.html">
<link rel="import" href="../../shared/gr-formatted-text/gr-formatted-text.html">
<link rel="import" href="../../shared/gr-overlay/gr-overlay.html">
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
<link rel="import" href="../../shared/gr-storage/gr-storage.html">
<link rel="import" href="../../shared/gr-tooltip-content/gr-tooltip-content.html">
<link rel="import" href="../gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog.html">
<link rel="import" href="../../../styles/shared-styles.html">

<script src="../../../scripts/rootElement.js"></script>

<dom-module id="gr-diff-comment">
  <template>
    <style include="shared-styles">
      :host {
        display: block;
        font-family: var(--font-family);
        padding: .7em .7em;
        --iron-autogrow-textarea: {
          box-sizing: border-box;
          padding: 2px;
        };
      }
      :host([disabled]) {
        pointer-events: none;
      }
      :host([disabled]) .container {
        opacity: .5;
      }
      :host([is-robot-comment]) {
        background-color: #cfe8fc;
      }
      .header {
        cursor: pointer;
        display: flex;
        font-family: 'Open Sans', sans-serif;
        margin-bottom: 0.7em;
        padding-bottom: 0;
      }
      .container.collapsed .header {
        margin: 0;
      }
      .headerMiddle {
        color: #666;
        flex: 1;
        overflow: hidden;
      }
      .authorName,
      .draftLabel,
      .draftTooltip {
        font-family: var(--font-family-bold);
      }
      .draftLabel,
      .draftTooltip {
        color: #999;
        display: none;
      }
      .date {
        justify-content: flex-end;
        margin-left: 5px;
        min-width: 4.5em;
        text-align: right;
        white-space: nowrap;
      }
      a.date:link,
      a.date:visited {
        color: #666;
      }
      .actions {
        display: flex;
        justify-content: flex-end;
        padding-top: 0;
      }
      .action {
        margin-left: 1em;
        --gr-button: {
          color: #212121;
        }
        --gr-button-hover-color: rgba(33, 33, 33, .75);
      }
      .rightActions {
        display: flex;
        justify-content: flex-end;
      }
      .editMessage {
        display: none;
        margin: .5em 0;
        width: 100%;
      }
      .container:not(.draft) .actions .hideOnPublished {
        display: none;
      }
      .draft .reply,
      .draft .quote,
      .draft .ack,
      .draft .done {
        display: none;
      }
      .draft .draftLabel,
      .draft .draftTooltip {
        display: inline;
      }
      .draft:not(.editing) .save,
      .draft:not(.editing) .cancel,
      .draft:not(.editing) .resolve {
        display: none;
      }
      .editing .message,
      .editing .reply,
      .editing .quote,
      .editing .ack,
      .editing .done,
      .editing .edit,
      .editing .unresolved {
        display: none;
      }
      .editing .editMessage {
        display: block;
      }
      .show-hide {
        margin-left: .4em;
      }
      .robotId {
        color: #808080;
        margin-bottom: .8em;
        margin-top: -.4em;
      }
      .runIdInformation {
        margin: 1em 0;
      }
      .robotRun {
        margin-left: .5em;
      }
      .robotRunLink {
        margin-left: .5em;
      }
      input.show-hide {
        display: none;
      }
      label.show-hide {
        color: #000;
        cursor: pointer;
        display: block;
        font-size: .8em;
        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,
      #container.collapsed gr-formatted-text,
      #container.collapsed gr-textarea {
        display: none;
      }
      .resolve,
      .unresolved {
        align-items: center;
        display: flex;
        flex: 1;
        margin: 0;
      }
      .resolve label {
        color: #333;
        font-size: 12px;
      }
      gr-confirm-dialog .main {
        background-color: #fef;
        display: flex;
        flex-direction: column;
        width: 100%;
      }
      #deleteBtn {
        color: #666;
        display: none;
      }
      #deleteBtn.showDeleteButtons {
        display: block;
      }
    </style>
    <div id="container"
        class="container"
        on-mouseenter="_handleMouseEnter"
        on-mouseleave="_handleMouseLeave">
      <div class="header" id="header" on-click="_handleToggleCollapsed">
        <div class="headerLeft">
          <span class="authorName">[[comment.author.name]]</span>
          <span class="draftLabel">DRAFT</span>
          <gr-tooltip-content class="draftTooltip"
              has-tooltip
              title="This draft is only visible to you. To publish drafts, click the red 'Reply' button at the top of the change or press the 'A' key."
              max-width="20em"
              show-icon></gr-tooltip-content>
        </div>
        <div class="headerMiddle">
          <span class="collapsedContent">[[comment.message]]</span>
        </div>
        <gr-button
            id="deleteBtn"
            link
            class$="action delete [[_computeDeleteButtonClass(_isAdmin, draft)]]"
            on-tap="_handleCommentDelete">
          (Delete)
        </gr-button>
        <a class="date" href$="[[_computeLinkToComment(comment)]]" on-tap="_handleLinkTap">
          <gr-date-formatter
              has-tooltip
              date-str="[[comment.updated]]"></gr-date-formatter>
        </a>
        <div class="show-hide">
          <label class="show-hide">
            <input type="checkbox" class="show-hide"
               checked$="[[collapsed]]"
               on-change="_handleToggleCollapsed">
            [[_computeShowHideText(collapsed)]]
          </label>
        </div>
      </div>
      <template is="dom-if" if="[[comment.robot_id]]">
        <div class="robotId" hidden$="[[collapsed]]">
          [[comment.robot_id]]
        </div>
      </template>
      <gr-textarea
          id="editTextarea"
          class="editMessage"
          autocomplete="on"
          monospace
          disabled="{{disabled}}"
          rows="4"
          text="{{_messageText}}"></gr-textarea>
      <gr-formatted-text class="message"
          content="[[comment.message]]"
          no-trailing-margin="[[!comment.__draft]]"
          collapsed="[[collapsed]]"
          config="[[projectConfig.commentlinks]]"></gr-formatted-text>
      <div hidden$="[[!comment.robot_run_id]]">
        <div class="runIdInformation" hidden$="[[collapsed]]">
          Run ID:
          <a class="robotRunLink" href$="[[comment.url]]">
            <span class="robotRun">[[comment.robot_run_id]]</span>
          </a>
        </div>
      </div>
      <div class="actions humanActions" hidden$="[[!_showHumanActions]]">
        <div class="action resolve hideOnPublished">
          <label>
            <input type="checkbox"
                checked$="[[resolved]]"
                on-change="_handleToggleResolved">
            Resolved
          </label>
        </div>
        <div class="action unresolved hideOnPublished" hidden$="[[resolved]]">
          Unresolved
        </div>
        <div class="rightActions">
          <gr-button link class="action cancel hideOnPublished"
              on-tap="_handleCancel" hidden>Cancel</gr-button>
          <gr-button link class="action discard hideOnPublished"
              on-tap="_handleDiscard">Discard</gr-button>
          <gr-button link class="action edit hideOnPublished"
              on-tap="_handleEdit">Edit</gr-button>
          <gr-button link class="action save hideOnPublished"
              on-tap="_handleSave"
              disabled$="[[_computeSaveDisabled(_messageText)]]">Save
          </gr-button>
        </div>
      </div>
      <div class="actions robotActions" hidden$="[[!_showRobotActions]]">
        <gr-button link class="action fix"
            on-tap="_handleFix"
            disabled="[[robotButtonDisabled]]">
          Please Fix
        </gr-button>
      </div>
    </div>
    <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="confirmDiscaDialog"
          confirm-label="Discard"
          on-confirm="_handleConfirmDiscard"
          on-cancel="_closeConfirmDiscardOverlay">
        <div class="header">
          Discard comment
        </div>
        <div class="main">
          Are you sure you want to discard this draft comment?
        </div>
      </gr-confirm-dialog>
    </gr-overlay>
    <gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
    <gr-storage id="storage"></gr-storage>
  </template>
  <script src="gr-diff-comment.js"></script>
</dom-module>