mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
* Fix links to the numeral formatting in the advanced settings (#84167) * Fix a link to the numeral formatting in the index pattern field settings (#84167) # Conflicts: # docs/development/core/public/kibana-plugin-core-public.doclinksstart.md # src/core/public/doc_links/doc_links_service.ts # src/plugins/index_pattern_field_editor/public/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.tsx.snap # src/plugins/index_pattern_field_editor/public/components/field_format_editor/editors/number/__snapshots__/number.test.tsx.snap # src/plugins/index_pattern_field_editor/public/components/field_format_editor/editors/number/number.tsx # src/plugins/index_pattern_field_editor/public/components/field_format_editor/editors/percent/__snapshots__/percent.test.tsx.snap # src/plugins/index_pattern_field_editor/public/components/field_format_editor/editors/percent/percent.test.tsx
This commit is contained in:
parent
91a6bff9bd
commit
37dfe5f746
12 changed files with 79 additions and 14 deletions
|
@ -101,6 +101,7 @@ readonly links: {
|
|||
readonly indexPatterns: {
|
||||
readonly loadingData: string;
|
||||
readonly introduction: string;
|
||||
readonly fieldFormattersNumber: string;
|
||||
};
|
||||
readonly addData: string;
|
||||
readonly kibana: string;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -121,6 +121,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`,
|
||||
|
@ -354,6 +355,7 @@ export interface DocLinksStart {
|
|||
readonly indexPatterns: {
|
||||
readonly loadingData: string;
|
||||
readonly introduction: string;
|
||||
readonly fieldFormattersNumber: string;
|
||||
};
|
||||
readonly addData: string;
|
||||
readonly kibana: string;
|
||||
|
|
|
@ -571,6 +571,7 @@ export interface DocLinksStart {
|
|||
readonly indexPatterns: {
|
||||
readonly loadingData: string;
|
||||
readonly introduction: string;
|
||||
readonly fieldFormattersNumber: string;
|
||||
};
|
||||
readonly addData: string;
|
||||
readonly kibana: string;
|
||||
|
|
|
@ -412,7 +412,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
|
|||
'data.advancedSettings.format.numberFormat.numeralFormatLinkText',
|
||||
values: {
|
||||
numeralFormatLink:
|
||||
'<a href="http://numeraljs.com/" target="_blank" rel="noopener noreferrer">' +
|
||||
'<a href="https://www.elastic.co/guide/en/kibana/current/numeral.html" target="_blank" rel="noopener">' +
|
||||
i18n.translate('data.advancedSettings.format.numberFormat.numeralFormatLinkText', {
|
||||
defaultMessage: 'numeral format',
|
||||
}) +
|
||||
|
@ -434,7 +434,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
|
|||
'data.advancedSettings.format.percentFormat.numeralFormatLinkText',
|
||||
values: {
|
||||
numeralFormatLink:
|
||||
'<a href="http://numeraljs.com/" target="_blank" rel="noopener noreferrer">' +
|
||||
'<a href="https://www.elastic.co/guide/en/kibana/current/numeral.html" target="_blank" rel="noopener">' +
|
||||
i18n.translate('data.advancedSettings.format.percentFormat.numeralFormatLinkText', {
|
||||
defaultMessage: 'numeral format',
|
||||
}) +
|
||||
|
@ -456,7 +456,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
|
|||
'data.advancedSettings.format.bytesFormat.numeralFormatLinkText',
|
||||
values: {
|
||||
numeralFormatLink:
|
||||
'<a href="http://numeraljs.com/" target="_blank" rel="noopener noreferrer">' +
|
||||
'<a href="https://www.elastic.co/guide/en/kibana/current/numeral.html" target="_blank" rel="noopener">' +
|
||||
i18n.translate('data.advancedSettings.format.bytesFormat.numeralFormatLinkText', {
|
||||
defaultMessage: 'numeral format',
|
||||
}) +
|
||||
|
@ -478,7 +478,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
|
|||
'data.advancedSettings.format.currencyFormat.numeralFormatLinkText',
|
||||
values: {
|
||||
numeralFormatLink:
|
||||
'<a href="http://numeraljs.com/" target="_blank" rel="noopener noreferrer">' +
|
||||
'<a href="https://www.elastic.co/guide/en/kibana/current/numeral.html" target="_blank" rel="noopener">' +
|
||||
i18n.translate('data.advancedSettings.format.currencyFormat.numeralFormatLinkText', {
|
||||
defaultMessage: 'numeral format',
|
||||
}) +
|
||||
|
@ -504,7 +504,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
|
|||
'data.advancedSettings.format.formattingLocaleText',
|
||||
values: {
|
||||
numeralLanguageLink:
|
||||
'<a href="http://numeraljs.com/" target="_blank" rel="noopener noreferrer">' +
|
||||
'<a href="https://www.elastic.co/guide/en/kibana/current/numeral.html" target="_blank" rel="noopener">' +
|
||||
i18n.translate(
|
||||
'data.advancedSettings.format.formattingLocale.numeralLanguageLinkText',
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ exports[`BytesFormatEditor should render normally 1`] = `
|
|||
helpText={
|
||||
<span>
|
||||
<EuiLink
|
||||
href="https://adamwdraper.github.io/Numeral-js/"
|
||||
href="https://www.elastic.co/guide/en/kibana/mocked-test-branch/numeral.html"
|
||||
target="_blank"
|
||||
>
|
||||
<FormattedMessage
|
||||
|
|
|
@ -8,9 +8,13 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { coreMock } from 'src/core/public/mocks';
|
||||
import { createKibanaReactContext } from '../../../../../../../../kibana_react/public';
|
||||
import { FieldFormat } from 'src/plugins/data/public';
|
||||
|
||||
import { BytesFormatEditor } from './bytes';
|
||||
import { FieldFormat } from 'src/plugins/data/public';
|
||||
|
||||
type BytesFormatEditorProps = React.ComponentProps<typeof BytesFormatEditor>;
|
||||
|
||||
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<BytesFormatEditorProps>).contextTypes = {
|
||||
services: () => null,
|
||||
};
|
||||
delete (BytesFormatEditor as Partial<typeof BytesFormatEditor>).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();
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ exports[`NumberFormatEditor should render normally 1`] = `
|
|||
helpText={
|
||||
<span>
|
||||
<EuiLink
|
||||
href="https://adamwdraper.github.io/Numeral-js/"
|
||||
href="https://www.elastic.co/guide/en/kibana/mocked-test-branch/numeral.html"
|
||||
target="_blank"
|
||||
>
|
||||
<FormattedMessage
|
||||
|
|
|
@ -8,10 +8,14 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { coreMock } from 'src/core/public/mocks';
|
||||
import { createKibanaReactContext } from '../../../../../../../../kibana_react/public';
|
||||
import { FieldFormat } from 'src/plugins/data/public';
|
||||
|
||||
import { NumberFormatEditor } from './number';
|
||||
|
||||
type NumberFormatEditorProps = React.ComponentProps<typeof NumberFormatEditor>;
|
||||
|
||||
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<NumberFormatEditorProps>).contextTypes = {
|
||||
services: () => null,
|
||||
};
|
||||
delete (NumberFormatEditor as Partial<typeof NumberFormatEditor>).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();
|
||||
});
|
||||
|
|
|
@ -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<NumberFormatEditorParams> {
|
||||
static contextType = contextType;
|
||||
static formatId = 'number';
|
||||
|
||||
context!: React.ContextType<typeof contextType>;
|
||||
state = {
|
||||
...defaultState,
|
||||
sampleInputs: [10000, 12.345678, -1, -999, 0.52],
|
||||
|
@ -43,7 +47,10 @@ export class NumberFormatEditor extends DefaultFormatEditor<NumberFormatEditorPa
|
|||
}
|
||||
helpText={
|
||||
<span>
|
||||
<EuiLink target="_blank" href="https://adamwdraper.github.io/Numeral-js/">
|
||||
<EuiLink
|
||||
target="_blank"
|
||||
href={this.context.services.docLinks?.links.indexPatterns.fieldFormattersNumber}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="indexPatternManagement.number.documentationLabel"
|
||||
defaultMessage="Documentation"
|
||||
|
|
|
@ -11,7 +11,7 @@ exports[`PercentFormatEditor should render normally 1`] = `
|
|||
helpText={
|
||||
<span>
|
||||
<EuiLink
|
||||
href="https://adamwdraper.github.io/Numeral-js/"
|
||||
href="https://www.elastic.co/guide/en/kibana/mocked-test-branch/numeral.html"
|
||||
target="_blank"
|
||||
>
|
||||
<FormattedMessage
|
||||
|
|
|
@ -8,10 +8,14 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { coreMock } from 'src/core/public/mocks';
|
||||
import { createKibanaReactContext } from '../../../../../../../../kibana_react/public';
|
||||
import { FieldFormat } from '../../../../../../../../data/public';
|
||||
|
||||
import { PercentFormatEditor } from './percent';
|
||||
|
||||
type PercentFormatEditorProps = React.ComponentProps<typeof PercentFormatEditor>;
|
||||
|
||||
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<PercentFormatEditorProps>).contextTypes = {
|
||||
services: () => null,
|
||||
};
|
||||
delete (PercentFormatEditor as Partial<typeof PercentFormatEditor>).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();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue