diff --git a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md index 522c01124de82..1a885b2b2a0a2 100644 --- a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md +++ b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md @@ -84,6 +84,7 @@ readonly links: { readonly indexPatterns: { readonly loadingData: string; readonly introduction: string; + readonly fieldFormattersNumber: string; }; readonly addData: string; readonly kibana: string; diff --git a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md index 2bb885cba434f..06752d7ca18df 100644 --- a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md +++ b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md @@ -17,5 +17,5 @@ export interface DocLinksStart | --- | --- | --- | | [DOC\_LINK\_VERSION](./kibana-plugin-core-public.doclinksstart.doc_link_version.md) | string | | | [ELASTIC\_WEBSITE\_URL](./kibana-plugin-core-public.doclinksstart.elastic_website_url.md) | string | | -| [links](./kibana-plugin-core-public.doclinksstart.links.md) | {
readonly dashboard: {
readonly guide: string;
readonly drilldowns: string;
readonly drilldownsTriggerPicker: string;
readonly urlDrilldownTemplateSyntax: string;
readonly urlDrilldownVariables: string;
};
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 addData: string;
readonly kibana: string;
readonly siem: {
readonly guide: string;
readonly gettingStarted: string;
};
readonly query: {
readonly eql: string;
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
};
readonly management: Record<string, string>;
readonly ml: Record<string, string>;
readonly visualize: Record<string, string>;
} | | +| [links](./kibana-plugin-core-public.doclinksstart.links.md) | {
readonly dashboard: {
readonly guide: string;
readonly drilldowns: string;
readonly drilldownsTriggerPicker: string;
readonly urlDrilldownTemplateSyntax: string;
readonly urlDrilldownVariables: string;
};
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 fieldFormattersNumber: string;
};
readonly addData: string;
readonly kibana: string;
readonly siem: {
readonly guide: string;
readonly gettingStarted: string;
};
readonly query: {
readonly eql: string;
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
};
readonly management: Record<string, string>;
readonly ml: Record<string, string>;
readonly visualize: Record<string, string>;
} | | diff --git a/src/core/public/doc_links/doc_links_service.ts b/src/core/public/doc_links/doc_links_service.ts index 637442de7f961..65288deb17360 100644 --- a/src/core/public/doc_links/doc_links_service.ts +++ b/src/core/public/doc_links/doc_links_service.ts @@ -101,6 +101,7 @@ export class DocLinksService { 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`, + fieldFormattersNumber: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/numeral.html`, }, addData: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/connect-to-elasticsearch.html`, kibana: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index.html`, @@ -230,6 +231,7 @@ export interface DocLinksStart { readonly indexPatterns: { readonly loadingData: string; readonly introduction: string; + readonly fieldFormattersNumber: string; }; readonly addData: string; readonly kibana: string; diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index 33ebddc1163c1..8cff784f6fe6f 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -556,6 +556,7 @@ export interface DocLinksStart { readonly indexPatterns: { readonly loadingData: string; readonly introduction: string; + readonly fieldFormattersNumber: string; }; readonly addData: string; readonly kibana: string; diff --git a/src/plugins/data/server/ui_settings.ts b/src/plugins/data/server/ui_settings.ts index 2df6e4cc34f10..8ab24df33c86a 100644 --- a/src/plugins/data/server/ui_settings.ts +++ b/src/plugins/data/server/ui_settings.ts @@ -392,7 +392,7 @@ export function getUiSettings(): Record> { 'data.advancedSettings.format.numberFormat.numeralFormatLinkText', values: { numeralFormatLink: - '' + + '' + i18n.translate('data.advancedSettings.format.numberFormat.numeralFormatLinkText', { defaultMessage: 'numeral format', }) + @@ -414,7 +414,7 @@ export function getUiSettings(): Record> { 'data.advancedSettings.format.percentFormat.numeralFormatLinkText', values: { numeralFormatLink: - '' + + '' + i18n.translate('data.advancedSettings.format.percentFormat.numeralFormatLinkText', { defaultMessage: 'numeral format', }) + @@ -436,7 +436,7 @@ export function getUiSettings(): Record> { 'data.advancedSettings.format.bytesFormat.numeralFormatLinkText', values: { numeralFormatLink: - '' + + '' + i18n.translate('data.advancedSettings.format.bytesFormat.numeralFormatLinkText', { defaultMessage: 'numeral format', }) + @@ -458,7 +458,7 @@ export function getUiSettings(): Record> { 'data.advancedSettings.format.currencyFormat.numeralFormatLinkText', values: { numeralFormatLink: - '' + + '' + i18n.translate('data.advancedSettings.format.currencyFormat.numeralFormatLinkText', { defaultMessage: 'numeral format', }) + @@ -484,7 +484,7 @@ export function getUiSettings(): Record> { 'data.advancedSettings.format.formattingLocaleText', values: { numeralLanguageLink: - '' + + '' + i18n.translate( 'data.advancedSettings.format.formattingLocale.numeralLanguageLinkText', { diff --git a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.tsx.snap b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.tsx.snap index 69ea6c481d49b..24ce19710b360 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.tsx.snap @@ -11,7 +11,7 @@ exports[`BytesFormatEditor should render normally 1`] = ` helpText={ ; const fieldType = 'number'; const format = { @@ -25,7 +29,20 @@ const formatParams = { const onChange = jest.fn(); const onError = jest.fn(); +const KibanaReactContext = createKibanaReactContext( + coreMock.createStart({ basePath: 'my-base-path' }) +); + describe('BytesFormatEditor', () => { + beforeAll(() => { + // Enzyme does not support the new Context API in shallow rendering. + // @see https://github.com/enzymejs/enzyme/issues/2189 + (BytesFormatEditor as React.ComponentType).contextTypes = { + services: () => null, + }; + delete (BytesFormatEditor as Partial).contextType; + }); + it('should have a formatId', () => { expect(BytesFormatEditor.formatId).toEqual('bytes'); }); @@ -38,7 +55,8 @@ describe('BytesFormatEditor', () => { formatParams={formatParams} onChange={onChange} onError={onError} - /> + />, + { context: KibanaReactContext.value } ); expect(component).toMatchSnapshot(); }); diff --git a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/number/__snapshots__/number.test.tsx.snap b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/number/__snapshots__/number.test.tsx.snap index c73b5e7186547..0d74b583b30d1 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/number/__snapshots__/number.test.tsx.snap +++ b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/number/__snapshots__/number.test.tsx.snap @@ -11,7 +11,7 @@ exports[`NumberFormatEditor should render normally 1`] = ` helpText={ ; + const fieldType = 'number'; const format = { getConverterFor: jest.fn().mockImplementation(() => (input: number) => input * 2), @@ -25,7 +29,20 @@ const formatParams = { const onChange = jest.fn(); const onError = jest.fn(); +const KibanaReactContext = createKibanaReactContext( + coreMock.createStart({ basePath: 'my-base-path' }) +); + describe('NumberFormatEditor', () => { + beforeAll(() => { + // Enzyme does not support the new Context API in shallow rendering. + // @see https://github.com/enzymejs/enzyme/issues/2189 + (NumberFormatEditor as React.ComponentType).contextTypes = { + services: () => null, + }; + delete (NumberFormatEditor as Partial).contextType; + }); + it('should have a formatId', () => { expect(NumberFormatEditor.formatId).toEqual('number'); }); @@ -38,7 +55,8 @@ describe('NumberFormatEditor', () => { formatParams={formatParams} onChange={onChange} onError={onError} - /> + />, + { context: KibanaReactContext.value } ); expect(component).toMatchSnapshot(); }); diff --git a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/number/number.tsx b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/number/number.tsx index 250bbe570a9c4..067bfb914e388 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/number/number.tsx +++ b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/number/number.tsx @@ -14,13 +14,17 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { DefaultFormatEditor, defaultState } from '../default'; import { FormatEditorSamples } from '../../samples'; +import { context as contextType } from '../../../../../../../../kibana_react/public'; export interface NumberFormatEditorParams { pattern: string; } export class NumberFormatEditor extends DefaultFormatEditor { + static contextType = contextType; static formatId = 'number'; + + context!: React.ContextType; state = { ...defaultState, sampleInputs: [10000, 12.345678, -1, -999, 0.52], @@ -43,7 +47,10 @@ export class NumberFormatEditor extends DefaultFormatEditor - + ; + const fieldType = 'number'; const format = { getConverterFor: jest.fn().mockImplementation(() => (input: number) => input * 2), @@ -25,7 +29,20 @@ const formatParams = { const onChange = jest.fn(); const onError = jest.fn(); +const KibanaReactContext = createKibanaReactContext( + coreMock.createStart({ basePath: 'my-base-path' }) +); + describe('PercentFormatEditor', () => { + beforeAll(() => { + // Enzyme does not support the new Context API in shallow rendering. + // @see https://github.com/enzymejs/enzyme/issues/2189 + (PercentFormatEditor as React.ComponentType).contextTypes = { + services: () => null, + }; + delete (PercentFormatEditor as Partial).contextType; + }); + it('should have a formatId', () => { expect(PercentFormatEditor.formatId).toEqual('percent'); }); @@ -38,7 +55,8 @@ describe('PercentFormatEditor', () => { formatParams={formatParams} onChange={onChange} onError={onError} - /> + />, + { context: KibanaReactContext.value } ); expect(component).toMatchSnapshot(); });