Skip to content

Commit

Permalink
Use documentation link service for index pattern field editor (#100609)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl committed May 26, 2021
1 parent e49db71 commit 639df23
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,24 @@ core.application.register({
title: 'Translated title',
keywords: ['translated keyword1', 'translated keyword2'],
deepLinks: [
{ id: 'sub1', title: 'Sub1', path: '/sub1', keywords: ['subpath1'] },
{
id: 'sub2',
title: 'Sub2',
deepLinks: [
{ id: 'subsub', title: 'SubSub', path: '/sub2/sub', keywords: ['subpath2'] }
]
}
{
id: 'sub1',
title: 'Sub1',
path: '/sub1',
keywords: ['subpath1'],
},
{
id: 'sub2',
title: 'Sub2',
deepLinks: [
{
id: 'subsub',
title: 'SubSub',
path: '/sub2/sub',
keywords: ['subpath2'],
},
],
},
],
mount: () => { ... }
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ readonly links: {
readonly introduction: string;
readonly fieldFormattersNumber: string;
readonly fieldFormattersString: string;
readonly runtimeFields: string;
};
readonly addData: string;
readonly kibana: string;
Expand Down

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export class DocLinksService {
introduction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index-patterns.html`,
fieldFormattersNumber: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/numeral.html`,
fieldFormattersString: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/field-formatters-string.html`,
runtimeFields: `${KIBANA_DOCS}managing-index-patterns.html#runtime-fields`,
},
addData: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/connect-to-elasticsearch.html`,
kibana: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index.html`,
Expand Down Expand Up @@ -512,6 +513,7 @@ export interface DocLinksStart {
readonly introduction: string;
readonly fieldFormattersNumber: string;
readonly fieldFormattersString: string;
readonly runtimeFields: string;
};
readonly addData: string;
readonly kibana: string;
Expand Down
1 change: 1 addition & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ export interface DocLinksStart {
readonly introduction: string;
readonly fieldFormattersNumber: string;
readonly fieldFormattersString: string;
readonly runtimeFields: string;
};
readonly addData: string;
readonly kibana: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ import { registerTestBed, TestBed, getCommonActions } from '../../test_utils';
import { RuntimeFieldPainlessError } from '../../lib';
import { Field } from '../../types';
import { FieldEditor, Props, FieldEditorFormState } from './field_editor';
import { docLinksServiceMock } from '../../../../../core/public/mocks';

const defaultProps: Props = {
onChange: jest.fn(),
links: {
runtimePainless: 'https://elastic.co',
},
links: docLinksServiceMock.createStartContract() as any,
ctx: {
existingConcreteFields: [],
namesNotAllowed: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
import { act } from 'react-dom/test-utils';

import '../test_utils/setup_environment';
import { registerTestBed, TestBed, noop, docLinks, getCommonActions } from '../test_utils';
import { registerTestBed, TestBed, noop, getCommonActions } from '../test_utils';

import { FieldEditor } from './field_editor';
import { FieldEditorFlyoutContent, Props } from './field_editor_flyout_content';
import { docLinksServiceMock } from '../../../../core/public/mocks';

const defaultProps: Props = {
onSave: noop,
onCancel: noop,
docLinks,
docLinks: docLinksServiceMock.createStartContract() as any,
FieldEditor,
indexPattern: { fields: [] } as any,
uiSettings: {} as any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@

import { DocLinksStart } from 'src/core/public';

export const getLinks = (docLinks: DocLinksStart) => {
const { DOC_LINK_VERSION, ELASTIC_WEBSITE_URL } = docLinks;
const docsBase = `${ELASTIC_WEBSITE_URL}guide/en`;
const painlessDocsBase = `${docsBase}/elasticsearch/painless/${DOC_LINK_VERSION}`;
const kibanaDocsBase = `${docsBase}/kibana/${DOC_LINK_VERSION}`;

export const getLinks = ({ links }: DocLinksStart) => {
return {
runtimePainless: `${kibanaDocsBase}/managing-index-patterns.html#runtime-fields`,
painlessSyntax: `${painlessDocsBase}/painless-lang-spec.html`,
runtimePainless: links.indexPatterns.runtimeFields,
painlessSyntax: links.scriptedFields.painlessLangSpec,
};
};

0 comments on commit 639df23

Please sign in to comment.