Skip to content

Commit 869a610

Browse files
committed
Bug 1146769: cc activity isn't shown
1 parent 2b4dfa9 commit 869a610

4 files changed

Lines changed: 77 additions & 48 deletions

File tree

extensions/BugModal/lib/ActivityStream.pm

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ use Bugzilla::Constants;
2424
# user_id => actor user-id
2525
# comment => optional, comment added
2626
# id => unique identifier for this change-set
27+
# cc_only => boolean
2728
# activty => [
2829
# {
2930
# who => user object
3031
# when => time (string)
32+
# cc_only => boolean
3133
# changes => [
3234
# {
3335
# fieldname => field name :)
@@ -55,7 +57,7 @@ sub activity_stream {
5557
foreach my $change_set (@$stream) {
5658
$change_set->{id} = $change_set->{comment}
5759
? 'c' . $change_set->{comment}->count
58-
: 'a' . ($change_set->{time} - $base_time) . '.' . $change_set->{user_id};
60+
: 'a' . ($change_set->{time} - $base_time) . '_' . $change_set->{user_id};
5961
$change_set->{activity} = [
6062
sort { $a->{fieldname} cmp $b->{fieldname} }
6163
@{ $change_set->{activity} }
@@ -91,13 +93,15 @@ sub _add_activity_to_stream {
9193
my ($stream, $time, $user_id, $data) = @_;
9294
foreach my $entry (@$stream) {
9395
next unless $entry->{time} == $time && $entry->{user_id} == $user_id;
96+
$entry->{cc_only} = $entry->{cc_only} && $data->{cc_only};
9497
push @{ $entry->{activity} }, $data;
9598
return;
9699
}
97100
push @$stream, {
98101
time => $time,
99102
user_id => $user_id,
100103
comment => undef,
104+
cc_only => $data->{cc_only},
101105
activity => [ $data ],
102106
};
103107
}
@@ -138,13 +142,13 @@ sub _add_activities_to_stream {
138142

139143
# envelope, augment and tweak
140144
foreach my $operation (@$raw_activity) {
141-
# until we can toggle their visibility, skip CC changes
142-
$operation->{changes} = [ grep { $_->{fieldname} ne 'cc' } @{ $operation->{changes} } ];
143-
next unless @{ $operation->{changes} };
144145

145146
# make operation.who an object
146147
$operation->{who} = Bugzilla::User->new({ name => $operation->{who}, cache => 1 });
147148

149+
# we need to track operations which are just cc changes
150+
$operation->{cc_only} = 1;
151+
148152
for (my $i = 0; $i < scalar(@{$operation->{changes}}); $i++) {
149153
my $change = $operation->{changes}->[$i];
150154

@@ -245,6 +249,11 @@ sub _add_activities_to_stream {
245249
}
246250
$i--;
247251
}
252+
253+
# track cc-only
254+
if ($change->{fieldname} ne 'cc') {
255+
$operation->{cc_only} = 0;
256+
}
248257
}
249258

250259
_add_activity_to_stream($stream, date_str_to_time($operation->{when}), $operation->{who}->id, $operation);

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

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,29 @@
88

99
<div id="comment-actions">
1010
<button type="button" id="comment-tags-btn" style="display:none" class="minor">Tags &#9662;</button>
11-
<button type="button" id="comment-toggle-btn" class="minor">Comments &#9662;</button>
11+
<button type="button" id="view-menu-btn" class="minor">View &#9662;</button>
1212
</div>
1313

14-
<menu id="comment-toggle-menu" type="context" style="display:none">
15-
<menuitem id="comment-reset" label="Reset"></menuitem>
14+
<menu id="view-menu" type="context" style="display:none">
15+
<menuitem id="view-reset" label="Reset"></menuitem>
1616
<hr>
17-
<menuitem id="comment-collapse-all" label="Collapse All"></menuitem>
18-
<menuitem id="comment-expand-all" label="Expand All"></menuitem>
17+
<menuitem id="view-collapse-all" label="Collapse All"></menuitem>
18+
<menuitem id="view-expand-all" label="Expand All"></menuitem>
19+
<menuitem id="view-comments-only" label="Comments Only"></menuitem>
1920
<hr>
20-
<menuitem id="comments-only" label="Comments Only"></menuitem>
21+
<menuitem id="view-toggle-cc" label="Show CC Changes"></menuitem>
2122
[% Hook.process('comments-toggle-menu') %]
2223
</menu>
2324

2425
[%
2526
PROCESS bug/time.html.tmpl;
2627

27-
activity_counter = 0;
2828
FOREACH change_set IN bug.activity_stream;
29-
'<div class="change-set" id="' _ change_set.id _ '">';
29+
IF change_set.cc_only;
30+
'<div class="change-set cc-only" id="' _ change_set.id _ '" style="display:none">';
31+
ELSE;
32+
'<div class="change-set" id="' _ change_set.id _ '">';
33+
END;
3034

3135
extra_class = "";
3236
IF change_set.user_id == bug.assigned_to.id;
@@ -38,15 +42,14 @@
3842
IF change_set.comment;
3943
PROCESS comment_header comment=change_set.comment;
4044
ELSE;
41-
activity_counter = activity_counter + 1;
42-
PROCESS activity_header activities=change_set.activity id=activity_counter;
45+
PROCESS activity_header activities=change_set.activity id=change_set.id;
4346
END;
4447

4548
IF change_set.comment;
4649
PROCESS comment_body comment=change_set.comment;
4750
END;
4851
FOREACH activity IN change_set.activity;
49-
PROCESS activity_body activity=activity;
52+
PROCESS activity_body activity=activity change_set=change_set;
5053
END;
5154

5255
'</div>';
@@ -219,16 +222,17 @@
219222

220223
[%
221224
BLOCK activity_body;
222-
'<div class="activity">';
223-
has_cc = 0;
225+
IF activity.cc_only && !change_set.cc_only;
226+
'<div class="activity cc-only" style="display:none">';
227+
ELSE;
228+
'<div class="activity">';
229+
END;
224230

225231
FOREACH change IN activity.changes;
226-
'<div class="change">';
227-
class = "";
228-
229-
IF change.fieldname == 'cc';
230-
has_cc = 1;
231-
class = "activity-cc";
232+
IF change.fieldname == 'cc' && !activity.cc_only && !change_set.cc_only;
233+
'<div class="change cc-only" style="display:none">';
234+
ELSE;
235+
'<div class="change">';
232236
END;
233237

234238
IF change.attachid;

extensions/BugModal/web/bug_modal.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,10 @@ td.flag-requestee {
488488
outline: 2px solid #0095dd;
489489
}
490490

491+
.change-set .comment, .change-set .change {
492+
padding-bottom: 1px;
493+
}
494+
491495
.change-head {
492496
width: 100%;
493497
background: #eee;
@@ -529,10 +533,8 @@ td.flag-requestee {
529533
padding: 2px 2px 0 0 !important;
530534
}
531535

532-
.comment-spinner {
533-
font-family: monospace;
534-
white-space: nowrap;
535-
vertical-align: bottom;
536+
.change-spinner {
537+
width: 29px;
536538
}
537539

538540
.comment-text {

extensions/BugModal/web/comments.js

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,30 @@ $(function() {
1111
// comment collapse/expand
1212

1313
function toggleChange(spinner, forced) {
14-
// find and cache the id
15-
var id = spinner.data('cid');
16-
if (!id) {
17-
id = spinner.attr('id').match(/\d+$/)[0];
18-
spinner.data('cid', id);
19-
}
14+
var spinnerID = spinner.attr('id');
15+
var id = spinnerID.substring(spinnerID.indexOf('-') + 1);
16+
17+
var activitySelector = $('#view-toggle-cc').data('shown') === '1' ? '.activity' : '.activity:not(.cc-only)';
2018

2119
// non-comment toggle
22-
if (spinner.attr('id').substr(0, 1) == 'a') {
20+
if (spinnerID.substr(0, 1) == 'a') {
2321
var changeSet = spinner.parents('.change-set');
2422
if (forced == 'hide') {
25-
changeSet.find('.activity').hide();
23+
changeSet.find(activitySelector).hide();
2624
changeSet.find('.gravatar').css('width', '16px').css('height', '16px');
2725
$('#ar-' + id).hide();
2826
spinner.text('+');
2927
}
3028
else if (forced == 'show' || forced == 'reset') {
31-
changeSet.find('.activity').show();
29+
changeSet.find(activitySelector).show();
3230
changeSet.find('.gravatar').css('width', '32px').css('height', '32px');
3331
$('#ar-' + id).show();
3432
spinner.text('-');
3533
}
3634
else {
37-
changeSet.find('.activity').slideToggle('fast', function() {
35+
changeSet.find(activitySelector).slideToggle('fast', function() {
3836
$('#ar-' + id).toggle();
39-
if (changeSet.find('.activity:visible').length) {
37+
if (changeSet.find(activitySelector + ':visible').length) {
4038
changeSet.find('.gravatar').css('width', '32px').css('height', '32px');
4139
spinner.text('-');
4240
}
@@ -69,7 +67,7 @@ $(function() {
6967
$('#ct-' + id).hide();
7068
if (BUGZILLA.user.id !== 0)
7169
$('#ctag-' + id).hide();
72-
$('#c' + id).find('.activity').hide();
70+
$('#c' + id).find(activitySelector).hide();
7371
$('#c' + id).find('.comment-tags').hide();
7472
$('#c' + id).find('.comment-tags').hide();
7573
$('#c' + id).find('.gravatar').css('width', '16px').css('height', '16px');
@@ -84,7 +82,7 @@ $(function() {
8482
$('#ct-' + id).show();
8583
if (BUGZILLA.user.id !== 0)
8684
$('#ctag-' + id).show();
87-
$('#c' + id).find('.activity').show();
85+
$('#c' + id).find(activitySelector).show();
8886
$('#c' + id).find('.comment-tags').show();
8987
$('#c' + id).find('.comment-tags').show();
9088
$('#c' + id).find('.gravatar').css('width', '32px').css('height', '32px');
@@ -93,7 +91,7 @@ $(function() {
9391
}
9492
else {
9593
$('#ct-' + id).slideToggle('fast', function() {
96-
$('#c' + id).find('.activity').toggle();
94+
$('#c' + id).find(activitySelector).toggle();
9795
$('#c' + id).find('.comment-tags').toggle();
9896
if ($('#ct-' + id + ':visible').length) {
9997
spinner.text('-');
@@ -127,40 +125,56 @@ $(function() {
127125
toggleChange($(this));
128126
});
129127

130-
// comment and tag menus
128+
// view and tag menus
131129

132-
$('#comment-reset')
130+
$('#view-reset')
133131
.click(function() {
134132
$('.change-spinner:visible').each(function() {
135133
toggleChange($(this), 'reset');
136134
});
137135
});
138136

139-
$('#comment-collapse-all')
137+
$('#view-collapse-all')
140138
.click(function() {
141139
$('.change-spinner:visible').each(function() {
142140
toggleChange($(this), 'hide');
143141
});
144142
});
145143

146-
$('#comment-expand-all')
144+
$('#view-expand-all')
147145
.click(function() {
148146
$('.change-spinner:visible').each(function() {
149147
toggleChange($(this), 'show');
150148
});
151149
});
152150

153-
$('#comments-only')
151+
$('#view-comments-only')
154152
.click(function() {
155153
$('.change-spinner:visible').each(function() {
156154
toggleChange($(this), this.id.substr(0, 3) === 'cs-' ? 'show' : 'hide');
157155
});
158156
});
159157

158+
$('#view-toggle-cc')
159+
.click(function() {
160+
var that = $(this);
161+
var item = $('.context-menu-item.hover');
162+
if (that.data('shown') === '1') {
163+
that.data('shown', '0');
164+
item.text('Show CC Changes');
165+
$('.cc-only').hide();
166+
}
167+
else {
168+
that.data('shown', '1');
169+
item.text('Hide CC Changes');
170+
$('.cc-only').show();
171+
}
172+
});
173+
160174
$.contextMenu({
161-
selector: '#comment-toggle-btn',
175+
selector: '#view-menu-btn',
162176
trigger: 'left',
163-
items: $.contextMenu.fromMenu($('#comment-toggle-menu'))
177+
items: $.contextMenu.fromMenu($('#view-menu'))
164178
});
165179

166180
function updateTagsMenu() {

0 commit comments

Comments
 (0)