Skip to content

Commit

Permalink
fixes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanwh committed Jan 25, 2019
1 parent f2f8ef6 commit 66a2199
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
4 changes: 4 additions & 0 deletions Bugzilla/Install.pm
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ use constant SYSTEM_GROUPS => (
name => 'bz_can_disable_mfa',
description => 'Can disable MFA when editing users',
},
{
name => 'bz_can_async_bulk_edit',
description => 'Can asynchronously bulk edit bugs',
},
);

use constant DEFAULT_CLASSIFICATION =>
Expand Down
2 changes: 1 addition & 1 deletion Bugzilla/Task/BulkEdit.pm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ sub _build_ids_with_ts {
sub run {
my ($self) = @_;

return {bulk_edit => 1, all_sent_changes => [map { $self->edit_bug(@$_) } @{$self->ids_with_ts}]};
return {async_bulk_edit => 1, all_sent_changes => [map { $self->edit_bug(@$_) } @{$self->ids_with_ts}]};
}

sub edit_bug {
Expand Down
18 changes: 9 additions & 9 deletions process_bug.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ if (Bugzilla->params->{disable_bug_updates}) {
my @bug_objects;
my @bug_ids;

# $bulk_edit is whether or not we use the bulk editing code,
# $async_bulk_edit is whether or not we use the bulk editing code,
# $background is if the background=1 parameter was passed.
my $bulk_edit = $cgi->param('bulk_edit') // 0;
$cgi->delete('bulk_edit') if $bulk_edit;
my $async_bulk_edit = $cgi->param('async_bulk_edit') // 0;
$cgi->delete('async_bulk_edit') if $async_bulk_edit;

if (defined $cgi->param('id')) {
my $bug = Bugzilla::Bug->check(scalar $cgi->param('id'));
Expand All @@ -91,10 +91,10 @@ else {

# Make sure there are bugs to process.
ThrowUserError("no_bugs_chosen", {action => 'modify'}) unless @bug_ids;
$bulk_edit = 1 if @bug_ids > 10;
$bulk_edit = 0 unless $user->in_group('bulk_edit');
$async_bulk_edit = 1 if @bug_ids > 10;
$async_bulk_edit = 0 unless $user->in_group('bz_can_async_bulk_edit');

if ($bulk_edit) {
if ($async_bulk_edit) {
# Not sure if we need $first_bug at all during a bulk update,
# but it won't hurt.
@bug_objects = (Bugzilla::Bug->check($bug_ids[0]));
Expand Down Expand Up @@ -241,7 +241,7 @@ else {
# For each bug, we have to check if the user can edit the bug the product
# is currently in, before we allow them to change anything.
# For bulk edits, this will be done in the background task.
if (!$bulk_edit) {
if (!$async_bulk_edit) {
foreach my $bug (@bug_objects) {
if (!Bugzilla->user->can_edit_product($bug->product_obj->id)) {
ThrowUserError("product_edit_denied", {product => $bug->product});
Expand Down Expand Up @@ -273,7 +273,7 @@ my %field_translation = (
);

my %set_all_fields;
if (not $bulk_edit) {
if (not $async_bulk_edit) {
$set_all_fields{other_bugs} = \@bug_objects;
}
else {
Expand Down Expand Up @@ -396,7 +396,7 @@ foreach my $field (keys %$user_match_fields) {
# We are going to alter the list of removed groups, so we keep a copy here.
my @unchecked_groups = @$removed_groups;

if ($bulk_edit) {
if ($async_bulk_edit) {
my $task = Bugzilla::Task::BulkEdit->new(
ids => \@bug_ids,
set_all => \%set_all_fields,
Expand Down
4 changes: 2 additions & 2 deletions template/en/default/bug/process/bugmail.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
%]
[% recipient_count = sent_bugmail.sent.size %]

[% IF bulk_edit %]
[% IF async_bulk_edit %]
[% show_recipients = 1 %]
[% ELSE %]
<script [% script_nonce FILTER none %]>
Expand Down Expand Up @@ -73,7 +73,7 @@
[% ELSE %]
no one
[% END %]
[% IF NOT bulk_edit %]
[% IF NOT async_bulk_edit %]
(<a href="#" class="toggleBugmailRecipients" data-mailing-bugid="[% mailing_bugid FILTER html %]"
data-mailing-show="false">hide</a>)
[% END %]
Expand Down
2 changes: 1 addition & 1 deletion template/en/default/bug/process/results.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

[% DEFAULT type="bug" %]

[% IF bulk_edit %]
[% IF async_bulk_edit %]
[% Link = BLOCK %][% "$terms.Bug $id" FILTER bug_link(id, full_url => 1) FILTER none %][% END %]
[% link = BLOCK %][% "$terms.bug $id" FILTER bug_link(id, full_url => 1) FILTER none %][% END %]
[% ELSE %]
Expand Down
6 changes: 3 additions & 3 deletions template/en/default/list/edit-multiple.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@
[%+ Hook.process('after_groups') %]

<input type="submit" id="commit" value="Commit">
<input type="checkbox" id="bulk_edit" name="bulk_edit" value="1">
[% IF user.in_group('bulk_edit') %]
<label for="bulk_edit">Bulk Edit</label>
[% IF user.in_group('bz_can_async_bulk_edit') %]
<label for="async_bulk_edit">Bulk Edit in Background</label>
<input type="checkbox" id="async_bulk_edit" name="async_bulk_edit" value="1">
[% END %]

[%############################################################################%]
Expand Down
2 changes: 1 addition & 1 deletion template/en/default/task/created.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
%]

<div id="page-index">
<p>Scheduled [% task.proper_name FILTER html %] task. You'll recieve an email when it is done.</p>.
<p>Scheduled [% task.proper_name FILTER html %] task. You'll recieve an email when it is done.</p>
</div>

[% PROCESS global/footer.html.tmpl %]

0 comments on commit 66a2199

Please sign in to comment.