Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization "Index Patterns" tab #20525

Merged
merged 40 commits into from
Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f99eca7
Integrate i18n-engine into "Index Patterns" tab
maryia-lapata Jun 30, 2018
d42e69d
Adjusted unit tests for "Index Patterns" tab
maryia-lapata Jul 6, 2018
63c798a
Localization of "Index patterns" section name
maryia-lapata Jul 6, 2018
2904a6f
Rename the function shallowIntl to shallowWithIntl, remove needless c…
maryia-lapata Jul 9, 2018
463490f
Refactoring of default message
maryia-lapata Jul 10, 2018
e29cf5f
Localization for FieldEditor component
maryia-lapata Jul 12, 2018
f186b43
Adjust unit tests for FieldEditor component
maryia-lapata Jul 12, 2018
4514ee8
Integrate i18n-engine into "Index Patterns" tab
maryia-lapata Jun 30, 2018
d41b9cb
Adjusted unit tests for "Index Patterns" tab
maryia-lapata Jul 6, 2018
512ba8a
Localization of "Index patterns" section name
maryia-lapata Jul 6, 2018
c32cfe0
Rename the function shallowIntl to shallowWithIntl, remove needless c…
maryia-lapata Jul 9, 2018
62d35af
Refactoring of default message
maryia-lapata Jul 10, 2018
407cdda
Localization for FieldEditor component
maryia-lapata Jul 12, 2018
6ad10c1
Adjust unit tests for FieldEditor component
maryia-lapata Jul 12, 2018
d92d137
Merge branch 'i18n-index-patterns' of https://github.com/maryia-lapat…
maryia-lapata Jul 13, 2018
1580330
Replace I18nContext to injectI18n according to changes in @kbn/i18n
maryia-lapata Jul 13, 2018
be05e40
Merge branch 'master' into i18n-index-patterns
maryia-lapata Jul 13, 2018
34a298c
Merge branch 'master' into i18n-index-patterns
maryia-lapata Jul 16, 2018
56d8ed4
Fix broken saving form
maryia-lapata Jul 16, 2018
3a1b6a4
Merge branch 'master' into i18n-index-patterns
maryia-lapata Jul 16, 2018
0ba29dd
Adjust components importing according to changes in @kbn/i18n
maryia-lapata Jul 16, 2018
c0087f2
Formatting and refactoring
maryia-lapata Jul 17, 2018
e36744f
Update ids
maryia-lapata Jul 18, 2018
a99d457
Merge branch 'master' into i18n-index-patterns
maryia-lapata Jul 18, 2018
7d80c98
Fix invalid HTML and refactoring
maryia-lapata Jul 18, 2018
80a463e
Merge branch 'master' into i18n-index-patterns
maryia-lapata Jul 19, 2018
b05eff1
Use i18n module instead of AngularJS service
maryia-lapata Jul 19, 2018
20b8265
Localize scripting_syntax.js, refactoring
maryia-lapata Jul 19, 2018
6d180c7
Update message ids.
maryia-lapata Jul 20, 2018
2aa7b1a
Merge branch 'master' into i18n-index-patterns
maryia-lapata Jul 20, 2018
736b5d8
Merge branch 'master' into i18n-index-patterns
maryia-lapata Jul 20, 2018
50b02f5
latest changes
Jul 23, 2018
bf0fd45
latest
Jul 24, 2018
4cd6f0c
fix plural form in status messages
Jul 24, 2018
031aa64
fix messages in status message, _field component
Jul 27, 2018
1f4711a
move back span in time_field
Jul 27, 2018
87fd943
refactor enzyme helper for providing intl into context
Jul 27, 2018
bf4a7f8
do not translate Painless
Jul 27, 2018
82a2e9d
test call params in formatMessage
Jul 30, 2018
04359eb
clear formatMessage mock after each test
Jul 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ exports[`EmptyState should render normally 1`] = `
}
}
>
Couldn't find any Elasticsearch data
<FormattedMessage
defaultMessage="Couldn't find any Elasticsearch data"
id="kbn.management.createIndexPattern.emptyStateHeader"
values={Object {}}
/>
</h2>
</EuiTextColor>
</EuiTitle>
Expand All @@ -44,28 +48,46 @@ exports[`EmptyState should render normally 1`] = `
grow={true}
>
<p>
<EuiTextColor
color="subdued"
component="span"
>
You'll need to index some data into Elasticsearch before you can create an index pattern.
</EuiTextColor>

