Skip to content

Commit

Permalink
handle url generator error when discover plugin is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth committed Sep 24, 2020
1 parent 7f62303 commit a1aa8d8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ export const AddDocumentForm: FunctionComponent<Props> = ({ onAddDocuments }) =>
<EuiIcon type="check" color="secondary" />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText color="secondary">{i18nTexts.addDocumentSuccessMessage}</EuiText>
<EuiText color="secondary" data-test-subj="addDocumentSuccess">
{i18nTexts.addDocumentSuccessMessage}
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';

import { EuiAccordion, EuiText, EuiSpacer, EuiLink } from '@elastic/eui';
import { UrlGeneratorsDefinition } from 'src/plugins/share/public';

import { useKibana } from '../../../../../../../shared_imports';
import { useIsMounted } from '../../../../use_is_mounted';
import { AddDocumentForm } from '../add_document_form';

import './add_documents_accordion.scss';

const DISCOVER_URL_GENERATOR_ID = 'DISCOVER_APP_URL_GENERATOR';

const i18nTexts = {
addDocumentsButton: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.addDocumentsAccordion.addDocumentsButtonLabel',
Expand All @@ -36,9 +39,20 @@ export const AddDocumentsAccordion: FunctionComponent<Props> = ({ onAddDocuments

useEffect(() => {
const getDiscoverUrl = async (): Promise<void> => {
const { isDeprecated, createUrl } = services.urlGenerators.getUrlGenerator(
'DISCOVER_APP_URL_GENERATOR'
);
let isDeprecated: UrlGeneratorsDefinition<typeof DISCOVER_URL_GENERATOR_ID>['isDeprecated'];
let createUrl: UrlGeneratorsDefinition<typeof DISCOVER_URL_GENERATOR_ID>['createUrl'];

// This try/catch may not be necessary once
// https://github.com/elastic/kibana/issues/78344 is addressed
try {
({ isDeprecated, createUrl } = services.urlGenerators.getUrlGenerator(
DISCOVER_URL_GENERATOR_ID
));
} catch (e) {
// Discover plugin is not enabled
setDiscoverLink(undefined);
return;
}

if (isDeprecated) {
setDiscoverLink(undefined);
Expand Down

0 comments on commit a1aa8d8

Please sign in to comment.