aboutsummaryrefslogtreecommitdiffstats
path: root/data/lib/otherButtons.js
blob: 80d92747c88ff173e977887cf839ffcdcefc6e1c (plain) (blame)
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
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
"use strict";

/**
 * Find default assignee based on the current component
 *
 * @return String what would be a default assignee if we haven't set it up.
 */
function getDefaultAssignee() {
  return filterByRegexp(constantData.defaultAssignee,
      getComponent());
}

/**
 * Set default assignee
 *
 * @return none sets this.defaultAssignee property according to defaultAssignee
 *         list
 */
function setDefaultAssignee() {
  var defAss = getDefaultAssignee();

  // Add setting default assignee
  if (defAss && (defAss !== getOwner())) {
    createNewButton("bz_assignee_edit_container", true, {
      "name" : "Def. Assignee",
      "assignee" : "default"
    });
  }
}

function markBugTriaged() {
  // https://fedoraproject.org/wiki/BugZappers/Meetings/Minutes-2009-Oct-27
  // http://meetbot.fedoraproject.org/fedora-meeting/2009-11-24\
  // /fedora-meeting.2009-11-24-15.11.log.html
  // http://meetbot.fedoraproject.org/fedora-meeting/2009-11-24\
  // /fedora-meeting.2009-11-24-15.11.log.html
  if (hasXorgBugsCategory && !hasXorgBugsCategory()) {
    alert("This won't do! First set the category!");
  }
  else if (isEnterprise && !isEnterprise()
      && (getSeverity() == 'unspecified')) {
    alert("This won't do! Specify some severity!");
  }
  else {
    addStuffToTextBox("keywords", "Triaged");
  }
}

var FillMagicDoneRE = new RegExp("^\\s*\\[[0-9a-zA-Z_]*\\]");

function addingEmbelishments(logList) {

  var maintCCAddr = "";
  if (constantData.CCmaintainer) {
    maintCCAddr = filterByRegexp(constantData.CCmaintainer,
        getComponent()); // filterByRegexp returns string, not array, now
  }

  // we should make visible whether maintCCAddr is in CCList
  if (maintCCAddr && isInList(maintCCAddr, getCCList())) {
    var ccEditBoxElem = document
        .getElementById("cc_edit_area_showhide");
    ccEditBoxElem.style.color = "navy";
    ccEditBoxElem.style.fontWeight = "bolder";
    ccEditBoxElem.style.textDecoration = "underline";
  }

  // Take care of signature for Fedora bugzappers
  if (config.signature && config.signature.length > 0) {
    var signaturesCounter = 0;
    var signatureFedoraString = config.signature;
    document.forms.namedItem("changeform").addEventListener(
        "submit", function(aEvt) {
          if (signaturesCounter < 1) {
            addStuffToTextBox("comment", signatureFedoraString);
            signaturesCounter += 1;
          }
        }, false);
  }

  // set default assignee on change of the component
  var compElement = document.getElementById("component");
  if (compElement && (compElement.options)) {
    document.getElementById("component").addEventListener(
        "change", function() {
          changeAssignee("default");
        }, false);
  }

  // TODO Get compiz bugs as well
  if ((new Boolean(constantData.chipNames))
      && (logList.length > 0) && (!isTriaged())
      && (!FillMagicDoneRE.test(getSummary()))
      && (maintCCAddr == "xgl-maint@redhat.com")) {
    // Add find chip magic button
    analyzeXorgLog(logList[0].id, "AnalyzeInterestingLine");
  }

  // Add links for creating new bug in the same product
  // and same component
  addNewLinks();
}

/**
 * Set branding colours to easily distinguish between Fedora and RHEL bugs
 *
 * @param brand
 *          String with product of the current bug
 * @param version
 *          String with the version of the bug
 * @param its
 *          String with the IsueTracker numbers
 * @return none
 */
function setBranding(things) {
  var brandColor = {};
  var TriagedColor = {};

  var atts = things.attachments;
  var xLogAtts = atts.getAttList(/[xX].*log/);

  var ITbutton = document.getElementById("cf_issuetracker");
  var its = ITbutton ? ITbutton.value.trim() : "";

  if (isEnterprise()) {
    if (its && (its.length > 0)) {
      brandColor = RHITColor;
    }
    else {
      brandColor = RHColor;
    }
  }
  else if (new RegExp("Fedora").test(document
      .getElementById("product").value)) {
    if (document.getElementById("version").value === "rawhide") {
      brandColor = RawhideColor;
    }
    else {
      brandColor = FedoraColor;
    }
  }

  // Comment each of the following lines to get only partial branding
  document.getElementsByTagName("body")[0].style.background = brandColor
      .toString()
      + " none";
  document.getElementById("titles").style.background = brandColor
      .toString()
      + " none";

  // Remove "Bug" from the title of the bug page, so we have more space with
  // plenty of tabs
  var titleElem = document.getElementsByTagName("title")[0];

  titleElem.textContent = titleElem.textContent.slice(4);
  var bodyTitleParent = document
      .getElementById("summary_alias_container").parentNode;
  var bodyTitleElem = bodyTitleParent.getElementsByTagName("b")[0];
  bodyTitleElem.textContent = bodyTitleElem.textContent.slice(4);

  // Make background-color of the body of bug salmon pink
  // for security bugs.
  if (hasKeyword("Security")) {
    document.getElementById("bugzilla-body").style.background = SalmonPink
        .toString()
        + ' none';
  }

  // Make it visible whether the bug has been triaged
  if (isTriaged()) {
    document.getElementById("bz_field_status").style.background = brandColor
        .lightColor().toString()
        + " none";
  }

  var compElems;
  if (config.suspiciousComponents
      && isInList(getComponent(), config.suspiciousComponents)
      && ((compElems = document
          .getElementById("bz_component_edit_container")))) {
    compElems.style.background = "red none";
  }

  addingEmbelishments(xLogAtts);
}