Watch
0
0
Fork
You've already forked hyperhive
0

let the operator set, replace and remove an agent's backend env from the swarm ui

This commit is contained in:
atlas 2026-10-28 01:33:52 +01:00 • committed by mara
commit 57b04d6c49

View file

@ -17,6 +17,7 @@ import { ConfirmDialog } from "../../ui/confirm-dialog/ConfirmDialog.js";
import { Dialog } from "../../ui/dialog/Dialog.js";
import { LinkMatrixAccountForm } from "../../pages/LinkMatrixAccountForm.js";
import { LinkForgeAccountForm } from "../../pages/LinkForgeAccountForm.js";
import { LinkBackendEnvForm } from "../../pages/LinkBackendEnvForm.js";
import { LinkGithubAccountForm } from "../../pages/LinkGithubAccountForm.js";
import type { AgentRow } from "../AgentTypes.js";
import type { LinkKind } from "../detail/LinkAccountMenu.js";
@ -96,6 +97,7 @@ export function useAgentActions(
const [matrixTarget, setMatrixTarget] = useState<AgentRow | null>(null);
const [forgeTarget, setForgeTarget] = useState<AgentRow | null>(null);
const [githubTarget, setGithubTarget] = useState<AgentRow | null>(null);
const [backendTarget, setBackendTarget] = useState<AgentRow | null>(null);
const [linkVersion, setLinkVersion] = useState(0);
const linkClosed = () => setLinkVersion((v) => v + 1);
@ -111,6 +113,10 @@ export function useAgentActions(
setGithubTarget(null);
linkClosed();
};
const closeBackend = () => {
setBackendTarget(null);
linkClosed();
};
// The one PUT every wanted-state selection ends at, whether or not it went
// through a `ConfirmDialog` first: PUT a new `wanted` declaration, track
@ -213,6 +219,20 @@ export function useAgentActions(
/>
) : null}
</Dialog>
<Dialog
open={backendTarget !== null}
onClose={closeBackend}
label="set the API-key environment"
plain
>
{backendTarget?.hive ? (
<LinkBackendEnvForm
hive={backendTarget.hive}
agent={backendTarget.name}
onClose={closeBackend}
/>
) : null}
</Dialog>
<ConfirmDialog
open={confirmTarget !== null}
label={confirmTarget ? CONFIRM_COPY[confirmTarget.state].label : ""}
@ -259,7 +279,8 @@ export function useAgentActions(
openLink: (row, kind) => {
if (kind === "matrix") setMatrixTarget(row);
else if (kind === "forge") setForgeTarget(row);
else setGithubTarget(row);
else if (kind === "github") setGithubTarget(row);
else setBackendTarget(row);
},
dialogs,
};