diff --git a/public/app/features/api-keys/ApiKeysAddedModal.tsx b/public/app/features/api-keys/ApiKeysAddedModal.tsx index 89043776102..b345416b588 100644 --- a/public/app/features/api-keys/ApiKeysAddedModal.tsx +++ b/public/app/features/api-keys/ApiKeysAddedModal.tsx @@ -1,7 +1,10 @@ -import React from 'react'; +import React, { useCallback } from 'react'; import { css } from '@emotion/css'; -import { Alert, Field, Modal, useStyles2 } from '@grafana/ui'; +import { Alert, Field, Modal, useStyles2, Input, Icon, ClipboardButton } from '@grafana/ui'; import { GrafanaTheme2 } from '@grafana/data'; +import { notifyApp } from '../../core/actions'; +import { dispatch } from '../../store/store'; +import { createSuccessNotification } from '../../core/copy/appNotification'; export interface Props { onDismiss: () => void; @@ -11,12 +14,24 @@ export interface Props { export function ApiKeysAddedModal({ onDismiss, apiKey, rootPath }: Props): JSX.Element { const styles = useStyles2(getStyles); + const getClipboardText = useCallback(() => apiKey, [apiKey]); + const onClipboardCopy = () => { + dispatch(notifyApp(createSuccessNotification('Content copied to clipboard'))); + }; return ( - {apiKey} + + Copy + + } + /> - It is not stored in this form, so be sure to copy it now. diff --git a/public/app/features/api-keys/__snapshots__/ApiKeysAddedModal.test.tsx.snap b/public/app/features/api-keys/__snapshots__/ApiKeysAddedModal.test.tsx.snap index 380a868aad9..2a5670c70f1 100644 --- a/public/app/features/api-keys/__snapshots__/ApiKeysAddedModal.test.tsx.snap +++ b/public/app/features/api-keys/__snapshots__/ApiKeysAddedModal.test.tsx.snap @@ -10,11 +10,23 @@ exports[`Render should render component 1`] = ` - - api key test - + + + Copy + + } + id="Key" + readOnly={true} + value="api key test" + />