summaryrefslogtreecommitdiffstats
path: root/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
blob: 5d38d8340a7661ff6666360d28576cafb0beacc6 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
[%# 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.
  #%]

[%
  USE Bugzilla;

  bug_modal = 1;

  # only edit one bug
  UNLESS bug.defined;
    bug = bugs.0;
  END;
  bugid = bug.id;

  # these are used in a few places
  is_cced = bug.cc.contains(user.login);
  unassigned = (bug.assigned_to.login == Param('nobody_user'))
               || (bug.assigned_to.login.search('\.bugs$'));

  # custom fields that have custom rendering, or should not be rendered
  rendered_custom_fields = [
    'cf_user_story',
    'cf_last_resolved',
  ];

  # all custom fields
  custom_fields = Bugzilla.active_custom_fields(product => bug.product_obj, component => bug.component_obj, bug_id => bug.id);

  # extract needinfo flags
  needinfo = [];
  FOREACH flag_type IN bug.flag_types;
    IF flag_type.name == 'needinfo';
    needinfo_flag_type = flag_type;
      FOREACH flag IN flag_type.flags;
        IF flag.status == '?';
          needinfo.push(flag);
        END;
      END;
    END;
  END;

  # count attachments
  active_attachments = 0;
  obsolete_attachments = 0;
  FOREACH attachment IN bug.attachments;
    NEXT IF attachment.isprivate && !(user.is_insider || attachment.attacher.id == user.id);
    IF attachment.isobsolete;
      obsolete_attachments = obsolete_attachments + 1;
    ELSE;
      active_attachments = active_attachments + 1;
    END;
  END;

  # count set bug flags (excluding needinfo)
  has_bug_flags = 0;
  FOREACH flag IN bug.flags;
    NEXT IF flag.name == 'needinfo';
    has_bug_flags = 1;
    LAST;
  END;

  # count set project/tracking/blocking flags
  tracking_flags_has = 0;
  tracking_flags_set = 0;
  project_flags_has = 0;
  project_flags_set = 0;
  blocking_flags_has = 0;
  blocking_flags_set = 0;
  FOREACH flag IN tracking_flags;
    is_set = flag.bug_flag(bug.id).value != "---";
    IF flag.flag_type == "tracking";
      tracking_flags_has = 1;
      IF is_set;
        tracking_flags_set = 1;
      END;
    END;
    IF flag.flag_type == "project";
      project_flags_has = 1;
      IF is_set;
        project_flags_set = 1;
      END;
    END;
    IF flag.flag_type == 'blocking';
      blocking_flags_has = 1;
      IF is_set;
        blocking_flags_set = 1;
      END;
    END;
  END;

  # build firefox flags subtitle
  firefox_flags = [];
  firefox_fixed_versions = [];
  scores = {firefox => 0, thunderbird => 0, seamonkey => 0};
  tracking_flags_title = "Firefox Tracking Flags";
  # project flags
  FOREACH row IN tracking_flags_table;
    NEXT UNLESS row.type == "project";
    status_value = row.status.bug_flag(bug.id).value;
    NEXT IF status_value == "---";
    firefox_flags.push(row.name _ ":" _ status_value);
  END;
  # tracking flags title and subtitle
  FOREACH row IN tracking_flags_table;
    NEXT UNLESS row.type == "tracking";
    tracking_value = row.tracking ? row.tracking.bug_flag(bug.id).value : "---";
    status_value = row.status.bug_flag(bug.id).value || "---";
    NEXT IF tracking_value == "---" && status_value == "---";
    blurb = row.name;
    IF tracking_value != "---";
      blurb = blurb _ tracking_value;
    END;
    IF status_value != "---";
      blurb = blurb _ " " _ status_value;
      IF status_value == "fixed" || status_value == "verified";
        flag_name = row.name;
        IF flag_name.substr(0, 7) == "firefox";
          IF firefox_fixed_versions.0 == "";
            firefox_fixed_versions.0 = "Firefox " _ flag_name.substr(7);
          END;
        ELSIF flag_name.substr(0, 4) == "b2g-";
          IF firefox_fixed_versions.1 == "";
            firefox_fixed_versions.1 = "Firefox OS " _ flag_name.substr(4);
          END;
        END;
      END;
    END;
    firefox_flags.push(blurb);
    IF row.name.search("^thunderbird");
      scores.thunderbird = scores.thunderbird + 1;
    ELSIF row.name.search("^seamonkey");
      scores.seamonkey = scores.seamonkey + 1;
    ELSE;
      scores.firefox = scores.firefox + 1;
    END;
  END;
  IF scores.thunderbird AND NOT scores.firefox;
    tracking_flags_title = "Thunderbird Tracking Flags";
  ELSIF scores.seamonkey AND NOT scores.firefox;
    tracking_flags_title = "SeaMonkey Tracking Flags";
  END;
  firefox_fixed_version = firefox_fixed_versions.join(", ");
  IF firefox_flags.size;
    firefox_flags_subtitle = firefox_flags.join(", ");
  ELSE;
    firefox_flags_subtitle = "Not tracked";
  END;
%]

[% IF user.id %]
  <form name="changeform" id="changeform" method="post" action="process_bug.cgi"[% IF bug.groups_in.size %] autocomplete="nope"[% END %]>
  <input type="hidden" name="delta_ts" value="[% bug.delta_ts FILTER html %]">
  <input type="hidden" name="longdesclength" value="[% bug.comments.size FILTER html %]">
  <input type="hidden" name="id" id="bug_id" value="[% bug.bug_id FILTER html %]">
  <input type="hidden" name="format" value="modal">
  <input type="hidden" name="editing" id="editing" value="">
  <input type="hidden" name="token" value="[% issue_hash_token([bug.id, bug.delta_ts]) FILTER html %]">

  [% PROCESS bug_modal/navigate.html.tmpl %]
[% END %]

[%# === header === %]

<div id="xhr-error" style="display:none"></div>
<div id="floating-message" style="display:none">
  <div id="floating-message-text"></div>
</div>

[% WRAPPER bug_modal/module.html.tmpl
    title = ""
%]
  <div id="summary-container">
    [%# bug id, alias, and summary %]
    [% WRAPPER bug_modal/field.html.tmpl
        container = 1
        no_label = 1
        view_only = 1
    %]
      <div id="field-value-bug_id">
        [% this_bug_href = "show_bug.cgi?id=$bug.id" %]
        [% IF cgi.param("format") %]
          [% format_uri = cgi.param("format") FILTER uri %]
          [% this_bug_href = this_bug_href _ "&format=" _ format_uri %]
        [% END %]
        <a id="this-bug" href="[% this_bug_href FILTER html %]">
          [%~ terms.Bug _ " " _ bug.id FILTER none ~%]
        </a>
        [% IF bug.alias %]
          <span class="edit-hide">
            ([% bug.alias FILTER html %])
          </span>
        [% END %]
      </div>
    [% END %]
    [% WRAPPER bug_modal/field.html.tmpl
        container = 1
        no_label = 1
        hide_on_edit = 1
    %]
      <h1 id="field-value-short_desc">[% bug.short_desc FILTER quoteUrls(bug) FILTER wbr %]</h1>
    [% END %]

    [%# alias %]
    [% INCLUDE bug_modal/field.html.tmpl
        field = bug_fields.alias
        field_type = constants.FIELD_TYPE_FREETEXT
        hide_on_view = 1
        short_width = 1
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#alias"
    %]

    [%# summary %]
    [% INCLUDE bug_modal/field.html.tmpl
        field = bug_fields.short_desc
        field_type = constants.FIELD_TYPE_FREETEXT
        hide_on_view = 1
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#short_desc"
        required = 1
    %]

    [%# status summary %]
    [% WRAPPER bug_modal/field.html.tmpl
        name = "status_summary"
        no_label = 1
        hide_on_edit = 1
    %]
      <b class="bz_status_[% bug.bug_status FILTER html %]">
        [% bug.bug_status FILTER html %]
        [%+ bug.resolution FILTER html IF bug.resolution %]
      </b>
      [% IF bug.resolution == "FIXED"
            && bug.target_milestone
            && bug.target_milestone != "---"
      %]
        in [% firefox_fixed_version || bug.target_milestone FILTER html %]
      [% ELSIF bug.dup_id %]
        of [% terms.bug _ " $bug.dup_id" FILTER bug_link(bug.dup_id) FILTER none %]
      [% ELSIF bug.resolution == "" %]
        <div id="status-assignee">
          [%
            IF unassigned;
              "Unassigned";
            ELSE;
              "Assigned to ";
              INCLUDE bug_modal/user.html.tmpl u=bug.assigned_to nick_only=1;
            END;
          %]
        </div>
      [% END %]
      [% IF needinfo.size %]
        <div id="status-needinfo">
          [%~ IF needinfo.size == 1 %]
            [%
              ni = needinfo.0;
              activity_id = bug.find_activity_id_for_flag(ni);
            %]
            [% IF activity_id %]
              (<a href="#[% activity_id FILTER none %]"
            [% ELSE %]
              (<span
            [% END %]
            [% IF user.setting("ui_use_absolute_time") == "on" %]
              class="flag-name-status abs-time-title[% " activity-ref" IF activity_id %]"
              title="[% ni.creation_date FILTER time("%Y-%m-%d %H:%M %Z") FILTER html %]"
            [% ELSE %]
              class="flag-name-status rel-time-title[% " activity-ref" IF activity_id %]"
              title="[% ni.creation_date FILTER time_duration FILTER html %]"
            [% END %]
              data-time="[% ni.creation_date FILTER epoch FILTER none %]"
            >NeedInfo
            [% activity_id ? "</a>" : "</span>" %]
            from
            [%
              IF ni.requestee;
                INCLUDE bug_modal/user.html.tmpl u=ni.requestee nick_only=1;
              ELSE;
                "anyone";
              END;
            %])
          [% ELSE %]
            (Needinfo from [% needinfo.size FILTER none %] people)
          [% END ~%]
        </div>
      [% END %]
    [% END %]
  </div>

  [%# buttons %]

  <div id="mode-container">
    <div>
      [% IF user.id %]
        <button type="button" id="cancel-btn" class="minor" style="display:none">Cancel</button>
        <button type="button" id="mode-btn" class="major">
          <span id="mode-btn-readonly" title="Enable editing fields for [% terms.bug %] metadata">Edit [% terms.Bug %]</span>
          <span id="mode-btn-loading">
            <img id="edit-throbber" src="extensions/BugModal/web/throbber.gif" width="16" height="11">
            Fetching
          </span>
        </button>
        <button type="submit" id="commit-btn" class="save-btn major" style="display:none">Save Changes</button>
      [% END %]
    </div>
    <div class="button-row">
      [% IF bug.assigned_to.id == user.id || user.in_group("editbugs") %]
        <button type="button" id="copy-summary" class="minor"
          title="Copy [% terms.bug %] number and summary to your clipboard">Copy Summary</button>
        <div id="clip-container" style="display:none"><input type="text" id="clip"></div>
      [% END %]
      [% IF user.id %]
        <button type="button" class="minor" id="cc-btn" data-is-cced="[% is_cced ? 1 : 0 %]">
          [% is_cced ? "Stop Following" : "Follow" %]
        </button>
      [% END %]
      <div class="dropdown">
        <button type="button" id="action-menu-btn" aria-haspopup="true" aria-label="Actions Menu"
          aria-expanded="false" aria-controls="action-menu" class="dropdown-button minor">&#9662;</button>
        <ul class="dropdown-content left" id="action-menu" role="menu" style="display:none;">
          <li role="presentation">
            <a id="action-reset" role="menuitem" tabindex="-1">Reset Sections</a>
          </li>
          <li role="presentation">
            <a id="action-expand-all" role="menuitem" tabindex="-1">Expand All Sections</a>
          </li>
          <li role="presentation">
            <a id="action-collapse-all" role="menuitem" tabindex="-1">Collapse All Sections</a>
          </li>
          <li role="separator"></li>
          [% IF user.id %]
            <li role="presentation">
              <a id="action-add-comment" role="menuitem" tabindex="-1">Add Comment</a>
            </li>
          [% END %]
          <li role="presentation">
            <a id="action-last-comment" role="menuitem" tabindex="-1">Last Comment</a>
          </li>
          <li role="separator"></li>
          <li role="presentation">
            <a id="action-history" role="menuitem" tabindex="-1">History</a>
          </li>
        </ul>
      </div>
    </div>
    <div id="user-guide">
      <a title="User guide for [% terms.Bugzilla %]" href="https://wiki.mozilla.org/BMO/UserGuide">Get help with this page</a>
    </div>
  </div>
[% END %]

[%# === status === %]
[% IF readable_bug_status_json %]
    [% readable_bug_status_span = BLOCK -%]
        [%- %]<span id="readable-bug-status" data-readable-bug-status="[% readable_bug_status_json FILTER html %]"></span>
    [% END %]

    [% subtitle = [{ unfiltered = readable_bug_status_span }] %]
[% END %]

[% WRAPPER bug_modal/module.html.tmpl
    title = "Status"
%]
  [% WRAPPER fields_lhs %]

    [%# product %]
    [% can_edit_product   = bug.check_can_change_field("product", 0, 1) %]
    [% filtered_product   = bug.product_obj.name FILTER uri %]
    [% filtered_component = bug.component_obj.name FILTER uri %]
    [% WRAPPER bug_modal/field.html.tmpl
        field        = bug_fields.product
        field_type   = constants.FIELD_TYPE_SINGLE_SELECT
        hide_on_edit = can_edit_product
        help         = "describecomponents.cgi?product=$filtered_product"
    %]
      <div class="name-info-outer dropdown">
        <span id="product-name" class="dropdown-button" tabindex="0" role="button"
             aria-haspopup="menu" aria-controls="product-info">
          [% bug.product FILTER html %]
          <span class="icon" aria-hidden="true">&#x25BE;</span>
        </span>
        <aside id="product-info" class="name-info-popup dropdown-content right hover-display" hidden role="menu"
               aria-label="Product description and actions">
          <header>
            <div class="title">[%~ bug.product FILTER html ~%]</div>
            <div class="description">[% bug.product_obj.description FILTER html_light %]</div>
          </header>
          <li role="separator"></li>
          <div class="actions">
            <div><a href="buglist.cgi?product=[% bug.product FILTER uri %]&amp;bug_status=__open__"
                    target="_blank" role="menuitem" tabindex="-1">See Other [% terms.Bugs %]</a></div>
            <div><button disabled type="button" class="minor component-watching" role="menuitem" tabindex="-1"
                         data-product="[% bug.product FILTER html %]"
                         data-label-watch="Watch This Product" data-label-unwatch="Unwatch This Product"
                         data-source="BugModal">Watch This Product</button></div>
          </div>
        </aside>
      </div>
    [% END %]
    [% WRAPPER bug_modal/field.html.tmpl
        field          = bug_fields.product
        field_type     = constants.FIELD_TYPE_SINGLE_SELECT
        hide_on_view   = 1
        hide_on_edit   = !can_edit_product
        append_content = 1
        help           = "describecomponents.cgi?product=$filtered_product"
    %]
      <span id="product-search-container">
        [% INCLUDE prodcompsearch/form.html.tmpl
            id            = "pcs"
            custom_select = 1
            hidden        = 1
            throbber      = "product-throbber"
        %]
        <button id="product-search" type="button" class="minor">Search</button>
        <button id="product-search-cancel" type="button" class="minor" style="display:none">X</button>
        <img id="product-throbber" src="extensions/BugModal/web/throbber.gif"
          width="16" height="11" style="display:none">
        <img id="product-search-error" class="tt" src="extensions/BugModal/web/error.png"
          width="16" height="16" style="display:none">
      </span>
    [% END %]

    [%# component %]
    [% WRAPPER bug_modal/field.html.tmpl
        field      = bug_fields.component
        field_type = constants.FIELD_TYPE_SINGLE_SELECT
        help       = "describecomponents.cgi?product=$filtered_product&component=$filtered_component#$filtered_component"

    %]
      <div class="name-info-outer dropdown">
        <span id="component-name" class="dropdown-button" tabindex="0" role="button"
             aria-haspopup="menu" aria-controls="component-info">
          [% bug.component FILTER html %]
          <span class="icon" aria-hidden="true">&#x25BE;</span>
        </span>
        <aside id="component-info" class="name-info-popup dropdown-content right hover-display" hidden role="menu"
               aria-label="Component description and actions">
          <header>
            <div class="title">[%~ bug.product _ " :: " _ bug.component FILTER html ~%]</div>
            <div class="description">[% bug.component_obj.description FILTER html_light %]</div>
          </header>
          <li role="separator"></li>
          <div class="actions">
            <div><a href="buglist.cgi?product=[% bug.product FILTER uri %]&amp;
                          [%~ %]component=[% bug.component FILTER uri %]&amp;bug_status=__open__"
                    target="_blank" role="menuitem" tabindex="-1">See Other [% terms.Bugs %]</a></div>
            <div><button disabled type="button" class="minor component-watching" role="menuitem" tabindex="-1"
                         data-product="[% bug.product FILTER html %]" data-component="[% bug.component FILTER html %]"
                         data-label-watch="Watch This Component" data-label-unwatch="Unwatch This Component"
                         data-source="BugModal">Watch This Component</button></div>
          </div>
        </aside>
      </div>
    [% END %]

    [%# importance %]
    [% WRAPPER bug_modal/field.html.tmpl
        label = "Importance"
        container = 1
        hide_on_view = bug.priority == "--" && bug.bug_severity == "normal"
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#priority"
    %]
      [% INCLUDE bug_modal/field.html.tmpl
          field = bug_fields.priority
          field_type = constants.FIELD_TYPE_SINGLE_SELECT
          aria_label = bug_fields.priority.description
          no_indent = 1
          inline = 1
      %]
      [% INCLUDE bug_modal/field.html.tmpl
          field = bug_fields.bug_severity
          field_type = constants.FIELD_TYPE_SINGLE_SELECT
          aria_label = bug_fields.bug_severity.description
          inline = 1
      %]
      [% UNLESS cf_hidden_in_product('cf_rank', bug.product, bug.component, bug) %]
        [% rendered_custom_fields.push('cf_rank') %]
        [% INCLUDE bug_modal/field.html.tmpl
            field = bug_fields.cf_rank
            field_type = constants.FIELD_TYPE_INTEGER
            inline = 1
            label = "Rank"
            hide_on_view = bug.cf_rank == ""
            hide_on_edit = !user.in_group('rank-setters')
        %]
      [% END %]
    [% END %]

    [%# status, resolution %]
    [% IF bug.assigned_to.id != user.id %]
      [% WRAPPER bug_modal/field.html.tmpl
          name         = "status-view"
          container    = 1
          label        = "Status"
          hide_on_edit = 1
          help         = "https://wiki.mozilla.org/BMO/UserGuide/BugStatuses"
      %]
        [% bug.bug_status FILTER html %]
        [%+ bug.resolution FILTER html IF bug.resolution %]
        [% IF bug.dup_id %]
          of [% terms.bug _ " $bug.dup_id" FILTER bug_link(bug.dup_id) FILTER none %]
        [% END %]
      [% END %]
    [% END %]

  [% END %]
  [% WRAPPER fields_rhs %]

    [%# creation time %]
    [% WRAPPER bug_modal/field.html.tmpl
        field = bug_fields.creation_ts
        label = "Reported"
        view_only = 1
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#creation_ts"
    %]
      [% INCLUDE bug_modal/rel_time.html.tmpl ts=bug.creation_ts %]
    [% END %]

    [%# last modified %]
    [% WRAPPER bug_modal/field.html.tmpl
        field = bug_fields.delta_ts
        label = "Modified"
        view_only = 1
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#delta_ts"
    %]
      [% INCLUDE bug_modal/rel_time.html.tmpl ts=bug.delta_ts %]
    [% END %]

  [% END %]

  [%# status/resolution knob %]
  [% WRAPPER bug_modal/field.html.tmpl
      name         = "status-edit"
      container    = 1
      label        = "Status"
      hide_on_view = bug.assigned_to.id != user.id
      help         = "https://wiki.mozilla.org/BMO/UserGuide/BugStatuses"
  %]
    [% INCLUDE status_block %]
  [% END %]
[% END %]

[% BLOCK status_block %]
  [% INCLUDE bug_modal/field.html.tmpl
      prefix = prefix
      field  = bug_fields.bug_status
      field_type = constants.FIELD_TYPE_SINGLE_SELECT
      aria_label = bug_fields.bug_status.description
      editable = bug.choices.bug_status.size > 1
      values = bug.choices.bug_status
      inline = 1
      no_indent = 1
      edit_only = 1
  %]
  [% INCLUDE bug_modal/field.html.tmpl
      prefix = prefix
      field  = bug_fields.resolution
      field_type = constants.FIELD_TYPE_SINGLE_SELECT
      aria_label = bug_fields.resolution.description
      editable = bug.choices.resolution.size > (bug.resolution == "" ? 0 : 1)
      values = bug.choices.resolution
      inline = 1
      edit_only = 1
  %]
  [% UNLESS prefix %]
    <div id="assigned-container" style="display:none">
      <button type="button" class="minor" id="mark-as-assigned-btn">
        Mark as Assigned
      </button>
    </div>
  [% END %]
  [% IF bug.choices.resolution.only("name", "DUPLICATE").size %]
    <div id="[% prefix FILTER none %]duplicate-container">
      of
      <input id="[% prefix FILTER none %]dup_id" name="[% prefix FILTER none %]dup_id"
        size="6" value="[% bug.dup_id FILTER html %]">
    </div>
    <div id="[% prefix FILTER none %]duplicate-actions">
      <button type="button" class="minor" id="[% prefix FILTER none %]mark-as-dup-btn">
        Mark as Duplicate
      </button>
    </div>
  [% END %]
[% END %]

[%# === people === %]

[%
  sub = [];
  sub.push("Reporter: " _ bug.reporter.nick);
  sub.push(unassigned ? "Unassigned" : "Assigned: " _ bug.assigned_to.nick);
  IF bug.mentors.size;
    sub.push("Mentored");
  END;
  IF needinfo.size;
    sub.push("NeedInfo");
  END;
%]
[% WRAPPER bug_modal/module.html.tmpl
    title = "People"
    subtitle = sub
    collapsed = 1
%]
  [% WRAPPER fields_lhs %]

    [%# assignee %]
    [% WRAPPER bug_modal/field.html.tmpl
        field = bug_fields.assigned_to
        field_type = constants.FIELD_TYPE_USER
        hide_on_edit = 1
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#assigned_to"
    %]
      [% IF unassigned %]
        <i>Unassigned</i>
        [% IF bug.check_can_change_field("assigned_to", 0, 1) %]
          <button type="button" class="take-btn minor" data-field="assigned_to">Take</button>
        [% END %]
      [% ELSE %]
        [% INCLUDE bug_modal/user.html.tmpl u=bug.assigned_to %]
      [% END %]
    [% END %]
    [% WRAPPER bug_modal/field.html.tmpl
        field = bug_fields.assigned_to
        field_type = constants.FIELD_TYPE_USER
        hide_on_view = 1
        action = {
          class   = "take-btn"
          caption = "Take"
          hidden  = bug.assigned_to.id == user.id || !user.in_group("editbugs")
        }
        append_content = 1
        default = bug.component_obj.default_assignee.login
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#assigned_to"
    %]
      <div class="set-default-container" style="display:none">
        <input type="checkbox" id="set-default-assignee" name="set_default_assignee" class="set-default"
          value="1" data-for="assigned_to">
        <label for="set-default-assignee">Reset Assignee to default</label>
      </div>
    [% END %]

    [%# mentors %]
    [% WRAPPER bug_modal/field.html.tmpl
        field = bug_fields.bug_mentor
        field_type = constants.FIELD_TYPE_USERS
        name = "bug_mentors"
        label = "Mentors"
        value = bug.mentors.pluck("login")
        hide_on_view = bug.mentors.size == 0
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#bug_mentor"
    %]
      [%
        IF bug.mentors.size;
          FOREACH mentor IN bug.mentors;
            INCLUDE bug_modal/user.html.tmpl u=mentor;
          END;
        ELSE;
          "---";
        END;
      %]
    [% END %]

    [%# qa contact %]
    [% WRAPPER bug_modal/field.html.tmpl
        field = bug_fields.qa_contact
        field_type = constants.FIELD_TYPE_USER
        hide_on_view = bug.qa_contact == ""
        hide_on_edit = 1
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#qa_contact"
    %]
      [% INCLUDE bug_modal/user.html.tmpl u=bug.qa_contact %]
    [% END %]
    [% WRAPPER bug_modal/field.html.tmpl
        field = bug_fields.qa_contact
        field_type = constants.FIELD_TYPE_USER
        hide_on_view = 1
        append_content = 1
        default = (bug.component_obj.default_qa_contact.id ? bug.component_obj.default_qa_contact.login : '')
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#qa_contact"
    %]
      <div class="set-default-container" style="display:none">
        <input type="checkbox" id="set-default-qa-contact" name="set_default_qa_contact" class="set-default"
          value="1" data-for="qa_contact">
        <label for="set-default-qa-contact">Reset QA Contact to default</label>
      </div>
    [% END %]

  [% END %]
  [% WRAPPER fields_rhs %]

    [%# reporter %]
    [% INCLUDE bug_modal/field.html.tmpl
        field = bug_fields.reporter
        field_type = constants.FIELD_TYPE_USER
        view_only = 1
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#reporter"
    %]

    [%# triage owner %]
    [% INCLUDE bug_modal/field.html.tmpl
        field = bug_fields.triage_owner
        field_type = constants.FIELD_TYPE_USER
        value = bug.component_obj.triage_owner
        view_only = 1
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#triage_owner"
    %]

    [%# needinfo %]
    [% WRAPPER bug_modal/field.html.tmpl
        container = 1
        label = "NeedInfo From"
        hide_on_view = needinfo.size == 0
        hide_on_edit = 1
    %]
      [% INCLUDE bug_modal/flags.html.tmpl
          types = bug.flag_types.only("name", "needinfo")
          view_only = 1
      %]
    [% END %]
    [% IF needinfo.size %]
      [% WRAPPER bug_modal/field.html.tmpl
          container = 1
          label = "NeedInfo"
          hide_on_view = 1
          help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#needinfo"
      %]
        <button type="button" id="needinfo-scroll" class="minor">Update</button>
      [% END %]
    [% END %]

    [%# cc %]
    [% WRAPPER bug_modal/field.html.tmpl
        container = 1
        label = "CC"
        hide_on_view = bug.cc.size == 0
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#cc"
    %]

      [% IF user.id %]
        <div id="add-cc-container" style="display:none">
          [% INCLUDE global/userselect.html.tmpl
              id = "add-cc"
              name = "newcc"
              value = ""
              classes = [ "bz_userfield" ]
              multiple = 5
          %]
        </div>
      [% END %]

      [% IF bug.cc && bug.cc.size %]
        <span aria-owns="cc-summary cc-latch">
          [% IF user.id %]
            <input type="hidden" name="removecc" id="removecc">
            <span role="button" aria-label="show cc list" tabindex="0" id="cc-latch">&#9656;</span>
          [% END %]
          <span role="button" tabindex="0" id="cc-summary" data-count="[% bug.cc.size FILTER none %]">
            [%
              IF bug.cc.size == 1;
                is_cced ? "Just you" : "1 person";
              ELSE;
                bug.cc.size _ " people";
              END;
            %]
          </span>
        </span>
      [% ELSE %]
        <i>Nobody</i>
      [% END %]

      [% IF user.id %]
        <button type="button" id="add-cc-btn" class="minor">Add</button>
      [% END %]

      [% IF bug.cc && bug.cc.size %]
        <div id="cc-list" style="display:none"></div>
      [% END %]
    [% END %]

  [% END %]
[% END %]

[%# === tracking === %]

[%
  col =
    (bug.version.lower == "unspecified" || bug.version.lower == "other" || bug.version == "---")
    && bug.target_milestone == "---"
    && !has_bug_flags
    && !project_flags_set
    && !tracking_flags_set
    && !blocking_flags_set;
  sub = [];
  open_deps = bug.depends_on_obj.only("resolution", "").size;
  IF open_deps;
    sub.push("Depends on: " _ open_deps _ " bug" _ (open_deps == 1 ? "" : "s"));
  END;
  open_deps = bug.blocks_obj.only("resolution", "").size;
  IF open_deps;
    sub.push("Blocks: " _ open_deps _ " bug" _ (open_deps == 1 ? "" : "s"));
  END;
  IF bug.keyword_objects.size;
    IF bug.keyword_objects.size <= 3;
      sub.push("{" _ bug.keyword_objects.pluck("name").join(", ") _ "}");
    ELSE;
      sub.push(bug.keyword_objects.size _ " keywords");
    END;
  END;
%]
[% WRAPPER bug_modal/module.html.tmpl
  title = "Tracking"
  subtitle = sub
  collapsed = col
%]
  [% WRAPPER fields_lhs %]

    [%# version %]
    [% INCLUDE bug_modal/field.html.tmpl
        field = bug_fields.version
        field_type = constants.FIELD_TYPE_SINGLE_SELECT
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#version"
    %]

    [%# milestone %]
    [% INCLUDE bug_modal/field.html.tmpl
        field = bug_fields.target_milestone
        field_type = constants.FIELD_TYPE_SINGLE_SELECT
        label = "Target"
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#target_milestone"
    %]

    [%# platform, op-sys %]
    [% WRAPPER bug_modal/field.html.tmpl
        container = 1
        label = "Platform"
        hide_on_view = (bug.rep_platform == 'All' && bug.op_sys == 'All')
          || (bug.rep_platform == 'Unspecified' && bug.op_sys == 'Unspecified')
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#rep_platform"
    %]
      [% INCLUDE bug_modal/field.html.tmpl
          field = bug_fields.rep_platform
          field_type = constants.FIELD_TYPE_SINGLE_SELECT
          aria_label = bug_fields.rep_platform.description
          inline = 1
          no_indent = 1
      %]
      [% INCLUDE bug_modal/field.html.tmpl
          field = bug_fields.op_sys
          field_type = constants.FIELD_TYPE_SINGLE_SELECT
          aria_label = bug_fields.op_sys.description
          inline = 1
      %]
      [% WRAPPER bug_modal/field.html.tmpl
          container = 1
          inline = 1
      %]
        [% Hook.process("after_op_sys", 'bug/edit.html.tmpl') %]
      [% END %]
    [% END %]

    [%# keywords %]
    [% WRAPPER bug_modal/field.html.tmpl
        field = bug_fields.keywords
        field_type = constants.FIELD_TYPE_KEYWORDS
        hide_on_view = bug.keyword_objects.size == 0
        help = "describekeywords.cgi"
    %]
      [% bug.keyword_objects.pluck("name").join(", ") || "---" FILTER html %]
    [% END %]

    [% UNLESS cf_hidden_in_product('cf_fx_iteration', bug.product, bug.component, bug) %]
      [% rendered_custom_fields.push('cf_fx_iteration') %]
      [% INCLUDE bug_modal/field.html.tmpl
          field = bug_fields.cf_fx_iteration
          field_type = bug_fields.cf_fx_iteration.type
          hide_on_view = bug.cf_iteration == ""
      %]
    [% END %]

    [% UNLESS cf_hidden_in_product('cf_fx_points', bug.product, bug.component, bug) %]
      [% rendered_custom_fields.push('cf_fx_points') %]
      [% INCLUDE bug_modal/field.html.tmpl
          field = bug_fields.cf_fx_points
          field_type = bug_fields.cf_fx_points.type
          hide_on_view = bug.cf_fx_points == ""
      %]
    [% END %]

    [% UNLESS cf_hidden_in_product('cf_cab_review', bug.product, bug.component, bug) %]
      [% rendered_custom_fields.push('cf_cab_review') %]
      [% IF bug.cf_cab_review == "---" %]
        [% WRAPPER bug_modal/field.html.tmpl
            field = bug_fields.cf_cab_review
            field_type = bug_fields.cf_cab_review.type
            container = 1
            hide_on_view = 1
        %]
          <span id="cab-review-gate">
            <a href="https://mozilla.service-now.com/change_request.do?sysparm_stack=change_request_list.do&amp;sys_id=-1&amp;sysparm_query=active=true" target="_blank" rel="noopener noreferrer">ServiceNow Change Request</a>
            <button id="cab-review-gate-close" type="button" class="minor">Use Flag</button>
          </span>
          <span id="cab-review-edit" style="display:none">
            [% INCLUDE bug_modal/field.html.tmpl
                field = bug_fields.cf_cab_review
                field_type = bug_fields.cf_cab_review.type
                inline = 1
                no_indent = 1
            %]
          </span>
        [% END %]
      [% ELSE %]
        [% INCLUDE bug_modal/field.html.tmpl
            field = bug_fields.cf_cab_review
            field_type = bug_fields.cf_cab_review.type
        %]
      [% END %]
    [% END %]

  [% END %]
  [% WRAPPER fields_rhs %]

    [%# depends on %]
    [% INCLUDE bug_modal/field.html.tmpl
        field = bug_fields.dependson
        field_type = constants.FIELD_TYPE_BUG_LIST
        values = bug.depends_on_obj
        hide_on_view = bug.dependson.size == 0
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#dependson"
    %]

    [%# blocks %]
    [% INCLUDE bug_modal/field.html.tmpl
        field = bug_fields.blocked
        field_type = constants.FIELD_TYPE_BUG_LIST
        values = bug.blocks_obj
        hide_on_view = bug.blocked.size == 0
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#blocks"
    %]

    [% IF bug.dependson.size + bug.blocked.size > 1 %]
      [% WRAPPER bug_modal/field.html.tmpl
          container = 1
          label = ""
          hide_on_edit = 1
      %]
        Dependency <a href="showdependencytree.cgi?id=[% bug.bug_id FILTER none %]&amp;hide_resolved=1">tree</a>
        / <a href="showdependencygraph.cgi?id=[% bug.bug_id FILTER none %]">graph</a>
      [% END %]
    [% END %]

    [%# duplicates %]
    [% IF bug.duplicates.size %]
      [% INCLUDE bug_modal/field.html.tmpl
          field = "duplicates"
          field_type = constants.FIELD_TYPE_BUG_LIST
          label = "Duplicates"
          values = bug.duplicates
          hide_on_edit = 1
          help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#duplicates"
      %]
    [% END %]

    [%# flags %]
    [% WRAPPER bug_modal/field.html.tmpl
        name = "bug_flags"
        container = 1
        label = terms.Bug _ " Flags"
        hide_on_view = !has_bug_flags
    %]
      [% INCLUDE bug_modal/flags.html.tmpl
          types = bug.flag_types.skip("name", "needinfo")
      %]
    [% END %]

  [% END %]
[% END %]

[% IF tracking_flags.size %]

  [%# === tracking flags === %]

  [% WRAPPER bug_modal/module.html.tmpl
      title = tracking_flags_title
      collapsed = 1
      subtitle = firefox_flags_subtitle
  %]
    [% WRAPPER fields_lhs %]

      [% UNLESS tracking_flags_set || project_flags_set || blocking_flags_set %]
        <p class="edit-hide">
          This [% terms.bug %] is not currently tracked.
        </p>
      [% END %]

      [% IF tracking_flags_has %]
        [%# tracking flags %]
        [% WRAPPER bug_modal/field.html.tmpl
            container    = 1
            label        = "Tracking Flags"
            hide_on_view = !tracking_flags_set
            help         = "https://wiki.mozilla.org/BMO/UserGuide#Tracking_Flags"
        %]
          [% INCLUDE bug_modal/tracking_flags.html.tmpl
              type = "tracking"
          %]
        [% END %]
      [% END %]

    [% END %]
    [% WRAPPER fields_rhs %]

      [% IF blocking_flags_has %]
        [%# blocking flags %]
        [% WRAPPER bug_modal/field.html.tmpl
            container = 1
            label = "Blocking Flags"
            hide_on_view = !blocking_flags_set
        %]
          [% INCLUDE bug_modal/tracking_flags.html.tmpl
              type = "blocking"
          %]
        [% END %]
      [% END %]

      [% IF project_flags_has %]
        [%# project flags %]
        [% WRAPPER bug_modal/field.html.tmpl
            container    = 1
            label        = "Project Flags"
            hide_on_view = !project_flags_set
            help         = "https://wiki.mozilla.org/BMO/UserGuide#Tracking_Flags"
        %]
          [% INCLUDE bug_modal/tracking_flags.html.tmpl
              type = "project"
          %]
        [% END %]
      [% END %]

    [% END %]
  [% END %]

[% END %]

[%# === details === %]

[%
  sub = [];
  IF bug.status_whiteboard != "";
    sub.push("Whiteboard: " _ bug.status_whiteboard.truncate(256, '…'));
  END;
  IF bug.cf_crash_signature != "";
    sub.push("crash signature");
  END;
  IF bug.bug_file_loc != "";
    loc_html = INCLUDE bug_url_link link_text="URL";
    sub.push({ unfiltered => loc_html });
  END;
%]
[% WRAPPER bug_modal/module.html.tmpl
  title = "Details"
  collapsed = 1
  subtitle = sub
%]
  [% WRAPPER fields_lhs %]

    [%# whiteboard %]
    [% WRAPPER bug_modal/field.html.tmpl
        field = bug_fields.status_whiteboard
        field_type = constants.FIELD_TYPE_FREETEXT
        help = "https://wiki.mozilla.org/BMO/UserGuide/Whiteboard"
    %]
      [% bug.status_whiteboard == "" ? "---" : bug.status_whiteboard FILTER html %]
    [% END %]

    [%# votes %]
    [% IF bug.product_obj.votesperuser %]
      [% WRAPPER bug_modal/field.html.tmpl
          container = 1
          label = "Votes"
          help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#votes"
      %]
        [% bug.votes FILTER html %]
        vote[% "s" IF bug.votes != 1 %]
        [% IF user.id %]
          <button type="button" class="minor" id="vote-btn">
            [% bug.user_votes ? "Remove vote" : "Vote" %]
          </button>
        [% END %]
      [% END %]
    [% END %]

    [%# custom fields (except textarea) %]
    [%
      FOREACH field = custom_fields;
        NEXT IF field.type == constants.FIELD_TYPE_EXTENSION || field.type == constants.FIELD_TYPE_TEXTAREA;
        NEXT IF rendered_custom_fields.exists(field.name);
        NEXT IF cf_hidden_in_product(field.name, bug.product, bug.component, bug);
        cf_value = bug.${field.name};
        IF field.type == constants.FIELD_TYPE_SINGLE_SELECT;
          has_value = cf_value != "---";
        ELSIF field.type == constants.FIELD_TYPE_MULTI_SELECT;
          has_value = cf_value.size != 0;
        ELSE;
          has_value = cf_value != "";
        END;
        INCLUDE bug_modal/field.html.tmpl
          field = field
          field_type = field.type
          hide_on_view = !has_value;
      END;
    %]

    [% Hook.process('details_lhs') %]
  [% END %]
  [% WRAPPER fields_rhs %]

    [%# url %]
    [% WRAPPER bug_modal/field.html.tmpl
        field = bug_fields.bug_file_loc
        field_type = constants.FIELD_TYPE_FREETEXT
        hide_on_view = bug.bug_file_loc == ""
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#bug_file_loc"
    %]
      [% INCLUDE bug_url_link %]
    [% END %]

    [%# see also %]
    [% INCLUDE bug_modal/field.html.tmpl
        field = bug_fields.see_also
        field_type = constants.FIELD_TYPE_BUG_URLS
        values = bug.see_also
        hide_on_view = bug.see_also.size == 0
        help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#see_also"
    %]

    [% Hook.process('details_rhs') %]
  [% END %]

  [%# custom fields (textarea) %]
  [%
    FOREACH field IN custom_fields;
      NEXT IF field.type != constants.FIELD_TYPE_TEXTAREA;
      Hook.process('custom_field-' _ field.name);
      NEXT IF rendered_custom_fields.exists(field.name);
      INCLUDE bug_modal/field.html.tmpl
        field = field
        field_type = field.type
        hide_on_view = bug.${field.name} == "" || bug.${field.name} == "---";
    END;
  %]
[% END %]

[%# === groups === %]

[% WRAPPER bug_modal/module.html.tmpl
  title = "Security"
  collapsed = 1
  subtitle = bug.groups_in.size ? bug.groups_in.pluck("description").join(", ") : "public"
  hide_on_view = bug.groups_in.size == 0
  hide_on_edit = bug.groups.size == 0 && !bug.product_obj.default_security_group
%]
  [% INCLUDE bug_modal/groups.html.tmpl %]
[% END %]

[%# === user story === %]

[% IF bug.user_story_visible.0 %]
  [% WRAPPER bug_modal/module.html.tmpl
    title = "User Story"
    hide_on_view = bug.cf_user_story == ""
    collapsed = bug.cf_user_story == ""
    no_collapse_persist = 1
    subtitle = ""
  %]
    [% IF user.id %]
      <div id="user-story-actions">
        [% IF bug.check_can_change_field('cf_user_story', 0, 1) %]
          <button type="button" class="minor" id="user-story-edit-btn">Edit</button>
        [% END %]
        [% IF bug.cf_user_story != "" && bug.check_can_change_field('longdesc', 0, 1) %]
          <button type="button" class="minor" id="user-story-reply-btn">Reply</button>
        [% END %]
      </div>
    [% END %]
    <pre id="user-story">[% bug.cf_user_story FILTER quoteUrls(bug) %]</pre>
    [% IF user.id %]
      <textarea id="cf_user_story" name="cf_user_story" style="display:none" rows="10" cols="80">
        [%~ bug.cf_user_story FILTER html ~%]
      </textarea>
    [% END %]
  [% END %]
[% END %]

[%# === timetracking === %]
[% IF user.is_timetracker %]
  [%
    PROCESS bug/time.html.tmpl;
    sub = [];
    IF bug.estimated_time > 0;
      estimated_time = PROCESS formattimeunit time_unit = bug.estimated_time;
      sub.push("Estimated: $estimated_time");
    END;
    IF bug.remaining_time > 0;
      remaining_time = PROCESS formattimeunit time_unit = bug.remaining_time;
      sub.push("Remaining: $remaining_time");
    END;
    IF bug.deadline;
      sub.push("Deadline: " _ bug.deadline);
    END;
  %]
  [% WRAPPER bug_modal/module.html.tmpl
    title     = "Time Tracking"
    collapsed = 1
    no_collapse_persist = 1
    subtitle = sub
  %]
    [% WRAPPER fields_lhs %]
      [% estimated_time = PROCESS formattimeunit time_unit = bug.estimated_time %]
      [% INCLUDE bug_modal/field.html.tmpl
         field        = bug_fields.estimated_time
         field_type   = constants.FIELD_TYPE_FREETEXT
         value        = estimated_time
         hide_on_view = 0
         short_width  = 1
         help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#estimated_time"
      %]
      [% current_estimate = PROCESS formattimeunit time_unit = (bug.actual_time + bug.remaining_time) %]
      [% INCLUDE bug_modal/field.html.tmpl
         label = "Current Est"
         value = current_estimate
         view_only = 1
         help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#current_estimate"
      %]
      [% hours_worked = PROCESS formattimeunit time_unit = bug.actual_time %]
      [% WRAPPER bug_modal/field.html.tmpl
         field_type  = constants.FIELD_TYPE_FREETEXT
         label       = "Hours Worked"
         name        = "work_time"
         value       = '0.0'
         short_width = 1
         help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#work_time"
      %]
        [% PROCESS formattimeunit time_unity = bug.actual_time %]
      [% END %]
      [% hours_left = PROCESS formattimeunit time_unit = bug.remaining_time %]
      [% INCLUDE bug_modal/field.html.tmpl
         field       = bug_fields.remaining_time
         field_type  = constants.FIELD_TYPE_FREETEXT
         value       = hours_left
         short_width = 1
         help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#remaining_time"
      %]
    [% END %]

    [% WRAPPER fields_rhs %]
      [% percentage_complete = PROCESS calculatepercentage act = bug.actual_time rem = bug.remaining_time %]
      [% INCLUDE bug_modal/field.html.tmpl
         label     = "% Complete"
         value     = percentage_complete
         view_only = 1
         help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#percentage_complete"
      %]
      [% time_gain = PROCESS formattimeunit  time_unit = bug.estimated_time - (bug.actual_time + bug.remaining_time) %]
      [% INCLUDE bug_modal/field.html.tmpl
         label = "Gain"
         value = time_gain
         view_only = 1
         help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#gain"
      %]
      [% INCLUDE bug_modal/field.html.tmpl
         field      = bug_fields.deadline
         field_type = constants.FIELD_TYPE_DATE
         value      = bug.deadline
         help = "https://wiki.mozilla.org/BMO/UserGuide/BugFields#deadline"
      %]
      <div>
        <a href="summarize_time.cgi?id=[% bug.bug_id FILTER none %]&amp;do_depends=1">
          Summarize time (including time for [% terms.bugs %]
          blocking this [% terms.bug %])</a>
      </div>
    [% END %]
  [% END %]
[% END %]

[%# === extensions which are modules === %]

[% Hook.process('module') %]

[%# === attachments === %]

[% IF active_attachments || obsolete_attachments %]
  [%
    sub = [];
    IF active_attachments;
      sub.push(active_attachments _ " attachment" _ (active_attachments == 1 ? "" : "s"));
    END;
    IF obsolete_attachments;
      sub.push(obsolete_attachments _ " obsolete attachment" _ (obsolete_attachments == 1 ? "" : "s"));
    END;
  %]
  [% WRAPPER bug_modal/module.html.tmpl
      title = "Attachments"
      subtitle = sub
      collapsed = active_attachments == 0
  %]
    [% INCLUDE bug_modal/attachments.html.tmpl
        active_attachments = active_attachments
        obsolete_attachments = obsolete_attachments
    %]
  [% END %]
[% END %]

[%# === initialise module visibility === %]

<script [% script_nonce FILTER none %]>
  init_module_visibility();
</script>

[%# === top (between modules and comments) actions === %]

[% IF user.id %]
  <div id="top-actions">
    <a href="attachment.cgi?bugid=[% bug.id FILTER uri %]&amp;action=enter" id="attachments-add-link">Attach File</a>
    [%+ Hook.process('top_actions') %]
    <button type="submit" class="save-btn major" id="top-save-btn" style="display:none">Save Changes</button>
  </div>
[% END %]

[% Hook.process('after_modules') %]

[%# === comments === %]

[%
  IF user.settings.comment_box_position.value == 'before_comments';
    INCLUDE new_comment;
  END;
  INCLUDE bug_modal/activity_stream.html.tmpl stream=bug.activity_stream;
  IF user.settings.comment_box_position.value == 'after_comments';
    INCLUDE new_comment;
  END;
%]

[%# === bottom actions === %]

<div id="bottom-actions">
  <div id="bottom-right-actions">
    <button type="button" id="top-btn" class="minor">Top &uarr;</button>
    <div class="dropdown">
      <button type="button" id="format-btn" aria-haspopup="true" aria-label="Format [% terms.Bug %] Menu"
        aria-expanded="false" aria-controls="format-menu" class="dropdown-button minor">Format [% terms.Bug %] &#9652;</button>
      <ul class="dropdown-content left menu-up" id="format-menu" role="menu" style="display:none;">
        <li role="presentation">
          <a href="show_bug.cgi?format=multiple&amp;id=[% bug.id FILTER uri %]" role="menuitem" tabindex="-1">For Printing</a>
        </li>
        <li role="presentation">
          <a href="show_bug.cgi?ctype=xml&amp;id=[% bug.id FILTER uri %]" role="menuitem" tabindex="-1">XML</a>
        </li>
        <li role="presentation">
          <a href="show_bug.cgi?format=default&amp;id=[% bug.id FILTER uri %]" role="menuitem" tabindex="-1">Legacy</a>
        </li>
        [% IF bug.groups_in.size == 0 %]
          <li role="presentation">
            <a href="rest/bug/[% bug.id FILTER uri %]" role="menuitem" tabindex="-1">JSON</a>
          </li>
        [% END %]
      </ul>
    </div>
    [% IF user.id %]
      <div class="dropdown">
        <button type="button" id="new-bug-btn" aria-haspopup="true" aria-label="New/Clone [% terms.Bug %] Menu"
          aria-expanded="false" aria-controls="new-bug-menu" class="dropdown-button minor">New/Clone [% terms.Bug %] &#9652;</button>
        <ul class="dropdown-content left menu-up" id="new-bug-menu" role="menu" style="display:none;">
          <li role="presentation">
            <a href="enter_bug.cgi" role="menuitem" tabindex="-1" target="_blank">
              Create a new [% terms.bug %]</a>
          </li>
          <li role="presentation">
            <a href="enter_bug.cgi?product=[% bug.product FILTER uri %]"
               role="menuitem" tabindex="-1" target="_blank">&#8230; in this product</a>
          </li>
          <li role="presentation">
            <a href="enter_bug.cgi?product=[% bug.product FILTER uri %]&amp;component=[% bug.component FILTER uri %]"
               role="menuitem" tabindex="-1" target="_blank">&#8230; in this component</a>
          </li>
          <li role="separator"></li>
          <li role="presentation">
            <a href="enter_bug.cgi?format=__default__&amp;product=[% bug.product FILTER uri %]&amp;blocked=[% bug.id FILTER uri %]"
               role="menuitem" tabindex="-1" target="_blank">&#8230; that blocks this [% terms.bug %]</a>
          </li>
          <li role="presentation">
            <a href="enter_bug.cgi?format=__default__&amp;product=[% bug.product FILTER uri %]&amp;dependson=[% bug.id FILTER uri %]"
               role="menuitem" tabindex="-1" target="_blank">&#8230; that depends on this [% terms.bug %]</a>
          </li>
          <li role="separator"></li>
          <li role="presentation">
            <a href="enter_bug.cgi?format=__default__&amp;product=[% bug.product FILTER uri %]&amp;cloned_bug_id=[% bug.id FILTER uri %]"
               role="menuitem" tabindex="-1" target="_blank">&#8230; as a clone of this [% terms.bug %]</a>
          </li>
          <li role="presentation">
            <a href="enter_bug.cgi?format=__default__&amp;cloned_bug_id=[% bug.id FILTER uri %]"
               role="menuitem" tabindex="-1" target="_blank">&#8230; as a clone, in a different product</a>
          </li>
        </ul>
      </div>
    [% END %]
  </div>
</div>

[% IF user.id %]
  </form>
[% END %]

[%# === individual bugs addition === %]

[% PROCESS "bug/tagging.html.tmpl" %]

[%# === blocks === %]

[% BLOCK new_comment %]
  [%# === new comment === %]
  [%
    IF user.id;
      INCLUDE bug_modal/new_comment.html.tmpl;
    ELSE;
      %]
        <div id="new-comment-notice">
          You need to <a href="show_bug.cgi?id=[% bug.bug_id FILTER none %]&amp;GoAheadAndLogIn=1">log in</a>
          before you can comment on or make changes to this [% terms.bug %].
        </div>
      [%
    END;
  %]
  [%# === comment actions === %]
  [% IF user.id %]
    <div id="new-comment-actions">
      <button type="submit" class="save-btn major" id="bottom-save-btn">Save Changes</button>
      <div id="resolve-as">
        [%
          IF bug.resolution == "";
            seen_header = 0;
            FOREACH resolution IN ["FIXED", "INVALID", "DUPLICATE"];
              NEXT UNLESS bug.choices.resolution.only("name", resolution).size;
              IF NOT seen_header;
                seen_header = 1;
                " Resolve as ";
              END;
              %] <button type="button" class="minor resolution-btn">[% resolution FILTER html %]</button> [%
            END;
          ELSE;
            IF bug.choices.bug_status.only("name", "VERIFIED").size && bug.bug_status != "VERIFIED";
              %] <button type="button" class="minor status-btn" data-status="VERIFIED">VERIFY</button> [%
            END;
            IF bug.choices.bug_status.only("name", "REOPENED").size;
              %] <button type="button" class="minor status-btn" data-status="REOPENED">REOPEN</button> [%
            END;
          END;
        %]
      </div>
      <div id="bottom-status" style="display:none">
        [% INCLUDE status_block prefix="bottom-" %]
      </div>
    </div>
  [% END %]
[% END %]

[% BLOCK fields_lhs %]
  <div class="fields-lhs">[% content FILTER none %]</div>
[% END %]

[% BLOCK fields_rhs %]
  <div class="fields-rhs">[% content FILTER none %]</div>
[% END %]

[% BLOCK bug_url_link %]
[%
  IF !link_text.defined;
    link_text = bug.bug_file_loc FILTER truncate(40);
  END;
%]
  <a href="[% bug.bug_file_loc FILTER html %]" target="_blank"
     rel="noreferrer" title="[% bug.bug_file_loc FILTER truncate(256) FILTER html %]"
     class="bug-url" data-safe="[% is_safe_url(bug.bug_file_loc) ? 1 : 0 %]"
  >[% link_text FILTER html %]</a>
[% END %]