Skip to content

Commit

Permalink
Use docLinks service for ui settings in Discover and Data plugins (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 authored Feb 4, 2022
1 parent cfaa08f commit 2446d11
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
2 changes: 2 additions & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
},
discover: {
guide: `${KIBANA_DOCS}discover.html`,
fieldStatistics: `${KIBANA_DOCS}show-field-statistics.html`,
},
filebeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}`,
Expand Down Expand Up @@ -234,6 +235,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
asyncSearch: `${ELASTICSEARCH_DOCS}async-search-intro.html`,
dataStreams: `${ELASTICSEARCH_DOCS}data-streams.html`,
deprecationLogging: `${ELASTICSEARCH_DOCS}logging.html#deprecation-logging`,
frozenIndices: `${ELASTICSEARCH_DOCS}frozen-indices.html`,
hiddenIndices: `${ELASTICSEARCH_DOCS}multi-index.html#hidden`,
ilm: `${ELASTICSEARCH_DOCS}index-lifecycle-management.html`,
ilmForceMerge: `${ELASTICSEARCH_DOCS}ilm-forcemerge.html`,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class DataServerPlugin
this.autocompleteService.setup(core);
this.kqlTelemetryService.setup(core, { usageCollection });

core.uiSettings.register(getUiSettings());
core.uiSettings.register(getUiSettings(core.docLinks));

