import { css } from '@emotion/css'; import React, { useState } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Alert, Button, ConfirmModal, useStyles2 } from '@grafana/ui'; interface Props { onMigrate: () => void; apikeysCount: number; disabled?: boolean; } export const MigrateToServiceAccountsCard = ({ onMigrate, apikeysCount, disabled }: Props): JSX.Element => { const [isModalOpen, setIsModalOpen] = useState(false); const styles = useStyles2(getStyles); const docsLink = ( Find out more about the migration here. ); const migrationBoxDesc = ( Migrating all API keys will hide the API keys tab.



The API keys API will remain available for you to create new API keys, but we strongly encourage you to use Service accounts instead.
); return ( <> {apikeysCount > 0 && (
We will soon deprecate API keys. Each API key will be migrated into a service account with a token and will continue to work as they were. We encourage you to migrate your API keys to service accounts now. {docsLink}
setIsModalOpen(false)} confirmVariant="primary" confirmButtonVariant="primary" />
)} {apikeysCount === 0 && ( <>
No API keys were found. If you reload the browser, this tab will be not available. If any API keys are created, this tab will appear again.
)} ); }; export const getStyles = (theme: GrafanaTheme2) => ({ text: css` margin-bottom: ${theme.spacing(2)}; `, actionRow: css` display: flex; align-items: center; `, actionButton: css` margin-right: ${theme.spacing(2)}; `, });