mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
feat(modpanel): the mod log as its own page
The admin panel's "What they did" table, in the moderator panel too: the latest 300 entries. A new permission, staff.log, which moderators and admins have by default, guards the page and its route. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
0f367c55b8
commit
8368692b99
3 files changed
+38
-1
No files matched your search
@@ -670,6 +670,17 @@ const handle = async (req, res, url, from, web) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// the mod log (lib/modlog.js): what staff did, as the admin panel's
|
||||
// Moderators page shows it.
|
||||
if (route === "GET /mod/api/modlog") {
|
||||
if (!roles.can(mod, "staff.log")) {
|
||||
reply(403, {error: "Your role does not allow that."});
|
||||
return;
|
||||
}
|
||||
reply(200, {log: modlog.recent()});
|
||||
return;
|
||||
}
|
||||
|
||||
// everything else shows players and what they did: not for a role that
|
||||
// only makes things.
|
||||
if (!roles.can(mod, "player.view")) {
|
||||
|
||||
+2
-1
@@ -33,10 +33,11 @@ const PERMISSIONS = {
|
||||
"room.effects": "run temporary room-wide size and colour effects (!roomfx)",
|
||||
"theater.control": "play or stop a YouTube video for everyone in the theatre",
|
||||
"music.upload": "upload MP3s as den music tracks, and delete those uploaded (the Music page)",
|
||||
"staff.log": "read the mod log: what staff did, in the panels and the game (the Mod log page)",
|
||||
};
|
||||
|
||||
const HELPER = ["server.view", "player.view", "staff.list", "player.warn", "player.goto", "chat.silence"];
|
||||
const MODERATOR = [...HELPER, "player.kick", "player.summon", "staff.invisible", "player.ban", "player.names", "address.ban", "items.approve", "items.restrict", "theater.control"];
|
||||
const MODERATOR = [...HELPER, "player.kick", "player.summon", "staff.invisible", "player.ban", "player.names", "address.ban", "items.approve", "items.restrict", "theater.control", "staff.log"];
|
||||
const ADMIN = [...MODERATOR, "items.create", "room.effects", "music.upload"];
|
||||
// a developer makes things, and moderates nobody.
|
||||
const DEVELOPER = ["server.view", "staff.list", "items.create", "room.effects", "theater.control"];
|
||||
|
||||
@@ -475,6 +475,7 @@
|
||||
<button role="tab" data-tab="masterpieces" data-needs="player.view" aria-selected="false"><span class="icon" aria-hidden="true">▣</span>Masterpieces<span id="masterpiece-count"></span></button>
|
||||
<button role="tab" data-tab="bans" data-needs="player.view" aria-selected="false"><span class="icon" aria-hidden="true">⊘</span>Bans</button>
|
||||
<button role="tab" data-tab="stats" data-needs="player.view" aria-selected="false"><span class="icon" aria-hidden="true">▤</span>Stats</button>
|
||||
<button role="tab" data-tab="mod-log" data-needs="staff.log" aria-selected="false" hidden><span class="icon" aria-hidden="true">☰</span>Mod log</button>
|
||||
<button role="tab" data-tab="review" data-needs="items.approve" aria-selected="false" hidden><span class="icon" aria-hidden="true">✔</span>Review</button>
|
||||
<button role="tab" data-tab="wear-rules" data-needs="items.restrict" aria-selected="false" hidden><span class="icon" aria-hidden="true">⚑</span>Wear rules</button>
|
||||
<button role="tab" data-tab="items" data-needs="items.create" aria-selected="false" hidden><span class="icon" aria-hidden="true">❖</span>Items</button>
|
||||
@@ -992,6 +993,17 @@
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div data-view="mod-log" hidden>
|
||||
<section>
|
||||
<h2>What staff did</h2>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>When</th><th>Who</th><th>What</th><th>Player</th><th>Detail</th></tr></thead>
|
||||
<tbody id="mod-log"></tbody>
|
||||
</table></div>
|
||||
<div class="empty" id="no-mod-log" hidden>Nothing yet.</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div data-view="bans" hidden>
|
||||
<section>
|
||||
<h2>Banned and silenced</h2>
|
||||
@@ -2961,6 +2973,19 @@
|
||||
else if (shown === "stats") {
|
||||
await window.statsView.load(api);
|
||||
}
|
||||
else if (shown === "mod-log") {
|
||||
const result = await api("modlog");
|
||||
if (result.ok) {
|
||||
$("mod-log").replaceChildren(...result.data.log.map(entry => {
|
||||
const row = el("tr");
|
||||
const detail = el("td", entry.detail);
|
||||
detail.style.whiteSpace = "normal";
|
||||
row.append(el("td", when(entry.at)), el("td", entry.by), el("td", entry.action), el("td", entry.target || "—"), detail);
|
||||
return row;
|
||||
}));
|
||||
$("no-mod-log").hidden = result.data.log.length > 0;
|
||||
}
|
||||
}
|
||||
else if (shown === "bans") {
|
||||
const [result, hits] = await Promise.all([api("bans"), api("filterhits")]);
|
||||
if (result.ok) {
|
||||
|
||||
Reference in new issue
Block a user