Skip to content

Commit 646d619

Browse files
committed
Bug 1146771: implement comment tagging
1 parent 4c75170 commit 646d619

File tree

8 files changed

+394
-36
lines changed

8 files changed

+394
-36
lines changed

extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,21 @@
3636
END;
3737
%]
3838

39+
[% IF user.can_tag_comments %]
40+
<div id="ctag" style="display:none">
41+
<input id="ctag-add" size="10" placeholder="add tag"
42+
maxlength="[% constants.MAX_COMMENT_TAG_LENGTH FILTER html %]">
43+
<button type="button" id="ctag-close" class="minor">X</button>
44+
<a href="https://wiki.mozilla.org/BMO/comment_tagging" target="_blank" title="About Comment Tagging">Help</a>
45+
</div>
46+
<div id="ctag-error" style="display:none">
47+
<a href="#" class="close-btn" data-for="ctag-error">x</a>
48+
<span id="ctag-error-message"></span>
49+
</div>
50+
[% END %]
51+
3952
[% BLOCK comment_header %]
40-
<div class="comment">
53+
<div class="comment" data-id="[% comment.id FILTER none %]" data-no="[% comment.count FILTER none %]">
4154
[%# normal comment header %]
4255
<table class="layout-table change-head [% extra_class FILTER none %]" id="ch-[% comment.count FILTER none %]"
4356
[% IF comment.collapsed +%] style="display:none"[% END %]>
@@ -49,6 +62,7 @@
4962
gravatar_only = 1
5063
%]
5164
</td>
65+
5266
<td class="change-author">
5367
[% INCLUDE bug_modal/user.html.tmpl
5468
u = comment.author
@@ -58,6 +72,7 @@
5872
[% END %]
5973
[% Hook.process('user', 'bug/comments.html.tmpl') %]
6074
</td>
75+
6176
<td class="comment-actions">
6277
[% IF user.is_insider && bug.check_can_change_field('longdesc', 0, 1) %]
6378
[% IF comment.is_private %]
@@ -74,14 +89,21 @@
7489
</div>
7590
[% END %]
7691
[% IF user.id %]
77-
<button class="reply-btn minor"
92+
[% IF user.can_tag_comments %]
93+
<button class="tag-btn minor" type="button"
94+
data-id="[% comment.id FILTER none %]"
95+
data-no="[% comment.count FILTER none %]"
96+
>Tag</button>
97+
[% END %]
98+
<button class="reply-btn minor" type="button"
7899
data-reply-id="[% comment.count FILTER none %]"
79100
data-reply-name="[% comment.author.name || comment.author.moz_nick FILTER html %]"
80101
>Reply</button>
81102
[% END %]
82103
<button class="comment-spinner minor" id="cs-[% comment.count FILTER none%]">-</button>
83104
</td>
84105
</tr>
106+
85107
<tr>
86108
<td colspan="2">
87109
<div class="change-name">
@@ -95,15 +117,16 @@
95117
</div>
96118
</td>
97119
</tr>
98-
[% IF comment.tags.size %]
99-
<tr>
100-
<td colspan="2" class="comment-tags">
101-
[% FOREACH tag IN comment.tags %]
102-
<span class="comment-tag">[% tag FILTER html %]</span>
103-
[% END %]
104-
</td>
105-
</tr>
106-
[% END %]
120+
121+
<tr id="ctag-[% comment.count FILTER none %]">
122+
<td colspan="2" class="comment-tags">
123+
[% FOREACH tag IN comment.tags ~%]
124+
<span class="comment-tag">
125+
[%~ "<a>x</a>" IF user.can_tag_comments %][% tag FILTER html ~%]
126+
</span>
127+
[%~ END %]
128+
</td>
129+
</tr>
107130
</table>
108131

109132
[%# default-collapsed comment header %]

extensions/BugModal/template/en/default/bug_modal/header.html.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
javascript_urls.push(
5151
"extensions/ProdCompSearch/web/js/prod_comp_search.js",
5252
"extensions/BugModal/web/bug_modal.js",
53+
"extensions/BugModal/web/comments.js",
5354
"extensions/BugModal/web/ZeroClipboard/ZeroClipboard.min.js",
5455
"js/field.js",
5556
"js/comments.js",
@@ -93,6 +94,7 @@
9394
id: [% user.id FILTER none %],
9495
login: '[% user.login FILTER js %]',
9596
is_insider: [% user.is_insider ? "true" : "false" %],
97+
can_tag: [% user.can_tag_comments ? "true" : "false" %],
9698
settings: {
9799
quote_replies: '[% user.settings.quote_replies.value FILTER js %]',
98100
zoom_textareas: [% user.settings.zoom_textareas.value == "on" ? "true" : "false" %]
@@ -101,6 +103,8 @@
101103
[% IF user.id %]
102104
BUGZILLA.default_assignee = '[% bug.component_obj.default_assignee.login FILTER js %]';
103105
BUGZILLA.default_qa_contact = '[% bug.component_obj.default_qa_contact.login FILTER js %]';
106+
BUGZILLA.constant.min_comment_tag_length = [% constants.MIN_COMMENT_TAG_LENGTH FILTER none %];
107+
BUGZILLA.constant.max_comment_tag_length = [% constants.MAX_COMMENT_TAG_LENGTH FILTER none %];
104108
[% END %]
105109
[% END %]
106110

extensions/BugModal/web/bug_modal.css

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,37 @@ td.flag-requestee {
545545
}
546546

547547
.comment-tag {
548-
border: 1px solid #ccc;
549-
padding: 2px 4px;
548+
border: 1px solid #eee;
549+
padding: 2px 6px 2px 4px;
550550
margin-right: 2px;
551-
border-radius: 0.5em;
551+
border-radius: 4px;
552552
background-color: #fff;
553553
color: #000;
554-
font-size: 12px;
554+
}
555+
556+
.comment-tag a {
557+
padding-right: 4px;
558+
cursor: pointer;
559+
}
560+
561+
#ctag {
562+
margin-bottom: 4px;
563+
}
564+
565+
#ctag button {
566+
margin-top: 2px;
567+
}
568+
569+
#ctag a {
570+
margin-left: 8px;
571+
}
572+
573+
#ctag-error {
574+
padding-left: 5px;
575+
background-color: #faa;
576+
color: #444;
577+
border-radius: 2px;
578+
margin-top: 2px;
555579
}
556580

