grafana/public/app/features/api-keys/ApiKeysController.tsx
Hugo Häggmark e87d48921e
Admin: Keeps expired api keys visible in table after delete (#31636)
* Admin: Keeps expired keys visible in table after delete

* Chore: covers component in tests before refactor

* Refactor: splitting up into smaller components

* Chore: fixes a small issue with the validation

* Chore: forgot to export type
2021-03-04 13:20:38 +01:00

20 lines
452 B
TypeScript

import { FC, useCallback, useState } from 'react';
interface Api {
isAdding: boolean;
toggleIsAdding: () => void;
}
interface Props {
children: (props: Api) => JSX.Element;
}
export const ApiKeysController: FC<Props> = ({ children }) => {
const [isAdding, setIsAdding] = useState<boolean>(false);
const toggleIsAdding = useCallback(() => {
setIsAdding(!isAdding);
}, [isAdding]);
return children({ isAdding, toggleIsAdding });
};