summaryrefslogtreecommitdiffstats
path: root/extensions/BMO
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2015-07-14 08:52:03 +0200
committerByron Jones <glob@mozilla.com>2015-07-14 08:52:03 +0200
commit425d780e7f77d8cc38191331cbcc84d7af5c871a (patch)
tree31cb71abdccc4d637c35b2769b7840b304a1e91b /extensions/BMO
parent940d6d427109280234dbdad8988b1c3dc7be5969 (diff)
downloadbugzilla-425d780e7f77d8cc38191331cbcc84d7af5c871a.tar.gz
bugzilla-425d780e7f77d8cc38191331cbcc84d7af5c871a.tar.xz
Bug 1173442 - Implement admin UI changes to allow selecting default product security group instead of editing code
Diffstat (limited to 'extensions/BMO')
-rw-r--r--extensions/BMO/Extension.pm40
-rw-r--r--extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl47
2 files changed, 75 insertions, 12 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm
index 5515f56db..2e2a9c168 100644
--- a/extensions/BMO/Extension.pm
+++ b/extensions/BMO/Extension.pm
@@ -158,6 +158,17 @@ sub template_before_process {
$vars->{attachment} = Bugzilla::Attachment->new({ id => $attachid, cache => 1 })
if $attachid;
}
+
+ if ($file =~ /^admin\/products\/(create|edit)\./) {
+ my $product = $vars->{product};
+ my $security_groups = Bugzilla::Group->match({ isbuggroup => 1, isactive => 1 });
+ # If set group is not active currently, we add it into the list
+ if (!grep($_->name eq $product->default_security_group, @$security_groups)) {
+ push(@$security_groups, $product->default_security_group_obj);
+ @$security_groups = sort { $a->name cmp $b->name } @$security_groups;
+ }
+ $vars->{security_groups} = $security_groups;
+ }
}
sub page_before_template {
@@ -678,13 +689,21 @@ sub quicksearch_map {
sub object_columns {
my ($self, $args) = @_;
return unless $args->{class}->isa('Bugzilla::Product');
- push @{ $args->{columns} }, qw( default_platform_id default_op_sys_id );
+ push @{ $args->{columns} }, qw(
+ default_platform_id
+ default_op_sys_id
+ security_group_id
+ );
}
sub object_update_columns {
my ($self, $args) = @_;
return unless $args->{object}->isa('Bugzilla::Product');
- push @{ $args->{columns} }, qw( default_platform_id default_op_sys_id );
+ push @{ $args->{columns} }, qw(
+ default_platform_id
+ default_op_sys_id
+ security_group_id
+ );
}
sub object_before_create {
@@ -693,7 +712,7 @@ sub object_before_create {
my $cgi = Bugzilla->cgi;
my $params = $args->{params};
- foreach my $field (qw( default_platform_id default_op_sys_id )) {
+ foreach my $field (qw( default_platform_id default_op_sys_id security_group_id )) {
$params->{$field} = $cgi->param($field);
}
}
@@ -705,7 +724,7 @@ sub object_end_of_set_all {
my $cgi = Bugzilla->cgi;
my $params = $args->{params};
- foreach my $field (qw( default_platform_id default_op_sys_id )) {
+ foreach my $field (qw( default_platform_id default_op_sys_id security_group_id )) {
my $value = $cgi->param($field);
detaint_natural($value);
$object->set($field, $value);
@@ -1989,16 +2008,15 @@ sub _group_always_settable {
}
sub _default_security_group {
- my ($self) = @_;
- return exists $product_sec_groups{$self->name}
- ? $product_sec_groups{$self->name}
- : $product_sec_groups{_default};
+ return $_[0]->default_security_group_obj->name;
}
sub _default_security_group_obj {
- my ($self) = @_;
- return unless my $group_name = $self->default_security_group;
- return Bugzilla::Group->new({ name => $group_name, cache => 1 })
+ my $group_id = $_[0]->{security_group_id};
+ if (!$group_id) {
+ return Bugzilla::Group->new({ name => Bugzilla->params->{insidergroup}, cache => 1 });
+ }
+ return Bugzilla::Group->new({ id => $group_id, cache => 1 });
}
# called from the verify version, component, and group page.
diff --git a/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl b/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl
index 7093bcfc6..f91e4052b 100644
--- a/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl
+++ b/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl
@@ -6,8 +6,53 @@
# defined by the Mozilla Public License, v. 2.0.
#%]
+[%
+ group_correct_visibility = {};
+ FOREACH g = product.group_controls.values;
+ IF (g.membercontrol == constants.CONTROLMAPSHOWN)
+ && (g.othercontrol == constants.CONTROLMAPSHOWN);
+ group_correct_visibility.${g.name} = 1;
+ ELSE;
+ group_correct_visibility.${g.name} = 0;
+ END;
+ END;
+%]
+
+<tr>
+ <th align="right">Default Security Group:</th>
+ <td>
+ <select required name="security_group_id" id="security_group_id">
+ <option value=""></option>
+ [% FOREACH g IN security_groups %]
+ <option value="[% g.id FILTER html %]"
+ data-group-correct-visibility="[% group_correct_visibility.${g.name} FILTER none %]"
+ [% " selected" IF product.default_security_group_obj.id == g.id %]>
+ [% g.name FILTER html %]
+ </option>
+ [% END %]
+ </select>
+ <span id="security_group_warning" style="color:red; display:none;">
+ The chosen security group needs to be set to SHOWN/SHOWN for this product
+ </span>
+ <script type="text/javascript">
+ var toggleGroupWarning = function() {
+ var correct_shown = $('#security_group_id option:selected')
+ .data('group-correct-visibility');
+ if (correct_shown) {
+ $('#security_group_warning').hide();
+ }
+ else {
+ $('#security_group_warning').show();
+ }
+ };
+ $('#security_group_id').change(toggleGroupWarning);
+ $(document).ready(toggleGroupWarning);
+ </script>
+ </td>
+</tr>
+
<tr>
- <th align="right">Default Platform</th>
+ <th align="right">Default Platform:</th>
<td>
[% INCLUDE default_select
field_name = 'default_platform_id'