~ubuntu-branches/ubuntu/precise/jenkins/precise-updates

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
<!--
The MIT License

Copyright (c) 2004-2011, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
  <f:block xmlns:local="local">
    <j:set var="groups" value="${descriptor.allGroups}"/>
    <d:taglib uri="local">
      <!-- generate one row for the sid name @sid -->
      <d:tag name="row">
        <td class="left-most">${title}</td>
        <j:forEach var="g" items="${groups}">
          <j:forEach var="p" items="${g.permissions}">
            <j:if test="${descriptor.showPermission(p)}">
              <td width="*">
                <f:checkbox name="[${p.id}]" checked="${instance.hasExplicitPermission(attrs.sid,p)}"/>
              </td>
            </j:if>
          </j:forEach>
        </j:forEach>
        <td class="stop">
          <j:if test="${attrs.sid!='anonymous'}">
            <a href="#">
              <img alt="remove" src="${imagesURL}/16x16/stop.png" height="16" width="16"/>
            </a>
          </j:if>
        </td>
      </d:tag>
    </d:taglib>
    <link rel="stylesheet" href="${rootURL}${app.VIEW_RESOURCE_PATH}/hudson/security/table.css" type="text/css" />
    <j:set var="strategyid" value="${descriptor.jsonSafeClassName}" />
    <table id="${strategyid}" class="center-align global-matrix-authorization-strategy-table" name="data">

      <!-- The first row will show grouping -->
      <tr class="group-row">
        <td rowspan="2" class="pane-header blank">
          ${%User/group}
        </td>
        <j:forEach var="g" items="${groups}">
          <j:set var="cnt" value="${0}" />
          <j:forEach var="p" items="${g.permissions}">
            <j:if test="${descriptor.showPermission(p)}">
              <j:set var="cnt" value="${cnt+1}"/>
            </j:if>
          </j:forEach>

          <td class="pane-header" colspan="${cnt}">
            ${g.title}
          </td>
        </j:forEach>
        <td rowspan="2" class="stop" />
      </tr>
      <!-- The second row for individual permission -->
      <tr class="caption-row">
        <j:forEach var="g" items="${groups}">
          <j:forEach var="p" items="${g.permissions}">
            <j:if test="${descriptor.showPermission(p)}">
              <th class="pane" tooltip="${p.description}">
                ${p.name}
              </th>
            </j:if>
          </j:forEach>
        </j:forEach>
      </tr>

      <j:forEach var="sid" items="${instance.allSIDs}">
        <tr name="[${sid}]" class="permission-row">
          <local:row title="${sid}" sid="${sid}"/>
        </tr>
      </j:forEach>
      <tr name="anonymous">
        <local:row sid="anonymous" title="${%Anonymous}" />
      </tr>


      <!-- template row to be used for adding a new row -->
      <j:set var="id" value="${h.generateId()}"/>
      <tr id="${id}" style="display:none" class="permission-row">
        <local:row sid="${null}" />
      </tr>
    </table>
    <table style="margin-top:0.5em; margin-left: 2em; width: 100%">
     <tr><td colspan="3">
      ${%User/group to add}:
      <input type="text" id="${id}text" />
      <input type="button" value="${%Add}" id="${id}button"/>
     </td><td align="right">
      <a href="#" class="help-button" helpURL="${rootURL}${descriptor.find('hudson.security.GlobalMatrixAuthorizationStrategy$DescriptorImpl').getHelpFile('user-group')}"><img src="${imagesURL}/16x16/help.png" alt="[help]" height="16" width="16"/></a>
     </td></tr>
     <f:helpArea />
    </table>
    <script>
      (function() {
        <!-- place master outside the DOM tree so that it won't creep into the submitted form -->
        var master = document.getElementById('${id}');
        var table = master.parentNode;
        table.removeChild(master);
      
        makeButton($$('${id}button'), function (e) {
          <!-- when 'add' is clicked... -->
          var name = $$('${id}text').value;
          if(name=="") {
            alert("Please enter a user name or a group name");
            return;
          }
          if(findElementsBySelector(table,"TR").find(function(n){return n.getAttribute("name")=='['+name+']';})!=null) {
            alert("Entry for '"+name+"' already exists");
            return;
          }

          if(document.importNode!=null)
            copy = document.importNode(master,true);
          else
            copy = master.cloneNode(true); <!-- for IE -->
          copy.removeAttribute("id");
          copy.removeAttribute("style");
          copy.firstChild.innerHTML = name;
          copy.setAttribute("name",'['+name+']');
          table.appendChild(copy);
          Behaviour.applySubtree(findAncestor(table,"TABLE"),true);
        });
      })();

      Behaviour.register({
        "#${strategyid} TD.stop A" : function(e) {
          e.onclick = function() {
            var tr = findAncestor(this,"TR");
            tr.parentNode.removeChild(tr);
            return false;
          }
          e = null; <!-- avoid memory leak -->
        },
        <j:if test="${empty(descriptorPath)}">
          <j:set var="descriptorPath" value="${descriptor.descriptorFullUrl}"/>
        </j:if>
        <!-- validates the name -->
        "#${strategyid} TR.permission-row" : function(e) {
          FormChecker.delayedCheck("${descriptorPath}/checkName?value="+encodeURIComponent(e.getAttribute("name")),"GET",e.firstChild);
        }
      });
    </script>
  </f:block>
</j:jelly>