Skip to content
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

Use documentation link service for runtime fields #95256

Merged
merged 7 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ readonly links: {
readonly sum: string;
readonly top_hits: string;
};
readonly runtimeFields: string;
readonly runtimeFields: {
readonly mapping: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
Expand Down

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export class DocLinksService {
sum: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-sum-aggregation.html`,
top_hits: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-top-hits-aggregation.html`,
},
runtimeFields: `${ELASTICSEARCH_DOCS}runtime.html`,
runtimeFields: {
mapping: `${ELASTICSEARCH_DOCS}runtime-mapping-fields.html`,
},
scriptedFields: {
scriptFields: `${ELASTICSEARCH_DOCS}search-request-script-fields.html`,
scriptAggs: `${ELASTICSEARCH_DOCS}search-aggregations.html`,
Expand Down Expand Up @@ -379,7 +381,9 @@ export interface DocLinksStart {
readonly sum: string;
readonly top_hits: string;
};
readonly runtimeFields: string;
readonly runtimeFields: {
readonly mapping: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
Expand Down
4 changes: 3 additions & 1 deletion src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,9 @@ export interface DocLinksStart {
readonly sum: string;
readonly top_hits: string;
};
readonly runtimeFields: string;
readonly runtimeFields: {
readonly mapping: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

import React from 'react';
import { GlobalFlyout } from '../../../../../../../../../../src/plugins/es_ui_shared/public';
import { uiSettingsServiceMock } from '../../../../../../../../../../src/core/public/mocks';
import {
docLinksServiceMock,
uiSettingsServiceMock,
} from '../../../../../../../../../../src/core/public/mocks';
import { MappingsEditorProvider } from '../../../mappings_editor_context';
import { createKibanaReactContext } from '../../../shared_imports';

Expand Down Expand Up @@ -80,10 +83,7 @@ const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
});

const defaultProps = {
docLinks: {
DOC_LINK_VERSION: 'master',
ELASTIC_WEBSITE_URL: 'https://jest.elastic.co',
},
docLinks: docLinksServiceMock.createStartContract(),
};

export const WithAppDependencies = (Comp: any) => (props: any) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ const setup = (props?: Props) =>
const docLinks: DocLinksStart = {
ELASTIC_WEBSITE_URL: 'https://jestTest.elastic.co',
DOC_LINK_VERSION: 'jest',
links: {} as any,
links: {
runtimeFields: { mapping: 'https://jestTest.elastic.co/to-be-defined.html' },
scriptedFields: {} as any,
} as any,
};

describe('Runtime field editor', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const setup = (props?: Props) =>
const docLinks: DocLinksStart = {
ELASTIC_WEBSITE_URL: 'htts://jestTest.elastic.co',
DOC_LINK_VERSION: 'jest',
links: {} as any,
links: {
runtimeFields: { mapping: 'https://jestTest.elastic.co/to-be-defined.html' },
scriptedFields: {} as any,
} as any,
};

const noop = () => {};
Expand Down
13 changes: 5 additions & 8 deletions x-pack/plugins/runtime_fields/public/lib/documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@

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 esDocsBase = `${docsBase}/elasticsearch/reference/${DOC_LINK_VERSION}`;
const painlessDocsBase = `${docsBase}/elasticsearch/painless/${DOC_LINK_VERSION}`;

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