Skip to content

Commit

Permalink
[7.x] Use doc link services in index management (#97020)
Browse files Browse the repository at this point in the history
Co-authored-by: Alison Goryachev <[email protected]>
  • Loading branch information
lcawl and alisonelizabeth authored Apr 13, 2021
1 parent 7e82baf commit 3279e7f
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ readonly links: {
readonly top_hits: string;
};
readonly runtimeFields: {
readonly overview: string;
readonly mapping: string;
};
readonly scriptedFields: {
Expand All @@ -114,9 +115,10 @@ readonly links: {
};
readonly query: {
readonly eql: string;
readonly kueryQuerySyntax: string;
readonly luceneQuerySyntax: string;
readonly percolate: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
Expand All @@ -127,6 +129,7 @@ readonly links: {
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
bulkIndexAlias: string;
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
Expand All @@ -143,6 +146,7 @@ readonly links: {
painlessExecuteAPIContexts: string;
putComponentTemplateMetadata: string;
putSnapshotLifecyclePolicy: string;
putIndexTemplateV1: string;
putWatch: string;
simulatePipeline: string;
updateTransform: string;
Expand Down

Large diffs are not rendered by default.

57 changes: 54 additions & 3 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class DocLinksService {
top_hits: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-top-hits-aggregation.html`,
},
runtimeFields: {
overview: `${ELASTICSEARCH_DOCS}runtime.html`,
mapping: `${ELASTICSEARCH_DOCS}runtime-mapping-fields.html`,
},
scriptedFields: {
Expand All @@ -130,8 +131,50 @@ export class DocLinksService {
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`,
elasticsearch: {
docsBase: `${ELASTICSEARCH_DOCS}`,
asyncSearch: `${ELASTICSEARCH_DOCS}async-search-intro.html`,
dataStreams: `${ELASTICSEARCH_DOCS}data-streams.html`,
indexModules: `${ELASTICSEARCH_DOCS}index-modules.html`,
indexSettings: `${ELASTICSEARCH_DOCS}index-modules.html#index-modules-settings`,
indexTemplates: `${ELASTICSEARCH_DOCS}indices-templates.html`,
mapping: `${ELASTICSEARCH_DOCS}mapping.html`,
mappingAnalyzer: `${ELASTICSEARCH_DOCS}analyzer.html`,
mappingBoost: `${ELASTICSEARCH_DOCS}mapping-boost.html`,
mappingCoerce: `${ELASTICSEARCH_DOCS}coerce.html`,
mappingCopyTo: `${ELASTICSEARCH_DOCS}copy-to.html`,
mappingDocValues: `${ELASTICSEARCH_DOCS}doc-values.html`,
mappingDynamic: `${ELASTICSEARCH_DOCS}dynamic.html`,
mappingDynamicFields: `${ELASTICSEARCH_DOCS}dynamic-field-mapping.html`,
mappingDynamicTemplates: `${ELASTICSEARCH_DOCS}dynamic-templates.html`,
mappingEagerGlobalOrdinals: `${ELASTICSEARCH_DOCS}eager-global-ordinals.html`,
mappingEnabled: `${ELASTICSEARCH_DOCS}enabled.html`,
mappingFieldData: `${ELASTICSEARCH_DOCS}text.html#fielddata-mapping-param`,
mappingFieldDataEnable: `${ELASTICSEARCH_DOCS}text.html#before-enabling-fielddata`,
mappingFieldDataFilter: `${ELASTICSEARCH_DOCS}text.html#field-data-filtering`,
mappingFieldDataTypes: `${ELASTICSEARCH_DOCS}mapping-types.html`,
mappingFormat: `${ELASTICSEARCH_DOCS}mapping-date-format.html`,
mappingIgnoreAbove: `${ELASTICSEARCH_DOCS}ignore-above.html`,
mappingIgnoreMalformed: `${ELASTICSEARCH_DOCS}ignore-malformed.html`,
mappingIndex: `${ELASTICSEARCH_DOCS}mapping-index.html`,
mappingIndexOptions: `${ELASTICSEARCH_DOCS}index-options.html`,
mappingIndexPhrases: `${ELASTICSEARCH_DOCS}index-phrases.html`,
mappingIndexPrefixes: `${ELASTICSEARCH_DOCS}index-prefixes.html`,
mappingJoinFieldsPerformance: `${ELASTICSEARCH_DOCS}parent-join.html#_parent_join_and_performance`,
mappingMeta: `${ELASTICSEARCH_DOCS}mapping-field-meta.html`,
mappingMetaFields: `${ELASTICSEARCH_DOCS}mapping-meta-field.html`,
mappingNormalizer: `${ELASTICSEARCH_DOCS}normalizer.html`,
mappingNorms: `${ELASTICSEARCH_DOCS}norms.html`,
mappingNullValue: `${ELASTICSEARCH_DOCS}null-value.html`,
mappingParameters: `${ELASTICSEARCH_DOCS}mapping-params.html`,
mappingPositionIncrementGap: `${ELASTICSEARCH_DOCS}position-increment-gap.html`,
mappingRankFeatureFields: `${ELASTICSEARCH_DOCS}rank-feature.html`,
mappingRouting: `${ELASTICSEARCH_DOCS}mapping-routing-field.html`,
mappingSimilarity: `${ELASTICSEARCH_DOCS}similarity.html`,
mappingSourceFields: `${ELASTICSEARCH_DOCS}mapping-source-field.html`,
mappingSourceFieldsDisable: `${ELASTICSEARCH_DOCS}mapping-source-field.html#disable-source-field`,
mappingStore: `${ELASTICSEARCH_DOCS}mapping-store.html`,
mappingTermVector: `${ELASTICSEARCH_DOCS}term-vector.html`,
mappingTypesRemoval: `${ELASTICSEARCH_DOCS}removal-of-types.html`,
nodeRoles: `${ELASTICSEARCH_DOCS}modules-node.html#node-roles`,
remoteClusters: `${ELASTICSEARCH_DOCS}modules-remote-clusters.html`,
remoteClustersProxy: `${ELASTICSEARCH_DOCS}modules-remote-clusters.html#proxy-mode`,
Expand All @@ -146,18 +189,20 @@ export class DocLinksService {
},
query: {
eql: `${ELASTICSEARCH_DOCS}eql.html`,
kueryQuerySyntax: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/kuery-query.html`,
luceneQuerySyntax: `${ELASTICSEARCH_DOCS}query-dsl-query-string-query.html#query-string-syntax`,
percolate: `${ELASTICSEARCH_DOCS}query-dsl-percolate-query.html`,
queryDsl: `${ELASTICSEARCH_DOCS}query-dsl.html`,
kueryQuerySyntax: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/kuery-query.html`,
},
date: {
dateMath: `${ELASTICSEARCH_DOCS}common-options.html#date-math`,
dateMathIndexNames: `${ELASTICSEARCH_DOCS}date-math-index-names.html`,
},
management: {
dashboardSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-dashboard-settings`,
indexManagement: `${ELASTICSEARCH_DOCS}index-mgmt.html`,
kibanaGeneralSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-general-settings`,
kibanaSearchSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-search-settings`,
dashboardSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-dashboard-settings`,
visualizationSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-visualization-settings`,
},
ml: {
Expand Down Expand Up @@ -259,6 +304,7 @@ export class DocLinksService {
skippingDisconnectedClusters: `${ELASTICSEARCH_DOCS}modules-cross-cluster-search.html#skip-unavailable-clusters`,
},
apis: {
bulkIndexAlias: `${ELASTICSEARCH_DOCS}indices-aliases.html`,
createIndex: `${ELASTICSEARCH_DOCS}indices-create-index.html`,
createSnapshotLifecyclePolicy: `${ELASTICSEARCH_DOCS}slm-api-put-policy.html`,
createRoleMapping: `${ELASTICSEARCH_DOCS}security-api-put-role-mapping.html`,
Expand All @@ -275,6 +321,7 @@ export class DocLinksService {
painlessExecuteAPIContexts: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/painless/${DOC_LINK_VERSION}/painless-execute-api.html#_contexts`,
putComponentTemplateMetadata: `${ELASTICSEARCH_DOCS}indices-component-template.html#component-templates-metadata`,
putEnrichPolicy: `${ELASTICSEARCH_DOCS}put-enrich-policy-api.html`,
putIndexTemplateV1: `${ELASTICSEARCH_DOCS}indices-templates-v1.html`,
putSnapshotLifecyclePolicy: `${ELASTICSEARCH_DOCS}slm-api-put-policy.html`,
putWatch: `${ELASTICSEARCH_DOCS}watcher-api-put-watch.html`,
simulatePipeline: `${ELASTICSEARCH_DOCS}simulate-pipeline-api.html`,
Expand Down Expand Up @@ -430,6 +477,7 @@ export interface DocLinksStart {
readonly top_hits: string;
};
readonly runtimeFields: {
readonly overview: string;
readonly mapping: string;
};
readonly scriptedFields: {
Expand All @@ -456,9 +504,10 @@ export interface DocLinksStart {
};
readonly query: {
readonly eql: string;
readonly kueryQuerySyntax: string;
readonly luceneQuerySyntax: string;
readonly percolate: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
Expand All @@ -469,6 +518,7 @@ export interface DocLinksStart {
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
bulkIndexAlias: string;
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
Expand All @@ -485,6 +535,7 @@ export interface DocLinksStart {
painlessExecuteAPIContexts: string;
putComponentTemplateMetadata: string;
putSnapshotLifecyclePolicy: string;
putIndexTemplateV1: string;
putWatch: string;
simulatePipeline: string;
updateTransform: string;
Expand Down
6 changes: 5 additions & 1 deletion src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ export interface DocLinksStart {
readonly top_hits: string;
};
readonly runtimeFields: {
readonly overview: string;
readonly mapping: string;
};
readonly scriptedFields: {
Expand All @@ -597,9 +598,10 @@ export interface DocLinksStart {
};
readonly query: {
readonly eql: string;
readonly kueryQuerySyntax: string;
readonly luceneQuerySyntax: string;
readonly percolate: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
Expand All @@ -610,6 +612,7 @@ export interface DocLinksStart {
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
bulkIndexAlias: string;
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
Expand All @@ -626,6 +629,7 @@ export interface DocLinksStart {
painlessExecuteAPIContexts: string;
putComponentTemplateMetadata: string;
putSnapshotLifecyclePolicy: string;
putIndexTemplateV1: string;
putWatch: string;
simulatePipeline: string;
updateTransform: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ describe('Background Search Session Management Main', () => {

describe('renders', () => {
const docLinks: DocLinksStart = {
ELASTIC_WEBSITE_URL: 'boo/',
DOC_LINK_VERSION: '#foo',
links: {} as any,
ELASTIC_WEBSITE_URL: `boo/`,
DOC_LINK_VERSION: `#foo`,
links: {
elasticsearch: { asyncSearch: `mock-url` } as any,
} as any,
};

let main: ReactWrapper;
Expand Down Expand Up @@ -93,9 +95,7 @@ describe('Background Search Session Management Main', () => {
test('documentation link', () => {
const docLink = main.find('a[href]').first();
expect(docLink.text()).toBe('Documentation');
expect(docLink.prop('href')).toBe(
'boo/guide/en/elasticsearch/reference/#foo/async-search-intro.html'
);
expect(docLink.prop('href')).toBe('mock-url');
});

test('table is present', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
import { DocLinksStart } from 'kibana/public';

export class AsyncSearchIntroDocumentation {
private docsBasePath: string = '';
private docUrl: string = '';

constructor(docs: DocLinksStart) {
const { DOC_LINK_VERSION, ELASTIC_WEBSITE_URL } = docs;
const docsBase = `${ELASTIC_WEBSITE_URL}guide/en`;
const { links } = docs;
// TODO: There should be Kibana documentation link about Search Sessions in Kibana
this.docsBasePath = `${docsBase}/elasticsearch/reference/${DOC_LINK_VERSION}`;
this.docUrl = links.elasticsearch.asyncSearch;
}

public getElasticsearchDocLink() {
return `${this.docsBasePath}/async-search-intro.html`;
return `${this.docUrl}`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@

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

// eslint-disable-next-line @typescript-eslint/naming-convention
export const getDocumentation = ({ ELASTIC_WEBSITE_URL, DOC_LINK_VERSION }: DocLinksStart) => {
const docsBase = `${ELASTIC_WEBSITE_URL}guide/en`;
const esDocsBase = `${docsBase}/elasticsearch/reference/${DOC_LINK_VERSION}`;

export const getDocumentation = ({ links }: DocLinksStart) => {
const esDocsBase = links.elasticsearch.docsBase;
return {
esDocsBase,
componentTemplates: `${esDocsBase}/indices-component-template.html`,
componentTemplatesMetadata: `${esDocsBase}/indices-component-template.html#component-templates-metadata`,
componentTemplates: links.apis.putComponentTemplate,
componentTemplatesMetadata: links.apis.putComponentTemplateMetadata,
};
};
Loading

0 comments on commit 3279e7f

Please sign in to comment.