const searchSetup = this.searchService.setup(core, {
bfetch,
Expand Down
22 changes: 12 additions & 10 deletions src/plugins/data/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { i18n } from '@kbn/i18n';
import { schema } from '@kbn/config-schema';
import { UiSettingsParams } from 'kibana/server';
import type { DocLinksServiceSetup, UiSettingsParams } from 'kibana/server';
import { DEFAULT_QUERY_LANGUAGE, UI_SETTINGS } from '../common';

const luceneQueryLanguageLabel = i18n.translate('data.advancedSettings.searchQueryLanguageLucene', {
Expand All @@ -31,7 +31,9 @@ const requestPreferenceOptionLabels = {
}),
};

export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
export function getUiSettings(
docLinks: DocLinksServiceSetup
): Record<string, UiSettingsParams<unknown>> {
return {
[UI_SETTINGS.META_FIELDS]: {
name: i18n.translate('data.advancedSettings.metaFieldsTitle', {
Expand Down Expand Up @@ -71,7 +73,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
'data.advancedSettings.query.queryStringOptionsText',
values: {
optionsLink:
'<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html" target="_blank" rel="noopener">' +
`<a href=${docLinks.links.query.luceneQuery} target="_blank" rel="noopener">` +
i18n.translate('data.advancedSettings.query.queryStringOptions.optionsLinkText', {
defaultMessage: 'Options',
}) +
Expand Down Expand Up @@ -150,7 +152,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
'data.advancedSettings.sortOptionsText',
values: {
optionsLink:
'<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html" target="_blank" rel="noopener">' +
`<a href=${docLinks?.links.elasticsearch.sortSearch} target="_blank" rel="noopener">` +
i18n.translate('data.advancedSettings.sortOptions.optionsLinkText', {
defaultMessage: 'Options',
}) +
Expand Down Expand Up @@ -232,7 +234,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
setRequestReferenceSetting: `<strong>${UI_SETTINGS.COURIER_SET_REQUEST_PREFERENCE}</strong>`,
customSettingValue: '"custom"',
requestPreferenceLink:
'<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-preference.html" target="_blank" rel="noopener">' +
`<a href=${docLinks.links.apis.searchPreference} target="_blank" rel="noopener">` +
i18n.translate(
'data.advancedSettings.courier.customRequestPreference.requestPreferenceLinkText',
{
Expand All @@ -256,7 +258,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
'Controls the {maxRequestsLink} setting used for _msearch requests sent by Kibana. ' +
'Set to 0 to disable this config and use the Elasticsearch default.',
values: {
maxRequestsLink: `<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html"
maxRequestsLink: `<a href=${docLinks.links.apis.multiSearch}
target="_blank" rel="noopener" >max_concurrent_shard_requests</a>`,
},
}),
Expand All @@ -265,7 +267,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
},
[UI_SETTINGS.SEARCH_INCLUDE_FROZEN]: {
name: 'Search in frozen indices',
description: `Will include <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen-indices.html"
description: `Will include <a href=${docLinks.links.elasticsearch.frozenIndices}
target="_blank" rel="noopener">frozen indices</a> in results if enabled. Searching through frozen indices
might increase the search time.`,
value: false,
Expand Down Expand Up @@ -444,7 +446,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
'data.advancedSettings.timepicker.quickRanges.acceptedFormatsLinkText',
values: {
acceptedFormatsLink:
`<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math"
`<a href=${docLinks.links.date.dateMath}
target="_blank" rel="noopener">` +
i18n.translate('data.advancedSettings.timepicker.quickRanges.acceptedFormatsLinkText', {
defaultMessage: 'accepted formats',
Expand Down Expand Up @@ -495,7 +497,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
'Elasticsearch terms aggregation. {learnMoreLink}',
values: {
learnMoreLink:
'<a href="https://www.elastic.co/guide/en/kibana/current/kibana-concepts-analysts.html#autocomplete-suggestions" target="_blank" rel="noopener">' +
`<a href=${docLinks.links.kibana.autocompleteSuggestions} target="_blank" rel="noopener">` +
i18n.translate('data.advancedSettings.autocompleteValueSuggestionMethodLink', {
defaultMessage: 'Learn more.',
}) +
Expand All @@ -517,7 +519,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
'Disable this property to get autocomplete suggestions from your full dataset, rather than from the current time range. {learnMoreLink}',
values: {
learnMoreLink:
'<a href="https://www.elastic.co/guide/en/kibana/current/kibana-concepts-analysts.html#autocomplete-suggestions" target="_blank" rel="noopener">' +
`<a href=${docLinks.links.kibana.autocompleteSuggestions} target="_blank" rel="noopener">` +
i18n.translate('data.advancedSettings.autocompleteValueSuggestionMethodLearnMoreLink', {
defaultMessage: 'Learn more.',
}) +
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/discover/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { searchSavedObjectType } from './saved_objects';
export class DiscoverServerPlugin implements Plugin<object, object> {
public setup(core: CoreSetup) {
core.capabilities.registerProvider(capabilitiesProvider);
core.uiSettings.register(getUiSettings());
core.uiSettings.register(getUiSettings(core.docLinks));
core.savedObjects.registerType(searchSavedObjectType);

return {};
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/discover/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { i18n } from '@kbn/i18n';
import { schema } from '@kbn/config-schema';

import { UiSettingsParams } from 'kibana/server';
import type { DocLinksServiceSetup, UiSettingsParams } from 'kibana/server';
import { METRIC_TYPE } from '@kbn/analytics';
import {
DEFAULT_COLUMNS_SETTING,
Expand All @@ -31,7 +31,9 @@ import {
ROW_HEIGHT_OPTION,
} from '../common';

export const getUiSettings: () => Record<string, UiSettingsParams> = () => ({
export const getUiSettings: (docLinks: DocLinksServiceSetup) => Record<string, UiSettingsParams> = (
docLinks: DocLinksServiceSetup
) => ({
[DEFAULT_COLUMNS_SETTING]: {
name: i18n.translate('discover.advancedSettings.defaultColumnsTitle', {
defaultMessage: 'Default columns',
Expand Down Expand Up @@ -215,7 +217,7 @@ export const getUiSettings: () => Record<string, UiSettingsParams> = () => ({
defaultMessage: `Enable the {fieldStatisticsDocs} to show details such as the minimum and maximum values of a numeric field or a map of a geo field. This functionality is in beta and is subject to change.`,
values: {
fieldStatisticsDocs:
`<a href="https://www.elastic.co/guide/en/kibana/current/show-field-statistics.html"
`<a href=${docLinks.links.discover.fieldStatistics}
target="_blank" rel="noopener">` +
i18n.translate('discover.advancedSettings.discover.fieldStatisticsLinkText', {
defaultMessage: 'Field statistics view',
Expand All @@ -240,7 +242,7 @@ export const getUiSettings: () => Record<string, UiSettingsParams> = () => ({
defaultMessage: `Controls whether {multiFields} display in the expanded document view. In most cases, multi-fields are the same as the original field. This option is only available when \`searchFieldsFromSource\` is off.`,
values: {
multiFields:
`<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html"
`<a href=${docLinks.links.elasticsearch.mappingMultifields}
target="_blank" rel="noopener">` +
i18n.translate('discover.advancedSettings.discover.multiFieldsLinkText', {
defaultMessage: 'multi-fields',
Expand Down

0 comments on commit 2446d11

Please sign in to comment.