Skip to content

Commit

Permalink
add index-pattern link when error contains 'click here' text (elastic…
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 authored Jul 20, 2020
1 parent e1a7db0 commit 8283561
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React, { FC } from 'react';

import { EuiCallOut, EuiPanel, EuiSpacer } from '@elastic/eui';
import { EuiCallOut, EuiLink, EuiPanel, EuiSpacer } from '@elastic/eui';

import { i18n } from '@kbn/i18n';

Expand All @@ -31,6 +31,23 @@ export const JobConfigErrorCallout: FC<Props> = ({
jobConfigErrorMessage,
title,
}) => {
const containsIndexPatternLink =
typeof jobCapsServiceErrorMessage === 'string' &&
jobCapsServiceErrorMessage.includes('locate that index-pattern') &&
jobCapsServiceErrorMessage.includes('click here to re-create');

const message = (
<p>{jobConfigErrorMessage ? jobConfigErrorMessage : jobCapsServiceErrorMessage}</p>
);

const calloutBody = containsIndexPatternLink ? (
<EuiLink href="management/kibana/indexPatterns" target="_blank">
{message}
</EuiLink>
) : (
message
);

return (
<EuiPanel grow={false}>
<ExplorationTitle title={title} />
Expand All @@ -40,7 +57,7 @@ export const JobConfigErrorCallout: FC<Props> = ({
color="danger"
iconType="cross"
>
<p>{jobConfigErrorMessage ? jobConfigErrorMessage : jobCapsServiceErrorMessage}</p>
{calloutBody}
</EuiCallOut>
</EuiPanel>
);
Expand Down

0 comments on commit 8283561

Please sign in to comment.