-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enterprise Search] Index Pipelines JSON Configurations #142609
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { useValues } from 'kea'; | ||
|
||
import { EuiBadgeGroup, EuiBadge, EuiToolTip } from '@elastic/eui'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
|
||
import { DEFAULT_PIPELINE_NAME } from '../../../../../../common/constants'; | ||
|
||
import { isManagedPipeline } from '../../../../shared/pipelines/is_managed'; | ||
|
||
import { IndexPipelinesConfigurationsLogic } from './pipelines_json_configurations_logic'; | ||
|
||
const ManagedPipelineBadge: React.FC = () => ( | ||
<EuiToolTip | ||
position="top" | ||
content={i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.managed.description', | ||
{ defaultMessage: 'This pipeline is managed and cannot be edited' } | ||
)} | ||
> | ||
<EuiBadge iconType="lock" color="warning"> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.managed', | ||
{ defaultMessage: 'Managed' } | ||
)} | ||
</EuiBadge> | ||
</EuiToolTip> | ||
); | ||
|
||
const UnmanagedPipelineBadge: React.FC = () => ( | ||
<EuiToolTip | ||
position="top" | ||
content={ | ||
<FormattedMessage | ||
id="xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.unmanaged.description" | ||
defaultMessage="Edit this pipeline from {ingestPipelines} in Stack Management" | ||
values={{ | ||
ingestPipelines: ( | ||
<strong> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.ingestPipelines', | ||
{ defaultMessage: 'Ingest Pipelines' } | ||
)} | ||
</strong> | ||
), | ||
}} | ||
/> | ||
} | ||
> | ||
<EuiBadge iconType="lockOpen"> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.unmanaged', | ||
{ defaultMessage: 'Unmanaged' } | ||
)} | ||
</EuiBadge> | ||
</EuiToolTip> | ||
); | ||
|
||
const SharedPipelineBadge: React.FC = () => ( | ||
<EuiToolTip | ||
position="top" | ||
content={i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.shared.description', | ||
{ defaultMessage: 'This pipeline is shared across all Enterprise Search ingestion methods' } | ||
)} | ||
> | ||
<EuiBadge iconType="logstashIf" color="hollow"> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.shared', | ||
{ defaultMessage: 'Shared' } | ||
)} | ||
</EuiBadge> | ||
</EuiToolTip> | ||
); | ||
|
||
const IndexPipelineBadge: React.FC = () => ( | ||
<EuiToolTip | ||
position="top" | ||
content={i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.indexSpecific.description', | ||
{ defaultMessage: 'This pipeline contains configurations specific to this index only' } | ||
)} | ||
> | ||
<EuiBadge iconType="document" color="hollow"> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.indexSpecific', | ||
{ defaultMessage: 'Index specific' } | ||
)} | ||
</EuiBadge> | ||
</EuiToolTip> | ||
); | ||
|
||
const MlInferenceBadge: React.FC = () => ( | ||
<EuiToolTip | ||
position="top" | ||
content={i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.mlInference.description', | ||
{ | ||
defaultMessage: | ||
'This pipeline references one or more ML Inference Pipelines for this index', | ||
} | ||
)} | ||
> | ||
<EuiBadge iconType="compute" color="hollow"> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.mlInference', | ||
{ defaultMessage: 'ML Inference' } | ||
)} | ||
</EuiBadge> | ||
</EuiToolTip> | ||
); | ||
|
||
export const PipelineJSONBadges: React.FC = () => { | ||
const { | ||
indexName, | ||
selectedPipeline: pipeline, | ||
selectedPipelineId: pipelineName, | ||
} = useValues(IndexPipelinesConfigurationsLogic); | ||
if (!pipeline) { | ||
return <></>; | ||
} | ||
const badges: JSX.Element[] = []; | ||
if (isManagedPipeline(pipeline)) { | ||
badges.push(<ManagedPipelineBadge />); | ||
} else { | ||
badges.push(<UnmanagedPipelineBadge />); | ||
} | ||
if (pipelineName === DEFAULT_PIPELINE_NAME) { | ||
badges.push(<SharedPipelineBadge />); | ||
} | ||
if (pipelineName?.endsWith('@ml-inference')) { | ||
badges.push(<MlInferenceBadge />); | ||
} else if (pipelineName?.includes(indexName)) { | ||
badges.push(<IndexPipelineBadge />); | ||
} | ||
return <EuiBadgeGroup gutterSize="s">{badges}</EuiBadgeGroup>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { useActions, useValues } from 'kea'; | ||
|
||
import { | ||
EuiButtonEmpty, | ||
EuiCodeBlock, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiFormRow, | ||
EuiLink, | ||
EuiNotificationBadge, | ||
EuiSelect, | ||
EuiSpacer, | ||
} from '@elastic/eui'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { DataPanel } from '../../../../shared/data_panel/data_panel'; | ||
import { docLinks } from '../../../../shared/doc_links'; | ||
import { HttpLogic } from '../../../../shared/http'; | ||
import { isManagedPipeline } from '../../../../shared/pipelines/is_managed'; | ||
|
||
import { PipelineJSONBadges } from './pipeline_json_badges'; | ||
import { IndexPipelinesConfigurationsLogic } from './pipelines_json_configurations_logic'; | ||
|
||
export const PipelinesJSONConfigurations: React.FC = () => { | ||
const { http } = useValues(HttpLogic); | ||
const { pipelineNames, selectedPipeline, selectedPipelineId, selectedPipelineJSON } = useValues( | ||
IndexPipelinesConfigurationsLogic | ||
); | ||
const { selectPipeline } = useActions(IndexPipelinesConfigurationsLogic); | ||
return ( | ||
<> | ||
<EuiSpacer /> | ||
<DataPanel | ||
hasBorder | ||
title={ | ||
<h2> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.title', | ||
{ defaultMessage: 'Pipeline configurations' } | ||
)} | ||
</h2> | ||
} | ||
subtitle={i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.subtitle', | ||
{ defaultMessage: 'View the JSON for your pipeline configurations on this index.' } | ||
)} | ||
footerDocLink={ | ||
<EuiLink href={docLinks.ingestPipelines} target="_blank" color="subdued"> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.ingestionPipelines.docLink', | ||
{ | ||
defaultMessage: 'Learn more about how Enterprise Search uses ingest pipelines', | ||
} | ||
)} | ||
</EuiLink> | ||
} | ||
action={ | ||
pipelineNames.length > 0 && ( | ||
<EuiNotificationBadge size="m">{pipelineNames.length}</EuiNotificationBadge> | ||
) | ||
} | ||
iconType="visVega" | ||
> | ||
<EuiFormRow | ||
fullWidth | ||
label={i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.selectLabel', | ||
{ defaultMessage: 'Select an ingest pipeline to view' } | ||
)} | ||
> | ||
<EuiSelect | ||
fullWidth | ||
options={pipelineNames.map((name) => ({ text: name, value: name }))} | ||
value={selectedPipelineId} | ||
onChange={(e) => selectPipeline(e.target.value)} | ||
/> | ||
</EuiFormRow> | ||
<EuiSpacer size="m" /> | ||
{selectedPipeline && ( | ||
<> | ||
<EuiFlexGroup alignItems="center"> | ||
<EuiFlexItem> | ||
<PipelineJSONBadges /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
{isManagedPipeline(selectedPipeline) ? ( | ||
<EuiButtonEmpty | ||
size="s" | ||
flush="both" | ||
iconType="eye" | ||
color="primary" | ||
href={http.basePath.prepend( | ||
`/app/management/ingest/ingest_pipelines/?pipeline=${selectedPipelineId}` | ||
)} | ||
> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.action.view', | ||
{ | ||
defaultMessage: 'View in Stack Management', | ||
TattdCodeMonkey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
)} | ||
</EuiButtonEmpty> | ||
) : ( | ||
<EuiButtonEmpty | ||
size="s" | ||
flush="both" | ||
iconType="pencil" | ||
color="primary" | ||
href={http.basePath.prepend( | ||
`/app/management/ingest/ingest_pipelines/edit/${selectedPipelineId}` | ||
)} | ||
> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.content.indices.pipelines.tabs.jsonConfigurations.action.edit', | ||
{ | ||
defaultMessage: 'Edit in Stack Management', | ||
} | ||
)} | ||
</EuiButtonEmpty> | ||
)} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<EuiSpacer size="m" /> | ||
<EuiCodeBlock language="json" overflowHeight={300} isCopyable> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we have, we can try to come up with one though. |
||
{selectedPipelineJSON} | ||
</EuiCodeBlock> | ||
</> | ||
)} | ||
</DataPanel> | ||
</> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure if we want to use the same doc link here since it's already in the footer for the Ingest Pipelines card.