557581
.comment-collapse-reason {

extensions/BugModal/web/bug_modal.js

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ $(function() {
111111
$('#cc-' + id).hide();
112112
$('#ch-' + id).show();
113113
}
114-
$('#ct-' + id).slideToggle('fast', function() {
114+
$('#ct-' + id + ', #ctag-' + id).slideToggle('fast', function() {
115115
$('#c' + id).find('.activity').toggle();
116116
spinner.text($('#ct-' + id + ':visible').length ? '-' : '+');
117117
});
@@ -345,11 +345,7 @@ $(function() {
345345
autoSelectFirst: true,
346346
formatResult: function(suggestion, currentValue) {
347347
// disable <b> wrapping of matched substring
348-
return suggestion.value
349-
.replace(/&/g, '&amp;')
350-
.replace(/</g, '&lt;')
351-
.replace(/>/g, '&gt;')
352-
.replace(/"/g, '&quot;');
348+
return suggestion.value.htmlEncode();
353349
},
354350
onSelect: function() {
355351
this.focus();
@@ -1067,7 +1063,7 @@ function bugzilla_ajax(request, done_fn, error_fn) {
10671063
request.data = JSON.stringify(request.data);
10681064
}
10691065
}
1070-
$.ajax(request)
1066+
return $.ajax(request)
10711067
.done(function(data) {
10721068
if (data.error) {
10731069
$('#xhr-error').html(data.message);
@@ -1080,6 +1076,8 @@ function bugzilla_ajax(request, done_fn, error_fn) {
10801076
}
10811077
})
10821078
.error(function(data) {
1079+
if (data.statusText === 'abort')
1080+
return;
10831081
var message = data.responseJSON ? data.responseJSON.message : 'Unexpected Error'; // all errors are unexpected :)
10841082
if (!request.hideError) {
10851083
$('#xhr-error').html(message);
@@ -1137,6 +1135,41 @@ function lb_close(event) {
11371135
$('#lb_overlay, #lb_overlay2, #lb_close_btn, #lb_img, #lb_text').remove();
11381136
}
11391137

1138+
// extensions
1139+
1140+
(function($) {
1141+
$.extend({
1142+
// Case insensative $.inArray (http://api.jquery.com/jquery.inarray/)
1143+
// $.inArrayIn(value, array [, fromIndex])
1144+
// value (type: String)
1145+
// The value to search for
1146+
// array (type: Array)
1147+
// An array through which to search.
1148+
// fromIndex (type: Number)
1149+
// The index of the array at which to begin the search.
1150+
// The default is 0, which will search the whole array.
1151+
inArrayIn: function(elem, arr, i) {
1152+
// not looking for a string anyways, use default method
1153+
if (typeof elem !== 'string') {
1154+
return $.inArray.apply(this, arguments);
1155+
}
1156+
// confirm array is populated
1157+
if (arr) {
1158+
var len = arr.length;
1159+
i = i ? (i < 0 ? Math.max(0, len + i) : i) : 0;
1160+
elem = elem.toLowerCase();
1161+
for (; i < len; i++) {
1162+
if (i in arr && arr[i].toLowerCase() == elem) {
1163+
return i;
1164+
}
1165+
}
1166+
}
1167+
// stick with inArray/indexOf and return -1 on no match
1168+
return -1;
1169+
}
1170+
});
1171+
})(jQuery);
1172+
11401173
// no-ops
11411174
function initHidingOptionsForIE() {}
11421175
function showFieldWhen() {}

0 commit comments

Comments
 (0)