[www] add instance clear button for staff

This commit is contained in:
Devin Zuczek
2026-10-26 18:27:59 -04:00
parent 207138ef97
commit d819bdbe3d
5 changed files with 135 additions and 1 deletions
+59
View File
@@ -3213,6 +3213,7 @@ function PublicRoomView({
<>
{isDeveloper() && <StaffRoomTokens room={room} />}
<StaffListing room={room} onRoomChange={onRoomChange} />
<StaffClearInstances room={room} />
{isDeveloper() && <StaffTakedown room={room} onTakenDown={onTakenDown} />}
</>
)}
@@ -3351,6 +3352,64 @@ function StaffListing({
)
}
/**
* Delete every instance of the room, for one whose sessions are stuck. Two steps, like the
* dorm clear: nothing is lost for good, but anyone inside is cut off from their session.
*/
function StaffClearInstances({ room }: { room: OwnedRoom }) {
const [confirming, setConfirming] = useState(false)
const { pending, error, done, run } = useAction()
return (
<section className="card">
<h2>Instances</h2>
<p className="hint">
Deletes every instance of this room, including ones with players in them. The next player to
join gets a fresh instance.
</p>
<div className="mod-filter-actions">
{confirming ? (
<>
<button
type="submit"
disabled={pending}
onClick={() =>
void run(async () => {
const res = await call<{ deleted: number[] }>(
`/api/staff/rooms/${room.RoomId}/clear-instances`,
{ authed: true, method: 'POST' }
)
setConfirming(false)
const n = res.deleted.length
return n === 0
? `^${room.Name} had no instances.`
: `Cleared ${n} instance${n === 1 ? '' : 's'} of ^${room.Name}.`
})
}
>
{pending ? 'Clearing…' : 'Confirm clear instances'}
</button>
<button
type="button"
className="linkish"
disabled={pending}
onClick={() => setConfirming(false)}
>
Cancel
</button>
</>
) : (
<button type="submit" onClick={() => setConfirming(true)}>
Clear instances
</button>
)}
</div>
{error && <p className="error">{error}</p>}
{done && <p className="ok">{done}</p>}
</section>
)
}
function StaffTakedown({ room, onTakenDown }: { room: OwnedRoom; onTakenDown: () => void }) {
const [confirming, setConfirming] = useState(false)
const { pending, error, run } = useAction()