summaryrefslogtreecommitdiffstats
path: root/extensions/TrackingFlags/template/en/default/hook/bug/create/create-form.html.tmpl
blob: 4bb9e1eab55b656b8263a0855b04fa6592c4c633 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[%
  RETURN UNLESS tracking_flag_components;

  # A list of products that will automatically set cf_status_firefox to
  # "affected" when filing bugs with nightly.  An empty component list
  # denotes all components.
  auto_affected = {
    "Firefox"               = [],
    "Firefox for Android"   = [],
    "Firefox OS"            = [],
    "Core"                  = [],
    "Toolkit"               = [],
    "Firefox Health Report" = [ "Client: Desktop", "Client: Android" ],
  };

  # map product names to lowercase
  FOREACH key IN auto_affected.keys;
    key_lc = key.lower;
    auto_affected.$key_lc = auto_affected.item(key);
  END;
%]

<script>
  $(function() {
    var tracking_flag_components_str = "[% tracking_flag_components FILTER js %]";
    var tracking_flag_components = $.parseJSON(tracking_flag_components_str);
    var highest_status_firefox = '[% highest_status_firefox FILTER js %]';

    $('#component')
      .click(function() {
        // First, we disable all flags.
        $('table.tracking_flags select').attr('disabled', true);
        // Now enable flags available for the selected component.
        var component = $('#component').val();
        if (!component || !tracking_flag_components[component])
          return;
        $.each(tracking_flag_components[component], function(i, v) {
          $('#' + v).attr('disabled', false);
        });
      }).click();

  [% IF highest_status_firefox && auto_affected.exists(product.name.lower) %]
    $('#version, #bug_status, #component')
      .change(function() {
        var version = $('#version').val();
        var component = $('#component').val() || '';
        if ($('#bug_status').val() != 'UNCONFIRMED'
            && (
              version.toLowerCase() == 'trunk'
              || version == highest_status_firefox + ' Branch'
              || version == 'Firefox ' + highest_status_firefox
            )
            [% auto_components = auto_affected.item(product.name.lower) %]
            [% IF auto_components.size %]
              && (
                [% FOREACH auto_component IN auto_components %]
                  [% " || " UNLESS loop.first %]
                  component.toLowerCase() === '[% auto_component.lower FILTER js %]'
                [% END %]
              )
            [% END %]
            )
        {
          $('#cf_status_firefox' + highest_status_firefox).val('affected');
        }
        else {
          $('#cf_status_firefox' + highest_status_firefox).val('---');
        }
      }).change();
  [% END %]
  });
</script>