Bug 1131862 - mcMerge: Display only the active milestones
authorEd Morley <emorley@mozilla.com>
Tue, 24 Feb 2015 09:30:44 +0000
changeset 1508 b7112fa3e56a495281e826eca56098ae87eb5d5a
parent 1507 51aa56262fc0641025581dcc2731bca8645baa97
child 1509 2cac016caba24a4511d9919be771fbdb03747e8c
push id872
push useremorley@mozilla.com
push dateTue, 24 Feb 2015 23:11:31 +0000
bugs1131862
Bug 1131862 - mcMerge: Display only the active milestones The bzapi config target_milestone property on each product returns all milestones for that product, including the inactive ones. A new property has been added to the API, of form: "target_milestone_detail" : [ { "id" : 2336, "is_active" : true, "name" : "---", "sortkey" : 0 }, We now use target_milestone_detail instead of target_milestone, and filter on is_active to find only the active milestones. We use map() to flattern the list of activate milestone names, so existing consumers do not need to be adjusted.
mcmerge/js/ConfigurationData.js
--- a/mcmerge/js/ConfigurationData.js
+++ b/mcmerge/js/ConfigurationData.js
@@ -53,26 +53,31 @@ var ConfigurationData = {
           break;
         }
       }
     }
     var products = data.product;
     var productMilestones = {}
     for (var product in products) {
       // Parse Milestones
-      var values = products[product].target_milestone;
+      var active_milestones = products[product].target_milestone_detail.filter(function (milestone) {
+        return milestone.is_active;
+      }).map(function (milestone) {
+        return milestone.name;
+      });
       productMilestones[product] = {}
-      productMilestones[product].values = values.map(UI.htmlEncode);
-      var dashIndex = values.indexOf('---');
+      productMilestones[product].values = active_milestones.map(UI.htmlEncode);
+      var dashIndex = active_milestones.indexOf('---');
       if (dashIndex != -1) {
-        if (dashIndex + 1 < values.length && this.useNext.indexOf(product) != -1)
+        if (dashIndex + 1 < active_milestones.length && this.useNext.indexOf(product) != -1) {
           productMilestones[product].defaultIndex = dashIndex + 1;
-        else
+        } else {
           productMilestones[product].defaultIndex = dashIndex;
-      } else
+        }
+      } else {
         productMilestones[product].defaultIndex = 0;
       }
 
       // Find which products/components can have in-testsuite set
       if (this.testsuiteFlagID != -1) {
         this.hasTestsuiteFlag[product] = {};
         for (var component in products[product].component) {
           var hasTestsuite = products[product].component[component].flag_type.indexOf(this.testsuiteFlagID) != -1;