Skip to content

Commit

Permalink
Fix type in tooltip of newly added rows (#121)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Beck <[email protected]>
  • Loading branch information
daniel-beck and daniel-beck authored May 3, 2022
1 parent 18f92c8 commit 4863da2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ default PermissionEntry entryFor(String type, String sid) {
@Restricted(DoNotUse.class) // Jelly only; cf. UpdateCenter#getCategoryDisplayName in core
default String getTypeLabel(String type) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
if (type == null) {
return null;
return "__TYPE__"; // placeholder
}
return Messages.class.getMethod("TypeLabel_" + type).invoke(null).toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,15 @@ THE SOFTWARE.
<input type="button" class="matrix-auth-add-button" value="${%Add user…}" id="${id}UserButton"
data-table-id="${id}"
data-type="USER"
data-type-label="${%user}"
data-message-prompt="${%userPrompt}"
data-message-empty="${%userEmpty}"
data-message-error="${%userError}"
/>
<input type="button" class="matrix-auth-add-button" value="${%Add group…}" id="${id}GroupButton"
data-table-id="${id}"
data-type="GROUP"
data-type-label="${%group}"
data-message-prompt="${%groupPrompt}"
data-message-empty="${%groupEmpty}"
data-message-error="${%groupError}"
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/hudson/security/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Behaviour.specify(".matrix-auth-add-button", 'GlobalMatrixAuthorizationStrategy'
var master = document.getElementById(dataReference.getAttribute('data-table-id'));
var table = master.parentNode;
var type = dataReference.getAttribute('data-type');
var typeLabel = dataReference.getAttribute('data-type-label');

var name = prompt(dataReference.getAttribute('data-message-prompt'));
if (name == null) {
Expand All @@ -32,15 +33,15 @@ Behaviour.specify(".matrix-auth-add-button", 'GlobalMatrixAuthorizationStrategy'

for(var child = copy.firstChild; child !== null; child = child.nextSibling) {
if (child.hasAttribute('data-permission-id')) {
child.setAttribute("data-tooltip-enabled", child.getAttribute("data-tooltip-enabled").replace("__SID__", name));
child.setAttribute("data-tooltip-disabled", child.getAttribute("data-tooltip-disabled").replace("__SID__", name));
child.setAttribute("data-tooltip-enabled", child.getAttribute("data-tooltip-enabled").replace("__SID__", name).replace("__TYPE__", typeLabel));
child.setAttribute("data-tooltip-disabled", child.getAttribute("data-tooltip-disabled").replace("__SID__", name).replace("__TYPE__", typeLabel));
}
}
findElementsBySelector(copy, ".stop img").each(function(item) {
item.setAttribute("title", item.getAttribute("title").replace("__SID__", name));
item.setAttribute("title", item.getAttribute("title").replace("__SID__", name).replace("__TYPE__", typeLabel));
});
findElementsBySelector(copy, "input[type=checkbox]").each(function(item) {
item.setAttribute("title", item.getAttribute("title").replace("__SID__", name));
item.setAttribute("title", item.getAttribute("title").replace("__SID__", name).replace("__TYPE__", typeLabel));
});
table.appendChild(copy);
Behaviour.applySubtree(findAncestor(table,"TABLE"),true);
Expand Down

0 comments on commit 4863da2

Please sign in to comment.