[ML] Update broken job config callout error (#75481)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Quynh Nguyen 2020-08-20 18:14:58 -05:00 committed by GitHub
parent 3201efe797
commit 958296c5c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,13 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/
import React, { FC } from 'react';
import React, { FC, useMemo } from 'react';
import { EuiCallOut, EuiLink, EuiPanel, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { ExplorationTitle } from '../exploration_title';
import { useMlKibana } from '../../../../../contexts/kibana';
const jobConfigErrorTitle = i18n.translate('xpack.ml.dataframe.analytics.jobConfig.errorTitle', {
defaultMessage: 'Unable to fetch results. An error occurred loading the job configuration data.',
@ -31,6 +32,11 @@ export const JobConfigErrorCallout: FC<Props> = ({
jobConfigErrorMessage,
title,
}) => {
const {
services: {
application: { getUrlForApp },
},
} = useMlKibana();
const containsIndexPatternLink =
typeof jobCapsServiceErrorMessage === 'string' &&
jobCapsServiceErrorMessage.includes('locate that index-pattern') &&
@ -39,9 +45,16 @@ export const JobConfigErrorCallout: FC<Props> = ({
const message = (
<p>{jobConfigErrorMessage ? jobConfigErrorMessage : jobCapsServiceErrorMessage}</p>
);
const newIndexPatternUrl = useMemo(
() =>
getUrlForApp('management', {
path: 'kibana/indexPatterns',
}),
[]
);
const calloutBody = containsIndexPatternLink ? (
<EuiLink href="management/kibana/indexPatterns" target="_blank">
<EuiLink href={newIndexPatternUrl} target="_blank">
{message}
</EuiLink>
) : (