<EuiLink
color="primary"
href="#/home/tutorial_directory"
type="button"
>
Learn how
</EuiLink>
or
<EuiLink
color="primary"
href="#/home/tutorial_directory/sampleData"
type="button"
>
get started with some sample data sets.
</EuiLink>
<FormattedMessage
defaultMessage="{needToIndex} {learnHowLink} or {getStartedLink}"
id="kbn.management.createIndexPattern.emptyStateLabel.emptyStateDetail"
values={
Object {
"getStartedLink": <EuiLink
color="primary"
href="#/home/tutorial_directory/sampleData"
type="button"
>
<FormattedMessage
defaultMessage="get started with some sample data sets."
id="kbn.management.createIndexPattern.emptyStateLabel.getStartedLink"
values={Object {}}
/>
</EuiLink>,
"learnHowLink": <EuiLink
color="primary"
href="#/home/tutorial_directory"
type="button"
>
<FormattedMessage
defaultMessage="Learn how"
id="kbn.management.createIndexPattern.emptyStateLabel.learnHowLink"
values={Object {}}
/>
</EuiLink>,
"needToIndex": <EuiTextColor
color="subdued"
component="span"
>
<FormattedMessage
defaultMessage="You'll need to index some data into Elasticsearch before you can create an index pattern."
id="kbn.management.createIndexPattern.emptyStateLabel.needToIndexLabel"
values={Object {}}
/>
</EuiTextColor>,
}
}
/>
</p>
</EuiText>
<EuiSpacer
Expand Down Expand Up @@ -93,7 +115,11 @@ exports[`EmptyState should render normally 1`] = `
onClick={[Function]}
type="button"
>
Check for new data
<FormattedMessage
defaultMessage="Check for new data"
id="kbn.management.createIndexPattern.emptyState.checkDataButton"
values={Object {}}
/>
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
EuiButton,
} from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n/react';

export const EmptyState = ({
onRefresh,
}) => (
Expand All @@ -40,27 +42,47 @@ export const EmptyState = ({
<EuiFlexItem grow={false}>
<EuiTitle>
<EuiTextColor color="subdued">
<h2 style={{ textAlign: 'center' }}>Couldn&apos;t find any Elasticsearch data</h2>
<h2 style={{ textAlign: 'center' }}>
<FormattedMessage
id="kbn.management.createIndexPattern.emptyStateHeader"
defaultMessage="Couldn't find any Elasticsearch data"
/>
</h2>
</EuiTextColor>
</EuiTitle>
<EuiSpacer size="s"/>
<EuiText>
<p>
<EuiTextColor color="subdued">
You&apos;ll need to index some data into Elasticsearch before you can create an index pattern.
</EuiTextColor>
&nbsp;
<EuiLink
href="#/home/tutorial_directory"
>
Learn how
</EuiLink>
{' or '}
<EuiLink
href="#/home/tutorial_directory/sampleData"
>
get started with some sample data sets.
</EuiLink>
<FormattedMessage
id="kbn.management.createIndexPattern.emptyStateLabel.emptyStateDetail"
defaultMessage="{needToIndex} {learnHowLink} or {getStartedLink}"
values={{
needToIndex: (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would prefer the values object here to be declared as a constant above and then referenced here. This would make things easier to read, and would also prevent a new object being created with each rerender. See this for an explanation of why that might be bad: https://medium.com/@esamatti/react-js-pure-render-performance-anti-pattern-fb88c101332f

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bmcconaghy Basically, this is common pattern for avoiding creation of new object, but I would not say, that in this case, because:

  1. Moving such objects to constants will decrease readability of code in general
  2. Some of values are React components too and use props. So if we move values to constant outside component we will not get props, if we will create it inside render it will be the same one
  3. This case is envisaged by react-intl guys. And for avoiding rerendering they espacially use shallow compare for values props. (Here)[https://github.com/yahoo/react-intl/blob/master/src/components/message.js#L43]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough on the performance point. I actually find the FormattedMessage nested in FormattedMessage harder to read personally, as I get lost in the multiple levels of nesting, so would still like to see the values defined outside of the FormattedMessage and then referenced there.

Copy link
Member

@azasypkin azasypkin Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like the right solution for this readability problem would be integrating i18n into EUI components at some point, so that this:

<EuiTextColor color="subdued">
  <FormattedMessage
    id="kbn.management.createIndexPattern.emptyStateLabel.needToIndexLabel"
    defaultMessage="You'll need to index ....."
  />
</EuiTextColor>

can be changed to:

<EuiTextColor color="subdued" i18n-id="kbn.management.createIndexPattern.emptyStateLabel.needToIndexLabel">
	You'll need to index .....
</EuiTextColor>

We'll still have to use values to keep all parts of the single message together though (can be quite important for RTL languges).

But that's a bigger effort that spans several teams and i18n should prove itself in practice first.

<EuiTextColor color="subdued">
<FormattedMessage
id="kbn.management.createIndexPattern.emptyStateLabel.needToIndexLabel"
defaultMessage="You'll need to index some data into Elasticsearch before you can create an index pattern."
/>
</EuiTextColor>
),
learnHowLink: (
<EuiLink href="#/home/tutorial_directory">
<FormattedMessage
id="kbn.management.createIndexPattern.emptyStateLabel.learnHowLink"
defaultMessage="Learn how"
/>
</EuiLink>
),
getStartedLink: (
<EuiLink href="#/home/tutorial_directory/sampleData">
<FormattedMessage
id="kbn.management.createIndexPattern.emptyStateLabel.getStartedLink"
defaultMessage="get started with some sample data sets."
/>
</EuiLink>
)
}}
/>
</p>
</EuiText>

Expand All @@ -73,7 +95,10 @@ export const EmptyState = ({
onClick={onRefresh}
data-test-subj="refreshIndicesButton"
>
Check for new data
<FormattedMessage
id="kbn.management.createIndexPattern.emptyState.checkDataButton"
defaultMessage="Check for new data"
/>
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ exports[`Header should render normally 1`] = `
size="m"
>
<h1>
Create index pattern
<FormattedMessage
defaultMessage="Create index pattern"
id="kbn.management.createIndexPatternHeader"
values={Object {}}
/>
</h1>
</EuiTitle>
<EuiFlexGroup
Expand All @@ -33,7 +37,11 @@ exports[`Header should render normally 1`] = `
color="subdued"
component="span"
>
Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations.
<FormattedMessage
defaultMessage="Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations."
id="kbn.management.createIndexPatternLabel"
values={Object {}}
/>
</EuiTextColor>
</p>
</EuiText>
Expand All @@ -45,7 +53,13 @@ exports[`Header should render normally 1`] = `
<EuiSwitch
checked={true}
id="checkboxShowSystemIndices"
label="Include system indices"
label={
<FormattedMessage
defaultMessage="Include system indices"
id="kbn.management.createIndexPattern.includeSystemIndicesToggleSwitch"
values={Object {}}
/>
}
onChange={[Function]}
/>
</EuiFlexItem>
Expand All @@ -65,7 +79,11 @@ exports[`Header should render without including system indices 1`] = `
size="m"
>
<h1>
Create index pattern
<FormattedMessage
defaultMessage="Create index pattern"
id="kbn.management.createIndexPatternHeader"
values={Object {}}
/>
</h1>
</EuiTitle>
<EuiFlexGroup
Expand All @@ -89,7 +107,11 @@ exports[`Header should render without including system indices 1`] = `
color="subdued"
component="span"
>
Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations.
<FormattedMessage
defaultMessage="Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations."
id="kbn.management.createIndexPatternLabel"
values={Object {}}
/>
</EuiTextColor>
</p>
</EuiText>
Expand All @@ -101,7 +123,13 @@ exports[`Header should render without including system indices 1`] = `
<EuiSwitch
checked={false}
id="checkboxShowSystemIndices"
label="Include system indices"
label={
<FormattedMessage
defaultMessage="Include system indices"
id="kbn.management.createIndexPattern.includeSystemIndicesToggleSwitch"
values={Object {}}
/>
}
onChange={[Function]}
/>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,43 @@ import {
EuiSwitch,
} from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n/react';

export const Header = ({
isIncludingSystemIndices,
onChangeIncludingSystemIndices,
}) => (
<div>
<EuiSpacer size="m"/>
<EuiTitle>
<h1>Create index pattern</h1>
<h1>
<FormattedMessage
id="kbn.management.createIndexPatternHeader"
defaultMessage="Create index pattern"
/>
</h1>

</EuiTitle>
<EuiFlexGroup justifyContent="spaceBetween" alignItems="flexEnd">
<EuiFlexItem grow={false}>
<EuiText>
<p>
<EuiTextColor color="subdued">
Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations.
<FormattedMessage
id="kbn.management.createIndexPatternLabel"
defaultMessage="Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations."
/>
</EuiTextColor>
</p>
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiSwitch
label={<FormattedMessage
id="kbn.management.createIndexPattern.includeSystemIndicesToggleSwitch"
defaultMessage="Include system indices"
/>}
id="checkboxShowSystemIndices"
label="Include system indices"
checked={isIncludingSystemIndices}
onChange={onChangeIncludingSystemIndices}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ exports[`LoadingState should render normally 1`] = `
}
}
>
Checking for Elasticsearch data
<FormattedMessage
defaultMessage="Checking for Elasticsearch data"
id="kbn.management.createIndexPattern.loadingState.checkingLabel"
values={Object {}}
/>
</h2>
</EuiTextColor>
</EuiTitle>
Expand Down Expand Up @@ -66,7 +70,11 @@ exports[`LoadingState should render normally 1`] = `
grow={true}
size="s"
>
Reticulating splines...
<FormattedMessage
defaultMessage="Reticulating splines..."
id="kbn.management.createIndexPattern.loadingState.reticulatingLabel"
values={Object {}}
/>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ import {
EuiTitle,
} from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n/react';

export const LoadingState = () => (
<EuiPanel paddingSize="l">
<EuiFlexGroup justifyContent="center" alignItems="center">
<EuiFlexItem grow={false}>
<EuiTitle>
<EuiTextColor color="subdued">
<h2 style={{ textAlign: 'center' }}>Checking for Elasticsearch data</h2>
<h2 style={{ textAlign: 'center' }}>
<FormattedMessage
id="kbn.management.createIndexPattern.loadingState.checkingLabel"
defaultMessage="Checking for Elasticsearch data"
/>
</h2>
</EuiTextColor>
</EuiTitle>

Expand All @@ -49,7 +56,10 @@ export const LoadingState = () => (

<EuiFlexItem grow={false}>
<EuiText size="s" color="subdued">
Reticulating splines...
<FormattedMessage
id="kbn.management.createIndexPattern.loadingState.reticulatingLabel"
defaultMessage="Reticulating splines..."
/>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Loading