[7.x] Move ui/documentation_links to Core (#39411) (#39530)

This commit is contained in:
Josh Dover 2019-06-24 16:27:51 -05:00 committed by GitHub
parent 9d78bed4f9
commit 892d096eb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 627 additions and 92 deletions

View file

@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [CoreStart](./kibana-plugin-public.corestart.md) &gt; [docLinks](./kibana-plugin-public.corestart.doclinks.md)
## CoreStart.docLinks property
[DocLinksStart](./kibana-plugin-public.doclinksstart.md)
<b>Signature:</b>
```typescript
docLinks: DocLinksStart;
```

View file

@ -18,6 +18,7 @@ export interface CoreStart
| --- | --- | --- |
| [application](./kibana-plugin-public.corestart.application.md) | <code>Pick&lt;ApplicationStart, 'capabilities'&gt;</code> | [ApplicationStart](./kibana-plugin-public.applicationstart.md) |
| [chrome](./kibana-plugin-public.corestart.chrome.md) | <code>ChromeStart</code> | [ChromeStart](./kibana-plugin-public.chromestart.md) |
| [docLinks](./kibana-plugin-public.corestart.doclinks.md) | <code>DocLinksStart</code> | [DocLinksStart](./kibana-plugin-public.doclinksstart.md) |
| [http](./kibana-plugin-public.corestart.http.md) | <code>HttpStart</code> | [HttpStart](./kibana-plugin-public.httpstart.md) |
| [i18n](./kibana-plugin-public.corestart.i18n.md) | <code>I18nStart</code> | [I18nStart](./kibana-plugin-public.i18nstart.md) |
| [notifications](./kibana-plugin-public.corestart.notifications.md) | <code>NotificationsStart</code> | [NotificationsStart](./kibana-plugin-public.notificationsstart.md) |

View file

@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [DocLinksStart](./kibana-plugin-public.doclinksstart.md) &gt; [DOC\_LINK\_VERSION](./kibana-plugin-public.doclinksstart.doc_link_version.md)
## DocLinksStart.DOC\_LINK\_VERSION property
<b>Signature:</b>
```typescript
readonly DOC_LINK_VERSION: string;
```

View file

@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [DocLinksStart](./kibana-plugin-public.doclinksstart.md) &gt; [ELASTIC\_WEBSITE\_URL](./kibana-plugin-public.doclinksstart.elastic_website_url.md)
## DocLinksStart.ELASTIC\_WEBSITE\_URL property
<b>Signature:</b>
```typescript
readonly ELASTIC_WEBSITE_URL: string;
```

View file

@ -0,0 +1,92 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [DocLinksStart](./kibana-plugin-public.doclinksstart.md) &gt; [links](./kibana-plugin-public.doclinksstart.links.md)
## DocLinksStart.links property
<b>Signature:</b>
```typescript
readonly links: {
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly startup: string;
readonly exportedFields: string;
};
readonly auditbeat: {
readonly base: string;
};
readonly metricbeat: {
readonly base: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly date_histogram: string;
readonly date_range: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessSyntax: string;
readonly luceneExpressions: string;
};
readonly indexPatterns: {
readonly loadingData: string;
readonly introduction: string;
};
readonly kibana: string;
readonly siem: string;
readonly query: {
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
};
};
```

View file

@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [DocLinksStart](./kibana-plugin-public.doclinksstart.md)
## DocLinksStart interface
<b>Signature:</b>
```typescript
export interface DocLinksStart
```
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [DOC\_LINK\_VERSION](./kibana-plugin-public.doclinksstart.doc_link_version.md) | <code>string</code> | |
| [ELASTIC\_WEBSITE\_URL](./kibana-plugin-public.doclinksstart.elastic_website_url.md) | <code>string</code> | |
| [links](./kibana-plugin-public.doclinksstart.links.md) | <code>{</code><br/><code> readonly filebeat: {</code><br/><code> readonly base: string;</code><br/><code> readonly installation: string;</code><br/><code> readonly configuration: string;</code><br/><code> readonly elasticsearchOutput: string;</code><br/><code> readonly startup: string;</code><br/><code> readonly exportedFields: string;</code><br/><code> };</code><br/><code> readonly auditbeat: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly metricbeat: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly heartbeat: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly logstash: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly functionbeat: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly winlogbeat: {</code><br/><code> readonly base: string;</code><br/><code> };</code><br/><code> readonly aggs: {</code><br/><code> readonly date_histogram: string;</code><br/><code> readonly date_range: string;</code><br/><code> readonly filter: string;</code><br/><code> readonly filters: string;</code><br/><code> readonly geohash_grid: string;</code><br/><code> readonly histogram: string;</code><br/><code> readonly ip_range: string;</code><br/><code> readonly range: string;</code><br/><code> readonly significant_terms: string;</code><br/><code> readonly terms: string;</code><br/><code> readonly avg: string;</code><br/><code> readonly avg_bucket: string;</code><br/><code> readonly max_bucket: string;</code><br/><code> readonly min_bucket: string;</code><br/><code> readonly sum_bucket: string;</code><br/><code> readonly cardinality: string;</code><br/><code> readonly count: string;</code><br/><code> readonly cumulative_sum: string;</code><br/><code> readonly derivative: string;</code><br/><code> readonly geo_bounds: string;</code><br/><code> readonly geo_centroid: string;</code><br/><code> readonly max: string;</code><br/><code> readonly median: string;</code><br/><code> readonly min: string;</code><br/><code> readonly moving_avg: string;</code><br/><code> readonly percentile_ranks: string;</code><br/><code> readonly serial_diff: string;</code><br/><code> readonly std_dev: string;</code><br/><code> readonly sum: string;</code><br/><code> readonly top_hits: string;</code><br/><code> };</code><br/><code> readonly scriptedFields: {</code><br/><code> readonly scriptFields: string;</code><br/><code> readonly scriptAggs: string;</code><br/><code> readonly painless: string;</code><br/><code> readonly painlessApi: string;</code><br/><code> readonly painlessSyntax: string;</code><br/><code> readonly luceneExpressions: string;</code><br/><code> };</code><br/><code> readonly indexPatterns: {</code><br/><code> readonly loadingData: string;</code><br/><code> readonly introduction: string;</code><br/><code> };</code><br/><code> readonly kibana: string;</code><br/><code> readonly siem: string;</code><br/><code> readonly query: {</code><br/><code> readonly luceneQuerySyntax: string;</code><br/><code> readonly queryDsl: string;</code><br/><code> readonly kueryQuerySyntax: string;</code><br/><code> };</code><br/><code> readonly date: {</code><br/><code> readonly dateMath: string;</code><br/><code> };</code><br/><code> }</code> | |

View file

@ -36,6 +36,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [ChromeStart](./kibana-plugin-public.chromestart.md) | |
| [CoreSetup](./kibana-plugin-public.coresetup.md) | Core services exposed to the <code>Plugin</code> setup lifecycle |
| [CoreStart](./kibana-plugin-public.corestart.md) | Core services exposed to the <code>Plugin</code> start lifecycle |
| [DocLinksStart](./kibana-plugin-public.doclinksstart.md) | |
| [ErrorToastOptions](./kibana-plugin-public.errortoastoptions.md) | |
| [FatalErrorInfo](./kibana-plugin-public.fatalerrorinfo.md) | Represents the <code>message</code> and <code>stack</code> of a fatal Error |
| [FatalErrorsSetup](./kibana-plugin-public.fatalerrorssetup.md) | FatalErrors stop the Kibana Public Core and displays a fatal error screen with details about the Kibana build and the error. |

View file

@ -28,6 +28,7 @@ import { notificationServiceMock } from './notifications/notifications_service.m
import { overlayServiceMock } from './overlays/overlay_service.mock';
import { pluginsServiceMock } from './plugins/plugins_service.mock';
import { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
import { docLinksServiceMock } from './doc_links/doc_links_service.mock';
export const MockLegacyPlatformService = legacyPlatformServiceMock.create();
export const LegacyPlatformServiceConstructor = jest
@ -106,3 +107,9 @@ export const ApplicationServiceConstructor = jest
jest.doMock('./application', () => ({
ApplicationService: ApplicationServiceConstructor,
}));
export const MockDocLinksService = docLinksServiceMock.create();
export const DocLinksServiceConstructor = jest.fn().mockImplementation(() => MockDocLinksService);
jest.doMock('./doc_links', () => ({
DocLinksService: DocLinksServiceConstructor,
}));

View file

@ -38,6 +38,7 @@ import {
OverlayServiceConstructor,
UiSettingsServiceConstructor,
MockApplicationService,
MockDocLinksService,
} from './core_system.test.mocks';
import { CoreSystem } from './core_system';
@ -210,6 +211,11 @@ describe('#start()', () => {
expect(MockApplicationService.start).toHaveBeenCalledTimes(1);
});
it('calls docLinks#start()', async () => {
await startCore();
expect(MockDocLinksService.start).toHaveBeenCalledTimes(1);
});
it('calls uiSettings#start()', async () => {
await startCore();
expect(MockUiSettingsService.start).toHaveBeenCalledTimes(1);

View file

@ -32,6 +32,7 @@ import { PluginsService } from './plugins';
import { UiSettingsService } from './ui_settings';
import { ApplicationService } from './application';
import { mapToObject } from '../utils/';
import { DocLinksService } from './doc_links';
interface Params {
rootDomElement: HTMLElement;
@ -65,6 +66,7 @@ export class CoreSystem {
private readonly overlay: OverlayService;
private readonly plugins: PluginsService;
private readonly application: ApplicationService;
private readonly docLinks: DocLinksService;
private readonly rootDomElement: HTMLElement;
private fatalErrorsSetup: FatalErrorsSetup | null = null;
@ -97,6 +99,7 @@ export class CoreSystem {
this.overlay = new OverlayService();
this.application = new ApplicationService();
this.chrome = new ChromeService({ browserSupportsCsp });
this.docLinks = new DocLinksService();
const core: CoreContext = {};
this.plugins = new PluginsService(core);
@ -149,6 +152,7 @@ export class CoreSystem {
public async start() {
try {
const injectedMetadata = await this.injectedMetadata.start();
const docLinks = await this.docLinks.start({ injectedMetadata });
const http = await this.http.start({ injectedMetadata, fatalErrors: this.fatalErrorsSetup });
const i18n = await this.i18n.start();
const application = await this.application.start({ injectedMetadata });
@ -181,6 +185,7 @@ export class CoreSystem {
const core: InternalCoreStart = {
application,
chrome,
docLinks,
http,
i18n,
injectedMetadata,

View file

@ -0,0 +1,38 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { injectedMetadataServiceMock } from '../injected_metadata/injected_metadata_service.mock';
import { DocLinksService, DocLinksStart } from './doc_links_service';
const createStartContractMock = (): DocLinksStart => {
// This service is so simple that we actually use the real implementation
const injectedMetadata = injectedMetadataServiceMock.createStartContract();
injectedMetadata.getKibanaBranch.mockReturnValue('mocked-test-branch');
return new DocLinksService().start({ injectedMetadata });
};
type DocLinksServiceContract = PublicMethodsOf<DocLinksService>;
const createMock = (): jest.Mocked<DocLinksServiceContract> => ({
start: jest.fn().mockReturnValue(createStartContractMock()),
});
export const docLinksServiceMock = {
create: createMock,
createStartContract: createStartContractMock,
};

View file

@ -0,0 +1,34 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { DocLinksService } from './doc_links_service';
import { injectedMetadataServiceMock } from '../injected_metadata/injected_metadata_service.mock';
describe('DocLinksService#start()', () => {
it('templates the doc links with the branch information from injectedMetadata', () => {
const injectedMetadata = injectedMetadataServiceMock.createStartContract();
injectedMetadata.getKibanaBranch.mockReturnValue('test-branch');
const service = new DocLinksService();
const start = service.start({ injectedMetadata });
expect(start.DOC_LINK_VERSION).toEqual('test-branch');
expect(start.links.kibana).toEqual(
'https://www.elastic.co/guide/en/kibana/test-branch/index.html'
);
});
});

View file

@ -0,0 +1,209 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { InjectedMetadataStart } from '../injected_metadata';
import { deepFreeze } from '../../utils';
interface StartDeps {
injectedMetadata: InjectedMetadataStart;
}
/** @internal */
export class DocLinksService {
public start({ injectedMetadata }: StartDeps): DocLinksStart {
const DOC_LINK_VERSION = injectedMetadata.getKibanaBranch();
const ELASTIC_WEBSITE_URL = 'https://www.elastic.co/';
const ELASTICSEARCH_DOCS = `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/`;
return deepFreeze({
DOC_LINK_VERSION,
ELASTIC_WEBSITE_URL,
links: {
filebeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}`,
installation: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`,
configuration: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-configuration.html`,
elasticsearchOutput: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/elasticsearch-output.html`,
startup: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-starting.html`,
exportedFields: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/exported-fields.html`,
},
auditbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/auditbeat/${DOC_LINK_VERSION}`,
},
metricbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/metricbeat/${DOC_LINK_VERSION}`,
},
heartbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/heartbeat/${DOC_LINK_VERSION}`,
},
logstash: {
base: `${ELASTIC_WEBSITE_URL}guide/en/logstash/${DOC_LINK_VERSION}`,
},
functionbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/functionbeat/${DOC_LINK_VERSION}`,
},
winlogbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/winlogbeat/${DOC_LINK_VERSION}`,
},
aggs: {
date_histogram: `${ELASTICSEARCH_DOCS}search-aggregations-bucket-datehistogram-aggregation.html`,
date_range: `${ELASTICSEARCH_DOCS}search-aggregations-bucket-daterange-aggregation.html`,
filter: `${ELASTICSEARCH_DOCS}search-aggregations-bucket-filter-aggregation.html`,
filters: `${ELASTICSEARCH_DOCS}search-aggregations-bucket-filters-aggregation.html`,
geohash_grid: `${ELASTICSEARCH_DOCS}search-aggregations-bucket-geohashgrid-aggregation.html`,
histogram: `${ELASTICSEARCH_DOCS}search-aggregations-bucket-histogram-aggregation.html`,
ip_range: `${ELASTICSEARCH_DOCS}search-aggregations-bucket-iprange-aggregation.html`,
range: `${ELASTICSEARCH_DOCS}search-aggregations-bucket-range-aggregation.html`,
significant_terms: `${ELASTICSEARCH_DOCS}search-aggregations-bucket-significantterms-aggregation.html`,
terms: `${ELASTICSEARCH_DOCS}search-aggregations-bucket-terms-aggregation.html`,
avg: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-avg-aggregation.html`,
avg_bucket: `${ELASTICSEARCH_DOCS}search-aggregations-pipeline-avg-bucket-aggregation.html`,
max_bucket: `${ELASTICSEARCH_DOCS}search-aggregations-pipeline-max-bucket-aggregation.html`,
min_bucket: `${ELASTICSEARCH_DOCS}search-aggregations-pipeline-min-bucket-aggregation.html`,
sum_bucket: `${ELASTICSEARCH_DOCS}search-aggregations-pipeline-sum-bucket-aggregation.html`,
cardinality: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-cardinality-aggregation.html`,
count: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-valuecount-aggregation.html`,
cumulative_sum: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-sum-aggregation.html`,
derivative: `${ELASTICSEARCH_DOCS}search-aggregations-pipeline-derivative-aggregation.html`,
geo_bounds: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-geobounds-aggregation.html`,
geo_centroid: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-geocentroid-aggregation.html`,
max: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-max-aggregation.html`,
median: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-percentile-aggregation.html`,
min: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-min-aggregation.html`,
moving_avg: `${ELASTICSEARCH_DOCS}search-aggregations-pipeline-movavg-aggregation.html`,
percentile_ranks: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-percentile-rank-aggregation.html`,
serial_diff: `${ELASTICSEARCH_DOCS}search-aggregations-pipeline-serialdiff-aggregation.html`,
std_dev: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-extendedstats-aggregation.html`,
sum: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-sum-aggregation.html`,
top_hits: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-top-hits-aggregation.html`,
},
scriptedFields: {
scriptFields: `${ELASTICSEARCH_DOCS}search-request-script-fields.html`,
scriptAggs: `${ELASTICSEARCH_DOCS}search-aggregations.html#_values_source`,
painless: `${ELASTICSEARCH_DOCS}modules-scripting-painless.html`,
painlessApi: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/painless/${DOC_LINK_VERSION}/painless-api-reference.html`,
painlessSyntax: `${ELASTICSEARCH_DOCS}modules-scripting-painless-syntax.html`,
luceneExpressions: `${ELASTICSEARCH_DOCS}modules-scripting-expression.html`,
},
indexPatterns: {
loadingData: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/tutorial-load-dataset.html`,
introduction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index-patterns.html`,
},
kibana: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index.html`,
siem: `${ELASTIC_WEBSITE_URL}guide/en/siem/guide/${DOC_LINK_VERSION}/index.html`,
query: {
luceneQuerySyntax: `${ELASTICSEARCH_DOCS}query-dsl-query-string-query.html#query-string-syntax`,
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`,
},
},
});
}
}
/** @public */
export interface DocLinksStart {
readonly DOC_LINK_VERSION: string;
readonly ELASTIC_WEBSITE_URL: string;
readonly links: {
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly startup: string;
readonly exportedFields: string;
};
readonly auditbeat: {
readonly base: string;
};
readonly metricbeat: {
readonly base: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly date_histogram: string;
readonly date_range: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessSyntax: string;
readonly luceneExpressions: string;
};
readonly indexPatterns: {
readonly loadingData: string;
readonly introduction: string;
};
readonly kibana: string;
readonly siem: string;
readonly query: {
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
};
};
}

View file

@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
export { DocLinksService, DocLinksStart } from './doc_links_service';

View file

@ -65,6 +65,7 @@ import { OverlayRef, OverlayStart } from './overlays';
import { Plugin, PluginInitializer, PluginInitializerContext } from './plugins';
import { UiSettingsClient, UiSettingsSetup, UiSettingsStart, UiSettingsState } from './ui_settings';
import { ApplicationSetup, Capabilities, ApplicationStart } from './application';
import { DocLinksStart } from './doc_links';
/** @interal */
export { CoreContext, CoreSystem } from './core_system';
@ -104,6 +105,8 @@ export interface CoreStart {
application: Pick<ApplicationStart, 'capabilities'>;
/** {@link ChromeStart} */
chrome: ChromeStart;
/** {@link DocLinksStart} */
docLinks: DocLinksStart;
/** {@link HttpStart} */
http: HttpStart;
/** {@link I18nStart} */
@ -131,6 +134,7 @@ export interface InternalCoreStart extends CoreStart {
export {
ApplicationSetup,
ApplicationStart,
DocLinksStart,
HttpServiceBase,
HttpSetup,
HttpStart,

View file

@ -22,6 +22,7 @@ const createSetupContractMock = () => {
const setupContract: jest.Mocked<InjectedMetadataSetup> = {
getBasePath: jest.fn(),
getKibanaVersion: jest.fn(),
getKibanaBranch: jest.fn(),
getCapabilities: jest.fn(),
getCspConfig: jest.fn(),
getLegacyMetadata: jest.fn(),

View file

@ -38,6 +38,7 @@ export interface InjectedMetadataParams {
injectedMetadata: {
version: string;
buildNumber: number;
branch: string;
basePath: string;
csp: {
warnLegacyBrowsers: boolean;
@ -126,6 +127,10 @@ export class InjectedMetadataService {
getKibanaBuildNumber: () => {
return this.state.buildNumber;
},
getKibanaBranch: () => {
return this.state.branch;
},
};
}
}
@ -138,6 +143,7 @@ export class InjectedMetadataService {
export interface InjectedMetadataSetup {
getBasePath: () => string;
getKibanaBuildNumber: () => number;
getKibanaBranch: () => string;
getKibanaVersion: () => string;
getCapabilities: () => Capabilities;
getCspConfig: () => {

View file

@ -57,6 +57,7 @@ import { overlayServiceMock } from '../overlays/overlay_service.mock';
import { uiSettingsServiceMock } from '../ui_settings/ui_settings_service.mock';
import { LegacyPlatformService } from './legacy_service';
import { applicationServiceMock } from '../application/application_service.mock';
import { docLinksServiceMock } from '../doc_links/doc_links_service.mock';
const applicationSetup = applicationServiceMock.createSetupContract();
const fatalErrorsSetup = fatalErrorsServiceMock.createSetupContract();
@ -84,6 +85,7 @@ const defaultSetupDeps = {
};
const applicationStart = applicationServiceMock.createStartContract();
const docLinksStart = docLinksServiceMock.createStartContract();
const httpStart = httpServiceMock.createStartContract();
const chromeStart = chromeServiceMock.createStartContract();
const i18nStart = i18nServiceMock.createStartContract();
@ -95,6 +97,7 @@ const uiSettingsStart = uiSettingsServiceMock.createStartContract();
const defaultStartDeps = {
core: {
application: applicationStart,
docLinks: docLinksStart,
http: httpStart,
chrome: chromeStart,
i18n: i18nStart,

View file

@ -18,6 +18,7 @@
*/
export { chromeServiceMock } from './chrome/chrome_service.mock';
export { docLinksServiceMock } from './doc_links/doc_links_service.mock';
export { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock';
export { httpServiceMock } from './http/http_service.mock';
export { i18nServiceMock } from './i18n/i18n_service.mock';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { DiscoveredPlugin } from '../../server';
import { DiscoveredPlugin, PluginName } from '../../server';
import { CoreContext } from '../core_system';
import { PluginWrapper } from './plugin';
import { PluginsServiceSetupDeps, PluginsServiceStartDeps } from './plugins_service';
@ -56,7 +56,12 @@ export function createPluginInitializerContext(
* @param plugin
* @internal
*/
export function createPluginSetupContext<TSetup, TStart, TPluginsSetup, TPluginsStart>(
export function createPluginSetupContext<
TSetup,
TStart,
TPluginsSetup extends Record<PluginName, unknown>,
TPluginsStart extends Record<PluginName, unknown>
>(
coreContext: CoreContext,
deps: PluginsServiceSetupDeps,
plugin: PluginWrapper<TSetup, TStart, TPluginsSetup, TPluginsStart>
@ -79,7 +84,12 @@ export function createPluginSetupContext<TSetup, TStart, TPluginsSetup, TPlugins
* @param plugin
* @internal
*/
export function createPluginStartContext<TSetup, TStart, TPluginsSetup, TPluginsStart>(
export function createPluginStartContext<
TSetup,
TStart,
TPluginsSetup extends Record<PluginName, unknown>,
TPluginsStart extends Record<PluginName, unknown>
>(
coreContext: CoreContext,
deps: PluginsServiceStartDeps,
plugin: PluginWrapper<TSetup, TStart, TPluginsSetup, TPluginsStart>
@ -88,6 +98,7 @@ export function createPluginStartContext<TSetup, TStart, TPluginsSetup, TPlugins
application: {
capabilities: deps.application.capabilities,
},
docLinks: deps.docLinks,
http: deps.http,
chrome: deps.chrome,
i18n: deps.i18n,

View file

@ -43,6 +43,7 @@ import { injectedMetadataServiceMock } from '../injected_metadata/injected_metad
import { httpServiceMock } from '../http/http_service.mock';
import { UiSettingsClient } from '../ui_settings';
import { CoreSetup, CoreStart } from '..';
import { docLinksServiceMock } from '../doc_links/doc_links_service.mock';
export let mockPluginInitializers: Map<PluginName, MockedPluginInitializer>;
@ -81,6 +82,7 @@ beforeEach(() => {
mockSetupContext = omit(mockSetupDeps, 'application', 'injectedMetadata');
mockStartDeps = {
application: applicationServiceMock.createStartContract(),
docLinks: docLinksServiceMock.createStartContract(),
http: httpServiceMock.createStartContract(),
chrome: chromeServiceMock.createStartContract(),
i18n: i18nServiceMock.createStartContract(),

View file

@ -184,6 +184,8 @@ export interface CoreStart {
// (undocumented)
chrome: ChromeStart;
// (undocumented)
docLinks: DocLinksStart;
// (undocumented)
http: HttpStart;
// (undocumented)
i18n: I18nStart;
@ -209,6 +211,97 @@ export class CoreSystem {
stop(): void;
}
// @public (undocumented)
export interface DocLinksStart {
// (undocumented)
readonly DOC_LINK_VERSION: string;
// (undocumented)
readonly ELASTIC_WEBSITE_URL: string;
// (undocumented)
readonly links: {
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly startup: string;
readonly exportedFields: string;
};
readonly auditbeat: {
readonly base: string;
};
readonly metricbeat: {
readonly base: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly date_histogram: string;
readonly date_range: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessSyntax: string;
readonly luceneExpressions: string;
};
readonly indexPatterns: {
readonly loadingData: string;
readonly introduction: string;
};
readonly kibana: string;
readonly siem: string;
readonly query: {
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
};
};
}
// Warning: (ae-missing-release-tag) "ErrorToastOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)

View file

@ -30,7 +30,7 @@ export const CopySourceTask = {
'src/**',
'!src/**/*.{test,test.mocks,mock}.{js,ts,tsx}',
'!src/**/mocks.ts', // special file who imports .mock files
'!src/**/{__tests__,__snapshots__}/**',
'!src/**/{__tests__,__snapshots__,__mocks__}/**',
'!src/test_utils/**',
'!src/fixtures/**',
'!src/legacy/core_plugins/tests_bundle/**',

View file

@ -35,6 +35,7 @@
*/
jest.mock('ui/metadata');
jest.mock('ui/documentation_links/documentation_links');
jest.mock('ui/chrome');
jest.mock('moment-timezone', () => {

View file

@ -50,7 +50,7 @@ exports[`LanguageSwitcher should toggle off if language is lucene 1`] = `
Object {
"docsLink": <EuiLink
color="primary"
href="https://www.elastic.co/guide/en/kibana/jest-metadata-mock-branch/kuery-query.html"
href="https://www.elastic.co/guide/en/kibana/mocked-test-branch/kuery-query.html"
target="_blank"
type="button"
>
@ -152,7 +152,7 @@ exports[`LanguageSwitcher should toggle on if language is kuery 1`] = `
Object {
"docsLink": <EuiLink
color="primary"
href="https://www.elastic.co/guide/en/kibana/jest-metadata-mock-branch/kuery-query.html"
href="https://www.elastic.co/guide/en/kibana/mocked-test-branch/kuery-query.html"
target="_blank"
type="button"
>

View file

@ -0,0 +1,25 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { docLinksServiceMock } from '../../../../../core/public/mocks';
const { DOC_LINK_VERSION, ELASTIC_WEBSITE_URL, links } = docLinksServiceMock.createStartContract();
export { DOC_LINK_VERSION, ELASTIC_WEBSITE_URL };
export const documentationLinks = links;

View file

@ -17,96 +17,14 @@
* under the License.
*/
import { metadata } from '../metadata';
import { npStart } from 'ui/new_platform';
/*
WARNING: The links in this file are validated during the docs build. This is accomplished with some regex magic that
looks for these particular constants. As a result, we should not add new constants or change the existing ones.
If you absolutely must make a change, talk to Clinton Gormley first so he can update his Perl scripts.
*/
export const DOC_LINK_VERSION = metadata.branch;
export const ELASTIC_WEBSITE_URL = 'https://www.elastic.co/';
const ELASTIC_DOCS = `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/`;
export const DOC_LINK_VERSION = npStart.core.docLinks.DOC_LINK_VERSION;
export const ELASTIC_WEBSITE_URL = npStart.core.docLinks.ELASTIC_WEBSITE_URL;
export const documentationLinks = {
filebeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}`,
installation: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`,
configuration: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-configuration.html`,
elasticsearchOutput: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/elasticsearch-output.html`,
startup: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-starting.html`,
exportedFields: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/exported-fields.html`,
},
auditbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/auditbeat/${DOC_LINK_VERSION}`,
},
metricbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/metricbeat/${DOC_LINK_VERSION}`,
},
heartbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/heartbeat/${DOC_LINK_VERSION}`,
},
logstash: {
base: `${ELASTIC_WEBSITE_URL}guide/en/logstash/${DOC_LINK_VERSION}`,
},
functionbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/functionbeat/${DOC_LINK_VERSION}`,
},
winlogbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/winlogbeat/${DOC_LINK_VERSION}`,
},
aggs: {
date_histogram: `${ELASTIC_DOCS}search-aggregations-bucket-datehistogram-aggregation.html`,
date_range: `${ELASTIC_DOCS}search-aggregations-bucket-daterange-aggregation.html`,
filter: `${ELASTIC_DOCS}search-aggregations-bucket-filter-aggregation.html`,
filters: `${ELASTIC_DOCS}search-aggregations-bucket-filters-aggregation.html`,
geohash_grid: `${ELASTIC_DOCS}search-aggregations-bucket-geohashgrid-aggregation.html`,
histogram: `${ELASTIC_DOCS}search-aggregations-bucket-histogram-aggregation.html`,
ip_range: `${ELASTIC_DOCS}search-aggregations-bucket-iprange-aggregation.html`,
range: `${ELASTIC_DOCS}search-aggregations-bucket-range-aggregation.html`,
significant_terms: `${ELASTIC_DOCS}search-aggregations-bucket-significantterms-aggregation.html`,
terms: `${ELASTIC_DOCS}search-aggregations-bucket-terms-aggregation.html`,
avg: `${ELASTIC_DOCS}search-aggregations-metrics-avg-aggregation.html`,
avg_bucket: `${ELASTIC_DOCS}search-aggregations-pipeline-avg-bucket-aggregation.html`,
max_bucket: `${ELASTIC_DOCS}search-aggregations-pipeline-max-bucket-aggregation.html`,
min_bucket: `${ELASTIC_DOCS}search-aggregations-pipeline-min-bucket-aggregation.html`,
sum_bucket: `${ELASTIC_DOCS}search-aggregations-pipeline-sum-bucket-aggregation.html`,
cardinality: `${ELASTIC_DOCS}search-aggregations-metrics-cardinality-aggregation.html`,
count: `${ELASTIC_DOCS}search-aggregations-metrics-valuecount-aggregation.html`,
cumulative_sum: `${ELASTIC_DOCS}search-aggregations-metrics-sum-aggregation.html`,
derivative: `${ELASTIC_DOCS}search-aggregations-pipeline-derivative-aggregation.html`,
geo_bounds: `${ELASTIC_DOCS}search-aggregations-metrics-geobounds-aggregation.html`,
geo_centroid: `${ELASTIC_DOCS}search-aggregations-metrics-geocentroid-aggregation.html`,
max: `${ELASTIC_DOCS}search-aggregations-metrics-max-aggregation.html`,
median: `${ELASTIC_DOCS}search-aggregations-metrics-percentile-aggregation.html`,
min: `${ELASTIC_DOCS}search-aggregations-metrics-min-aggregation.html`,
moving_avg: `${ELASTIC_DOCS}search-aggregations-pipeline-movavg-aggregation.html`,
percentile_ranks: `${ELASTIC_DOCS}search-aggregations-metrics-percentile-rank-aggregation.html`,
serial_diff: `${ELASTIC_DOCS}search-aggregations-pipeline-serialdiff-aggregation.html`,
std_dev: `${ELASTIC_DOCS}search-aggregations-metrics-extendedstats-aggregation.html`,
sum: `${ELASTIC_DOCS}search-aggregations-metrics-sum-aggregation.html`,
top_hits: `${ELASTIC_DOCS}search-aggregations-metrics-top-hits-aggregation.html`,
},
scriptedFields: {
scriptFields: `${ELASTIC_DOCS}search-request-script-fields.html`,
scriptAggs: `${ELASTIC_DOCS}search-aggregations.html#_values_source`,
painless: `${ELASTIC_DOCS}modules-scripting-painless.html`,
painlessApi: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/painless/${DOC_LINK_VERSION}/painless-api-reference.html`,
painlessSyntax: `${ELASTIC_DOCS}modules-scripting-painless-syntax.html`,
luceneExpressions: `${ELASTIC_DOCS}modules-scripting-expression.html`,
},
indexPatterns: {
loadingData: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/tutorial-load-dataset.html`,
introduction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index-patterns.html`,
},
kibana: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index.html`,
siem: `${ELASTIC_WEBSITE_URL}guide/en/siem/guide/${DOC_LINK_VERSION}/index.html`,
query: {
luceneQuerySyntax: `${ELASTIC_DOCS}query-dsl-query-string-query.html#query-string-syntax`,
queryDsl: `${ELASTIC_DOCS}query-dsl.html`,
kueryQuerySyntax: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/kuery-query.html`,
},
date: {
dateMath: `${ELASTIC_DOCS}common-options.html#date-math`,
},
};
export const documentationLinks = npStart.core.docLinks.links;

View file

@ -236,6 +236,7 @@ export function uiRenderMixin(kbnServer, server, config) {
injectedMetadata: {
version: kbnServer.version,
buildNumber: config.get('pkg.buildNum'),
branch: config.get('pkg.branch'),
basePath,
i18n: {
translationsUrl: `${basePath}/translations/${i18n.getLocale()}.json`,