Hub stage 6: blocking and cache actions on several servers

One endpoint, hub/servers/run (operate), runs a fixed set of actions on
the chosen servers in parallel with each server's admin token: add or
remove a domain in Blocked or Allowed, disable blocking for a time or
enable it, update block lists, replace the block list URLs, flush the
cache or delete a domain from it. Each server gets its own result and
the console offers Retry failed.

In "All servers", Blocking, Cache and Query Logs rows open this flow
instead of being disabled. The hub validates domains, minutes and the
server's list grammar (allow lists with !, switched-off lines with #)
and logs no URL list. Operators can now use the blocking switch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
DenozordecandClaude Opus 5.5 committed 2026-10-31 22:50:09 +07:00
1 parent 8bb1e01936
commit 34de910e04
31 files changed
+1560 -40

No files matched your search

+40 -1
View File
@@ -1,10 +1,11 @@
import { useState } from 'react'
import { useContext, useState } from 'react'
import { getSettings, setSettings, temporaryDisableBlocking } from '../../api/settings'
import { Confirm } from '../../ui/Confirm'
import { Menu } from '../../ui/Menu'
import { Button } from '../../ui/Button'
import { Tooltip } from '../../ui/Tooltip'
import { nodeArg, useHubWrite } from '../../lib/hub-write'
import { HubAll } from '../../lib/hub-all'
import type { AlertType } from '../../ui/Alert'
import { noticeFromFailure } from '../../lib/notice'
@@ -73,6 +74,8 @@ export function BlockingMenu({
const [active, setActive] = useState<boolean | null>(null)
const [pending, setPending] = useState<Pending | null>(null)
const [busy, setBusy] = useState(false)
/* Behind a hub with "All servers" chosen: the choice opens the flow that makes it on the servers picked next. */
const all = useContext(HubAll)
async function loadState() {
setActive(null)
@@ -137,6 +140,42 @@ export function BlockingMenu({
/* Behind a hub, only on a chosen server the hub can write to; the tooltip says why not. */
const write = useHubWrite(node, allowed)
if (all !== null) {
return (
<Menu label="Blocking options" text={text}>
{(close) => (
<>
<button
role="menuitem"
onClick={() => {
close()
all({ action: 'blocking.enable', title: 'Enable blocking on several servers', confirmLabel: 'Enable blocking' })
}}
>
Enable Blocking
</button>
{DURATIONS.map((p) => (
<button
key={p.minutes}
role="menuitem"
onClick={() => {
close()
all({
action: 'blocking.disable',
params: { minutes: String(p.minutes) },
title: `Disable blocking for ${p.minutes} minute(s) on several servers`,
confirmLabel: 'Disable blocking',
})
}}
>
{p.text}
</button>
))}
</>
)}
</Menu>
)
}
if (!write.allowed) {
return (
<Tooltip text={write.reason ?? 'Requires Settings: Modify'}>