Use doc link services in rollups (#99137)

This commit is contained in:
Lisa Cawley 2021-05-10 10:01:19 -07:00 committed by GitHub
parent c092fbfe1a
commit c787495f00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 55 additions and 61 deletions

View file

@ -144,6 +144,7 @@ readonly links: {
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
createRoleMappingTemplates: string;
createRollupJobsRequest: string;
createApiKey: string;
createPipeline: string;
createTransformRequest: string;

File diff suppressed because one or more lines are too long

View file

@ -319,6 +319,7 @@ export class DocLinksService {
createSnapshotLifecyclePolicy: `${ELASTICSEARCH_DOCS}slm-api-put-policy.html`,
createRoleMapping: `${ELASTICSEARCH_DOCS}security-api-put-role-mapping.html`,
createRoleMappingTemplates: `${ELASTICSEARCH_DOCS}security-api-put-role-mapping.html#_role_templates`,
createRollupJobsRequest: `${ELASTICSEARCH_DOCS}rollup-put-job.html#rollup-put-job-api-request-body`,
createApiKey: `${ELASTICSEARCH_DOCS}security-api-create-api-key.html`,
createPipeline: `${ELASTICSEARCH_DOCS}put-pipeline-api.html`,
createTransformRequest: `${ELASTICSEARCH_DOCS}put-transform.html#put-transform-request-body`,
@ -544,6 +545,7 @@ export interface DocLinksStart {
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
createRoleMappingTemplates: string;
createRollupJobsRequest: string;
createApiKey: string;
createPipeline: string;
createTransformRequest: string;

View file

@ -629,6 +629,7 @@ export interface DocLinksStart {
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
createRoleMappingTemplates: string;
createRollupJobsRequest: string;
createApiKey: string;
createPipeline: string;
createTransformRequest: string;

View file

@ -28,7 +28,7 @@ import {
import { search } from '../../../../../../../../src/plugins/data/public';
const { parseEsInterval } = search.aggs;
import { getDateHistogramDetailsUrl, getDateHistogramAggregationUrl } from '../../../services';
import { documentationLinks } from '../../../services/documentation_links';
import { StepError } from './components';
@ -194,7 +194,7 @@ export class StepDateHistogram extends Component {
<EuiButtonEmpty
size="s"
flush="right"
href={getDateHistogramDetailsUrl()}
href={documentationLinks.apis.createRollupJobsRequest}
target="_blank"
iconType="help"
data-test-subj="rollupJobCreateDateHistogramDocsButton"
@ -220,7 +220,7 @@ export class StepDateHistogram extends Component {
defaultMessage="Define how {link} will operate on your rollup data."
values={{
link: (
<EuiLink href={getDateHistogramAggregationUrl()} target="_blank">
<EuiLink href={documentationLinks.aggs.date_histogram} target="_blank">
<FormattedMessage
id="xpack.rollupJobs.create.stepDateHistogramDescription.aggregationsLinkLabel"
defaultMessage="date histogram aggregations"

View file

@ -21,7 +21,7 @@ import {
EuiTitle,
} from '@elastic/eui';
import { getHistogramDetailsUrl } from '../../../services';
import { documentationLinks } from '../../../services/documentation_links';
import { FieldList } from '../../components';
@ -97,7 +97,7 @@ export class StepHistogram extends Component {
<EuiButtonEmpty
size="s"
flush="right"
href={getHistogramDetailsUrl()}
href={documentationLinks.apis.createRollupJobsRequest}
target="_blank"
iconType="help"
data-test-subj="rollupJobCreateHistogramDocsButton"

View file

@ -29,7 +29,7 @@ import { CronEditor } from '../../../../../../../../src/plugins/es_ui_shared/pub
import { indexPatterns } from '../../../../../../../../src/plugins/data/public';
import { indices } from '../../../../shared_imports';
import { getLogisticalDetailsUrl, getCronUrl } from '../../../services';
import { documentationLinks } from '../../../services/documentation_links';
import { StepError } from './components';
const indexPatternIllegalCharacters = indexPatterns.ILLEGAL_CHARACTERS_VISIBLE.join(' ');
@ -149,7 +149,7 @@ export class StepLogistics extends Component {
isInvalid={Boolean(areStepErrorsVisible && errorRollupCron)}
helpText={
<p>
<EuiLink href={getCronUrl()} target="_blank">
<EuiLink href={documentationLinks.apis.cronExpressions} target="_blank">
<FormattedMessage
id="xpack.rollupJobs.create.stepLogistics.fieldCron.helpReferenceLinkLabel"
defaultMessage="Learn more about cron expressions"
@ -263,7 +263,7 @@ export class StepLogistics extends Component {
<EuiButtonEmpty
size="s"
flush="right"
href={getLogisticalDetailsUrl()}
href={documentationLinks.apis.createRollupJobsRequest}
target="_blank"
iconType="help"
data-test-subj="rollupJobCreateLogisticsDocsButton"

View file

@ -23,7 +23,7 @@ import {
EuiButton,
} from '@elastic/eui';
import { getMetricsDetailsUrl } from '../../../services';
import { documentationLinks } from '../../../services/documentation_links';
import { FieldList } from '../../components';
import { FieldChooser, StepError } from './components';
import { METRICS_CONFIG } from '../../../constants';
@ -387,7 +387,7 @@ export class StepMetrics extends Component {
<EuiButtonEmpty
size="s"
flush="right"
href={getMetricsDetailsUrl()}
href={documentationLinks.apis.createRollupJobsRequest}
target="_blank"
iconType="help"
data-test-subj="rollupJobCreateMetricsDocsButton"

View file

@ -18,7 +18,7 @@ import {
EuiTitle,
} from '@elastic/eui';
import { getTermsDetailsUrl } from '../../../services';
import { documentationLinks } from '../../../services/documentation_links';
import { FieldList } from '../../components';
@ -100,7 +100,7 @@ export class StepTerms extends Component {
<EuiButtonEmpty
size="s"
flush="right"
href={getTermsDetailsUrl()}
href={documentationLinks.apis.createRollupJobsRequest}
target="_blank"
iconType="help"
data-test-subj="rollupJobCreateTermsDocsButton"

View file

@ -1,23 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
let esBase = '';
export function setEsBaseAndXPackBase(elasticWebsiteUrl, docLinksVersion) {
esBase = `${elasticWebsiteUrl}guide/en/elasticsearch/reference/${docLinksVersion}`;
}
export const getLogisticalDetailsUrl = () => `${esBase}/rollup-job-config.html#_logistical_details`;
export const getDateHistogramDetailsUrl = () =>
`${esBase}/rollup-job-config.html#_date_histogram_2`;
export const getTermsDetailsUrl = () => `${esBase}/rollup-job-config.html#_terms_2`;
export const getHistogramDetailsUrl = () => `${esBase}/rollup-job-config.html#_histogram_2`;
export const getMetricsDetailsUrl = () => `${esBase}/rollup-job-config.html#rollup-metrics-config`;
export const getDateHistogramAggregationUrl = () =>
`${esBase}/search-aggregations-bucket-datehistogram-aggregation.html`;
export const getCronUrl = () => `${esBase}/trigger-schedule.html#_cron_expressions`;

View file

@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { DocLinksStart } from 'src/core/public';
export let documentationLinks: DocLinksStart['links'];
export const init = (docLinks: DocLinksStart) => {
documentationLinks = docLinks.links;
};

View file

@ -11,17 +11,6 @@ export { showApiError, showApiWarning } from './api_errors';
export { listBreadcrumb, createBreadcrumb } from './breadcrumbs';
export {
setEsBaseAndXPackBase,
getLogisticalDetailsUrl,
getDateHistogramDetailsUrl,
getDateHistogramAggregationUrl,
getTermsDetailsUrl,
getHistogramDetailsUrl,
getMetricsDetailsUrl,
getCronUrl,
} from './documentation_links';
export { filterItems } from './filter_items';
export { flattenPanelTree } from './flatten_panel_tree';
@ -47,3 +36,5 @@ export { sortTable } from './sort_table';
export { retypeMetrics } from './retype_metrics';
export { METRIC_TYPE } from './track_ui_metric';
export { init } from './documentation_links';

View file

@ -21,7 +21,7 @@ import { ManagementSetup } from '../../../../src/plugins/management/public';
import { IndexManagementPluginSetup } from '../../index_management/public';
import { IndexPatternManagementSetup } from '../../../../src/plugins/index_pattern_management/public';
// @ts-ignore
import { setEsBaseAndXPackBase, setHttp } from './crud_app/services/index';
import { setHttp, init as initDocumentation } from './crud_app/services/index';
import { setNotifications, setFatalErrors, setUiStatsReporter } from './kibana_services';
import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/public';
@ -108,6 +108,6 @@ export class RollupPlugin implements Plugin {
start(core: CoreStart) {
setHttp(core.http);
setNotifications(core.notifications);
setEsBaseAndXPackBase(core.docLinks.ELASTIC_WEBSITE_URL, core.docLinks.DOC_LINK_VERSION);
initDocumentation(core.docLinks);
}
}

View file

@ -5,10 +5,10 @@
* 2.0.
*/
import { setHttp } from '../../crud_app/services';
import { setHttp, init as initDocumentation } from '../../crud_app/services';
import { mockHttpRequest, pageHelpers, nextTick } from './helpers';
import { JOB_TO_CLONE, JOB_CLONE_INDEX_PATTERN_CHECK } from './helpers/constants';
import { coreMock } from '../../../../../../src/core/public/mocks';
import { coreMock, docLinksServiceMock } from '../../../../../../src/core/public/mocks';
jest.mock('lodash', () => ({
...jest.requireActual('lodash'),
@ -31,6 +31,7 @@ describe('Cloning a rollup job through create job wizard', () => {
beforeAll(() => {
startMock = coreMock.createStart();
setHttp(startMock.http);
initDocumentation(docLinksServiceMock.createStartContract());
});
beforeEach(() => {

View file

@ -7,9 +7,9 @@
import moment from 'moment-timezone';
import { setHttp } from '../../crud_app/services';
import { setHttp, init as initDocumentation } from '../../crud_app/services';
import { mockHttpRequest, pageHelpers } from './helpers';
import { coreMock } from '../../../../../../src/core/public/mocks';
import { docLinksServiceMock, coreMock } from '../../../../../../src/core/public/mocks';
jest.mock('lodash', () => ({
...jest.requireActual('lodash'),
@ -30,6 +30,7 @@ describe('Create Rollup Job, step 2: Date histogram', () => {
beforeAll(() => {
startMock = coreMock.createStart();
setHttp(startMock.http);
initDocumentation(docLinksServiceMock.createStartContract());
});
beforeEach(() => {
// Set "default" mock responses by not providing any arguments

View file

@ -5,9 +5,9 @@
* 2.0.
*/
import { setHttp } from '../../crud_app/services';
import { setHttp, init as initDocumentation } from '../../crud_app/services';
import { mockHttpRequest, pageHelpers } from './helpers';
import { coreMock } from '../../../../../../src/core/public/mocks';
import { coreMock, docLinksServiceMock } from '../../../../../../src/core/public/mocks';
jest.mock('lodash', () => ({
...jest.requireActual('lodash'),
@ -29,6 +29,7 @@ describe('Create Rollup Job, step 4: Histogram', () => {
beforeAll(() => {
startMock = coreMock.createStart();
setHttp(startMock.http);
initDocumentation(docLinksServiceMock.createStartContract());
});
beforeEach(() => {

View file

@ -6,9 +6,9 @@
*/
import { indexPatterns } from '../../../../../../src/plugins/data/public';
import { setHttp } from '../../crud_app/services';
import { setHttp, init as initDocumentation } from '../../crud_app/services';
import { mockHttpRequest, pageHelpers } from './helpers';
import { coreMock } from '../../../../../../src/core/public/mocks';
import { coreMock, docLinksServiceMock } from '../../../../../../src/core/public/mocks';
jest.mock('lodash', () => ({
...jest.requireActual('lodash'),
@ -28,6 +28,7 @@ describe('Create Rollup Job, step 1: Logistics', () => {
beforeAll(() => {
startMock = coreMock.createStart();
setHttp(startMock.http);
initDocumentation(docLinksServiceMock.createStartContract());
});
beforeEach(() => {

View file

@ -5,9 +5,9 @@
* 2.0.
*/
import { setHttp } from '../../crud_app/services';
import { setHttp, init as initDocumentation } from '../../crud_app/services';
import { mockHttpRequest, pageHelpers } from './helpers';
import { coreMock } from '../../../../../../src/core/public/mocks';
import { coreMock, docLinksServiceMock } from '../../../../../../src/core/public/mocks';
jest.mock('lodash', () => ({
...jest.requireActual('lodash'),
@ -29,6 +29,7 @@ describe('Create Rollup Job, step 5: Metrics', () => {
beforeAll(() => {
startMock = coreMock.createStart();
setHttp(startMock.http);
initDocumentation(docLinksServiceMock.createStartContract());
});
beforeEach(() => {

View file

@ -5,9 +5,9 @@
* 2.0.
*/
import { setHttp } from '../../crud_app/services';
import { setHttp, init as initDocumentation } from '../../crud_app/services';
import { pageHelpers, mockHttpRequest } from './helpers';
import { coreMock } from '../../../../../../src/core/public/mocks';
import { coreMock, docLinksServiceMock } from '../../../../../../src/core/public/mocks';
jest.mock('lodash', () => ({
...jest.requireActual('lodash'),
@ -28,6 +28,7 @@ describe('Create Rollup Job, step 3: Terms', () => {
beforeAll(() => {
startMock = coreMock.createStart();
setHttp(startMock.http);
initDocumentation(docLinksServiceMock.createStartContract());
});
beforeEach(() => {