This is an automated email from the ASF dual-hosted git repository.
dspavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git
The following commit(s) were added to refs/heads/master by this push:
new 01635c45 Admin - change display method for user list (#221)
01635c45 is described below
commit 01635c45fac46d7462c0a0caa6badf2b214545f2
Author: ignitetcbot <[email protected]>
AuthorDate: Sat May 9 14:28:02 2026 +0300
Admin - change display method for user list (#221)
Codex co-authored-by: Dmitriy Pavlov <[email protected]>
---
.../src/main/webapp/css/style-1.5.css | 47 --------------------
.../src/main/webapp/js/common-1.7.js | 50 +++++++++++++---------
.../src/main/webapp/monitoring.html | 9 ++++
ignite-tc-helper-web/src/main/webapp/user.html | 34 +--------------
.../ignite/ci/web/rest/login/UserServiceTest.java | 21 ++++++++-
.../monitoring/MonitoringServiceSecurityTest.java | 9 ++++
6 files changed, 68 insertions(+), 102 deletions(-)
diff --git a/ignite-tc-helper-web/src/main/webapp/css/style-1.5.css
b/ignite-tc-helper-web/src/main/webapp/css/style-1.5.css
index 66a622b4..3da4b7e4 100644
--- a/ignite-tc-helper-web/src/main/webapp/css/style-1.5.css
+++ b/ignite-tc-helper-web/src/main/webapp/css/style-1.5.css
@@ -106,53 +106,6 @@ table.stat tr:nth-child(odd) { background-color: #fafaff; }
float: right;
}
-.navbar .dropdown {
- float: left;
- overflow: hidden;
-}
-
-.navbar .dropdown .dropbtn {
- display: block;
- padding: 7px 8px;
- border: none;
- outline: none;
- background: inherit;
- color: inherit;
- box-shadow: none;
- height: auto;
- margin: 0;
- font-weight: 500;
-}
-
-.navbar .dropdown:hover .dropbtn {
- color: white;
- background: #125CAA;
-}
-
-.navbar .dropdown-content {
- display: none;
- position: absolute;
- min-width: 190px;
- background-color: #f9f9f9;
- box-shadow: 3px 2px 6px -2px rgba(0,0,0,0.64);
- z-index: 2;
-}
-
-.navbar .dropdown-content a {
- float: none;
- display: block;
- text-align: left;
-}
-
-.navbar .dropdown:hover .dropdown-content {
- display: block;
-}
-
-.admin-marker {
- color: #125CAA;
- font-size: 12px;
-}
-
.adminOnly {
display: none;
}
diff --git a/ignite-tc-helper-web/src/main/webapp/js/common-1.7.js
b/ignite-tc-helper-web/src/main/webapp/js/common-1.7.js
index 1773bd17..69bd7af0 100644
--- a/ignite-tc-helper-web/src/main/webapp/js/common-1.7.js
+++ b/ignite-tc-helper-web/src/main/webapp/js/common-1.7.js
@@ -226,10 +226,6 @@ function showMenu(menuData) {
res += "<a href='/monitoring.html'>Server state</a>";
- if (menuData.admin) {
- res += adminUsersMenu(menuData.users);
- }
-
res += "<a id='userName' href='/user.html'>" + escapeHtml(userName) +
"</a>";
var logout = "/login.html" + "?exit=true&backref=" +
encodeURIComponent(window.location.href);
res += "<a href='" + logout + "'>Logout</a>";
@@ -241,31 +237,43 @@ function showMenu(menuData) {
$(document.body).prepend(res);
}
-function adminUsersMenu(users) {
- if (!Array.isArray(users) || users.length === 0)
- return "";
-
- var res = "<div class='dropdown'>";
- res += "<button class='dropbtn'>Users</button>";
- res += "<div class='dropdown-content'>";
+function renderAdminUsersList(menuData, blockSelector, usersSelector) {
+ if (!menuData || menuData.admin !== true) {
+ $(usersSelector).html("");
+ $(blockSelector).hide();
- for (var i = 0; i < users.length; i++) {
- var user = users[i];
- var label = escapeHtml(user.displayName || user.username);
+ return;
+ }
- if (user.admin)
- label += " <span class='admin-marker'>admin</span>";
+ var users = Array.isArray(menuData.users) ? menuData.users : [];
+ var res = "";
- res += "<a href='/user.html?login=" +
encodeURIComponent(user.username) + "'>" + label + "</a>";
+ if (users.length === 0) {
+ res = "No other users";
}
+ else {
+ res += "<table class='stat'>";
+ res += "<tr><th>User</th><th>Login</th><th>Role</th></tr>";
+
+ for (var i = 0; i < users.length; i++) {
+ var user = users[i];
+ var login = user.username || "";
+ var label = user.displayName || login;
+
+ res += "<tr>";
+ res += "<td><a href='/user.html?login=" +
encodeURIComponent(login) + "'>" + escapeHtml(label) + "</a></td>";
+ res += "<td>" + escapeHtml(login) + "</td>";
+ res += "<td>" + (user.admin ? "admin" : "") + "</td>";
+ res += "</tr>";
+ }
- res += "</div>";
- res += "</div>";
+ res += "</table>";
+ }
- return res;
+ $(usersSelector).html(res);
+ $(blockSelector).show();
}
-
function authorizeServer() {
$.ajax({
type: "POST",
diff --git a/ignite-tc-helper-web/src/main/webapp/monitoring.html
b/ignite-tc-helper-web/src/main/webapp/monitoring.html
index c6a92b94..5a4236c3 100644
--- a/ignite-tc-helper-web/src/main/webapp/monitoring.html
+++ b/ignite-tc-helper-web/src/main/webapp/monitoring.html
@@ -29,6 +29,7 @@
monitoringAdmin = result.admin === true;
initAdminControls();
+ renderAdminUsersList(result, "#adminUsersBlock",
"#adminUsers");
loadData();
setInterval(loadAiPromptsData, 5000);
},
@@ -36,6 +37,7 @@
monitoringAdmin = false;
initAdminControls();
+ $("#adminUsersBlock").hide();
loadData();
setInterval(loadAiPromptsData, 5000);
}
@@ -359,6 +361,13 @@
<br>
</div>
+<div id="adminUsersBlock" class="adminOnly" style="display: none">
+ <hr>
+ <b>Users:</b>
+ <div id="adminUsers"></div>
+ <br>
+</div>
+
<hr>
<b>AI Prompt Requests:</b>
<div id="aiPrompts" style="font-family: monospace"></div>
diff --git a/ignite-tc-helper-web/src/main/webapp/user.html
b/ignite-tc-helper-web/src/main/webapp/user.html
index 3bbd1af3..815d648d 100644
--- a/ignite-tc-helper-web/src/main/webapp/user.html
+++ b/ignite-tc-helper-web/src/main/webapp/user.html
@@ -159,39 +159,7 @@ function loadUsersList() {
}
function showUsersList(menuData) {
- if (menuData.admin !== true) {
- $("#adminUsersBlock").hide();
-
- return;
- }
-
- var users = Array.isArray(menuData.users) ? menuData.users : [];
- var res = "";
-
- if (users.length === 0) {
- res = "No other users";
- }
- else {
- res += "<table class='stat'>";
- res += "<tr><th>User</th><th>Login</th><th>Role</th></tr>";
-
- for (var i = 0; i < users.length; i++) {
- var user = users[i];
- var login = user.username || "";
- var label = user.displayName || login;
-
- res += "<tr>";
- res += "<td><a href='/user.html?login=" +
encodeURIComponent(login) + "'>" + escapeHtml(label) + "</a></td>";
- res += "<td>" + escapeHtml(login) + "</td>";
- res += "<td>" + (user.admin ? "admin" : "") + "</td>";
- res += "</tr>";
- }
-
- res += "</table>";
- }
-
- $("#adminUsers").html(res);
- $("#adminUsersBlock").show();
+ renderAdminUsersList(menuData, "#adminUsersBlock", "#adminUsers");
}
function setupEditDialog() {
diff --git
a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/web/rest/login/UserServiceTest.java
b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/web/rest/login/UserServiceTest.java
index c9dd36ce..716c90cc 100644
---
a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/web/rest/login/UserServiceTest.java
+++
b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/web/rest/login/UserServiceTest.java
@@ -109,11 +109,21 @@ public class UserServiceTest {
@Test
public void userPageHasExplicitAdminUsersList() throws IOException {
String html = new String(Files.readAllBytes(userHtml()),
StandardCharsets.UTF_8);
+ String commonScript = new String(Files.readAllBytes(commonJs()),
StandardCharsets.UTF_8);
assertTrue(html.contains("loadUsersList()"));
assertTrue(html.contains("id=\"adminUsersBlock\""));
assertTrue(html.contains("rest/user/currentUserName"));
- assertTrue(html.contains("/user.html?login="));
+ assertTrue(html.contains("renderAdminUsersList(menuData,
\"#adminUsersBlock\", \"#adminUsers\")"));
+ assertTrue(commonScript.contains("/user.html?login="));
+ }
+
+ @Test
+ public void mainMenuDoesNotRenderAdminUsersDropdown() throws IOException {
+ String commonScript = new String(Files.readAllBytes(commonJs()),
StandardCharsets.UTF_8);
+
+ assertFalse(commonScript.contains("adminUsersMenu"));
+ assertFalse(commonScript.contains("dropbtn'>Users"));
}
private static UserService service(IUserStorage users, ITcBotUserCreds
creds) throws Exception {
@@ -179,4 +189,13 @@ public class UserServiceTest {
return Paths.get("ignite-tc-helper-web/src/main/webapp/user.html");
}
+
+ private static Path commonJs() {
+ Path projectPath = Paths.get("src/main/webapp/js/common-1.7.js");
+
+ if (Files.exists(projectPath))
+ return projectPath;
+
+ return
Paths.get("ignite-tc-helper-web/src/main/webapp/js/common-1.7.js");
+ }
}
diff --git
a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringServiceSecurityTest.java
b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringServiceSecurityTest.java
index 9e9fcb4b..501cb5bb 100644
---
a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringServiceSecurityTest.java
+++
b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/web/rest/monitoring/MonitoringServiceSecurityTest.java
@@ -90,6 +90,15 @@ public class MonitoringServiceSecurityTest {
assertFalse(html.contains("Application warnings/errors are available
for bot admins."));
}
+ @Test
+ public void monitoringPageContainsAdminUsersList() throws IOException {
+ String html = readFile(monitoringHtml());
+
+ assertTrue(html.contains("renderAdminUsersList(result,
\"#adminUsersBlock\", \"#adminUsers\")"));
+ assertTrue(html.contains("id=\"adminUsersBlock\"
class=\"adminOnly\""));
+ assertTrue(html.contains("<b>Users:</b>"));
+ }
+
private static void assertAuthRequired(Method method) {
assertFalse(method.isAnnotationPresent(PermitAll.class));
}