Skip to content

Commit

Permalink
Use doc link services in rollups (#99137)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl authored May 10, 2021
1 parent c092fbf commit c787495
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ readonly links: {
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
createRoleMappingTemplates: string;
createRollupJobsRequest: string;
createApiKey: string;
createPipeline: string;
createTransformRequest: 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 @@ -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`,
Expand Down Expand Up @@ -544,6 +545,7 @@ export interface DocLinksStart {
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
createRoleMappingTemplates: string;
createRollupJobsRequest: string;
createApiKey: string;
createPipeline: string;
createTransformRequest: 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 @@ -629,6 +629,7 @@ export interface DocLinksStart {
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
createRoleMappingTemplates: string;
createRollupJobsRequest: string;
createApiKey: string;
createPipeline: string;
createTransformRequest: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
EuiTitle,
} from '@elastic/eui';

import { getHistogramDetailsUrl } from '../../../services';
import { documentationLinks } from '../../../services/documentation_links';

import { FieldList } from '../../components';

Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ');
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
EuiTitle,
} from '@elastic/eui';

import { getTermsDetailsUrl } from '../../../services';
import { documentationLinks } from '../../../services/documentation_links';

import { FieldList } from '../../components';

Expand Down Expand Up @@ -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"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
};
13 changes: 2 additions & 11 deletions x-pack/plugins/rollup/public/crud_app/services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
4 changes: 2 additions & 2 deletions x-pack/plugins/rollup/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -31,6 +31,7 @@ describe('Cloning a rollup job through create job wizard', () => {
beforeAll(() => {
startMock = coreMock.createStart();
setHttp(startMock.http);
initDocumentation(docLinksServiceMock.createStartContract());
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -29,6 +29,7 @@ describe('Create Rollup Job, step 4: Histogram', () => {
beforeAll(() => {
startMock = coreMock.createStart();
setHttp(startMock.http);
initDocumentation(docLinksServiceMock.createStartContract());
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -28,6 +28,7 @@ describe('Create Rollup Job, step 1: Logistics', () => {
beforeAll(() => {
startMock = coreMock.createStart();
setHttp(startMock.http);
initDocumentation(docLinksServiceMock.createStartContract());
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -29,6 +29,7 @@ describe('Create Rollup Job, step 5: Metrics', () => {
beforeAll(() => {
startMock = coreMock.createStart();
setHttp(startMock.http);
initDocumentation(docLinksServiceMock.createStartContract());
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -28,6 +28,7 @@ describe('Create Rollup Job, step 3: Terms', () => {
beforeAll(() => {
startMock = coreMock.createStart();
setHttp(startMock.http);
initDocumentation(docLinksServiceMock.createStartContract());
});

beforeEach(() => {
Expand Down

0 comments on commit c787495

Please sign in to comment.