]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 77193 - Add the ability to retire (disable) old versions, components and milestones
authorDave Lawrence <dkl@redhat.com>
Tue, 31 Aug 2010 04:20:07 +0000 (00:20 -0400)
committerDave Lawrence <dkl@redhat.com>
Tue, 31 Aug 2010 04:20:07 +0000 (00:20 -0400)
r/a=mkanat

21 files changed:
Bugzilla/Component.pm
Bugzilla/DB/Schema.pm
Bugzilla/Install/DB.pm
Bugzilla/Milestone.pm
Bugzilla/Version.pm
buglist.cgi
editcomponents.cgi
editmilestones.cgi
editversions.cgi
enter_bug.cgi
template/en/default/admin/components/confirm-delete.html.tmpl
template/en/default/admin/components/edit.html.tmpl
template/en/default/admin/components/list.html.tmpl
template/en/default/admin/milestones/edit.html.tmpl
template/en/default/admin/milestones/list.html.tmpl
template/en/default/admin/versions/edit.html.tmpl
template/en/default/admin/versions/list.html.tmpl
template/en/default/bug/create/create.html.tmpl
template/en/default/bug/edit.html.tmpl
template/en/default/bug/field.html.tmpl
template/en/default/global/messages.html.tmpl

index e5eb78a2d941ebf6be519623dee336548cbd2d0a..2a176f5dc47504852fb980b95d05b085e4fda0f2 100644 (file)
@@ -45,6 +45,7 @@ use constant DB_COLUMNS => qw(
     initialowner
     initialqacontact
     description
+    isactive
 );
 
 use constant UPDATE_COLUMNS => qw(
@@ -52,6 +53,7 @@ use constant UPDATE_COLUMNS => qw(
     initialowner
     initialqacontact
     description
+    isactive
 );
 
 use constant REQUIRED_FIELD_MAP => {
@@ -66,6 +68,7 @@ use constant VALIDATORS => {
     description      => \&_check_description,
     initial_cc       => \&_check_cc_list,
     name             => \&_check_name,
+    isactive         => \&Bugzilla::Object::check_boolean,
 };
 
 use constant VALIDATOR_DEPENDENCIES => {
@@ -300,6 +303,7 @@ sub _create_series {
 
 sub set_name { $_[0]->set('name', $_[1]); }
 sub set_description { $_[0]->set('description', $_[1]); }
+sub set_is_active { $_[0]->set('isactive', $_[1]); }
 sub set_default_assignee {
     my ($self, $owner) = @_;
 
@@ -416,6 +420,7 @@ sub product {
 
 sub description { return $_[0]->{'description'}; }
 sub product_id  { return $_[0]->{'product_id'};  }
+sub is_active   { return $_[0]->{'isactive'};    }
 
 ##############################################
 # Implement Bugzilla::Field::ChoiceInterface #
@@ -423,7 +428,6 @@ sub product_id  { return $_[0]->{'product_id'};  }
 
 use constant FIELD_NAME => 'component';
 use constant is_default => 0;
-use constant is_active => 1;
 
 sub is_set_on_bug {
     my ($self, $bug) = @_;
index 2efdbefc415ab8eb8d5a340bc0c5778f9852d071..356480e3ba3b33c445b7af2e82d168d3896c5b72 100644 (file)
@@ -718,6 +718,8 @@ use constant ABSTRACT_SCHEMA => {
                             REFERENCES => {TABLE  => 'products',
                                            COLUMN => 'id',
                                            DELETE => 'CASCADE'}},
+            isactive   =>  {TYPE => 'BOOLEAN', NOTNULL => 1, 
+                            DEFAULT => 'TRUE'},
         ],
         INDEXES => [
             versions_product_id_idx => {FIELDS => [qw(product_id value)],
@@ -736,6 +738,8 @@ use constant ABSTRACT_SCHEMA => {
             value      => {TYPE => 'varchar(20)', NOTNULL => 1},
             sortkey    => {TYPE => 'INT2', NOTNULL => 1,
                            DEFAULT => 0},
+            isactive   => {TYPE => 'BOOLEAN', NOTNULL => 1, 
+                           DEFAULT => 'TRUE'},
         ],
         INDEXES => [
             milestones_product_id_idx => {FIELDS => [qw(product_id value)],
@@ -1264,6 +1268,8 @@ use constant ABSTRACT_SCHEMA => {
                                                 COLUMN => 'userid',
                                                 DELETE => 'SET NULL'}},
             description      => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
+            isactive         => {TYPE => 'BOOLEAN', NOTNULL => 1, 
+                                 DEFAULT => 'TRUE'},
         ],
         INDEXES => [
             components_product_id_idx => {FIELDS => [qw(product_id name)],
index 21739fab9f1c31c4cd711f75f32ee8c09a4ae4cd..df4ea737eac8254bacde0bd0f16453cdf8fcde88 100644 (file)
@@ -631,6 +631,9 @@ sub update_table_definitions {
     # 2010-07-18 LpSolit@gmail.com - Bug 119703
     _remove_attachment_isurl();
 
+    # 2009-05-07 ghendricks@novell.com - Bug 77193
+    _add_isactive_to_product_fields();
+
     ################################################################
     # New --TABLE-- changes should go *** A B O V E *** this point #
     ################################################################
@@ -3397,6 +3400,26 @@ sub _remove_attachment_isurl {
     }
 }
 
+sub _add_isactive_to_product_fields {
+    my $dbh = Bugzilla->dbh;
+
+    # If we add the isactive column all values should start off as active
+    if (!$dbh->bz_column_info('components', 'isactive')) {
+        $dbh->bz_add_column('components', 'isactive', 
+            {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'});
+    }
+    
+    if (!$dbh->bz_column_info('versions', 'isactive')) {
+        $dbh->bz_add_column('versions', 'isactive', 
+            {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'});
+    }
+
+    if (!$dbh->bz_column_info('milestones', 'isactive')) {
+        $dbh->bz_add_column('milestones', 'isactive', 
+            {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'});
+    }
+}
+
 sub _migrate_field_visibility_value {
     my $dbh = Bugzilla->dbh;
 
index cb7d53da3fe4d6da3565fa6b277b6ba485989e3e..92bc2192a719af87768099a5218ecc6ae3d2a0ae 100644 (file)
@@ -43,6 +43,7 @@ use constant DB_COLUMNS => qw(
     value
     product_id
     sortkey
+    isactive
 );
 
 use constant REQUIRED_FIELD_MAP => {
@@ -52,12 +53,14 @@ use constant REQUIRED_FIELD_MAP => {
 use constant UPDATE_COLUMNS => qw(
     value
     sortkey
+    isactive
 );
 
 use constant VALIDATORS => {
-    product => \&_check_product,
-    sortkey => \&_check_sortkey,
-    value   => \&_check_value,
+    product  => \&_check_product,
+    sortkey  => \&_check_sortkey,
+    value    => \&_check_value,
+    isactive => \&Bugzilla::Object::check_boolean,
 };
 
 use constant VALIDATOR_DEPENDENCIES => {
@@ -203,8 +206,9 @@ sub _check_product {
 # Methods
 ################################
 
-sub set_name { $_[0]->set('value', $_[1]); }
-sub set_sortkey { $_[0]->set('sortkey', $_[1]); }
+sub set_name      { $_[0]->set('value', $_[1]);    }
+sub set_sortkey   { $_[0]->set('sortkey', $_[1]);  }
+sub set_is_active { $_[0]->set('isactive', $_[1]); }
 
 sub bug_count {
     my $self = shift;
@@ -226,6 +230,7 @@ sub bug_count {
 sub name       { return $_[0]->{'value'};      }
 sub product_id { return $_[0]->{'product_id'}; }
 sub sortkey    { return $_[0]->{'sortkey'};    }
+sub is_active  { return $_[0]->{'isactive'};   }
 
 sub product {
     my $self = shift;
index 4270b1e5fda9e4e1b46b5fce231619f9631d4f9a..7f53add138996e95094a0deb847f9259bd5d5fa1 100644 (file)
@@ -44,6 +44,7 @@ use constant DB_COLUMNS => qw(
     id
     value
     product_id
+    isactive
 );
 
 use constant REQUIRED_FIELD_MAP => {
@@ -52,11 +53,13 @@ use constant REQUIRED_FIELD_MAP => {
 
 use constant UPDATE_COLUMNS => qw(
     value
+    isactive
 );
 
 use constant VALIDATORS => {
-    product => \&_check_product,
-    value   => \&_check_value,
+    product  => \&_check_product,
+    value    => \&_check_value,
+    isactive => \&Bugzilla::Object::check_boolean,
 };
 
 use constant VALIDATOR_DEPENDENCIES => {
@@ -153,6 +156,7 @@ sub remove_from_db {
 ###############################
 
 sub product_id { return $_[0]->{'product_id'}; }
+sub is_active  { return $_[0]->{'isactive'};   }
 
 sub product {
     my $self = shift;
@@ -166,7 +170,8 @@ sub product {
 # Validators
 ################################
 
-sub set_name { $_[0]->set('value', $_[1]); }
+sub set_name      { $_[0]->set('value', $_[1]);    }
+sub set_is_active { $_[0]->set('isactive', $_[1]); }
 
 sub _check_value {
     my ($invocant, $name, undef, $params) = @_;
index d43e065354c8f760b4931078ee9f90e56c485e89..38681ff931e90da0e0041c9077f9d72614728109 100755 (executable)
@@ -1171,11 +1171,11 @@ if ($dotweak && scalar @bugs) {
     # versions for the product (if there is only one product on the list of
     # products), and a list of components for the product.
     if ($one_product) {
-        $vars->{'versions'} = [map($_->name ,@{ $one_product->versions })];
-        $vars->{'components'} = [map($_->name, @{ $one_product->components })];
+        $vars->{'versions'} = [map($_->name, grep($_->is_active, @{ $one_product->versions }))];
+        $vars->{'components'} = [map($_->name, grep($_->is_active, @{ $one_product->components }))];
         if (Bugzilla->params->{'usetargetmilestone'}) {
-            $vars->{'targetmilestones'} = [map($_->name, 
-                                               @{ $one_product->milestones })];
+            $vars->{'targetmilestones'} = [map($_->name, grep($_->is_active,  
+                                               @{ $one_product->milestones }))];
         }
     }
 }
index fd30daed45f38f8ae78734cb0aaf118d255762c7..7da22211b1b98d9a0a1e0b5f32dc4a15e82c4315 100755 (executable)
@@ -128,6 +128,7 @@ if ($action eq 'new') {
     my $default_qa_contact = trim($cgi->param('initialqacontact') || '');
     my $description        = trim($cgi->param('description')      || '');
     my @initial_cc         = $cgi->param('initialcc');
+    my $isactive           = $cgi->param('isactive');
 
     my $component = Bugzilla::Component->create({
         name             => $comp_name,
@@ -230,7 +231,8 @@ if ($action eq 'update') {
     my $default_qa_contact    = trim($cgi->param('initialqacontact') || '');
     my $description           = trim($cgi->param('description')      || '');
     my @initial_cc            = $cgi->param('initialcc');
-
+    my $isactive              = $cgi->param('isactive');
+  
     my $component =
         Bugzilla::Component->check({ product => $product, name => $comp_old_name });
 
@@ -239,6 +241,7 @@ if ($action eq 'update') {
     $component->set_default_assignee($default_assignee);
     $component->set_default_qa_contact($default_qa_contact);
     $component->set_cc_list(\@initial_cc);
+    $component->set_is_active($isactive);
     my $changes = $component->update();
 
     $vars->{'message'} = 'component_updated';
index ff5076bee4141d8f37030835b7456a2c974f50fa..ca1c4368e8fcd50f7920c0e69992c875f23d9d06 100755 (executable)
@@ -60,6 +60,7 @@ my $sortkey        = trim($cgi->param('sortkey')     || 0);
 my $action         = trim($cgi->param('action')      || '');
 my $showbugcounts = (defined $cgi->param('showbugcounts'));
 my $token          = $cgi->param('token');
+my $isactive       = $cgi->param('isactive');
 
 #
 # product = '' -> Show nice list of products
@@ -115,9 +116,11 @@ if ($action eq 'add') {
 
 if ($action eq 'new') {
     check_token_data($token, 'add_milestone');
-    my $milestone = Bugzilla::Milestone->create({ value   => $milestone_name,
-                                                  product => $product,
-                                                  sortkey => $sortkey });
+
+    my $milestone = Bugzilla::Milestone->create({ value    => $milestone_name,
+                                                  product  => $product,
+                                                  sortkey  => $sortkey });
+
     delete_token($token);
 
     $vars->{'message'} = 'milestone_created';
@@ -205,6 +208,7 @@ if ($action eq 'update') {
 
     $milestone->set_name($milestone_name);
     $milestone->set_sortkey($sortkey);
+    $milestone->set_is_active($isactive);
     my $changes = $milestone->update();
     # Reloading the product since the default milestone name
     # could have been changed.
index 0888ef0c64376c2007198df88a6a2990a065ab9d..165a174b5ad0947693402a2a542afeaaf3f9a08d 100755 (executable)
@@ -63,6 +63,7 @@ my $version_name = trim($cgi->param('version') || '');
 my $action       = trim($cgi->param('action')  || '');
 my $showbugcounts = (defined $cgi->param('showbugcounts'));
 my $token        = $cgi->param('token');
+my $isactive     = $cgi->param('isactive');
 
 #
 # product = '' -> Show nice list of products
@@ -204,6 +205,7 @@ if ($action eq 'update') {
     $dbh->bz_start_transaction();
 
     $version->set_name($version_name);
+    $version->set_is_active($isactive);
     my $changes = $version->update();
 
     $dbh->bz_commit_transaction();
index b1889cd03339d994e8b3f4c0a832545ab54b1a6f..9b5eb52c0dad0f4d75287ae63354359e240aa6ed 100755 (executable)
@@ -502,7 +502,7 @@ else {
 #
 # Eventually maybe each product should have a "current version"
 # parameter.
-$vars->{'version'} = [map($_->name, @{$product->versions})];
+$vars->{'version'} = $product->versions;
 
 my $version_cookie = $cgi->cookie("VERSION-" . $product->name);
 
@@ -521,7 +521,7 @@ if ( ($cloned_bug_id) &&
 
 # Get list of milestones.
 if ( Bugzilla->params->{'usetargetmilestone'} ) {
-    $vars->{'target_milestone'} = [map($_->name, @{$product->milestones})];
+    $vars->{'target_milestone'} = $product->milestones;
     if (formvalue('target_milestone')) {
        $default{'target_milestone'} = formvalue('target_milestone');
     } else {
index e2caa5208b23ff69d515cd55fbafca780fd783cb..da934f4200ef57dc0c070891da8ae7100a5c2e85 100644 (file)
@@ -83,7 +83,7 @@ from '[% product.name FILTER html %]' product
 </tr>
 <tr>
   <TD VALIGN="top">Open for [% terms.bugs %]:</TD>
-  <TD VALIGN="top">[% IF product.is_active %]Yes[% ELSE %]No[% END %]</td>
+  <TD VALIGN="top">[% IF product.is_active && comp.isactive %]Yes[% ELSE %]No[% END %]</td>
 </tr>
 <tr>
   <td valign="top">[% terms.Bugs %]:</td>
index e34e18d0c88f2a517c092942dabf9bbae1680257..b5fc3c321c87095d611c55daf54adc19c9611e27 100644 (file)
 
     [% PROCESS "admin/components/edit-common.html.tmpl" %]
 
+    <tr>
+      <td><label for="isactive">Enabled For [% terms.Bugs %]:</label></td>
+      <td><input id="isactive" name="isactive" type="checkbox" value="1" 
+                 [% 'checked="checked"' IF comp.isactive %]></td>
+    </tr>
     <tr>
       <td>[% terms.Bugs %]:</td>
       <td>
index b62ce1bae6b39b74ca82c953f3a60732d48afbd5..b45b9756596b788a004bd072256cd3001471ece1 100644 (file)
        name => "initialowner"
        heading => "Default Assignee"
      },
+     {
+       name => "isactive"
+       heading => "Active"
+       yesno_field => 1
+     },
    ]
 %]
 
index dfe9d1bd8baaf7d525e0fa0d2e56ddd4ddd09960..6a2be869e80bdd5960cbd153111a5540ca86e051 100644 (file)
       <td><input id="sortkey" size="20" maxlength="20" name="sortkey" value="
       [%- milestone.sortkey FILTER html %]"></td>
     </tr>
-
+    <tr>
+      <th><label for="isactive">Enabled For [% terms.Bugs %]:</label></th>
+      <td><input id="isactive" name="isactive" type="checkbox" value="1"
+                 [% 'checked="checked"' IF milestone.isactive %]></td>
+    </tr>
   </table>
 
   <input type="hidden" name="milestoneold" value="[% milestone.name FILTER html %]">
index 56f621e1efc9b866d192efc8e72f576f6539ee7e..6392f567f73b14c5d36c4d4c2149e4910d25975e 100644 (file)
      { 
        name => "sortkey"
        heading => "Sortkey"
+     },
+     {
+       name => "isactive"
+       heading => "Active"
+       yesno_field => 1
      }
    ]
 %]
index 2a7c78423a52310ed1c0450b140ac6c05971854c..1de233567361ab65da6bbf52a4a65a01b4044565 100644 (file)
       <td><input id="version" size="64" maxlength="64" name="version" value="
       [%- version.name FILTER html %]"></td>
     </tr>
-
+    <tr>
+      <th><label for="isactive">Enabled For [% terms.Bugs %]:</label></th>
+      <td><input id="isactive" name="isactive" type="checkbox" value="1"
+                 [% 'checked="checked"' IF version.isactive %]></td>
+    </tr>
   </table>
 
   <input type="hidden" name="versionold" value="[% version.name FILTER html %]">
index ae21bbf5c8294d23c0f7ac1bb842034a9bc20870..69435d22031a717100f78500da82bf184ab5209a 100644 (file)
        name => "name"
        heading => "Edit version..."
        contentlink => edit_contentlink
+     },
+     {
+       name => "isactive"
+       heading => "Active"
+       yesno_field => 1
      }
    ]
 %]
index 08eb44c4e869f7b4ae9a91730c94293ffe40690b..ebb2228507db056534d42e846ed33fe96f8bd23e 100644 (file)
@@ -238,6 +238,7 @@ TUI_hide_default('attachment_text_field');
         [% END %]
 
         [%- FOREACH c = product.components %]
+          [% NEXT IF NOT c.is_active %]
           <option value="[% c.name FILTER html %]"
                   id="v[% c.id FILTER html %]_component"
             [% IF c.name == default.component_ %]
@@ -288,8 +289,9 @@ TUI_hide_default('attachment_text_field');
     <td rowspan="3">
       <select name="version" id="version" size="5">
         [%- FOREACH v = version %]
-          <option value="[% v FILTER html %]"
-            [% ' selected="selected"' IF v == default.version %]>[% v FILTER html -%]
+          [% NEXT IF NOT v.is_active %]
+          <option value="[% v.name FILTER html %]"
+            [% ' selected="selected"' IF v.name == default.version %]>[% v.name FILTER html -%]
           </option>
         [%- END %]
       </select>
@@ -733,9 +735,10 @@ TUI_hide_default('attachment_text_field');
     <select name="[% field.name FILTER html %]" 
             id="[% field.name FILTER html %]">
     [%- FOREACH x = ${field.name} %]
-      <option value="[% x FILTER html %]"
-        [% " selected=\"selected\"" IF x == default.${field.name} %]>
-        [% display_value(field.name, x) FILTER html %]
+      [% NEXT IF NOT x.is_active %]
+      <option value="[% x.name FILTER html %]"
+        [% " selected=\"selected\"" IF x.name == default.${field.name} %]>
+        [% display_value(field.name, x.name) FILTER html %]
       </option>
     [% END %]
     </select>
index 0a558ecc199a4ac0dc8c40ee34e45434d276c46c..4b5e7769e4d89ef090adabe5200db11ed4f6e6a4 100644 (file)
           AND bug.choices.${selname}.size > 1 %]
       <select id="[% selname %]" name="[% selname %]">
         [% FOREACH x = bug.choices.${selname} %]
+          [% NEXT IF NOT x.is_active AND x.name != bug.${selname} %]
           <option value="[% x.name FILTER html %]"
             [% " selected" IF x.name == bug.${selname} %]>
             [%- x.name FILTER html %]
index 34347b21c80a796d2ee6f992a57edab97e2a3198..4065b3af0cf07e4088d637acccf46530f7c8c751 100644 (file)
             [% legal_values = field.legal_values %]
           [% END %]
           [% FOREACH legal_value = legal_values %]
+            [% NEXT IF NOT legal_value.is_active AND NOT value.contains(legal_value.name).size %]
             <option value="[% legal_value.name FILTER html %]"
                     id="v[% legal_value.id FILTER html %]_
                         [%- field.name FILTER html %]"
index 85c2ed513cc154cc8ca2e32022d21559895e98c7..8747c56bf43820bc43ccf41aaad52d08078547f7 100644 (file)
           <li>Default CC list deleted</li>
         [% END %]
       [% END %]
+      [% IF changes.isactive.defined %]
+        <li>[% comp.is_active ? "Enabled" : "Disabled" %] for [% terms.bugs %]</li>
+      [% END %]
       [% Hook.process('component_updated_fields') %]
       </ul>
     [% ELSE %]
         [% IF changes.sortkey.defined %]
           <li>Sortkey updated to <em>[% milestone.sortkey FILTER html %]</em>
         [% END %]
+        [% IF changes.isactive.defined %]
+          <li>[% milestone.is_active ? "Enabled" : "Disabled" %] for [% terms.bugs %]</li>
+        [% END %]
       </ul>
     [% ELSE %]
       No changes made to milestone <em>[% milestone.name FILTER html %]</em>.
   [% ELSIF message_tag == "version_updated" %]
     [% title = "Version Updated" %]
     [% IF changes.size %]
-      [% IF changes.value.defined %]
-        Version renamed to <em>[% version.name FILTER html %]</em>.
-      [% END %]
+      Changes to the version <em>[% version.name FILTER html %]</em>
+      have been saved:
+      <ul>
+        [% IF changes.value.defined %]
+          <li>Version renamed to <em>[% version.name FILTER html %]</em></li>
+        [% END %]
+        [% IF changes.isactive.defined %]
+          <li>[% version.is_active ? "Enabled" : "Disabled" %] for [% terms.bugs %]</li>
+        [% END %]
+      </ul>
     [% ELSE %]
       No changes made to version <em>[% version.name FILTER html %]</em>.
     [% END %]