Use doc link services in CCR (#98436) (#98937)

Co-authored-by: Alison Goryachev <alisonmllr20@gmail.com>

Co-authored-by: Alison Goryachev <alisonmllr20@gmail.com>
This commit is contained in:
Lisa Cawley 2021-04-30 11:13:36 -07:00 committed by GitHub
parent 2de4a5c896
commit 07b821bf8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 368 additions and 345 deletions

View file

@ -134,6 +134,9 @@ readonly links: {
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
bulkIndexAlias: string;
byteSizeUnits: string;
createAutoFollowPattern: string;
createFollower: string;
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
@ -153,6 +156,7 @@ readonly links: {
putIndexTemplateV1: string;
putWatch: string;
simulatePipeline: string;
timeUnits: string;
updateTransform: string;
}>;
readonly observability: Record<string, string>;

File diff suppressed because one or more lines are too long

View file

@ -311,6 +311,9 @@ export class DocLinksService {
},
apis: {
bulkIndexAlias: `${ELASTICSEARCH_DOCS}indices-aliases.html`,
byteSizeUnits: `${ELASTICSEARCH_DOCS}common-options.html#byte-units`,
createAutoFollowPattern: `${ELASTICSEARCH_DOCS}ccr-put-auto-follow-pattern.html`,
createFollower: `${ELASTICSEARCH_DOCS}ccr-put-follow.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`,
@ -331,6 +334,7 @@ export class DocLinksService {
putSnapshotLifecyclePolicy: `${ELASTICSEARCH_DOCS}slm-api-put-policy.html`,
putWatch: `${ELASTICSEARCH_DOCS}watcher-api-put-watch.html`,
simulatePipeline: `${ELASTICSEARCH_DOCS}simulate-pipeline-api.html`,
timeUnits: `${ELASTICSEARCH_DOCS}common-options.html#time-units`,
updateTransform: `${ELASTICSEARCH_DOCS}update-transform.html`,
},
plugins: {
@ -529,6 +533,9 @@ export interface DocLinksStart {
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
bulkIndexAlias: string;
byteSizeUnits: string;
createAutoFollowPattern: string;
createFollower: string;
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
@ -548,6 +555,7 @@ export interface DocLinksStart {
putIndexTemplateV1: string;
putWatch: string;
simulatePipeline: string;
timeUnits: string;
updateTransform: string;
}>;
readonly observability: Record<string, string>;

View file

@ -619,6 +619,9 @@ export interface DocLinksStart {
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
bulkIndexAlias: string;
byteSizeUnits: string;
createAutoFollowPattern: string;
createFollower: string;
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
@ -638,6 +641,7 @@ export interface DocLinksStart {
putIndexTemplateV1: string;
putWatch: string;
simulatePipeline: string;
timeUnits: string;
updateTransform: string;
}>;
readonly observability: Record<string, string>;

View file

@ -8,7 +8,9 @@
import axios from 'axios';
import axiosXhrAdapter from 'axios/lib/adapters/xhr';
import { docLinksServiceMock } from '../../../../../../../src/core/public/mocks';
import { setHttpClient } from '../../../app/services/api';
import { init as initDocumentation } from '../../../app/services/documentation_links';
import { init as initHttpRequests } from './http_requests';
export const setupEnvironment = () => {
@ -17,6 +19,7 @@ export const setupEnvironment = () => {
const client = axios.create({ adapter: axiosXhrAdapter });
client.interceptors.response.use(({ data }) => data);
setHttpClient(client);
initDocumentation(docLinksServiceMock.createStartContract());
const { server, httpRequestsMockHelpers } = initHttpRequests();

View file

@ -18,7 +18,7 @@ import {
EuiTitle,
} from '@elastic/eui';
import { getAutoFollowPatternUrl } from '../services/documentation_links';
import { documentationLinks } from '../services/documentation_links';
export const AutoFollowPatternPageTitle = ({ title }) => (
<Fragment>
@ -36,7 +36,7 @@ export const AutoFollowPatternPageTitle = ({ title }) => (
<EuiButtonEmpty
size="s"
flush="right"
href={getAutoFollowPatternUrl()}
href={documentationLinks.apis.createAutoFollowPattern}
target="_blank"
iconType="help"
data-test-subj="docsButton"

View file

@ -8,310 +8,314 @@
import React from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { getByteUnitsUrl, getTimeUnitsUrl } from '../../services/documentation_links';
import { EuiLink } from '@elastic/eui';
import { getSettingDefault } from '../../services/follower_index_default_settings';
const byteUnitsHelpText = (
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexForm.advancedSettings.byteUnitsHelpText"
defaultMessage="Example values: 10b, 1024kb, 1mb, 5gb, 2tb, 1pb. {link}"
values={{
link: (
<a href={getByteUnitsUrl()} target="_blank">
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexForm.advancedSettings.byteUnitsHelpTextLinkMessage"
defaultMessage="Learn more"
/>
</a>
export const getAdvancedSettingsFields = (documentationLinks) => {
const byteUnitsHelpText = (
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexForm.advancedSettings.byteUnitsHelpText"
defaultMessage="Example values: 10b, 1024kb, 1mb, 5gb, 2tb, 1pb. {link}"
values={{
link: (
<EuiLink href={documentationLinks.apis.byteSizeUnits} target="_blank">
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexForm.advancedSettings.byteUnitsHelpTextLinkMessage"
defaultMessage="Learn more"
/>
</EuiLink>
),
}}
/>
);
const timeUnitsHelpText = (
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexForm.advancedSettings.timeUnitsHelpText"
defaultMessage="Example values: 2d, 24h, 20m, 30s, 500ms, 10000micros, 80000nanos. {link}"
values={{
link: (
<EuiLink href={documentationLinks.apis.timeUnits} target="_blank">
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexForm.advancedSettings.timeUnitsHelpTextLinkMessage"
defaultMessage="Learn more"
/>
</EuiLink>
),
}}
/>
);
return [
{
field: 'maxReadRequestOperationCount',
testSubject: 'maxReadRequestOperationCountInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestOperationCountTitle',
{
defaultMessage: 'Max read request operation count',
}
),
}}
/>
);
const timeUnitsHelpText = (
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexForm.advancedSettings.timeUnitsHelpText"
defaultMessage="Example values: 2d, 24h, 20m, 30s, 500ms, 10000micros, 80000nanos. {link}"
values={{
link: (
<a href={getTimeUnitsUrl()} target="_blank">
<FormattedMessage
id="xpack.crossClusterReplication.followerIndexForm.advancedSettings.timeUnitsHelpTextLinkMessage"
defaultMessage="Learn more"
/>
</a>
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestOperationCountDescription',
{
defaultMessage:
'The maximum number of operations to pull per read from the remote cluster.',
}
),
}}
/>
);
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestOperationCountLabel',
{
defaultMessage: 'Max read request operation count',
}
),
defaultValue: getSettingDefault('maxReadRequestOperationCount'),
type: 'number',
},
{
field: 'maxOutstandingReadRequests',
testSubject: 'maxOutstandingReadRequestsInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingReadRequestsTitle',
{
defaultMessage: 'Max outstanding read requests',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingReadRequestsDescription',
{
defaultMessage:
'The maximum number of outstanding read requests from the remote cluster.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingReadRequestsLabel',
{
defaultMessage: 'Max outstanding read requests',
}
),
defaultValue: getSettingDefault('maxOutstandingReadRequests'),
type: 'number',
},
{
field: 'maxReadRequestSize',
testSubject: 'maxReadRequestSizeInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestSizeTitle',
{
defaultMessage: 'Max read request size',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestSizeDescription',
{
defaultMessage:
'The maximum size in bytes of per read of a batch of operations pulled from the remote cluster.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestSizeLabel',
{
defaultMessage: 'Max read request size',
}
),
defaultValue: getSettingDefault('maxReadRequestSize'),
helpText: byteUnitsHelpText,
},
{
field: 'maxWriteRequestOperationCount',
testSubject: 'maxWriteRequestOperationCountInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestOperationCountTitle',
{
defaultMessage: 'Max write request operation count',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestOperationCountDescription',
{
defaultMessage:
'The maximum number of operations per bulk write request executed on the follower.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestOperationCountLabel',
{
defaultMessage: 'Max write request operation count',
}
),
defaultValue: getSettingDefault('maxWriteRequestOperationCount'),
type: 'number',
},
{
field: 'maxWriteRequestSize',
testSubject: 'maxWriteRequestSizeInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestSizeTitle',
{
defaultMessage: 'Max write request size',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestSizeDescription',
{
defaultMessage:
'The maximum total bytes of operations per bulk write request executed on the follower.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestSizeLabel',
{
defaultMessage: 'Max write request size',
}
),
defaultValue: getSettingDefault('maxWriteRequestSize'),
helpText: byteUnitsHelpText,
},
{
field: 'maxOutstandingWriteRequests',
testSubject: 'maxOutstandingWriteRequestsInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingWriteRequestsTitle',
{
defaultMessage: 'Max outstanding write requests',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingWriteRequestsDescription',
{
defaultMessage: 'The maximum number of outstanding write requests on the follower.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingWriteRequestsLabel',
{
defaultMessage: 'Max outstanding write requests',
}
),
defaultValue: getSettingDefault('maxOutstandingWriteRequests'),
type: 'number',
},
{
field: 'maxWriteBufferCount',
testSubject: 'maxWriteBufferCountInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferCountTitle',
{
defaultMessage: 'Max write buffer count',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferCountDescription',
{
defaultMessage:
'The maximum number of operations that can be queued for writing; when this ' +
'limit is reached, reads from the remote cluster will be deferred until the number of queued ' +
'operations goes below the limit.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferCountLabel',
{
defaultMessage: 'Max write buffer count',
}
),
defaultValue: getSettingDefault('maxWriteBufferCount'),
type: 'number',
},
{
field: 'maxWriteBufferSize',
testSubject: 'maxWriteBufferSizeInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferSizeTitle',
{
defaultMessage: 'Max write buffer size',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferSizeDescription',
{
defaultMessage:
'The maximum total bytes of operations that can be queued for writing; when ' +
'this limit is reached, reads from the remote cluster will be deferred until the total bytes ' +
'of queued operations goes below the limit.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferSizeLabel',
{
defaultMessage: 'Max write buffer size',
}
),
defaultValue: getSettingDefault('maxWriteBufferSize'),
helpText: byteUnitsHelpText,
},
{
field: 'maxRetryDelay',
testSubject: 'maxRetryDelayInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxRetryDelayTitle',
{
defaultMessage: 'Max retry delay',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxRetryDelayDescription',
{
defaultMessage:
'The maximum time to wait before retrying an operation that failed exceptionally; ' +
'an exponential backoff strategy is employed when retrying.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxRetryDelayLabel',
{
defaultMessage: 'Max retry delay',
}
),
defaultValue: getSettingDefault('maxRetryDelay'),
helpText: timeUnitsHelpText,
},
{
field: 'readPollTimeout',
testSubject: 'readPollTimeoutInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.readPollTimeoutTitle',
{
defaultMessage: 'Read poll timeout',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.readPollTimeoutDescription',
{
defaultMessage:
'The maximum time to wait for new operations on the remote cluster when the ' +
'follower index is synchronized with the leader index; when the timeout has elapsed, the ' +
'poll for operations will return to the follower so that it can update some statistics, and ' +
'then the follower will immediately attempt to read from the leader again.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.readPollTimeoutLabel',
{
defaultMessage: 'Read poll timeout',
}
),
defaultValue: getSettingDefault('readPollTimeout'),
helpText: timeUnitsHelpText,
},
];
};
export const advancedSettingsFields = [
{
field: 'maxReadRequestOperationCount',
testSubject: 'maxReadRequestOperationCountInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestOperationCountTitle',
{
defaultMessage: 'Max read request operation count',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestOperationCountDescription',
{
defaultMessage:
'The maximum number of operations to pull per read from the remote cluster.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestOperationCountLabel',
{
defaultMessage: 'Max read request operation count',
}
),
defaultValue: getSettingDefault('maxReadRequestOperationCount'),
type: 'number',
},
{
field: 'maxOutstandingReadRequests',
testSubject: 'maxOutstandingReadRequestsInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingReadRequestsTitle',
{
defaultMessage: 'Max outstanding read requests',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingReadRequestsDescription',
{
defaultMessage: 'The maximum number of outstanding read requests from the remote cluster.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingReadRequestsLabel',
{
defaultMessage: 'Max outstanding read requests',
}
),
defaultValue: getSettingDefault('maxOutstandingReadRequests'),
type: 'number',
},
{
field: 'maxReadRequestSize',
testSubject: 'maxReadRequestSizeInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestSizeTitle',
{
defaultMessage: 'Max read request size',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestSizeDescription',
{
defaultMessage:
'The maximum size in bytes of per read of a batch of operations pulled from the remote cluster.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxReadRequestSizeLabel',
{
defaultMessage: 'Max read request size',
}
),
defaultValue: getSettingDefault('maxReadRequestSize'),
helpText: byteUnitsHelpText,
},
{
field: 'maxWriteRequestOperationCount',
testSubject: 'maxWriteRequestOperationCountInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestOperationCountTitle',
{
defaultMessage: 'Max write request operation count',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestOperationCountDescription',
{
defaultMessage:
'The maximum number of operations per bulk write request executed on the follower.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestOperationCountLabel',
{
defaultMessage: 'Max write request operation count',
}
),
defaultValue: getSettingDefault('maxWriteRequestOperationCount'),
type: 'number',
},
{
field: 'maxWriteRequestSize',
testSubject: 'maxWriteRequestSizeInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestSizeTitle',
{
defaultMessage: 'Max write request size',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestSizeDescription',
{
defaultMessage:
'The maximum total bytes of operations per bulk write request executed on the follower.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteRequestSizeLabel',
{
defaultMessage: 'Max write request size',
}
),
defaultValue: getSettingDefault('maxWriteRequestSize'),
helpText: byteUnitsHelpText,
},
{
field: 'maxOutstandingWriteRequests',
testSubject: 'maxOutstandingWriteRequestsInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingWriteRequestsTitle',
{
defaultMessage: 'Max outstanding write requests',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingWriteRequestsDescription',
{
defaultMessage: 'The maximum number of outstanding write requests on the follower.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxOutstandingWriteRequestsLabel',
{
defaultMessage: 'Max outstanding write requests',
}
),
defaultValue: getSettingDefault('maxOutstandingWriteRequests'),
type: 'number',
},
{
field: 'maxWriteBufferCount',
testSubject: 'maxWriteBufferCountInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferCountTitle',
{
defaultMessage: 'Max write buffer count',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferCountDescription',
{
defaultMessage:
'The maximum number of operations that can be queued for writing; when this ' +
'limit is reached, reads from the remote cluster will be deferred until the number of queued ' +
'operations goes below the limit.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferCountLabel',
{
defaultMessage: 'Max write buffer count',
}
),
defaultValue: getSettingDefault('maxWriteBufferCount'),
type: 'number',
},
{
field: 'maxWriteBufferSize',
testSubject: 'maxWriteBufferSizeInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferSizeTitle',
{
defaultMessage: 'Max write buffer size',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferSizeDescription',
{
defaultMessage:
'The maximum total bytes of operations that can be queued for writing; when ' +
'this limit is reached, reads from the remote cluster will be deferred until the total bytes ' +
'of queued operations goes below the limit.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxWriteBufferSizeLabel',
{
defaultMessage: 'Max write buffer size',
}
),
defaultValue: getSettingDefault('maxWriteBufferSize'),
helpText: byteUnitsHelpText,
},
{
field: 'maxRetryDelay',
testSubject: 'maxRetryDelayInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxRetryDelayTitle',
{
defaultMessage: 'Max retry delay',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxRetryDelayDescription',
{
defaultMessage:
'The maximum time to wait before retrying an operation that failed exceptionally; ' +
'an exponential backoff strategy is employed when retrying.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.maxRetryDelayLabel',
{
defaultMessage: 'Max retry delay',
}
),
defaultValue: getSettingDefault('maxRetryDelay'),
helpText: timeUnitsHelpText,
},
{
field: 'readPollTimeout',
testSubject: 'readPollTimeoutInput',
title: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.readPollTimeoutTitle',
{
defaultMessage: 'Read poll timeout',
}
),
description: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.readPollTimeoutDescription',
{
defaultMessage:
'The maximum time to wait for new operations on the remote cluster when the ' +
'follower index is synchronized with the leader index; when the timeout has elapsed, the ' +
'poll for operations will return to the follower so that it can update some statistics, and ' +
'then the follower will immediately attempt to read from the leader again.',
}
),
label: i18n.translate(
'xpack.crossClusterReplication.followerIndexForm.advancedSettings.readPollTimeoutLabel',
{
defaultMessage: 'Read poll timeout',
}
),
defaultValue: getSettingDefault('readPollTimeout'),
helpText: timeUnitsHelpText,
},
];
export const getEmptyAdvancedSettings = (documentationLinks) =>
getAdvancedSettingsFields(documentationLinks).reduce((obj, advancedSetting) => {
const { field, defaultValue } = advancedSetting;
return { ...obj, [field]: defaultValue };
}, {});
export const emptyAdvancedSettings = advancedSettingsFields.reduce((obj, advancedSetting) => {
const { field, defaultValue } = advancedSetting;
return { ...obj, [field]: defaultValue };
}, {});
export function areAdvancedSettingsEdited(followerIndex) {
return advancedSettingsFields.some((advancedSetting) => {
export function areAdvancedSettingsEdited(followerIndex, documentationLinks) {
return getAdvancedSettingsFields(documentationLinks).some((advancedSetting) => {
const { field } = advancedSetting;
return followerIndex[field] !== emptyAdvancedSettings[field];
return followerIndex[field] !== getEmptyAdvancedSettings(documentationLinks)[field];
});
}

View file

@ -34,14 +34,15 @@ import { indexNameValidator, leaderIndexValidator } from '../../services/input_v
import { routing } from '../../services/routing';
import { getFatalErrors } from '../../services/notifications';
import { loadIndices } from '../../services/api';
import { documentationLinks } from '../../services/documentation_links';
import { API_STATUS } from '../../constants';
import { getRemoteClusterName } from '../../services/get_remote_cluster_name';
import { RemoteClustersFormField } from '../remote_clusters_form_field';
import { SectionError } from '../section_error';
import { FormEntryRow } from '../form_entry_row';
import {
advancedSettingsFields,
emptyAdvancedSettings,
getAdvancedSettingsFields,
getEmptyAdvancedSettings,
areAdvancedSettingsEdited,
} from './advanced_settings_fields';
@ -49,23 +50,24 @@ import { FollowerIndexRequestFlyout } from './follower_index_request_flyout';
const indexNameIllegalCharacters = indices.INDEX_ILLEGAL_CHARACTERS_VISIBLE.join(' ');
const fieldToValidatorMap = advancedSettingsFields.reduce(
(map, advancedSetting) => {
const { field, validator } = advancedSetting;
map[field] = validator;
return map;
},
{
name: indexNameValidator,
leaderIndex: leaderIndexValidator,
}
);
const getFieldToValidatorMap = (advancedSettingsFields) =>
advancedSettingsFields.reduce(
(map, advancedSetting) => {
const { field, validator } = advancedSetting;
map[field] = validator;
return map;
},
{
name: indexNameValidator,
leaderIndex: leaderIndexValidator,
}
);
const getEmptyFollowerIndex = (remoteClusterName = '') => ({
name: '',
remoteCluster: remoteClusterName,
leaderIndex: '',
...emptyAdvancedSettings,
...getEmptyAdvancedSettings(documentationLinks),
});
/**
@ -121,7 +123,7 @@ export class FollowerIndexForm extends PureComponent {
// eslint-disable-next-line no-nested-ternary
const areAdvancedSettingsVisible = isNew
? false
: areAdvancedSettingsEdited(followerIndex)
: areAdvancedSettingsEdited(followerIndex, documentationLinks)
? true
: false;
@ -164,7 +166,8 @@ export class FollowerIndexForm extends PureComponent {
getFieldsErrors = (newFields) => {
return Object.keys(newFields).reduce((errors, field) => {
const validator = fieldToValidatorMap[field];
const advancedSettings = getAdvancedSettingsFields(documentationLinks);
const validator = getFieldToValidatorMap(advancedSettings)[field];
const value = newFields[field];
if (validator) {
@ -278,17 +281,20 @@ export class FollowerIndexForm extends PureComponent {
}
// Clear the advanced settings form.
this.onFieldsChange(emptyAdvancedSettings);
this.onFieldsChange(getEmptyAdvancedSettings(documentationLinks));
// Save a cache of the advanced settings.
const fields = this.getFields();
this.cachedAdvancedSettings = advancedSettingsFields.reduce((cache, { field }) => {
const value = fields[field];
if (value !== '') {
cache[field] = value;
}
return cache;
}, {});
this.cachedAdvancedSettings = getAdvancedSettingsFields(documentationLinks).reduce(
(cache, { field }) => {
const value = fields[field];
if (value !== '') {
cache[field] = value;
}
return cache;
},
{}
);
// Hide the advanced settings.
this.setState({
@ -614,7 +620,7 @@ export class FollowerIndexForm extends PureComponent {
{areAdvancedSettingsVisible && (
<Fragment>
<EuiSpacer size="s" />
{advancedSettingsFields.map((advancedSetting) => {
{getAdvancedSettingsFields(documentationLinks).map((advancedSetting) => {
const {
field,
testSubject,

View file

@ -18,7 +18,7 @@ import {
EuiTitle,
} from '@elastic/eui';
import { getFollowerIndexUrl } from '../services/documentation_links';
import { documentationLinks } from '../services/documentation_links';
export const FollowerIndexPageTitle = ({ title }) => (
<Fragment>
@ -36,7 +36,7 @@ export const FollowerIndexPageTitle = ({ title }) => (
<EuiButtonEmpty
size="s"
flush="right"
href={getFollowerIndexUrl()}
href={documentationLinks.apis.createFollower}
target="_blank"
iconType="help"
data-test-subj="docsButton"

View file

@ -10,7 +10,7 @@ import { render, unmountComponentAtNode } from 'react-dom';
import { Provider } from 'react-redux';
import { I18nStart, ScopedHistory, ApplicationStart } from 'kibana/public';
import { UnmountCallback } from 'src/core/public';
import { DocLinksStart } from 'kibana/public';
import { init as initBreadcrumbs, SetBreadcrumbs } from './services/breadcrumbs';
import { init as initDocumentation } from './services/documentation_links';
import { App } from './app';
@ -38,23 +38,21 @@ export async function mountApp({
element,
setBreadcrumbs,
I18nContext,
ELASTIC_WEBSITE_URL, // eslint-disable-line @typescript-eslint/naming-convention
DOC_LINK_VERSION, // eslint-disable-line @typescript-eslint/naming-convention
docLinks,
history,
getUrlForApp,
}: {
element: Element;
setBreadcrumbs: SetBreadcrumbs;
I18nContext: I18nStart['Context'];
ELASTIC_WEBSITE_URL: string;
DOC_LINK_VERSION: string;
docLinks: DocLinksStart;
history: ScopedHistory;
getUrlForApp: ApplicationStart['getUrlForApp'];
}): Promise<UnmountCallback> {
// Import and initialize additional services here instead of in plugin.ts to reduce the size of the
// initial bundle as much as possible.
initBreadcrumbs(setBreadcrumbs);
initDocumentation(`${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/`);
initDocumentation(docLinks);
return renderApp(element, I18nContext, history, getUrlForApp);
}

View file

@ -5,13 +5,10 @@
* 2.0.
*/
let _esBase: string;
import type { DocLinksStart } from 'src/core/public';
export const init = (esBase: string) => {
_esBase = esBase;
export let documentationLinks: DocLinksStart['links'];
export const init = (docLinks: DocLinksStart) => {
documentationLinks = docLinks.links;
};
export const getAutoFollowPatternUrl = (): string => `${_esBase}/ccr-put-auto-follow-pattern.html`;
export const getFollowerIndexUrl = (): string => `${_esBase}/ccr-put-follow.html`;
export const getByteUnitsUrl = (): string => `${_esBase}/common-options.html#byte-units`;
export const getTimeUnitsUrl = (): string => `${_esBase}/common-options.html#time-units`;

View file

@ -48,7 +48,7 @@ export class CrossClusterReplicationPlugin implements Plugin {
const {
chrome: { docTitle },
i18n: { Context: I18nContext },
docLinks: { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION },
docLinks,
application: { getUrlForApp },
} = coreStart;
@ -58,8 +58,7 @@ export class CrossClusterReplicationPlugin implements Plugin {
element,
setBreadcrumbs,
I18nContext,
ELASTIC_WEBSITE_URL,
DOC_LINK_VERSION,
docLinks,
history,
getUrlForApp,
});