Files
outline/app/hooks/useApiKeyMenuActions.ts
Tom Moor 69e8aac4f1 Move "Api Keys" listing to filterable table (#12117)
* Move 'Api Keys' listing to filterable table

* Add context menu
Allow copying new keys
2026-04-19 18:12:32 -04:00

22 lines
615 B
TypeScript

import { useMemo } from "react";
import {
copyApiKeyFactory,
revokeApiKeyFactory,
} from "~/actions/definitions/apiKeys";
import type ApiKey from "~/models/ApiKey";
import { useMenuAction } from "~/hooks/useMenuAction";
/**
* Hook that constructs the action menu for API key operations.
*
* @param apiKey - the API key to build actions for.
* @returns action with children for use in menus.
*/
export function useApiKeyMenuActions(apiKey: ApiKey) {
const actions = useMemo(
() => [copyApiKeyFactory({ apiKey }), revokeApiKeyFactory({ apiKey })],
[apiKey]
);
return useMenuAction(actions);
}