Skip to content

Commit

Permalink
Update more doc links for ingest pipelines app (elastic#112767)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl committed Sep 23, 2021
1 parent a0e2981 commit 749e518
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 33 deletions.
1 change: 1 addition & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ export class DocLinksService {
fail: `${ELASTICSEARCH_DOCS}fail-processor.html`,
foreach: `${ELASTICSEARCH_DOCS}foreach-processor.html`,
geoIp: `${ELASTICSEARCH_DOCS}geoip-processor.html`,
geoMatch: `${ELASTICSEARCH_DOCS}geo-match-enrich-policy-type.html`,
grok: `${ELASTICSEARCH_DOCS}grok-processor.html`,
gsub: `${ELASTICSEARCH_DOCS}gsub-processor.html`,
htmlString: `${ELASTICSEARCH_DOCS}htmlstrip-processor.html`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ const getFieldsConfig = (esDocUrl: string): Record<string, FieldConfig> => {
defaultMessage="Pattern used to dissect the specified field. The pattern is defined by the parts of the string to discard. Use a {keyModifier} to alter the dissection behavior."
values={{
keyModifier: (
<EuiLink
target="_blank"
external
href={esDocUrl + '/dissect-processor.html#dissect-key-modifiers'}
>
<EuiLink target="_blank" external href={esDocUrl}>
{i18n.translate(
'xpack.ingestPipelines.pipelineEditor.dissectForm.patternFieldHelpText.dissectProcessorLink',
{
Expand Down Expand Up @@ -97,7 +93,7 @@ const getFieldsConfig = (esDocUrl: string): Record<string, FieldConfig> => {

export const Dissect: FunctionComponent = () => {
const { services } = useKibana();
const fieldsConfig = getFieldsConfig(services.documentation.getEsDocsBasePath());
const fieldsConfig = getFieldsConfig(services.documentation.getDissectKeyModifiersUrl());

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ const fieldsConfig: FieldsConfig = {

export const Enrich: FunctionComponent = () => {
const { services } = useKibana();
const esDocUrl = services.documentation.getEsDocsBasePath();
return (
<>
<FieldNameField
Expand All @@ -161,7 +160,11 @@ export const Enrich: FunctionComponent = () => {
defaultMessage="Name of the {enrichPolicyLink}."
values={{
enrichPolicyLink: (
<EuiLink external target="_blank" href={esDocUrl + '/ingest-enriching-data.html'}>
<EuiLink
external
target="_blank"
href={services.documentation.getEnrichDataUrl()}
>
{i18n.translate(
'xpack.ingestPipelines.pipelineEditor.enrichForm.policyNameHelpText.enrichPolicyLink',
{ defaultMessage: 'enrich policy' }
Expand Down Expand Up @@ -206,11 +209,7 @@ export const Enrich: FunctionComponent = () => {
defaultMessage="Operator used to match the geo-shape of incoming documents to enrich documents. Only used for {geoMatchPolicyLink}."
values={{
geoMatchPolicyLink: (
<EuiLink
external
target="_blank"
href={esDocUrl + '/enrich-policy-definition.html'}
>
<EuiLink external target="_blank" href={services.documentation.getGeoMatchUrl()}>
{i18n.translate(
'xpack.ingestPipelines.pipelineEditor.enrichForm.shapeRelationFieldHelpText.geoMatchPoliciesLink',
{ defaultMessage: 'geo-match enrich policies' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,35 @@ const { emptyField, isJsonField } = fieldValidators;

const INFERENCE_CONFIG_DOCS = {
regression: {
path: 'inference-processor.html#inference-processor-regression-opt',
linkLabel: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.inferenceForm.inferenceConfigField.regressionLinkLabel',
{ defaultMessage: 'regression' }
),
},
classification: {
path: 'inference-processor.html#inference-processor-classification-opt',
linkLabel: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.inferenceForm.inferenceConfigField.classificationLinkLabel',
{ defaultMessage: 'classification' }
),
},
};

const getInferenceConfigHelpText = (esDocsBasePath: string): React.ReactNode => {
const getInferenceConfigHelpText = (
regressionDocsLink: string,
classificationDocsLink: string
): React.ReactNode => {
return (
<FormattedMessage
id="xpack.ingestPipelines.pipelineEditor.inferenceForm.inferenceConfigurationHelpText"
defaultMessage="Contains the inference type and its options. There are two types: {regression} and {classification}."
values={{
regression: (
<EuiLink
external
target="_blank"
href={`${esDocsBasePath}/${INFERENCE_CONFIG_DOCS.regression.path}`}
>
<EuiLink external target="_blank" href={regressionDocsLink}>
{INFERENCE_CONFIG_DOCS.regression.linkLabel}
</EuiLink>
),
classification: (
<EuiLink
external
target="_blank"
href={`${esDocsBasePath}/${INFERENCE_CONFIG_DOCS.classification.path}`}
>
<EuiLink external target="_blank" href={classificationDocsLink}>
{INFERENCE_CONFIG_DOCS.classification.linkLabel}
</EuiLink>
),
Expand Down Expand Up @@ -158,7 +151,8 @@ const fieldsConfig: FieldsConfig = {

export const Inference: FunctionComponent = () => {
const { services } = useKibana();
const esDocUrl = services.documentation.getEsDocsBasePath();
const regressionDocsLink = services.documentation.getRegressionUrl();
const classificationDocsLink = services.documentation.getClassificationUrl();
return (
<>
<UseField config={fieldsConfig.model_id} component={Field} path="fields.model_id" />
Expand Down Expand Up @@ -188,7 +182,7 @@ export const Inference: FunctionComponent = () => {
<UseField
config={{
...fieldsConfig.inference_config,
helpText: getInferenceConfigHelpText(esDocUrl),
helpText: getInferenceConfigHelpText(regressionDocsLink, classificationDocsLink),
}}
component={XJsonEditor}
componentProps={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const DocumentsTab: FunctionComponent<Props> = ({
values={{
learnMoreLink: (
<EuiLink
href={`${services.documentation.getEsDocsBasePath()}/simulate-pipeline-api.html`}
href={services.documentation.getSimulatePipelineApiUrl()}
target="_blank"
external
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,28 @@ export class DocumentationService {
private processorsUrl: string = '';
private handlingFailureUrl: string = '';
private putPipelineApiUrl: string = '';
private simulatePipelineApiUrl: string = '';
private enrichDataUrl: string = '';
private geoMatchUrl: string = '';
private dissectKeyModifiersUrl: string = '';
private classificationUrl: string = '';
private regressionUrl: string = '';

public setup(docLinks: DocLinksStart): void {
const { DOC_LINK_VERSION, ELASTIC_WEBSITE_URL, links } = docLinks;
const docsBase = `${ELASTIC_WEBSITE_URL}guide/en`;

this.esDocBasePath = `${docsBase}/elasticsearch/reference/${DOC_LINK_VERSION}`;
this.ingestNodeUrl = `${links.ingest.pipelines}`;
this.processorsUrl = `${links.ingest.processors}`;
this.handlingFailureUrl = `${links.ingest.pipelineFailure}`;
this.putPipelineApiUrl = `${links.apis.createPipeline}`;
this.ingestNodeUrl = links.ingest.pipelines;
this.processorsUrl = links.ingest.processors;
this.handlingFailureUrl = links.ingest.pipelineFailure;
this.putPipelineApiUrl = links.apis.createPipeline;
this.simulatePipelineApiUrl = links.apis.simulatePipeline;
this.enrichDataUrl = links.ingest.enrich;
this.geoMatchUrl = links.ingest.geoMatch;
this.dissectKeyModifiersUrl = links.ingest.dissectKeyModifiers;
this.classificationUrl = links.ingest.inferenceClassification;
this.regressionUrl = links.ingest.inferenceRegression;
}

public getEsDocsBasePath() {
Expand All @@ -44,6 +56,30 @@ export class DocumentationService {
public getPutPipelineApiUrl() {
return this.putPipelineApiUrl;
}

public getSimulatePipelineApiUrl() {
return this.simulatePipelineApiUrl;
}

public getEnrichDataUrl() {
return this.enrichDataUrl;
}

public getGeoMatchUrl() {
return this.geoMatchUrl;
}

public getDissectKeyModifiersUrl() {
return this.dissectKeyModifiersUrl;
}

public getClassificationUrl() {
return this.classificationUrl;
}

public getRegressionUrl() {
return this.regressionUrl;
}
}

export const documentationService = new DocumentationService();

0 comments on commit 749e518

Please sign in to comment.