Updating support for Launch with the script launchbugs.html

Added support for EngProd Bit Approvers
Added support for multiple tes and approvers comma separated
Added support for searches without milestone
Added js/getParameters.js for functions that are shared

BUG=None
TEST=go/launchbugs?
- go/launchbugs?te=new
- go/launchbugs?m=105
- go/launchbugs?te=awendy
- go/launchbugs?m=105&te=dhaddock
- go/launchbugs?team=corex
- go/launchbugs?m=108&te=awendy,dhaddock&a=abodeti

Change-Id: I77e36c967edaec0e833ce4c1fbb9c847f66c5130
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crostestutils/+/3988744
Reviewed-by: Hyung Tae Kim <hyungtaekim@chromium.org>
Commit-Queue: Wendy Aleman Martinez <awendy@chromium.org>
Reviewed-by: David Haddock <dhaddock@chromium.org>
Tested-by: Wendy Aleman Martinez <awendy@chromium.org>
diff --git a/provingground/launchbugs/README.md b/provingground/launchbugs/README.md
index 89a93fc..bbced73 100644
--- a/provingground/launchbugs/README.md
+++ b/provingground/launchbugs/README.md
@@ -1,8 +1,8 @@
 # Launchbugs Redirect
 
 ## Launchbugs -- Launch
-launchbugs.html is a helper that opens filtered launchbugs based on Milestones
-and Test Engineers on go/launch
+launchbugs.html is a helper that opens filtered launchbugs based on Milestones,
+Test Engineers, and EngProd Bit Approvers on go/launch
 
 ## Launchbugs Old -- Monorail
 launchbugsold.html is a helper that opens filtered launchbugs based on
@@ -15,6 +15,9 @@
 Filter by Milestone: go/launchbugs?m=105
 Filter by Test Engineers: go/launchbugs?te=dhaddock
 Filter by Team: go/launchbugs?team=coreX
+Filter by Engprod Approvers: go/launchbugs?a=dhaddock
+Filter by Multiple Ldaps: go/launchbugs?te=dhadock,awendy&a=dhadock,awendy
+Filter by Unassigned Launches for a given Milestone: go/launchbugs?te=new&m=109
 
 ### Monorail
 Navigate to go/launchbugsold?
@@ -34,20 +37,23 @@
 After modifying the script, please make sure that the old functionalities are
 still working
 
-Some good urls to test in Monorail:
-- go/launchbugsold?
-- go/launchbugsold?te=new
-- go/launchbugsold?m=105
-- go/launchbugsold?m=105&te=dhaddock
-- go/launchbugsold?team=corex
-- go/launchbugsold?team=corex&m=105
-- go/launchbugsold?&m=101&te=dhaddock&s=Fixed
-- go/launchbugsold?team=corex&m=101&te=sdantuluri&status=Fixed&c=OS>Systems>Update
-
 Some good urls to test in Launch:
 - go/launchbugs?
 - go/launchbugs?te=new
 - go/launchbugs?m=105
 - go/launchbugs?m=105&te=dhaddock
+- go/launchbugs?te=dhaddock
 - go/launchbugs?team=corex
+- go/launchbugs?a=dhaddock
 - go/launchbugs?team=corex&m=105
