Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 2x 2x 100x 100x 100x 100x | import NiceModal from "@ebay/nice-modal-react";
import { upperFirst } from "lodash";
import DeveloperApiActionModal from "../modals/DeveloperApiActionmodal";
const bodies: Record<string, string> = {
revoke:
"Are you sure you want to revoke this API key? Revoking the key will disable access to the associated resources.",
activate: "Are you sure you want to activate this API key?",
roll: "Are you sure you want to roll this API key? Rolling the key will generate a new unique API key string, invalidating the current key.",
delete:
"Are you sure you want to delete this API key? Deleting the key will permanently remove it from the system, and it cannot be undone. Any associated resources relying on this key will lose access.",
};
const generateSuccessMessage = (keyName: string): Record<string, string> => {
return {
revoke: `${keyName} is revoked`,
activate: `${keyName} is activated`,
roll: "",
delete: `${keyName} has been deleted`,
};
};
type ActionModalProps = {
action: string;
onClick?: () => void;
type?: string;
};
export function useCreateDeveloperApiActions({ rowData }: { rowData: any }) {
const keyId = rowData?.id;
const apiKeyName = rowData?.name;
const openActionModal = ({ action, type = "success" }: ActionModalProps) => {
if (!keyId || !apiKeyName) return;
NiceModal.show(DeveloperApiActionModal, {
title: `${upperFirst(action)} ${apiKeyName}`,
body: bodies[action],
primaryActionLabel: upperFirst(action),
action,
keyId,
type,
successMessage: generateSuccessMessage(apiKeyName)[action],
});
};
return {
openActionModal,
};
}
|