import React, { FC } from 'react'; import { DeleteButton } from '@grafana/ui'; import { dateTimeFormat, TimeZone } from '@grafana/data'; import { ApiKey } from '../../types'; interface Props { apiKeys: ApiKey[]; timeZone: TimeZone; onDelete: (apiKey: ApiKey) => void; } export const ApiKeysTable: FC = ({ apiKeys, timeZone, onDelete }) => { return ( {apiKeys.length > 0 ? ( {apiKeys.map((key) => { return ( ); })} ) : null}
Name Role Expires
{key.name} {key.role} {formatDate(key.expiration, timeZone)} onDelete(key)} />
); }; function formatDate(expiration: string | undefined, timeZone: TimeZone): string { if (!expiration) { return 'No expiration date'; } return dateTimeFormat(expiration, { timeZone }); }