-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2752f77
commit 4b4c81b
Showing
9 changed files
with
198 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...ors_editor/components/test_pipeline/test_pipeline_flyout_tabs/add_documents_accordion.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { FunctionComponent, useState, useEffect } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
import { EuiAccordion, EuiText, EuiSpacer, EuiLink } from '@elastic/eui'; | ||
|
||
import { useKibana } from '../../../../../../shared_imports'; | ||
import { useIsMounted } from '../../../use_is_mounted'; | ||
import { AddDocumentForm } from './add_document_form'; | ||
|
||
const i18nTexts = { | ||
addDocumentsButton: i18n.translate( | ||
'xpack.ingestPipelines.pipelineEditor.addDocumentsAccordion.addDocumentsButtonLabel', | ||
{ | ||
defaultMessage: 'Add documents from index', | ||
} | ||
), | ||
}; | ||
|
||
interface Props { | ||
onAddDocuments: (document: any) => void; | ||
} | ||
|
||
export const AddDocumentsAccordion: FunctionComponent<Props> = ({ onAddDocuments }) => { | ||
const { services } = useKibana(); | ||
const isMounted = useIsMounted(); | ||
const [discoverLink, setDiscoverLink] = useState<string | undefined>(undefined); | ||
|
||
useEffect(() => { | ||
const getDiscoverUrl = async (): Promise<void> => { | ||
const { isDeprecated, createUrl } = services.urlGenerators.getUrlGenerator( | ||
'DISCOVER_APP_URL_GENERATOR' | ||
); | ||
|
||
if (isDeprecated) { | ||
setDiscoverLink(undefined); | ||
return; | ||
} | ||
|
||
const discoverUrl = await createUrl({ indexPatternId: undefined }); | ||
|
||
if (isMounted.current) { | ||
setDiscoverLink(discoverUrl); | ||
} | ||
}; | ||
|
||
getDiscoverUrl(); | ||
}, [isMounted, services.urlGenerators]); | ||
|
||
return ( | ||
<EuiAccordion | ||
id="addDocumentsAccordion" | ||
buttonContent={i18nTexts.addDocumentsButton} | ||
paddingSize="s" | ||
data-test-subj="addDocumentsAccordion" | ||
> | ||
<> | ||
<EuiText size="s" color="subdued"> | ||
<p> | ||
<FormattedMessage | ||
id="xpack.ingestPipelines.pipelineEditor.addDocumentsAccordion.contentDescriptionText" | ||
defaultMessage="Provide the index name and document ID of the indexed document to test." | ||
/> | ||
{discoverLink && ( | ||
<> | ||
{' '} | ||
<FormattedMessage | ||
id="xpack.ingestPipelines.pipelineEditor.addDocumentsAccordion.discoverLinkDescriptionText" | ||
defaultMessage="To explore your existing data, use {discoverLink}." | ||
values={{ | ||
discoverLink: ( | ||
<EuiLink href={discoverLink} target="_blank" external> | ||
Discover | ||
</EuiLink> | ||
), | ||
}} | ||
/> | ||
</> | ||
)} | ||
</p> | ||
</EuiText> | ||
|
||
<EuiSpacer size="m" /> | ||
|
||
<AddDocumentForm onAddDocuments={onAddDocuments} /> | ||
</> | ||
</EuiAccordion> | ||
); | ||
}; |
Oops, something went wrong.