From 677136eaabc0302f414a533b03db4457ab929802 Mon Sep 17 00:00:00 2001 From: Maryia Lapata Date: Mon, 30 Jul 2018 21:33:01 +0300 Subject: [PATCH] Localization "Index Patterns" tab (#20525) * Integrate i18n-engine into "Index Patterns" tab * Adjusted unit tests for "Index Patterns" tab * Localization of "Index patterns" section name * Rename the function shallowIntl to shallowWithIntl, remove needless check for translation type id * Refactoring of default message * Localization for FieldEditor component * Adjust unit tests for FieldEditor component * Integrate i18n-engine into "Index Patterns" tab * Adjusted unit tests for "Index Patterns" tab * Localization of "Index patterns" section name * Rename the function shallowIntl to shallowWithIntl, remove needless check for translation type id * Refactoring of default message * Localization for FieldEditor component * Adjust unit tests for FieldEditor component * Replace I18nContext to injectI18n according to changes in @kbn/i18n * Fix broken saving form * Adjust components importing according to changes in @kbn/i18n * Formatting and refactoring * Update ids * Fix invalid HTML and refactoring * Use i18n module instead of AngularJS service * Localize scripting_syntax.js, refactoring * Update message ids. * fix plural form in status messages * fix messages in status message, _field component * move back span in time_field * refactor enzyme helper for providing intl into context * do not translate Painless * test call params in formatMessage * clear formatMessage mock after each test Co-authored-by: maryia-lapata --- .../__snapshots__/empty_state.test.js.snap | 74 ++-- .../components/empty_state/empty_state.js | 59 ++- .../__snapshots__/header.test.js.snap | 40 +- .../components/header/header.js | 20 +- .../__snapshots__/loading_state.test.js.snap | 12 +- .../components/loading_state/loading_state.js | 14 +- .../step_index_pattern.test.js.snap | 66 +++- .../__tests__/step_index_pattern.test.js | 19 +- .../__snapshots__/header.test.js.snap | 104 +++-- .../header/__tests__/header.test.js | 12 +- .../components/header/header.js | 43 ++- .../__snapshots__/indices_list.test.js.snap | 55 ++- .../components/indices_list/indices_list.js | 8 +- .../loading_indices.test.js.snap | 12 +- .../loading_indices/loading_indices.js | 12 +- .../__snapshots__/status_message.test.js.snap | 121 ++++-- .../status_message/status_message.js | 89 ++++- .../step_index_pattern/step_index_pattern.js | 29 +- .../step_time_field.test.js.snap | 6 +- .../__tests__/step_time_field.test.js | 40 +- .../action_buttons/action_buttons.js | 12 +- .../advanced_options.test.js.snap | 16 +- .../__tests__/advanced_options.test.js | 12 +- .../advanced_options/advanced_options.js | 40 +- .../__snapshots__/header.test.js.snap | 24 +- .../components/header/header.js | 16 +- .../__snapshots__/time_field.test.js.snap | 72 +++- .../time_field/__tests__/time_field.test.js | 20 +- .../components/time_field/time_field.js | 48 ++- .../step_time_field/step_time_field.js | 15 +- .../lib/extract_time_fields.js | 12 +- .../create_index_pattern_wizard/render.js | 12 +- .../create_edit_field/create_edit_field.js | 44 ++- .../edit_index_pattern.html | 45 ++- .../edit_index_pattern/edit_index_pattern.js | 104 ++--- .../edit_index_pattern/edit_sections.js | 7 +- .../edit_index_pattern/field_controls.html | 4 +- .../index_header/index_header.html | 12 +- .../indexed_fields_table.test.js.snap | 174 ++++----- .../components/table/__tests__/table.test.js | 35 +- .../components/table/table.js | 75 +++- .../indexed_fields_table.js | 18 +- .../scripted_field_table.test.js.snap | 338 +++++++++-------- .../__tests__/scripted_field_table.test.js | 28 +- .../__snapshots__/call_outs.test.js.snap | 27 +- .../call_outs/__tests__/call_outs.test.js | 12 +- .../components/call_outs/call_outs.js | 26 +- .../__snapshots__/header.test.js.snap | 18 +- .../components/header/header.js | 15 +- .../components/table/__tests__/table.test.js | 19 +- .../components/table/table.js | 38 +- .../scripted_fields_table.js | 47 ++- .../source_filters_table.test.js.snap | 109 +++--- .../__tests__/source_filters_table.test.js | 39 +- .../__snapshots__/add_filter.test.js.snap | 12 +- .../add_filter/__tests__/add_filter.test.js | 16 +- .../components/add_filter/add_filter.js | 15 +- .../__snapshots__/header.test.js.snap | 18 +- .../components/header/header.js | 27 +- .../components/table/__tests__/table.test.js | 32 +- .../components/table/table.js | 38 +- .../source_filters_table.js | 16 +- .../management/sections/indices/index.html | 14 +- .../management/sections/indices/index.js | 8 +- src/test_utils/public/enzyme_helpers.js | 58 +++ src/test_utils/public/mocks/intl.js | 30 ++ .../__snapshots__/field_editor.test.js.snap | 356 ++++++++++++------ .../bytes/__snapshots__/bytes.test.js.snap | 27 +- .../color/__snapshots__/color.test.js.snap | 18 +- .../editors/color/color.js | 26 +- .../editors/color/color.test.js | 17 +- .../date/__snapshots__/date.test.js.snap | 27 +- .../field_format_editor/editors/date/date.js | 15 +- .../editors/default/default.js | 6 +- .../__snapshots__/duration.test.js.snap | 44 ++- .../editors/duration/duration.js | 13 +- .../number/__snapshots__/number.test.js.snap | 27 +- .../editors/number/number.js | 13 +- .../__snapshots__/percent.test.js.snap | 27 +- .../__snapshots__/static_lookup.test.js.snap | 12 +- .../editors/static_lookup/static_lookup.js | 25 +- .../static_lookup/static_lookup.test.js | 12 +- .../string/__snapshots__/string.test.js.snap | 10 +- .../editors/string/string.js | 4 +- .../__snapshots__/truncate.test.js.snap | 10 +- .../editors/truncate/truncate.js | 4 +- .../label_template_flyout.test.js.snap | 44 ++- .../url/__snapshots__/url.test.js.snap | 108 ++++-- .../url_template_flyout.test.js.snap | 55 ++- .../editors/url/label_template_flyout.js | 54 ++- .../editors/url/label_template_flyout.test.js | 12 +- .../field_format_editor/editors/url/url.js | 19 +- .../editors/url/url_template_flyout.js | 50 ++- .../editors/url/url_template_flyout.test.js | 12 +- .../field_format_editor/samples/samples.js | 14 +- .../samples/samples.test.js | 12 +- .../disabled_call_out.test.js.snap | 6 +- .../warning_call_out.test.js.snap | 75 ++-- .../scripting_call_outs/disabled_call_out.js | 18 +- .../disabled_call_out.test.js | 12 +- .../scripting_call_outs/warning_call_out.js | 57 +-- .../warning_call_out.test.js | 12 +- .../scripting_help/scripting_syntax.js | 201 +++++++--- src/ui/public/field_editor/field_editor.js | 187 +++++++-- .../public/field_editor/field_editor.test.js | 20 +- .../field_editor/lib/get_default_format.js | 4 +- .../__tests__/_index_pattern.test.js | 3 +- src/ui/public/index_patterns/_field.js | 11 +- .../public/index_patterns/_index_pattern.js | 38 +- src/ui/public/index_patterns/_intervals.js | 18 +- .../route_setup/load_default.js | 6 +- 111 files changed, 3030 insertions(+), 1363 deletions(-) create mode 100644 src/test_utils/public/enzyme_helpers.js create mode 100644 src/test_utils/public/mocks/intl.js diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/__tests__/__snapshots__/empty_state.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/__tests__/__snapshots__/empty_state.test.js.snap index 981a64b1adca9..8fae8c92fd817 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/__tests__/__snapshots__/empty_state.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/__tests__/__snapshots__/empty_state.test.js.snap @@ -33,7 +33,11 @@ exports[`EmptyState should render normally 1`] = ` } } > - Couldn't find any Elasticsearch data + @@ -44,28 +48,46 @@ exports[`EmptyState should render normally 1`] = ` grow={true} >

- - You'll need to index some data into Elasticsearch before you can create an index pattern. - -   - - Learn how - - or - - get started with some sample data sets. - + + + , + "learnHowLink": + + , + "needToIndex": + + , + } + } + />

- Check for new data + diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/empty_state.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/empty_state.js index 304f3875cc05e..ab068b92d9267 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/empty_state.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/empty_state.js @@ -32,6 +32,8 @@ import { EuiButton, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; + export const EmptyState = ({ onRefresh, }) => ( @@ -40,27 +42,47 @@ export const EmptyState = ({ -

Couldn't find any Elasticsearch data

+

+ +

- - You'll need to index some data into Elasticsearch before you can create an index pattern. - -   - - Learn how - - {' or '} - - get started with some sample data sets. - + + + + ), + learnHowLink: ( + + + + ), + getStartedLink: ( + + + + ) + }} + />

@@ -73,7 +95,10 @@ export const EmptyState = ({ onClick={onRefresh} data-test-subj="refreshIndicesButton" > - Check for new data +
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/__tests__/__snapshots__/header.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/__tests__/__snapshots__/header.test.js.snap index 3572d2d788dc3..3f072dcb8bfeb 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/__tests__/__snapshots__/header.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/__tests__/__snapshots__/header.test.js.snap @@ -9,7 +9,11 @@ exports[`Header should render normally 1`] = ` size="m" >

- Create index pattern +

- Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations. +

@@ -45,7 +53,13 @@ exports[`Header should render normally 1`] = ` + } onChange={[Function]} /> @@ -65,7 +79,11 @@ exports[`Header should render without including system indices 1`] = ` size="m" >

- Create index pattern +

- Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations. +

@@ -101,7 +123,13 @@ exports[`Header should render without including system indices 1`] = ` + } onChange={[Function]} /> diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/header.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/header.js index 67e455e01f82c..0c7ba277ff6ab 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/header.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/header.js @@ -29,6 +29,8 @@ import { EuiSwitch, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; + export const Header = ({ isIncludingSystemIndices, onChangeIncludingSystemIndices, @@ -36,22 +38,34 @@ export const Header = ({
-

Create index pattern

+

+ +

+

- Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations. +

} id="checkboxShowSystemIndices" - label="Include system indices" checked={isIncludingSystemIndices} onChange={onChangeIncludingSystemIndices} /> diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/__tests__/__snapshots__/loading_state.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/__tests__/__snapshots__/loading_state.test.js.snap index e724e73eb2a53..d1e5bdc3ff55f 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/__tests__/__snapshots__/loading_state.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/__tests__/__snapshots__/loading_state.test.js.snap @@ -33,7 +33,11 @@ exports[`LoadingState should render normally 1`] = ` } } > - Checking for Elasticsearch data + @@ -66,7 +70,11 @@ exports[`LoadingState should render normally 1`] = ` grow={true} size="s" > - Reticulating splines... +
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/loading_state.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/loading_state.js index 692f76cc29a2f..f416b29c989c9 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/loading_state.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/loading_state.js @@ -30,13 +30,20 @@ import { EuiTitle, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; + export const LoadingState = () => ( -

Checking for Elasticsearch data

+

+ +

@@ -49,7 +56,10 @@ export const LoadingState = () => ( - Reticulating splines... +
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/__snapshots__/step_index_pattern.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/__snapshots__/step_index_pattern.test.js.snap index 6aafbb2efad43..6e1a64e823e41 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/__snapshots__/step_index_pattern.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/__snapshots__/step_index_pattern.test.js.snap @@ -1,20 +1,60 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`StepIndexPattern renders errors when input is invalid 1`] = ` -
, |" - data-test-subj="createIndexPatternStep1Header" - errors={ +Object { + "component": , |" + data-test-subj="createIndexPatternStep1Header" + errors={ + Array [ + "An index pattern cannot contain spaces or the characters: {characterList}", + ] + } + goToNextStep={[Function]} + isInputInvalid={true} + isNextStepDisabled={true} + onQueryChanged={[Function]} + query="?" + />, + "i18n": Array [ Array [ - "An index pattern cannot contain spaces or the characters: \\\\, /, ?, \\", <, >, |", - ] - } - goToNextStep={[Function]} - isInputInvalid={true} - isNextStepDisabled={true} - onQueryChanged={[Function]} - query="?" -/> + Object { + "defaultMessage": "An index pattern cannot contain spaces or the characters: {characterList}", + "id": "kbn.management.createIndexPattern.step.invalidCharactersErrorMessage", + }, + Object { + "characterList": "\\\\, /, ?, \\", <, >, |", + }, + ], + Array [ + Object { + "defaultMessage": "An index pattern cannot contain spaces or the characters: {characterList}", + "id": "kbn.management.createIndexPattern.step.invalidCharactersErrorMessage", + }, + Object { + "characterList": "\\\\, /, ?, \\", <, >, |", + }, + ], + Array [ + Object { + "defaultMessage": "An index pattern cannot contain spaces or the characters: {characterList}", + "id": "kbn.management.createIndexPattern.step.invalidCharactersErrorMessage", + }, + Object { + "characterList": "\\\\, /, ?, \\", <, >, |", + }, + ], + Array [ + Object { + "defaultMessage": "An index pattern cannot contain spaces or the characters: {characterList}", + "id": "kbn.management.createIndexPattern.step.invalidCharactersErrorMessage", + }, + Object { + "characterList": "\\\\, /, ?, \\", <, >, |", + }, + ], + ], +} `; exports[`StepIndexPattern renders indices which match the initial query 1`] = ` diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/step_index_pattern.test.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/step_index_pattern.test.js index f434f88c25497..3b05ec4b71ec4 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/step_index_pattern.test.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/step_index_pattern.test.js @@ -18,8 +18,9 @@ */ import React from 'react'; -import { shallow } from 'enzyme'; -import { StepIndexPattern } from '../step_index_pattern'; +import { StepIndexPatternComponent } from '../step_index_pattern'; +import { shallowWithIntl, intl } from 'test_utils/enzyme_helpers'; +import { Header } from '../components/header'; jest.mock('../../../lib/ensure_minimum_time', () => ({ ensureMinimumTime: async (promises) => Array.isArray(promises) ? await Promise.all(promises) : await promises @@ -53,8 +54,8 @@ const savedObjectsClient = { const goToNextStep = () => {}; const createComponent = props => { - return shallow( - { }; describe('StepIndexPattern', () => { + afterEach(() => intl.formatMessage.mockClear()); + it('renders the loading state', () => { const component = createComponent(); component.setState({ isLoadingIndices: true }); @@ -92,8 +95,10 @@ describe('StepIndexPattern', () => { await new Promise(resolve => process.nextTick(resolve)); // Ensure the state changes are reflected component.update(); - - expect(component.find('[data-test-subj="createIndexPatternStep1Header"]')).toMatchSnapshot(); + expect({ + component: component.find('[data-test-subj="createIndexPatternStep1Header"]'), + i18n: intl.formatMessage.mock.calls, + }).toMatchSnapshot(); }); it('renders matching indices when input is valid', async () => { @@ -119,7 +124,7 @@ describe('StepIndexPattern', () => { it('disables the next step if the index pattern exists', async () => { const component = createComponent(); component.setState({ indexPatternExists: true }); - expect(component.find('Header').prop('isNextStepDisabled')).toBe(true); + expect(component.find(Header).prop('isNextStepDisabled')).toBe(true); }); it('ensures the response of the latest request is persisted', async () => { diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/__snapshots__/header.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/__snapshots__/header.test.js.snap index e8f55b9c86dee..56622bbf677e7 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/__snapshots__/header.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/__snapshots__/header.test.js.snap @@ -6,7 +6,11 @@ exports[`Header should mark the input as invalid 1`] = ` size="s" >

- Step 1 of 2: Define index pattern +

- You can use a - - * - - as a wildcard in your index pattern. + + * + , + } + } + />

- You can't use spaces or the characters - - % - - . + + % + , + } + } + />

} isInvalid={true} - label="Index pattern" + label={ + + } > - Next step +
@@ -99,7 +125,11 @@ exports[`Header should render normally 1`] = ` size="s" >

- Step 1 of 2: Define index pattern +

- You can use a - - * - - as a wildcard in your index pattern. + + * + , + } + } + />

- You can't use spaces or the characters - - % - - . + + % + , + } + } + />

} isInvalid={false} - label="Index pattern" + label={ + + } > - Next step +
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/header.test.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/header.test.js index 5a21bc53a3a2e..975b627c9a7d1 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/header.test.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/header.test.js @@ -18,13 +18,13 @@ */ import React from 'react'; -import { Header } from '../header'; -import { shallow } from 'enzyme'; +import { HeaderComponent } from '../header'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; describe('Header', () => { it('should render normally', () => { - const component = shallow( -
{ }); it('should mark the input as invalid', () => { - const component = shallow( -
(

- Step 1 of 2: Define index pattern +

@@ -53,19 +59,37 @@ export const Header = ({ isInvalid={isInputInvalid} > } isInvalid={isInputInvalid} error={errors} helpText={
-

You can use a * as a wildcard in your index pattern.

-

You can't use spaces or the characters {characterList}.

+

+ * }} + /> +

+

+ {characterList} }} + /> +

} > - Next step +
); + +export const Header = injectI18n(HeaderComponent); diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__tests__/__snapshots__/indices_list.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__tests__/__snapshots__/indices_list.test.js.snap index b0d1d6396047f..943303f0bfdb2 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__tests__/__snapshots__/indices_list.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__tests__/__snapshots__/indices_list.test.js.snap @@ -55,8 +55,15 @@ exports[`IndicesList should change pages 1`] = ` size="s" type="button" > - Rows per page: - 1 + } closePopover={[Function]} @@ -152,8 +159,15 @@ exports[`IndicesList should change per page 1`] = ` size="s" type="button" > - Rows per page: - 1 + } closePopover={[Function]} @@ -274,8 +288,15 @@ exports[`IndicesList should highlight the query in the matches 1`] = ` size="s" type="button" > - Rows per page: - 10 + } closePopover={[Function]} @@ -381,8 +402,15 @@ exports[`IndicesList should render normally 1`] = ` size="s" type="button" > - Rows per page: - 10 + } closePopover={[Function]} @@ -568,8 +596,15 @@ exports[`IndicesList updating props should render all new indices 1`] = ` size="s" type="button" > - Rows per page: - 10 + } closePopover={[Function]} diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.js index f04de5d2fe80c..c8a1f89b18458 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.js @@ -40,6 +40,8 @@ import { Pager } from '@elastic/eui/lib/services'; +import { FormattedMessage } from '@kbn/i18n/react'; + export class IndicesList extends Component { static propTypes = { indices: PropTypes.array.isRequired, @@ -98,7 +100,11 @@ export class IndicesList extends Component { iconSide="right" onClick={this.openPerPageControl} > - Rows per page: {perPage} + ); diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__tests__/__snapshots__/loading_indices.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__tests__/__snapshots__/loading_indices.test.js.snap index 5ae2e4c84a63f..f5ffda2fa08c2 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__tests__/__snapshots__/loading_indices.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__tests__/__snapshots__/loading_indices.test.js.snap @@ -29,7 +29,11 @@ exports[`LoadingIndices should render normally 1`] = ` color="subdued" component="span" > - Looking for matching indices... + - Just a sec... + diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.js index dfbe4fea78bc2..bcf25cd363973 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.js @@ -27,6 +27,8 @@ import { EuiLoadingSpinner, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; + export const LoadingIndices = ({ ...rest }) => ( ( - Looking for matching indices... + - Just a sec... + diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__tests__/__snapshots__/status_message.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__tests__/__snapshots__/status_message.test.js.snap index 0fdb7a7a88182..41d1ee57bea20 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__tests__/__snapshots__/status_message.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__tests__/__snapshots__/status_message.test.js.snap @@ -15,16 +15,32 @@ exports[`StatusMessage should render with exact matches 1`] = ` />   - - Success! - -   Your index pattern matches - - 1 - - index - - . + + + , + "strongSuccess": + + , + } + } + /> @@ -40,12 +56,26 @@ exports[`StatusMessage should render with no partial matches 1`] = ` component="span" > - The index pattern you've entered doesn't match any indices. You can match any of your - - 2 - indices - - , below. + + + , + } + } + /> @@ -61,15 +91,26 @@ exports[`StatusMessage should render with partial matches 1`] = ` component="span" > - Your index pattern doesn't match any indices, but you have  - - 1 - - index - - which - looks - similar. + + + , + } + } + /> @@ -85,12 +126,18 @@ exports[`StatusMessage should render without a query 1`] = ` component="span" > - Your index pattern can match any of your - - 2 - indices - - , below. + + 2 + indices + , + } + } + /> @@ -106,7 +153,11 @@ exports[`StatusMessage should show that no indices exist 1`] = ` component="span" > - No Elasticsearch indices match your pattern. + @@ -122,7 +173,11 @@ exports[`StatusMessage should show that system indices exist 1`] = ` component="span" > - No Elasticsearch indices match your pattern. To view the matching system indices, toggle the switch in the upper right. + diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js index 4bd24c0c07b0d..a403925f24dd1 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js @@ -25,6 +25,8 @@ import { EuiIcon, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; + export const StatusMessage = ({ matchedIndices: { allIndices = [], @@ -38,21 +40,32 @@ export const StatusMessage = ({ let statusMessage; let statusColor; + const allIndicesLength = allIndices.length; + if (query.length === 0) { statusIcon = null; statusColor = 'default'; - if (allIndices.length > 1) { + + if (allIndicesLength > 1) { statusMessage = ( - Your index pattern can match any of your {allIndices.length} indices, below. + {allIndicesLength} indices) }} + /> ); } else if (!isIncludingSystemIndices) { statusMessage = ( - No Elasticsearch indices match your pattern. To view the matching system indices, toggle the switch in the upper right. + ); } @@ -60,7 +73,10 @@ export const StatusMessage = ({ // This should never really happen but let's handle it just in case statusMessage = ( - No Elasticsearch indices match your pattern. + ); } @@ -71,9 +87,27 @@ export const StatusMessage = ({ statusMessage = (   - Success! -   - Your index pattern matches {exactMatchedIndices.length} {exactMatchedIndices.length > 1 ? 'indices' : 'index'}. + + + ), + strongIndices: ( + + + ) + }} + /> ); } @@ -82,21 +116,46 @@ export const StatusMessage = ({ statusColor = 'default'; statusMessage = ( - Your index pattern doesn't match any indices, but you have  - - {partialMatchedIndices.length} {partialMatchedIndices.length > 1 ? 'indices ' : 'index '} - - which {partialMatchedIndices.length > 1 ? 'look' : 'looks'} similar. + + + ) + }} + /> ); } - else if (allIndices.length) { + else if (allIndicesLength) { statusIcon = null; statusColor = 'default'; statusMessage = ( - The index pattern you've entered doesn't match any indices. - You can match any of your {allIndices.length} indices, below. + + + ), + indicesLength: allIndicesLength, + }} + /> ); } diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js index cae0a1c8f4736..bf6468c3bf15b 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js @@ -38,11 +38,12 @@ import { EuiCallOut, } from '@elastic/eui'; +import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; import chrome from 'ui/chrome'; const uiSettings = chrome.getUiSettingsClient(); -export class StepIndexPattern extends Component { +export class StepIndexPatternComponent extends Component { static propTypes = { allIndices: PropTypes.array.isRequired, isIncludingSystemIndices: PropTypes.bool.isRequired, @@ -209,17 +210,26 @@ export class StepIndexPattern extends Component { return ( } iconType="help" color="warning" > -

There's already an index pattern called `{query}`

+

+ +

); } renderHeader({ exactMatchedIndices: indices }) { - const { goToNextStep } = this.props; + const { goToNextStep, intl } = this.props; const { query, showingIndexPatternQueryErrors, indexPatternExists } = this.state; let containsErrors = false; @@ -231,7 +241,14 @@ export class StepIndexPattern extends Component { containsErrors = true; } else if (!containsInvalidCharacters(query, ILLEGAL_CHARACTERS)) { - errors.push(`An index pattern cannot contain spaces or the characters: ${characterList}`); + const errorMessage = intl.formatMessage( + { + id: 'kbn.management.createIndexPattern.step.invalidCharactersErrorMessage', + defaultMessage: 'An index pattern cannot contain spaces or the characters: {characterList}' + }, + { characterList }); + + errors.push(errorMessage); containsErrors = true; } @@ -277,3 +294,5 @@ export class StepIndexPattern extends Component { ); } } + +export const StepIndexPattern = injectI18n(StepIndexPatternComponent); diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/__snapshots__/step_time_field.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/__snapshots__/step_time_field.test.js.snap index c6b7f0cd1a268..78b941d09c129 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/__snapshots__/step_time_field.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/__snapshots__/step_time_field.test.js.snap @@ -44,7 +44,11 @@ exports[`StepTimeField should render a loading state when creating the index pat - Creating index pattern... +
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/step_time_field.test.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/step_time_field.test.js index 0561f1a9be502..edef17e238433 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/step_time_field.test.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/step_time_field.test.js @@ -18,9 +18,9 @@ */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; -import { StepTimeField } from '../step_time_field'; +import { StepTimeFieldComponent } from '../step_time_field'; jest.mock('../components/header', () => ({ Header: 'Header' })); jest.mock('../components/time_field', () => ({ TimeField: 'TimeField' })); @@ -39,8 +39,8 @@ const indexPatternsService = { describe('StepTimeField', () => { it('should render normally', () => { - const component = shallow( - { }); it('should render timeFields', () => { - const component = shallow( - { }); it('should render a selected timeField', () => { - const component = shallow( - { }); it('should ensure disabled time field options work properly', () => { - const component = shallow( - { }); it('should disable the action button if an invalid time field is selected', () => { - const component = shallow( - { }); it('should enable the action button if the user decides to not select a time field', () => { - const component = shallow( - { }); it('should render advanced options', () => { - const component = shallow( - { }); it('should render advanced options with an index pattern id', () => { - const component = shallow( - { }); it('should render a loading state when creating the index pattern', () => { - const component = shallow( - - Back + @@ -47,7 +52,10 @@ export const ActionButtons = ({ fill onClick={createIndexPattern} > - Create index pattern + diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__tests__/__snapshots__/advanced_options.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__tests__/__snapshots__/advanced_options.test.js.snap index 155d41f3b8d72..17f0d860720fb 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__tests__/__snapshots__/advanced_options.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__tests__/__snapshots__/advanced_options.test.js.snap @@ -9,9 +9,11 @@ exports[`AdvancedOptions should hide if not showing 1`] = ` onClick={[Function]} type="button" > - - Show advanced options - + - - Show advanced options - + { it('should render normally', () => { - const component = shallow( - {}} @@ -36,8 +36,8 @@ describe('AdvancedOptions', () => { }); it('should hide if not showing', () => { - const component = shallow( - {}} diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.js index fbb0c3af41b70..9ad692baf0e94 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.js @@ -27,11 +27,14 @@ import { EuiSpacer, } from '@elastic/eui'; -export const AdvancedOptions = ({ +import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; + +export const AdvancedOptionsComponent = ({ isVisible, indexPatternId, toggleAdvancedOptions, onChangeIndexPatternId, + intl, }) => (
{ isVisible - ? (Hide advanced options) - : (Show advanced options) + ? ( + + ) + : ( + + ) } @@ -48,12 +61,16 @@ export const AdvancedOptions = ({ { isVisible ? - Kibana will provide a unique identifier for each index pattern. - If you do not want to use this unique ID, enter a custom one. - + } > @@ -69,3 +89,5 @@ export const AdvancedOptions = ({ }
); + +export const AdvancedOptions = injectI18n(AdvancedOptionsComponent); diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/__tests__/__snapshots__/header.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/__tests__/__snapshots__/header.test.js.snap index 4744d49588e14..414b83eccb77c 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/__tests__/__snapshots__/header.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/__tests__/__snapshots__/header.test.js.snap @@ -6,7 +6,11 @@ exports[`Header should render normally 1`] = ` size="s" >

- Step 2 of 2: Configure settings +

- - You've defined - - ki* - - as your index pattern. Now you can specify some settings before we create it. - + + ki* + , + } + } + /> `; diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/header.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/header.js index 00660a87c3289..1ccaf90f66484 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/header.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/header.js @@ -25,21 +25,27 @@ import { EuiText, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; + export const Header = ({ indexPattern, }) => (

- Step 2 of 2: Configure settings +

- - You've defined {indexPattern} as your index pattern. - Now you can specify some settings before we create it. - + {indexPattern} }} + />
); diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/__snapshots__/time_field.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/__snapshots__/time_field.test.js.snap index b04aa723bc5e7..03fee7dd7278d 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/__snapshots__/time_field.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/__snapshots__/time_field.test.js.snap @@ -9,10 +9,18 @@ exports[`TimeField should render a loading state 1`] = ` helpText={

- The Time Filter will use this field to filter your data by time. +

- You can choose not to have a time field, but you will not be able to narrow down your data by a time range. +

} @@ -31,7 +39,11 @@ exports[`TimeField should render a loading state 1`] = ` grow={false} > - Time Filter field name +

- The Time Filter will use this field to filter your data by time. +

- You can choose not to have a time field, but you will not be able to narrow down your data by a time range. +

} @@ -97,7 +117,11 @@ exports[`TimeField should render a selected time field 1`] = ` grow={false} > - Time Filter field name +
- Refresh + @@ -148,10 +176,18 @@ exports[`TimeField should render normally 1`] = ` helpText={

- The Time Filter will use this field to filter your data by time. +

- You can choose not to have a time field, but you will not be able to narrow down your data by a time range. +

} @@ -170,7 +206,11 @@ exports[`TimeField should render normally 1`] = ` grow={false} > - Time Filter field name + - Refresh + @@ -218,7 +262,11 @@ exports[`TimeField should render something if hiding time field 1`] = ` grow={true} >

- The indices which match this index pattern don't contain any time fields. +

diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/time_field.test.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/time_field.test.js index 5e42643f59c9b..bda1198b194fd 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/time_field.test.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/time_field.test.js @@ -18,13 +18,13 @@ */ import React from 'react'; -import { TimeField } from '../time_field'; -import { shallow } from 'enzyme'; +import { TimeFieldComponent } from '../time_field'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; describe('TimeField', () => { it('should render normally', () => { - const component = shallow( - {}} timeFieldOptions={[{ text: '@timestamp', value: '@timestamp' }]} @@ -38,8 +38,8 @@ describe('TimeField', () => { }); it('should render something if hiding time field', () => { - const component = shallow( - {}} timeFieldOptions={[{ text: '@timestamp', value: '@timestamp' }]} @@ -53,8 +53,8 @@ describe('TimeField', () => { }); it('should render a selected time field', () => { - const component = shallow( - {}} timeFieldOptions={[{ text: '@timestamp', value: '@timestamp' }]} @@ -68,8 +68,8 @@ describe('TimeField', () => { }); it('should render a loading state', () => { - const component = shallow( - {}} timeFieldOptions={[{ text: '@timestamp', value: '@timestamp' }]} diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.js index b720ca37d2b43..0e87d80e5316c 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.js @@ -32,13 +32,16 @@ import { EuiLoadingSpinner, } from '@elastic/eui'; -export const TimeField = ({ +import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; + +export const TimeFieldComponent = ({ isVisible, fetchTimeFields, timeFieldOptions, isLoading, selectedTimeField, onTimeFieldChanged, + intl, }) => ( { isVisible ? @@ -46,7 +49,12 @@ export const TimeField = ({ label={ - Time Filter field name + + + { isLoading ? ( @@ -57,7 +65,10 @@ export const TimeField = ({ className="timeFieldRefreshButton" onClick={fetchTimeFields} > - Refresh + ) } @@ -66,8 +77,18 @@ export const TimeField = ({ } helpText={
-

The Time Filter will use this field to filter your data by time.

-

You can choose not to have a time field, but you will not be able to narrow down your data by a time range.

+

+ +

+

+ +

} > @@ -76,7 +97,13 @@ export const TimeField = ({ name="timeField" data-test-subj="createIndexPatternTimeFieldSelect" options={[ - { text: 'Loading...', value: '' } + { + text: intl.formatMessage({ + id: 'kbn.management.createIndexPattern.stepTime.field.loadingDropDown', + defaultMessage: 'Loading...' + }), + value: '' + } ]} disabled={true} /> @@ -94,8 +121,15 @@ export const TimeField = ({ : -

The indices which match this index pattern don't contain any time fields.

+

+ +

}
); + +export const TimeField = injectI18n(TimeFieldComponent); diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/step_time_field.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/step_time_field.js index 7b82b62d06c70..b514e571166d1 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/step_time_field.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/step_time_field.js @@ -35,7 +35,9 @@ import { EuiLoadingSpinner, } from '@elastic/eui'; -export class StepTimeField extends Component { +import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; + +export class StepTimeFieldComponent extends Component { static propTypes = { indexPattern: PropTypes.string.isRequired, indexPatternsService: PropTypes.object.isRequired, @@ -121,7 +123,12 @@ export class StepTimeField extends Component { - Creating index pattern... + + + @@ -149,7 +156,7 @@ export class StepTimeField extends Component { return ( -
+
field.type === 'date'); + const label = i18n.translate('kbn.management.createIndexPattern.stepTime.noTimeFieldsLabel', { + defaultMessage: 'The indices which match this index pattern don\'t contain any time fields.' + }); if (dateFields.length === 0) { return [{ - display: `The indices which match this index pattern don't contain any time fields.`, + display: label, }]; } @@ -31,8 +36,11 @@ export function extractTimeFields(fields) { display: '───', fieldName: '', }; + const noTimeFieldLabel = i18n.translate('kbn.management.createIndexPattern.stepTime.noTimeFieldOptionLabel', { + defaultMessage: 'I don\'t want to use the Time Filter' + }); const noTimeFieldOption = { - display: `I don't want to use the Time Filter`, + display: noTimeFieldLabel, fieldName: undefined, }; diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/render.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/render.js index 192afb5174242..f6bae5911355d 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/render.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/render.js @@ -21,6 +21,8 @@ import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; import { CreateIndexPatternWizard } from './create_index_pattern_wizard'; +import { I18nProvider } from '@kbn/i18n/react'; + const CREATE_INDEX_PATTERN_DOM_ELEMENT_ID = 'createIndexPatternReact'; export function renderCreateIndexPatternWizard( @@ -33,10 +35,12 @@ export function renderCreateIndexPatternWizard( } render( - , + + + , node, ); } diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/create_edit_field/create_edit_field.js b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/create_edit_field/create_edit_field.js index f6bfce959e87c..bf86a0a0effe3 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/create_edit_field/create_edit_field.js +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/create_edit_field/create_edit_field.js @@ -27,6 +27,8 @@ import template from './create_edit_field.html'; import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; import { FieldEditor } from 'ui/field_editor'; +import { I18nProvider } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; const REACT_FIELD_EDITOR_ID = 'reactFieldEditor'; const renderFieldEditor = ($scope, indexPattern, field, { @@ -43,17 +45,19 @@ const renderFieldEditor = ($scope, indexPattern, field, { } render( - , + + + , node, ); }); @@ -103,7 +107,12 @@ uiRoutes this.field = this.indexPattern.fields.byName[fieldName]; if (!this.field) { - toastNotifications.add(`'${this.indexPattern.title}' index pattern doesn't have a scripted field called '${fieldName}'`); + const message = i18n.translate('kbn.management.editIndexPattern.scripted.noFieldLabel', + { + defaultMessage: '\'{indexPatternTitle}\' index pattern doesn\'t have a scripted field called \'{fieldName}\'', + values: { indexPatternTitle: this.indexPattern.title, fieldName } + }); + toastNotifications.add(message); kbnUrl.redirectToRoute(this.indexPattern, 'edit'); return; @@ -117,10 +126,17 @@ uiRoutes }); } else { - throw new Error('unknown fieldSettings mode ' + this.mode); + const errorMessage = i18n.translate('kbn.management.editIndexPattern.scripted.unknownModeErrorMessage', + { + defaultMessage: 'unknown fieldSettings mode {mode}', + values: { mode: this.mode } + }); + throw new Error(errorMessage); } - docTitle.change([this.field.name || 'New Scripted Field', this.indexPattern.title]); + const fieldName = this.field.name || i18n.translate('kbn.management.editIndexPattern.scripted.newFieldPlaceholder', + { defaultMessage: 'New Scripted Field' }); + docTitle.change([fieldName, this.indexPattern.title]); renderFieldEditor($scope, this.indexPattern, this.field, { Field, diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html index 6ef99c10c25b3..47dcb7758d731 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html @@ -5,7 +5,7 @@ data-test-subj="editIndexPattern" class="kuiViewContent" role="region" - aria-label="Index pattern details" + aria-label="{{'kbn.management.editIndexPattern.detailsAria' | i18n: { defaultMessage: 'Index pattern details' } }}" > - Time Filter field name: {{indexPattern.timeFieldName}} +

- This page lists every field in the {{::indexPattern.title}} index and the field's associated core type as recorded by Elasticsearch. To change a field type, use the Elasticsearch + - Mapping API +

@@ -37,16 +42,16 @@ >
- - Support for repeating index patterns removed +
- Support for time-interval based index patterns has been removed! In the next major - version of Kibana this index patterns will stop working. Migrate saved objects that - use this index pattern to a wildcard pattern and delete this one. +
@@ -57,14 +62,16 @@ >
- - Mapping conflict - +
- {{conflictFields.length > 1 ? conflictFields.length : 'A'}} field{{conflictFields.length > 1 ? 's' : ''}} {{conflictFields.length > 1 ? 'are' : 'is'}} defined as several types (string, integer, etc) across the indices that match this pattern. You may still be able to use these conflict fields in parts of Kibana, but they will be unavailable for functions that require Kibana to know their type. Correcting this issue will require reindexing your data. +
@@ -96,9 +103,9 @@ @@ -115,7 +122,9 @@ ng-change="changeFilter('indexedFieldTypeFilter', indexedFieldTypeFilter)" ng-options="o for o in indexedFieldTypes" > - + @@ -130,7 +139,9 @@ ng-change="changeFilter('scriptedFieldLanguageFilter', scriptedFieldLanguageFilter)" ng-options="o for o in scriptedFieldLanguages" > - + diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js index b1a400eaf93a4..dc7b253d1370f 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js @@ -32,6 +32,8 @@ import { render, unmountComponentAtNode } from 'react-dom'; import { SourceFiltersTable } from './source_filters_table'; import { IndexedFieldsTable } from './indexed_fields_table'; import { ScriptedFieldsTable } from './scripted_fields_table'; +import { I18nProvider } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; const REACT_SOURCE_FILTERS_DOM_ELEMENT_ID = 'reactSourceFiltersTable'; const REACT_INDEXED_FIELDS_DOM_ELEMENT_ID = 'reactIndexedFieldsTable'; @@ -46,16 +48,18 @@ function updateSourceFiltersTable($scope, $state) { } render( - { - $scope.editSections = $scope.editSectionsProvider($scope.indexPattern); - $scope.refreshFilters(); - $scope.$apply(); - }} - />, + + { + $scope.editSections = $scope.editSectionsProvider($scope.indexPattern); + $scope.refreshFilters(); + $scope.$apply(); + }} + /> + , node, ); }); @@ -79,22 +83,24 @@ function updateScriptedFieldsTable($scope, $state) { } render( - { - $scope.kbnUrl.redirectToRoute(obj, route); - $scope.$apply(); - }, - getRouteHref: (obj, route) => $scope.kbnUrl.getRouteHref(obj, route), - }} - onRemoveField={() => { - $scope.editSections = $scope.editSectionsProvider($scope.indexPattern); - $scope.refreshFilters(); - }} - />, + + { + $scope.kbnUrl.redirectToRoute(obj, route); + $scope.$apply(); + }, + getRouteHref: (obj, route) => $scope.kbnUrl.getRouteHref(obj, route), + }} + onRemoveField={() => { + $scope.editSections = $scope.editSectionsProvider($scope.indexPattern); + $scope.refreshFilters(); + }} + /> + , node, ); }); @@ -117,19 +123,21 @@ function updateIndexedFieldsTable($scope, $state) { } render( - { - $scope.kbnUrl.redirectToRoute(obj, route); - $scope.$apply(); - }, - }} - />, + + { + $scope.kbnUrl.redirectToRoute(obj, route); + $scope.$apply(); + }, + }} + /> + , node, ); }); @@ -233,16 +241,19 @@ uiModules.get('apps/management') }); $scope.refreshFields = function () { + const confirmMessage = i18n.translate('kbn.management.editIndexPattern.refreshLabel', { + defaultMessage: 'This action resets the popularity counter of each field.' + }); const confirmModalOptions = { - confirmButtonText: 'Refresh', + confirmButtonText: i18n.translate('kbn.management.editIndexPattern.refreshButton', { defaultMessage: 'Refresh' }), onConfirm: async () => { await $scope.indexPattern.init(true); $scope.fields = $scope.indexPattern.getNonScriptedFields(); }, - title: 'Refresh field list?' + title: i18n.translate('kbn.management.editIndexPattern.refreshHeader', { defaultMessage: 'Refresh field list?' }) }; confirmModal( - 'This action resets the popularity counter of each field.', + confirmMessage, confirmModalOptions ); }; @@ -265,9 +276,9 @@ uiModules.get('apps/management') } const confirmModalOptions = { - confirmButtonText: 'Delete', + confirmButtonText: i18n.translate('kbn.management.editIndexPattern.deleteButton', { defaultMessage: 'Delete' }), onConfirm: doRemove, - title: 'Delete index pattern?' + title: i18n.translate('kbn.management.editIndexPattern.deleteHeader', { defaultMessage: 'Delete index pattern?' }) }; confirmModal('', confirmModalOptions); }; @@ -278,7 +289,10 @@ uiModules.get('apps/management') $scope.setIndexPatternsTimeField = function (field) { if (field.type !== 'date') { - notify.error('That field is a ' + field.type + ' not a date.'); + const errorMessage = i18n.translate('kbn.management.editIndexPattern.notDateErrorMessage', { + defaultMessage: 'That field is a {fieldType} not a date.', values: { fieldType: field.type } + }); + notify.error(errorMessage); return; } $scope.indexPattern.timeFieldName = field.name; diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_sections.js b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_sections.js index cdc65a110636f..20a8e49c7eee2 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_sections.js +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_sections.js @@ -18,6 +18,7 @@ */ import _ from 'lodash'; +import { i18n } from '@kbn/i18n'; export function IndicesEditSectionsProvider() { @@ -34,17 +35,17 @@ export function IndicesEditSectionsProvider() { return [ { - title: 'Fields', + title: i18n.translate('kbn.management.editIndexPattern.tabs.fieldsHeader', { defaultMessage: 'Fields' }), index: 'indexedFields', count: fieldCount.indexed }, { - title: 'Scripted fields', + title: i18n.translate('kbn.management.editIndexPattern.tabs.scriptedHeader', { defaultMessage: 'Scripted fields' }), index: 'scriptedFields', count: fieldCount.scripted }, { - title: 'Source filters', + title: i18n.translate('kbn.management.editIndexPattern.tabs.sourceHeader', { defaultMessage: 'Source filters' }), index: 'sourceFilters', count: fieldCount.sourceFilters } diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/field_controls.html b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/field_controls.html index 794f1da2a7b79..c5ab67cb37f2c 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/field_controls.html +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/field_controls.html @@ -2,7 +2,7 @@ @@ -12,7 +12,7 @@ ng-if="field.scripted" ng-click="remove(field)" class="kuiButton kuiButton--danger kuiButton--small" - aria-label="Delete" + aria-label="{{'kbn.management.editIndexPattern.deleteFieldButton' | i18n: { defaultMessage: 'Delete' } }}" > diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/index_header/index_header.html b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/index_header/index_header.html index 2e2d828cd6e2e..1b3b4379ec85b 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/index_header/index_header.html +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/index_header/index_header.html @@ -18,8 +18,8 @@