+
+Some good urls to test in Monorail:
+- go/launchbugsold?
+- go/launchbugsold?te=new
+- go/launchbugsold?m=105
+- go/launchbugsold?m=105&te=dhaddock
+- go/launchbugsold?te=dhaddock
+- go/launchbugsold?team=corex
+- go/launchbugsold?team=corex&m=105
+- go/launchbugsold?&m=101&te=dhaddock&s=Fixed
+- go/launchbugsold?team=corex&m=101&te=sdantuluri&status=Fixed&c=OS>Systems>Update
diff --git a/provingground/launchbugs/js/getParameters.js b/provingground/launchbugs/js/getParameters.js
new file mode 100644
index 0000000..6717ad9
--- /dev/null
+++ b/provingground/launchbugs/js/getParameters.js
@@ -0,0 +1,13 @@
+//  Copyright 2022 The ChromiumOS Authors
+//  Use of this source code is governed by a BSD-style license that can be
+//  found in the LICENSE file.
+function GetURLParameter(sParam) {
+  var sPageURL = window.location.search.substring(1);
+  var sURLVariables = sPageURL.split('&');
+  for (var i = 0; i < sURLVariables.length; i++) {
+    var sParameterName = sURLVariables[i].split('=');
+    if (sParameterName[0] == sParam) {
+      return sParameterName[1];
+    }
+  }
+}
diff --git a/provingground/launchbugs/launchbugs.html b/provingground/launchbugs/launchbugs.html
index b5801aa..8c9b667 100644
--- a/provingground/launchbugs/launchbugs.html
+++ b/provingground/launchbugs/launchbugs.html
@@ -1,61 +1,64 @@
 <!DOCTYPE html>
 <html>
-    <head>
-        <meta charset="utf-8">
-        <title>ChromeOS Launch Bugs go/launchbugs </title>
-    </head>
-    <body >
-      <script>
-            // Read the parameters passed to the url
-            function GetURLParameter(sParam) {
-                var sPageURL = window.location.search.substring(1);
-                var sURLVariables = sPageURL.split('&');
-                for (var i = 0; i < sURLVariables.length; i++) {
-                    var sParameterName = sURLVariables[i].split('=');
-                    if (sParameterName[0] == sParam) {
-                      return sParameterName[1];
-                    }
-                }
-            }
-            var base_url = 'https://launch.corp.google.com/launches?'
-            //Add milestone and TE to launch url and redirect to it
-            function UpdateUrlsWithMilestone(milestone, te, team) {
-              var src = base_url.concat('&q=calendarId:2197 status:current "Stable Target Milestone":"<milestone>" <TE>')
-              src = src.replace(/<milestone>/g, milestone)
-              if (!team){
-                if (!te) {
-                  console.log('No te')
-                  src = src.replace(/<TE>/g, "")
-                }
-                else {
-                  console.log('Replace te')
-                  src = src.replace(/<TE>/g, '"te":"'+te+'"')
-                }
-              }
-              else{ 
-                console.log('Team found, overrides TE')
-                src = src.replace(/<TE>/g, team)
-              }
-              window.location.replace(src);
-            }
-            var m = GetURLParameter('m')
-            var te = GetURLParameter('te')
-            //Add use of team variables
-            var team = GetURLParameter('team')
-            if (team && team.toLowerCase() == "corex"){
-                team = '\"te\":(\"dhaddock\" OR \"kyleshima\" OR \"hyungtaekim\" OR \"awendy\")'
-            }
-            if (te == "new") {
-              console.log('te = new url')
-              window.location.replace(base_url.concat('&q=calendarId:2197 status:current te:NULL'))
-            }
-            else if (!m) {
-              console.log('Error: No milestone supplied.')
-              window.location.replace(base_url.concat('&q=calendarId:2197 status:current'))
-            }
-            else {
-              UpdateUrlsWithMilestone(m, te, team)
-            }
-        </script>
-    </body>
+
+<head>
+  <meta charset="utf-8">
+  <title>ChromeOS Launch Bugs go/launchbugs </title>
+</head>
+
+<body>
+  <script type = "text/javascript" src="js/getParameters.js"></script>
+  <script>
+    var base_url = 'https://launch.corp.google.com/launches?'
+    // Add milestone, TEs, and Approver to launch url and redirect to it
+    function UpdateUrlsWithMilestone(m, team, te, approver) {
+      var src = base_url.concat('&q=calendarId:2197 status:current<milestone><TE><approver>')
+      // Milestone
+      if (!m) {
+        console.log('No Milestone provided')
+        m = ''
+      }
+      else {
+        m = ' ("Stable Target Milestone":"' + m + '" OR "Stable Experiment Target Milestone":"' + m + '")'
+      }
+      src = src.replace(/<milestone>/g, m)
+      // Team Logic overrides TE
+      if (team && team.toLowerCase() == "corex") {
+        console.log('Team found, overrides TE')
+        te = 'dhaddock,kyleshima,hyungtaekim,awendy'
+      }
+      // TE
+      if (!te) {
+        console.log('No TE provided')
+        te = ''
+      }
+      else if (te == "new") {
+        console.log('New TEs')
+        te = ' te:NULL'
+      }
+      else {
+        // Verify if multiple TEs provided
+        te = ' "te":("' +te.replace(/,/g, '" OR "')+ '")'
+      }
+      src = src.replace(/<TE>/g, te)
+      // EngProd Bit Approver
+      if (!approver) {
+        console.log('No Approver provided')
+        approver = ''
+      }
+      else {
+        // Verify if multiple Approvers provided
+        approver =  ' "EngProd owners":("' +approver.replace(/,/g, '" OR "') + '")'
+      }
+      src = src.replace(/<approver>/g, approver)
+      window.location.replace(src);
+    }
+    // Get Params
+    var m = GetURLParameter('m')
+    var team = GetURLParameter('team')
+    var te = GetURLParameter('te')
+    var approver = GetURLParameter('a')
+    UpdateUrlsWithMilestone(m, team, te, approver)
+  </script>
+</body>
 </html>
