MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / ApiKeysPage

Function ApiKeysPage

packages/react/src/pages/api-keys.tsx:225–379  ·  view source on GitHub ↗
(props: { readonly orgKeysSection?: ReactNode })

Source from the content-addressed store, hash-verified

223}
224
225export function ApiKeysPage(props: { readonly orgKeysSection?: ReactNode }) {
226 useExecutorDocumentTitle("API keys");
227 const result = useAtomValue(apiKeysAtom);
228 const refreshApiKeys = useAtomRefresh(apiKeysAtom);
229 const doCreate = useAtomSet(createApiKey, { mode: "promiseExit" });
230 const doRevoke = useAtomSet(revokeApiKey, { mode: "promiseExit" });
231 const [createOpen, setCreateOpen] = useState(false);
232 // Bumped per open so the dialog body remounts with fresh state; the shell
233 // stays mounted for Radix's exit animation (see CreateKeyDialogBody).
234 const [openCount, setOpenCount] = useState(0);
235 const [revokingId, setRevokingId] = useState<string | null>(null);
236 const [confirmRevoke, setConfirmRevoke] = useState<ApiKeySummary | null>(null);
237
238 const handleCreate = async (name: string): Promise<CreatedKey | null> => {
239 const exit = await doCreate({ payload: { name }, reactivityKeys: apiKeyWriteKeys });
240 trackEvent("api_key_created", { success: Exit.isSuccess(exit) });
241 if (Exit.isSuccess(exit)) {
242 toast.success("API key created");
243 return exit.value;
244 }
245 toast.error("Failed to create API key");
246 return null;
247 };
248
249 const handleRevoke = async (key: ApiKeySummary) => {
250 setRevokingId(key.id);
251 const exit = await doRevoke({ params: { apiKeyId: key.id }, reactivityKeys: apiKeyWriteKeys });
252 setRevokingId(null);
253 trackEvent("api_key_revoked", { success: Exit.isSuccess(exit) });
254 if (Exit.isSuccess(exit)) {
255 toast.success(`Revoked ${key.name}`);
256 return;
257 }
258 toast.error("Failed to revoke API key");
259 };
260
261 return (
262 <PageContainer>
263 <PageHeader
264 title="API keys"
265 description="Keys for accessing the Executor API and MCP endpoint from scripts and tools."
266 actions={
267 <Button
268 onClick={() => {
269 setOpenCount((count) => count + 1);
270 setCreateOpen(true);
271 }}
272 >
273 <span aria-hidden="true">+</span>
274 New key
275 </Button>
276 }
277 >
278 <div className="mt-4 flex max-w-2xl items-center gap-2 rounded-md border border-border bg-card px-3 py-2">
279 <code className="min-w-0 flex-1 truncate font-mono text-xs text-foreground">
280 Authorization: Bearer &lt;api-key&gt;
281 </code>
282 <CopyButton value="Authorization: Bearer <api-key>" />

Callers

nothing calls this directly

Calls 5

useExecutorDocumentTitleFunction · 0.90
isAsyncResultLoadingFunction · 0.90
trackEventFunction · 0.90
defaultKeyNameFunction · 0.85
handleRevokeFunction · 0.85

Tested by

no test coverage detected