-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for View permissions at the View level rather than only…
… at global level
- Loading branch information
1 parent
4d7e065
commit 079b05c
Showing
7 changed files
with
403 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
...s/com/michelin/cio/hudson/plugins/rolestrategy/RoleStrategyConfig/assign-view-roles.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<!-- | ||
- The MIT License | ||
- | ||
- Copyright (c) 2016, Suresh. | ||
- | ||
- Original file: manage-project-roles.jelly | ||
- Thomas Maurel & Romain Seguy, Manufacture Française des Pneumatiques Michelin | ||
- | ||
- 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" xmlns:local="local"> | ||
|
||
<j:set var="id" value="${h.generateId()}"/> | ||
|
||
<table id="viewRoles" class="center-align global-matrix-authorization-strategy-table" name="data"> | ||
|
||
<!-- The first row will show grouping --> | ||
<tr class="group-row"> | ||
<td class="start" /> | ||
<td class="pane-header blank"> | ||
${%User/group} | ||
</td> | ||
<j:forEach var="role" items="${viewGrantedRoles}"> | ||
<td class="pane-header"> | ||
${role.key.name} | ||
</td> | ||
</j:forEach> | ||
<td class="stop" /> | ||
</tr> | ||
<j:set var="nbAssignedViewRoles" value="${0}" /> | ||
<j:forEach var="sid" items="${viewSIDs}"> | ||
<tr name="[${sid}]" class="permission-row"> | ||
<local:userRow sid="${sid}" title="${sid}" global="${false}" type="${it.strategy.VIEW}"/> | ||
</tr> | ||
<j:set var="nbAssignedViewRoles" value="${nbAssignedViewRoles+1}" /> | ||
</j:forEach> | ||
<tr name="anonymous"> | ||
<local:userRow sid="anonymous" title="${%Anonymous}" global="${false}" type="${it.strategy.VIEW}"/> | ||
</tr> | ||
<tr id="${id}" style="display:none" class="permission-row"> | ||
<local:userRow global="${false}" type="${it.strategy.VIEW}"/> | ||
</tr> | ||
<!-- The last row is used to repeat the header (if more than 19+1 lines) --> | ||
<j:if test="${nbAssignedViewRoles ge 19}"> | ||
<tr class="group-row"> | ||
<td class="start" /> | ||
<td class="pane-header blank"> | ||
${%User/group} | ||
</td> | ||
<j:forEach var="role" items="${viewGrantedRoles}"> | ||
<td class="pane-header"> | ||
${role.key.name} | ||
</td> | ||
</j:forEach> | ||
<td class="stop" /> | ||
</tr> | ||
</j:if> | ||
</table> | ||
|
||
<br /><br /> | ||
<f:entry title="${%User/group to add}" help="${rootURL}/plugin/role-strategy/help/help-user-group-add.html"> | ||
<f:textbox type="text" id="${id}text" /> | ||
</f:entry> | ||
<f:entry> | ||
<input type="button" value="${%Add}" id="${id}button"/> | ||
</f:entry> | ||
|
||
<script> | ||
var tableHighlighter; | ||
(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 role 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.childNodes[1].innerHTML = name; | ||
copy.setAttribute("name",'['+name+']'); | ||
<j:if test="${nbAssignedViewRoles lt 19}"> | ||
table.appendChild(copy); | ||
</j:if> | ||
<j:if test="${nbAssignedViewRoles ge 19}"> | ||
table.insertBefore(copy,table.childNodes[table.rows.length-1]); | ||
</j:if> | ||
tableHighlighter.scan(copy); | ||
Behaviour.applySubtree(findAncestor(table,"TABLE")); | ||
}); | ||
})(); | ||
|
||
Event.observe(window, 'load', function(event) { | ||
tableHighlighter = new TableHighlighter('viewRoles', 0, 1); | ||
}); | ||
|
||
var deleteAssignedViewRole = function(e) { | ||
e.onclick = function() { | ||
var tr = findAncestor(this,"TR"); | ||
tr.parentNode.removeChild(tr); | ||
return false; | ||
} | ||
e = null; <!-- avoid memory leak --> | ||
} | ||
Behaviour.register({ | ||
"#viewRoles TD.start A" : deleteAssignedViewRole, | ||
"#viewRoles TD.stop A" : deleteAssignedViewRole, | ||
"#viewRoles TR.permission-row" : function(e) { | ||
FormChecker.delayedCheck("${descriptorPath}/checkName?value="+encodeURIComponent(e.getAttribute("name")),"GET",e.childNodes[1]); | ||
} | ||
}); | ||
</script> | ||
</j:jelly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.