##// END OF EJS Templates
ui: updated comments box with latest styling.
marcink -
r4130:97ab7b84 default
parent child Browse files
Show More
@@ -1,611 +1,629 b''
1 1 // comments.less
2 2 // For use in RhodeCode applications;
3 3 // see style guide documentation for guidelines.
4 4
5 5
6 6 // Comments
7 7 @comment-outdated-opacity: 0.6;
8 8
9 9 .comments {
10 10 width: 100%;
11 11 }
12 12
13 13 .comments-heading {
14 14 margin-bottom: -1px;
15 15 background: @grey6;
16 16 display: block;
17 17 padding: 10px 0px;
18 18 font-size: 18px
19 19 }
20 20
21 21 #comment-tr-show {
22 22 padding: 5px 0;
23 23 }
24 24
25 25 tr.inline-comments div {
26 26 max-width: 100%;
27 27
28 28 p {
29 29 white-space: normal;
30 30 }
31 31
32 32 code, pre, .code, dd {
33 33 overflow-x: auto;
34 34 width: 1062px;
35 35 }
36 36
37 37 dd {
38 38 width: auto;
39 39 }
40 40 }
41 41
42 42 #injected_page_comments {
43 43 .comment-previous-link,
44 44 .comment-next-link,
45 45 .comment-links-divider {
46 46 display: none;
47 47 }
48 48 }
49 49
50 50 .add-comment {
51 51 margin-bottom: 10px;
52 52 }
53 53 .hide-comment-button .add-comment {
54 54 display: none;
55 55 }
56 56
57 57 .comment-bubble {
58 58 color: @grey4;
59 59 margin-top: 4px;
60 60 margin-right: 30px;
61 61 visibility: hidden;
62 62 }
63 63
64 64 .comment-label {
65 65 float: left;
66 66
67 67 padding: 0.4em 0.4em;
68 68 margin: 3px 5px 0px -10px;
69 69 display: inline-block;
70 70 min-height: 0;
71 71
72 72 text-align: center;
73 73 font-size: 10px;
74 74 line-height: .8em;
75 75
76 76 font-family: @text-italic;
77 77 font-style: italic;
78 78 background: #fff none;
79 79 color: @grey4;
80 80 border: 1px solid @grey4;
81 81 white-space: nowrap;
82 82
83 83 text-transform: uppercase;
84 84 min-width: 40px;
85 85
86 86 &.todo {
87 87 color: @color5;
88 88 font-style: italic;
89 89 font-weight: @text-bold-italic-weight;
90 90 font-family: @text-bold-italic;
91 91 }
92 92
93 93 .resolve {
94 94 cursor: pointer;
95 95 text-decoration: underline;
96 96 }
97 97
98 98 .resolved {
99 99 text-decoration: line-through;
100 100 color: @color1;
101 101 }
102 102 .resolved a {
103 103 text-decoration: line-through;
104 104 color: @color1;
105 105 }
106 106 .resolve-text {
107 107 color: @color1;
108 108 margin: 2px 8px;
109 109 font-family: @text-italic;
110 110 font-style: italic;
111 111 }
112 112 }
113 113
114 114 .has-spacer-after {
115 115 &:after {
116 116 content: ' | ';
117 117 color: @grey5;
118 118 }
119 119 }
120 120
121 121 .has-spacer-before {
122 122 &:before {
123 123 content: ' | ';
124 124 color: @grey5;
125 125 }
126 126 }
127 127
128 128 .comment {
129 129
130 130 &.comment-general {
131 131 border: 1px solid @grey5;
132 132 padding: 5px 5px 5px 5px;
133 133 }
134 134
135 135 margin: @padding 0;
136 136 padding: 4px 0 0 0;
137 137 line-height: 1em;
138 138
139 139 .rc-user {
140 140 min-width: 0;
141 141 margin: 0px .5em 0 0;
142 142
143 143 .user {
144 144 display: inline;
145 145 }
146 146 }
147 147
148 148 .meta {
149 149 position: relative;
150 150 width: 100%;
151 151 border-bottom: 1px solid @grey5;
152 152 margin: -5px 0px;
153 153 line-height: 24px;
154 154
155 155 &:hover .permalink {
156 156 visibility: visible;
157 157 color: @rcblue;
158 158 }
159 159 }
160 160
161 161 .author,
162 162 .date {
163 163 display: inline;
164 164
165 165 &:after {
166 166 content: ' | ';
167 167 color: @grey5;
168 168 }
169 169 }
170 170
171 171 .author-general img {
172 172 top: 3px;
173 173 }
174 174 .author-inline img {
175 175 top: 3px;
176 176 }
177 177
178 178 .status-change,
179 179 .permalink,
180 180 .changeset-status-lbl {
181 181 display: inline;
182 182 }
183 183
184 184 .permalink {
185 185 visibility: hidden;
186 186 }
187 187
188 188 .comment-links-divider {
189 189 display: inline;
190 190 }
191 191
192 192 .comment-links-block {
193 193 float:right;
194 194 text-align: right;
195 195 min-width: 85px;
196 196
197 197 [class^="icon-"]:before,
198 198 [class*=" icon-"]:before {
199 199 margin-left: 0;
200 200 margin-right: 0;
201 201 }
202 202 }
203 203
204 204 .comment-previous-link {
205 205 display: inline-block;
206 206
207 207 .arrow_comment_link{
208 208 cursor: pointer;
209 209 i {
210 210 font-size:10px;
211 211 }
212 212 }
213 213 .arrow_comment_link.disabled {
214 214 cursor: default;
215 215 color: @grey5;
216 216 }
217 217 }
218 218
219 219 .comment-next-link {
220 220 display: inline-block;
221 221
222 222 .arrow_comment_link{
223 223 cursor: pointer;
224 224 i {
225 225 font-size:10px;
226 226 }
227 227 }
228 228 .arrow_comment_link.disabled {
229 229 cursor: default;
230 230 color: @grey5;
231 231 }
232 232 }
233 233
234 234 .delete-comment {
235 235 display: inline-block;
236 236 color: @rcblue;
237 237
238 238 &:hover {
239 239 cursor: pointer;
240 240 }
241 241 }
242 242
243 243 .text {
244 244 clear: both;
245 245 .border-radius(@border-radius);
246 246 .box-sizing(border-box);
247 247
248 248 .markdown-block p,
249 249 .rst-block p {
250 250 margin: .5em 0 !important;
251 251 // TODO: lisa: This is needed because of other rst !important rules :[
252 252 }
253 253 }
254 254
255 255 .pr-version {
256 256 float: left;
257 257 margin: 0px 4px;
258 258 }
259 259 .pr-version-inline {
260 260 float: left;
261 261 margin: 0px 4px;
262 262 }
263 263 .pr-version-num {
264 264 font-size: 10px;
265 265 }
266 266 }
267 267
268 268 @comment-padding: 5px;
269 269
270 270 .general-comments {
271 271 .comment-outdated {
272 272 opacity: @comment-outdated-opacity;
273 273 }
274 274 }
275 275
276 276 .inline-comments {
277 277 border-radius: @border-radius;
278 278 .comment {
279 279 margin: 0;
280 280 border-radius: @border-radius;
281 281 }
282 282 .comment-outdated {
283 283 opacity: @comment-outdated-opacity;
284 284 }
285 285
286 286 .comment-inline {
287 287 background: white;
288 288 padding: @comment-padding @comment-padding;
289 289 border: @comment-padding solid @grey6;
290 290
291 291 .text {
292 292 border: none;
293 293 }
294 294 .meta {
295 295 border-bottom: 1px solid @grey6;
296 296 margin: -5px 0px;
297 297 line-height: 24px;
298 298 }
299 299 }
300 300 .comment-selected {
301 301 border-left: 6px solid @comment-highlight-color;
302 302 }
303 303 .comment-inline-form {
304 304 padding: @comment-padding;
305 305 display: none;
306 306 }
307 307 .cb-comment-add-button {
308 308 margin: @comment-padding;
309 309 }
310 310 /* hide add comment button when form is open */
311 311 .comment-inline-form-open ~ .cb-comment-add-button {
312 312 display: none;
313 313 }
314 314 .comment-inline-form-open {
315 315 display: block;
316 316 }
317 317 /* hide add comment button when form but no comments */
318 318 .comment-inline-form:first-child + .cb-comment-add-button {
319 319 display: none;
320 320 }
321 321 /* hide add comment button when no comments or form */
322 322 .cb-comment-add-button:first-child {
323 323 display: none;
324 324 }
325 325 /* hide add comment button when only comment is being deleted */
326 326 .comment-deleting:first-child + .cb-comment-add-button {
327 327 display: none;
328 328 }
329 329 }
330 330
331 331
332 332 .show-outdated-comments {
333 333 display: inline;
334 334 color: @rcblue;
335 335 }
336 336
337 337 // Comment Form
338 338 div.comment-form {
339 339 margin-top: 20px;
340 340 }
341 341
342 342 .comment-form strong {
343 343 display: block;
344 344 margin-bottom: 15px;
345 345 }
346 346
347 347 .comment-form textarea {
348 348 width: 100%;
349 349 height: 100px;
350 350 font-family: @text-monospace;
351 351 }
352 352
353 353 form.comment-form {
354 354 margin-top: 10px;
355 355 margin-left: 10px;
356 356 }
357 357
358 358 .comment-inline-form .comment-block-ta,
359 359 .comment-form .comment-block-ta,
360 360 .comment-form .preview-box {
361 361 .border-radius(@border-radius);
362 362 .box-sizing(border-box);
363 363 background-color: white;
364 364 }
365 365
366 366 .comment-form-submit {
367 367 margin-top: 5px;
368 368 margin-left: 525px;
369 369 }
370 370
371 371 .file-comments {
372 372 display: none;
373 373 }
374 374
375 375 .comment-form .preview-box.unloaded,
376 376 .comment-inline-form .preview-box.unloaded {
377 377 height: 50px;
378 378 text-align: center;
379 379 padding: 20px;
380 380 background-color: white;
381 381 }
382 382
383 383 .comment-footer {
384 384 position: relative;
385 385 width: 100%;
386 386 min-height: 42px;
387 387
388 388 .status_box,
389 389 .cancel-button {
390 390 float: left;
391 391 display: inline-block;
392 392 }
393 393
394 .status_box {
395 margin-left: 10px;
396 }
397
394 398 .action-buttons {
395 float: right;
399 float: left;
396 400 display: inline-block;
397 401 }
398 402
399 403 .action-buttons-extra {
400 404 display: inline-block;
401 405 }
402 406 }
403 407
404 408 .comment-form {
405 409
406 410 .comment {
407 411 margin-left: 10px;
408 412 }
409 413
410 414 .comment-help {
411 415 color: @grey4;
412 416 padding: 5px 0 5px 0;
413 417 }
414 418
415 419 .comment-title {
416 420 padding: 5px 0 5px 0;
417 421 }
418 422
419 423 .comment-button {
420 424 display: inline-block;
421 425 }
422 426
423 427 .comment-button-input {
424 428 margin-right: 0;
425 429 }
426 430
427 431 .comment-footer {
428 432 margin-bottom: 50px;
429 433 margin-top: 10px;
430 434 }
431 435 }
432 436
433 437
434 438 .comment-form-login {
435 439 .comment-help {
436 440 padding: 0.7em; //same as the button
437 441 }
438 442
439 443 div.clearfix {
440 444 clear: both;
441 445 width: 100%;
442 446 display: block;
443 447 }
444 448 }
445 449
446 450 .comment-type {
447 451 margin: 0px;
448 452 border-radius: inherit;
449 453 border-color: @grey6;
450 454 }
451 455
452 456 .preview-box {
453 457 min-height: 105px;
454 458 margin-bottom: 15px;
455 459 background-color: white;
456 460 .border-radius(@border-radius);
457 461 .box-sizing(border-box);
458 462 }
459 463
460 464 .add-another-button {
461 465 margin-left: 10px;
462 466 margin-top: 10px;
463 467 margin-bottom: 10px;
464 468 }
465 469
466 470 .comment .buttons {
467 471 float: right;
468 472 margin: -1px 0px 0px 0px;
469 473 }
470 474
471 475 // Inline Comment Form
472 476 .injected_diff .comment-inline-form,
473 477 .comment-inline-form {
474 478 background-color: white;
475 479 margin-top: 10px;
476 480 margin-bottom: 20px;
477 481 }
478 482
479 483 .inline-form {
480 484 padding: 10px 7px;
481 485 }
482 486
483 487 .inline-form div {
484 488 max-width: 100%;
485 489 }
486 490
487 491 .overlay {
488 492 display: none;
489 493 position: absolute;
490 494 width: 100%;
491 495 text-align: center;
492 496 vertical-align: middle;
493 497 font-size: 16px;
494 498 background: none repeat scroll 0 0 white;
495 499
496 500 &.submitting {
497 501 display: block;
498 502 opacity: 0.5;
499 503 z-index: 100;
500 504 }
501 505 }
502 506 .comment-inline-form .overlay.submitting .overlay-text {
503 507 margin-top: 5%;
504 508 }
505 509
506 510 .comment-inline-form .clearfix,
507 511 .comment-form .clearfix {
508 512 .border-radius(@border-radius);
509 513 margin: 0px;
510 514 }
511 515
512 516 .comment-inline-form .comment-footer {
513 517 margin: 10px 0px 0px 0px;
514 518 }
515 519
516 520 .hide-inline-form-button {
517 521 margin-left: 5px;
518 522 }
519 523 .comment-button .hide-inline-form {
520 524 background: white;
521 525 }
522 526
523 527 .comment-area {
524 padding: 8px 12px;
528 padding: 6px 8px;
525 529 border: 1px solid @grey5;
526 530 .border-radius(@border-radius);
527 531
528 532 .resolve-action {
529 533 padding: 1px 0px 0px 6px;
530 534 }
531 535
532 536 }
533 537
538 comment-area-text {
539 color: @grey3;
540 }
541
542 .comment-area-header {
543 height: 35px;
544 }
545
534 546 .comment-area-header .nav-links {
535 547 display: flex;
536 548 flex-flow: row wrap;
537 549 -webkit-flex-flow: row wrap;
538 550 width: 100%;
539 551 }
540 552
541 553 .comment-area-footer {
542 554 min-height: 30px;
543 555 }
544 556
545 557 .comment-footer .toolbar {
546 558
547 559 }
548 560
549 561 .comment-attachment-uploader {
550 562 border: 1px dashed white;
551 563 border-radius: @border-radius;
552 564 margin-top: -10px;
553
565 line-height: 30px;
554 566 &.dz-drag-hover {
555 567 border-color: @grey3;
556 568 }
557 569
558 570 .dz-error-message {
559 571 padding-top: 0;
560 572 }
561 573 }
562 574
563 575 .comment-attachment-text {
564 576 clear: both;
565 577 font-size: 11px;
566 578 color: #8F8F8F;
567 579 width: 100%;
568 580 .pick-attachment {
569 581 color: #8F8F8F;
570 582 }
571 583 .pick-attachment:hover {
572 584 color: @rcblue;
573 585 }
574 586 }
575 587
576 588 .nav-links {
577 589 padding: 0;
578 590 margin: 0;
579 591 list-style: none;
580 592 height: auto;
581 593 border-bottom: 1px solid @grey5;
582 594 }
583 595 .nav-links li {
584 596 display: inline-block;
585 597 list-style-type: none;
586 598 }
587 599
588 600 .nav-links li a.disabled {
589 601 cursor: not-allowed;
590 602 }
591 603
592 604 .nav-links li.active a {
593 605 border-bottom: 2px solid @rcblue;
594 606 color: #000;
595 607 font-weight: 600;
596 608 }
597 609 .nav-links li a {
598 610 display: inline-block;
599 611 padding: 0px 10px 5px 10px;
600 612 margin-bottom: -1px;
601 613 font-size: 14px;
602 614 line-height: 28px;
603 615 color: #8f8f8f;
604 616 border-bottom: 2px solid transparent;
605 617 }
606 618
607 619 .toolbar-text {
608 float: left;
609 font-size: 12px;
620 float: right;
621 font-size: 11px;
622 color: @grey4;
623 text-align: right;
624
625 a {
626 color: @grey4;
627 }
610 628 }
611 629
@@ -1,419 +1,422 b''
1 1 ## -*- coding: utf-8 -*-
2 2 ## usage:
3 3 ## <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/>
4 4 ## ${comment.comment_block(comment)}
5 5 ##
6 6 <%namespace name="base" file="/base/base.mako"/>
7 7
8 8 <%def name="comment_block(comment, inline=False)">
9 9 <% pr_index_ver = comment.get_index_version(getattr(c, 'versions', [])) %>
10 10 <% latest_ver = len(getattr(c, 'versions', [])) %>
11 11 % if inline:
12 12 <% outdated_at_ver = comment.outdated_at_version(getattr(c, 'at_version_num', None)) %>
13 13 % else:
14 14 <% outdated_at_ver = comment.older_than_version(getattr(c, 'at_version_num', None)) %>
15 15 % endif
16 16
17 17 <div class="comment
18 18 ${'comment-inline' if inline else 'comment-general'}
19 19 ${'comment-outdated' if outdated_at_ver else 'comment-current'}"
20 20 id="comment-${comment.comment_id}"
21 21 line="${comment.line_no}"
22 22 data-comment-id="${comment.comment_id}"
23 23 data-comment-type="${comment.comment_type}"
24 24 data-comment-line-no="${comment.line_no}"
25 25 data-comment-inline=${h.json.dumps(inline)}
26 26 style="${'display: none;' if outdated_at_ver else ''}">
27 27
28 28 <div class="meta">
29 29 <div class="comment-type-label">
30 30 <div class="comment-label ${comment.comment_type or 'note'}" id="comment-label-${comment.comment_id}" title="line: ${comment.line_no}">
31 31 % if comment.comment_type == 'todo':
32 32 % if comment.resolved:
33 33 <div class="resolved tooltip" title="${_('Resolved by comment #{}').format(comment.resolved.comment_id)}">
34 34 <a href="#comment-${comment.resolved.comment_id}">${comment.comment_type}</a>
35 35 </div>
36 36 % else:
37 37 <div class="resolved tooltip" style="display: none">
38 38 <span>${comment.comment_type}</span>
39 39 </div>
40 40 <div class="resolve tooltip" onclick="return Rhodecode.comments.createResolutionComment(${comment.comment_id});" title="${_('Click to resolve this comment')}">
41 41 ${comment.comment_type}
42 42 </div>
43 43 % endif
44 44 % else:
45 45 % if comment.resolved_comment:
46 46 fix
47 47 <a href="#comment-${comment.resolved_comment.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${comment.resolved_comment.comment_id}'), 0, ${h.json.dumps(comment.resolved_comment.outdated)})">
48 48 <span style="text-decoration: line-through">#${comment.resolved_comment.comment_id}</span>
49 49 </a>
50 50 % else:
51 51 ${comment.comment_type or 'note'}
52 52 % endif
53 53 % endif
54 54 </div>
55 55 </div>
56 56
57 57 <div class="author ${'author-inline' if inline else 'author-general'}">
58 58 ${base.gravatar_with_user(comment.author.email, 16, tooltip=True)}
59 59 </div>
60 60 <div class="date">
61 61 ${h.age_component(comment.modified_at, time_is_local=True)}
62 62 </div>
63 63 % if inline:
64 64 <span></span>
65 65 % else:
66 66 <div class="status-change">
67 67 % if comment.pull_request:
68 68 <a href="${h.route_path('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id)}">
69 69 % if comment.status_change:
70 70 ${_('pull request !{}').format(comment.pull_request.pull_request_id)}:
71 71 % else:
72 72 ${_('pull request !{}').format(comment.pull_request.pull_request_id)}
73 73 % endif
74 74 </a>
75 75 % else:
76 76 % if comment.status_change:
77 77 ${_('Status change on commit')}:
78 78 % endif
79 79 % endif
80 80 </div>
81 81 % endif
82 82
83 83 % if comment.status_change:
84 84 <i class="icon-circle review-status-${comment.status_change[0].status}"></i>
85 85 <div title="${_('Commit status')}" class="changeset-status-lbl">
86 86 ${comment.status_change[0].status_lbl}
87 87 </div>
88 88 % endif
89 89
90 90 <a class="permalink" href="#comment-${comment.comment_id}"> &para;</a>
91 91
92 92 <div class="comment-links-block">
93 93 % if comment.pull_request and comment.pull_request.author.user_id == comment.author.user_id:
94 94 <span class="tag authortag tooltip" title="${_('Pull request author')}">
95 95 ${_('author')}
96 96 </span>
97 97 |
98 98 % endif
99 99 % if inline:
100 100 <div class="pr-version-inline">
101 101 <a href="${request.current_route_path(_query=dict(version=comment.pull_request_version_id), _anchor='comment-{}'.format(comment.comment_id))}">
102 102 % if outdated_at_ver:
103 103 <code class="pr-version-num" title="${_('Outdated comment from pull request version v{0}, latest v{1}').format(pr_index_ver, latest_ver)}">
104 104 outdated ${'v{}'.format(pr_index_ver)} |
105 105 </code>
106 106 % elif pr_index_ver:
107 107 <code class="pr-version-num" title="${_('Comment from pull request version v{0}, latest v{1}').format(pr_index_ver, latest_ver)}">
108 108 ${'v{}'.format(pr_index_ver)} |
109 109 </code>
110 110 % endif
111 111 </a>
112 112 </div>
113 113 % else:
114 114 % if comment.pull_request_version_id and pr_index_ver:
115 115 |
116 116 <div class="pr-version">
117 117 % if comment.outdated:
118 118 <a href="?version=${comment.pull_request_version_id}#comment-${comment.comment_id}">
119 119 ${_('Outdated comment from pull request version v{0}, latest v{1}').format(pr_index_ver, latest_ver)}
120 120 </a>
121 121 % else:
122 122 <div title="${_('Comment from pull request version v{0}, latest v{1}').format(pr_index_ver, latest_ver)}">
123 123 <a href="${h.route_path('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id, version=comment.pull_request_version_id)}">
124 124 <code class="pr-version-num">
125 125 ${'v{}'.format(pr_index_ver)}
126 126 </code>
127 127 </a>
128 128 </div>
129 129 % endif
130 130 </div>
131 131 % endif
132 132 % endif
133 133
134 134 ## show delete comment if it's not a PR (regular comments) or it's PR that is not closed
135 135 ## only super-admin, repo admin OR comment owner can delete, also hide delete if currently viewed comment is outdated
136 136 %if not outdated_at_ver and (not comment.pull_request or (comment.pull_request and not comment.pull_request.is_closed())):
137 137 ## permissions to delete
138 138 %if c.is_super_admin or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or comment.author.user_id == c.rhodecode_user.user_id:
139 139 ## TODO: dan: add edit comment here
140 140 <a onclick="return Rhodecode.comments.deleteComment(this);" class="delete-comment"> ${_('Delete')}</a>
141 141 %else:
142 142 <button class="btn-link" disabled="disabled"> ${_('Delete')}</button>
143 143 %endif
144 144 %else:
145 145 <button class="btn-link" disabled="disabled"> ${_('Delete')}</button>
146 146 %endif
147 147
148 148 % if outdated_at_ver:
149 149 | <a onclick="return Rhodecode.comments.prevOutdatedComment(this);" class="prev-comment"> ${_('Prev')}</a>
150 150 | <a onclick="return Rhodecode.comments.nextOutdatedComment(this);" class="next-comment"> ${_('Next')}</a>
151 151 % else:
152 152 | <a onclick="return Rhodecode.comments.prevComment(this);" class="prev-comment"> ${_('Prev')}</a>
153 153 | <a onclick="return Rhodecode.comments.nextComment(this);" class="next-comment"> ${_('Next')}</a>
154 154 % endif
155 155
156 156 </div>
157 157 </div>
158 158 <div class="text">
159 159 ${h.render(comment.text, renderer=comment.renderer, mentions=True, repo_name=getattr(c, 'repo_name', None))}
160 160 </div>
161 161
162 162 </div>
163 163 </%def>
164 164
165 165 ## generate main comments
166 166 <%def name="generate_comments(comments, include_pull_request=False, is_pull_request=False)">
167 167 <div class="general-comments" id="comments">
168 168 %for comment in comments:
169 169 <div id="comment-tr-${comment.comment_id}">
170 170 ## only render comments that are not from pull request, or from
171 171 ## pull request and a status change
172 172 %if not comment.pull_request or (comment.pull_request and comment.status_change) or include_pull_request:
173 173 ${comment_block(comment)}
174 174 %endif
175 175 </div>
176 176 %endfor
177 177 ## to anchor ajax comments
178 178 <div id="injected_page_comments"></div>
179 179 </div>
180 180 </%def>
181 181
182 182
183 183 <%def name="comments(post_url, cur_status, is_pull_request=False, is_compare=False, change_status=True, form_extras=None)">
184 184
185 185 <div class="comments">
186 186 <%
187 187 if is_pull_request:
188 188 placeholder = _('Leave a comment on this Pull Request.')
189 189 elif is_compare:
190 190 placeholder = _('Leave a comment on {} commits in this range.').format(len(form_extras))
191 191 else:
192 192 placeholder = _('Leave a comment on this Commit.')
193 193 %>
194 194
195 195 % if c.rhodecode_user.username != h.DEFAULT_USER:
196 196 <div class="js-template" id="cb-comment-general-form-template">
197 197 ## template generated for injection
198 198 ${comment_form(form_type='general', review_statuses=c.commit_statuses, form_extras=form_extras)}
199 199 </div>
200 200
201 201 <div id="cb-comment-general-form-placeholder" class="comment-form ac">
202 202 ## inject form here
203 203 </div>
204 204 <script type="text/javascript">
205 205 var lineNo = 'general';
206 206 var resolvesCommentId = null;
207 207 var generalCommentForm = Rhodecode.comments.createGeneralComment(
208 208 lineNo, "${placeholder}", resolvesCommentId);
209 209
210 210 // set custom success callback on rangeCommit
211 211 % if is_compare:
212 212 generalCommentForm.setHandleFormSubmit(function(o) {
213 213 var self = generalCommentForm;
214 214
215 215 var text = self.cm.getValue();
216 216 var status = self.getCommentStatus();
217 217 var commentType = self.getCommentType();
218 218
219 219 if (text === "" && !status) {
220 220 return;
221 221 }
222 222
223 223 // we can pick which commits we want to make the comment by
224 224 // selecting them via click on preview pane, this will alter the hidden inputs
225 225 var cherryPicked = $('#changeset_compare_view_content .compare_select.hl').length > 0;
226 226
227 227 var commitIds = [];
228 228 $('#changeset_compare_view_content .compare_select').each(function(el) {
229 229 var commitId = this.id.replace('row-', '');
230 230 if ($(this).hasClass('hl') || !cherryPicked) {
231 231 $("input[data-commit-id='{0}']".format(commitId)).val(commitId);
232 232 commitIds.push(commitId);
233 233 } else {
234 234 $("input[data-commit-id='{0}']".format(commitId)).val('')
235 235 }
236 236 });
237 237
238 238 self.setActionButtonsDisabled(true);
239 239 self.cm.setOption("readOnly", true);
240 240 var postData = {
241 241 'text': text,
242 242 'changeset_status': status,
243 243 'comment_type': commentType,
244 244 'commit_ids': commitIds,
245 245 'csrf_token': CSRF_TOKEN
246 246 };
247 247
248 248 var submitSuccessCallback = function(o) {
249 249 location.reload(true);
250 250 };
251 251 var submitFailCallback = function(){
252 252 self.resetCommentFormState(text)
253 253 };
254 254 self.submitAjaxPOST(
255 255 self.submitUrl, postData, submitSuccessCallback, submitFailCallback);
256 256 });
257 257 % endif
258 258
259 259 </script>
260 260 % else:
261 261 ## form state when not logged in
262 262 <div class="comment-form ac">
263 263
264 264 <div class="comment-area">
265 265 <div class="comment-area-header">
266 266 <ul class="nav-links clearfix">
267 267 <li class="active">
268 268 <a class="disabled" href="#edit-btn" disabled="disabled" onclick="return false">${_('Write')}</a>
269 269 </li>
270 270 <li class="">
271 271 <a class="disabled" href="#preview-btn" disabled="disabled" onclick="return false">${_('Preview')}</a>
272 272 </li>
273 273 </ul>
274 274 </div>
275 275
276 276 <div class="comment-area-write" style="display: block;">
277 277 <div id="edit-container">
278 278 <div style="padding: 40px 0">
279 279 ${_('You need to be logged in to leave comments.')}
280 280 <a href="${h.route_path('login', _query={'came_from': h.current_route_path(request)})}">${_('Login now')}</a>
281 281 </div>
282 282 </div>
283 283 <div id="preview-container" class="clearfix" style="display: none;">
284 284 <div id="preview-box" class="preview-box"></div>
285 285 </div>
286 286 </div>
287 287
288 288 <div class="comment-area-footer">
289 289 <div class="toolbar">
290 290 <div class="toolbar-text">
291 291 </div>
292 292 </div>
293 293 </div>
294 294 </div>
295 295
296 296 <div class="comment-footer">
297 297 </div>
298 298
299 299 </div>
300 300 % endif
301 301
302 302 <script type="text/javascript">
303 303 bindToggleButtons();
304 304 </script>
305 305 </div>
306 306 </%def>
307 307
308 308
309 309 <%def name="comment_form(form_type, form_id='', lineno_id='{1}', review_statuses=None, form_extras=None)">
310 310
311 311 ## comment injected based on assumption that user is logged in
312 <form ${'id="{}"'.format(form_id) if form_id else '' |n} action="#" method="GET">
312 <form ${('id="{}"'.format(form_id) if form_id else '') |n} action="#" method="GET">
313 313
314 314 <div class="comment-area">
315 315 <div class="comment-area-header">
316 <ul class="nav-links clearfix">
317 <li class="active">
318 <a href="#edit-btn" tabindex="-1" id="edit-btn_${lineno_id}">${_('Write')}</a>
319 </li>
320 <li class="">
321 <a href="#preview-btn" tabindex="-1" id="preview-btn_${lineno_id}">${_('Preview')}</a>
322 </li>
323 <li class="pull-right">
324 <select class="comment-type" id="comment_type_${lineno_id}" name="comment_type">
325 % for val in c.visual.comment_types:
326 <option value="${val}">${val.upper()}</option>
327 % endfor
328 </select>
329 </li>
330 </ul>
316 <div class="pull-left">
317 <ul class="nav-links clearfix">
318 <li class="active">
319 <a href="#edit-btn" tabindex="-1" id="edit-btn_${lineno_id}">${_('Write')}</a>
320 </li>
321 <li class="">
322 <a href="#preview-btn" tabindex="-1" id="preview-btn_${lineno_id}">${_('Preview')}</a>
323 </li>
324 </ul>
325 </div>
326 <div class="pull-right">
327 <span class="comment-area-text">${_('Mark as')}:</span>
328 <select class="comment-type" id="comment_type_${lineno_id}" name="comment_type">
329 % for val in c.visual.comment_types:
330 <option value="${val}">${val.upper()}</option>
331 % endfor
332 </select>
333 </div>
331 334 </div>
332 335
333 336 <div class="comment-area-write" style="display: block;">
334 337 <div id="edit-container_${lineno_id}">
335 338 <textarea id="text_${lineno_id}" name="text" class="comment-block-ta ac-input"></textarea>
336 339 </div>
337 340 <div id="preview-container_${lineno_id}" class="clearfix" style="display: none;">
338 341 <div id="preview-box_${lineno_id}" class="preview-box"></div>
339 342 </div>
340 343 </div>
341 344
342 345 <div class="comment-area-footer comment-attachment-uploader">
343 346 <div class="toolbar">
344 <div class="toolbar-text">
345 ${(_('Comments parsed using %s syntax with %s, and %s actions support.') % (
346 ('<a href="%s">%s</a>' % (h.route_url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
347 ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user')),
348 ('<span class="tooltip" title="%s">`/`</span>' % _('Start typing with / for certain actions to be triggered via text box.'))
349 )
350 )|n}
351 </div>
352 347
353 348 <div class="comment-attachment-text">
354 349 <div class="dropzone-text">
355 350 ${_("Drag'n Drop files here or")} <span class="link pick-attachment">${_('Choose your files')}</span>.<br>
356 351 </div>
357 352 <div class="dropzone-upload" style="display:none">
358 353 <i class="icon-spin animate-spin"></i> ${_('uploading...')}
359 354 </div>
360 355 </div>
361 356
362 357 ## comments dropzone template, empty on purpose
363 358 <div style="display: none" class="comment-attachment-uploader-template">
364 359 <div class="dz-file-preview" style="margin: 0">
365 360 <div class="dz-error-message"></div>
366 361 </div>
367 362 </div>
368 363
369 364 </div>
370 365 </div>
371 366 </div>
372 367
373 368 <div class="comment-footer">
374 369
370 ## inject extra inputs into the form
371 % if form_extras and isinstance(form_extras, (list, tuple)):
372 <div id="comment_form_extras">
373 % for form_ex_el in form_extras:
374 ${form_ex_el|n}
375 % endfor
376 </div>
377 % endif
378
379 <div class="action-buttons">
380 % if form_type != 'inline':
381 <div class="action-buttons-extra"></div>
382 % endif
383
384 <input class="btn btn-success comment-button-input" id="save_${lineno_id}" name="save" type="submit" value="${_('Comment')}">
385
386 ## inline for has a file, and line-number together with cancel hide button.
387 % if form_type == 'inline':
388 <input type="hidden" name="f_path" value="{0}">
389 <input type="hidden" name="line" value="${lineno_id}">
390 <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);">
391 ${_('Cancel')}
392 </button>
393 % endif
394 </div>
395
375 396 % if review_statuses:
376 397 <div class="status_box">
377 398 <select id="change_status_${lineno_id}" name="changeset_status">
378 399 <option></option> ## Placeholder
379 400 % for status, lbl in review_statuses:
380 401 <option value="${status}" data-status="${status}">${lbl}</option>
381 402 %if is_pull_request and change_status and status in ('approved', 'rejected'):
382 403 <option value="${status}_closed" data-status="${status}">${lbl} & ${_('Closed')}</option>
383 404 %endif
384 405 % endfor
385 406 </select>
386 407 </div>
387 408 % endif
388 409
389 ## inject extra inputs into the form
390 % if form_extras and isinstance(form_extras, (list, tuple)):
391 <div id="comment_form_extras">
392 % for form_ex_el in form_extras:
393 ${form_ex_el|n}
394 % endfor
395 </div>
396 % endif
397
398 <div class="action-buttons">
399 ## inline for has a file, and line-number together with cancel hide button.
400 % if form_type == 'inline':
401 <input type="hidden" name="f_path" value="{0}">
402 <input type="hidden" name="line" value="${lineno_id}">
403 <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);">
404 ${_('Cancel')}
405 </button>
406 % endif
407
408 % if form_type != 'inline':
409 <div class="action-buttons-extra"></div>
410 % endif
411
412 ${h.submit('save', _('Comment'), class_='btn btn-success comment-button-input')}
413
410 <div class="toolbar-text">
411 <% renderer_url = '<a href="%s">%s</a>' % (h.route_url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper()) %>
412 ${_('Comments parsed using {} syntax.').format(renderer_url)|n} <br/>
413 <span class="tooltip" title="${_('Use @username inside this text to send notification to this RhodeCode user')}">@mention</span>
414 ${_('and')}
415 <span class="tooltip" title="${_('Start typing with / for certain actions to be triggered via text box.')}">`/` autocomplete</span>
416 ${_('actions supported.')}
414 417 </div>
415 418 </div>
416 419
417 420 </form>
418 421
419 422 </%def> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now