diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/components/generate_api_key_modal/modal.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/components/generate_api_key_modal/modal.tsx index 18514ef93d9d9..d19568bea9e3c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/components/generate_api_key_modal/modal.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/components/generate_api_key_modal/modal.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React from 'react'; +import React, { useRef, useEffect } from 'react'; import { useValues, useActions } from 'kea'; @@ -26,11 +26,12 @@ import { EuiText, EuiSpacer, EuiLink, - EuiFormLabel, EuiCodeBlock, + EuiCallOut, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n-react'; import { docLinks } from '../../../../../shared/doc_links'; @@ -49,6 +50,13 @@ export const GenerateApiKeyModal: React.FC = ({ indexN const { ingestionMethod } = useValues(IndexViewLogic); const { setKeyName } = useActions(GenerateApiKeyModalLogic); const { makeRequest } = useActions(GenerateApiKeyLogic); + const copyApiKeyRef = useRef(null); + + useEffect(() => { + if (isSuccess) { + copyApiKeyRef.current?.focus(); + } + }, [isSuccess]); return ( @@ -68,7 +76,11 @@ export const GenerateApiKeyModal: React.FC = ({ indexN "Before you can start posting documents to your Elasticsearch index you'll need to create at least one API key.", })}   - + {i18n.translate( 'xpack.enterpriseSearch.content.overview.generateApiKeyModal.learnMore', { defaultMessage: 'Learn more about API keys' } @@ -77,15 +89,25 @@ export const GenerateApiKeyModal: React.FC = ({ indexN

- + + {!isSuccess ? ( <> - + + } + fullWidth + > = ({ indexN ) : ( - {keyName} - + {keyName}, + }} + /> + } + color="success" + iconType="check" + role="alert" + /> = ({ indexN = ({ indexN