diff --git a/provingground/launchbugs/launchbugsold.html b/provingground/launchbugs/launchbugsold.html
index dbb2b18..bb36d98 100644
--- a/provingground/launchbugs/launchbugsold.html
+++ b/provingground/launchbugs/launchbugsold.html
@@ -1,77 +1,72 @@
 <!DOCTYPE html>
 <html>
-    <head>
-        <meta charset="utf-8">
-        <title>ChromeOS Launch Bugs go/launchbugsold </title>
-    </head>
-    <body >
-      <script>
-            // Read the parameters passed to the url
-            function GetURLParameter(sParam) {
-                var sPageURL = window.location.search.substring(1);
-                var sURLVariables = sPageURL.split('&');
-                for (var i = 0; i < sURLVariables.length; i++) {
-                    var sParameterName = sURLVariables[i].split('=');
-                    if (sParameterName[0] == sParam) {
-                      return sParameterName[1];
-                    }
-                }
-            }
-            var base_url = 'https://bugs.chromium.org/p/chromium/issues/list?sort=-component te&groupby=&colspec=ID Pri Component Summary TL PM TE ChromeOS-Test stable.M-Target Opened ATFw ChromeOS-Test-approver'
-            //Add milestone and TE to crbug url and redirect to it
-            function UpdateUrlsWithMilestone(milestone, te, s, c) {
-              var src = base_url.concat('&q=(stable.M-Target=<milestone> OR stable-Full.M-Target=<milestone> OR stable-Exp.M-Target=<milestone>) <TE> <COMPONENT> <status>').concat(' OS=Chrome -OS:Mac,IOS,linux,Android,Windows,Fuchsia,All -Status:Duplicate,WontFix has:ChromeOS-Leadership-Full&can=1')
-              src = src.replace(/<milestone>/g, milestone)
-              if (!te) {
-                console.log('No te')
-                src = src.replace(/<TE>/g, "")
-              }
-              else {
-                console.log('replace te')
-                src = src.replace(/<TE>/g, "TE:"+te)
-              }
-              if (!s) {
-                console.log('No status')
-                src = src.replace(/<status>/g, "")
-              }
-              else {
-                console.log('replace status')
-                src = src.replace(/<status>/g, "Status:"+s)
-              }
-              if (!c) {
-                console.log('No component')
-                src = src.replace(/<COMPONENT>/g, "")
-              }
-              else {
-                console.log('replace component')
-                src = src.replace(/<COMPONENT>/g, "component:"+c)
-              }
-              window.location.replace(src);
-            }
-            var m = GetURLParameter('m')
-            var te = GetURLParameter('te')
-            var s = GetURLParameter('status')
-            var c = GetURLParameter('c')
-            //Add use of team variables
-            var team = GetURLParameter('team')
-            if (team && team.toLowerCase() == "corex"){
-                if (!te)
-                    te = 'dhaddock,kyleshima,hyungtaekim,awendy'
-                else if(te != "new"){
-                    te = te.concat(',dhaddock,kyleshima,hyungtaekim,awendy')
-                }
-            }
-            if (te == "new") {
-              console.log('te = new url')
-              window.location.replace(base_url.concat('&num=100&q=Type=FLT-Launch OS=Chrome -OS:Mac,IOS,linux,Android,Windows,Fuchsia,All -ChromeOS-Test=APPROVED has:ChromeOS-Leadership-Full -has:TE&can=2'))
-             }
-            else if (!m) {
-              console.log('Error: No milestone supplied.')
-              window.location.replace(base_url.concat('&num=100&q=Type=FLT-Launch OS=Chrome -OS:Mac,IOS,linux,Android,Windows,Fuchsia,All -ChromeOS-Test=APPROVED has:ChromeOS-Leadership-Full&can=2'))
-            }
-            else {
-              UpdateUrlsWithMilestone(m, te, s, c)
-            }
-        </script>
-    </body>
+
+<head>
+  <meta charset="utf-8">
+  <title>ChromeOS Launch Bugs go/launchbugsold </title>
+</head>
+
+<body>
+  <script type = "text/javascript" src="js/getParameters.js"></script>
+  <script>
+    var base_url = 'https://bugs.chromium.org/p/chromium/issues/list?sort=-component te&groupby=&colspec=ID Pri Component Summary TL PM TE ChromeOS-Test stable.M-Target Opened ATFw ChromeOS-Test-approver'
+    // Add milestone, TE, status, and component to crbug url and redirect to it
+    function UpdateUrlsWithMilestone(m, team, te, s, c) {
+      var src = base_url.concat('&q=<milestone> <TE> <component> <status>').concat(' OS=Chrome -OS:Mac,IOS,linux,Android,Windows,Fuchsia,All -Status:Duplicate,WontFix has:ChromeOS-Leadership-Full&can=1')
+      // Milestone
+      if (!m) {
+        console.log('No Milestone provided')
+        m = ''
+      }
+      else {
+        console.log('Replace Milestone')
+        m = '(stable.M-Target=' + m + ' OR stable-Full.M-Target=' + m + ' OR stable-Exp.M-Target=' + m + ')'
+      }
+      src = src.replace(/<milestone>/g, m)
+      // Team logic overrides TE
+      if (team && team.toLowerCase() == "corex") {
+        console.log('Team found, overrides TE')
+        te = 'dhaddock,kyleshima,hyungtaekim,awendy'
+      }
+      // TE
+      if (!te) {
+        console.log('No TE')
+        te =  ''
+      }
+      else if (te == 'new') {
+        console.log('TE = new')
+        te = '-has:TE'
+      }
+      else {
+        te = 'TE:' + te
+      }
+      src = src.replace(/<TE>/g, te)
+      // Status
+      if (!s) {
+        console.log('No status')
+        s =  ''
+      }
+      else {
+        s = 'Status:' + s
+      }
+      src = src.replace(/<status>/g, s)
+      // Component
+      if (!c) {
+        console.log('No component')
+        c = ''
+      }
+      else {
+        c = 'component:' + c
+      }
+      src = src.replace(/<component>/g, c)
+      window.location.replace(src);
+    }
+    var m = GetURLParameter('m')
+    var team = GetURLParameter('team')
+    var te = GetURLParameter('te')
+    var s = GetURLParameter('status')
+    var c = GetURLParameter('c')
+    UpdateUrlsWithMilestone(m, team, te, s, c)
+  </script>
+</body>
 </html>