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

[i18n] Translate Query_bar #26264

Merged
merged 57 commits into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c7ec189
Merge pull request #1 from elastic/master
Nox911 Sep 24, 2018
fa01b88
Merge pull request #2 from elastic/master
Nox911 Sep 27, 2018
70f6c7e
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Sep 27, 2018
68587a0
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Sep 28, 2018
42aa7d3
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 2, 2018
efeaefe
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 2, 2018
8a054ed
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 8, 2018
b0d1660
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 16, 2018
62b6ad1
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 17, 2018
acbad4b
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 18, 2018
a850650
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 22, 2018
0a200ce
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 25, 2018
b2a8244
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 29, 2018
b4b979e
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 30, 2018
d349a4f
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Oct 31, 2018
ae285b9
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 2, 2018
3051641
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 5, 2018
6231971
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 8, 2018
f86a3d4
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 9, 2018
cf813c7
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 13, 2018
1aba03f
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 14, 2018
491009b
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 15, 2018
e243126
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 22, 2018
e74bd61
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 22, 2018
8bc5ffa
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 23, 2018
5787937
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 23, 2018
f17fa1e
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 24, 2018
c63b0a6
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 26, 2018
ed62b5b
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 26, 2018
df4fab4
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 26, 2018
46d284a
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 27, 2018
146168e
Translate ui -> query_bar
Nox911 Nov 27, 2018
0de07df
Fix id names
Nox911 Nov 29, 2018
d1fd49e
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 29, 2018
f5da175
Merge branch 'master' into feature/translate-query_bar
Nox911 Nov 29, 2018
21a4393
Update snapshots
maryia-lapata Nov 29, 2018
15cf1e2
Fix tests
Nox911 Nov 29, 2018
8093e74
Add intl to props interface
Nox911 Nov 29, 2018
996d186
Fix test
Nox911 Nov 29, 2018
db20b6d
Merge branch 'master' of https://github.com/elastic/kibana into featu…
Nox911 Nov 29, 2018
ec1ad76
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 29, 2018
4e176a6
Merge branch 'master' into feature/translate-query_bar
Nox911 Nov 29, 2018
6ebd934
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Nov 30, 2018
2238bb4
Fix tests
Nox911 Nov 30, 2018
36a7c8d
Fix tests
Nox911 Nov 30, 2018
1340d58
Fix test
Nox911 Nov 30, 2018
ce02e76
Fix tests
Nox911 Nov 30, 2018
332d867
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Dec 3, 2018
4a99411
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Dec 3, 2018
9246e8a
Merge branch 'master' into feature/translate-query_bar
Nox911 Dec 3, 2018
4cdec42
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Dec 4, 2018
5d44df7
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Dec 4, 2018
c6e63aa
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Dec 4, 2018
8182d1f
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Dec 4, 2018
527f2ab
Merge branch 'master' into feature/translate-query_bar
Nox911 Dec 4, 2018
aefb90f
Merge branch 'master' of https://github.com/elastic/kibana
Nox911 Dec 5, 2018
1d5f611
Merge branch 'master' into feature/translate-query_bar
Nox911 Dec 5, 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
61 changes: 43 additions & 18 deletions src/ui/public/query_bar/components/language_switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
EuiSwitch,
EuiText,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { Component } from 'react';
import { documentationLinks } from '../../documentation_links/documentation_links';

Expand All @@ -52,7 +53,7 @@ export class QueryLanguageSwitcher extends Component<Props, State> {
public render() {
const button = (
<EuiButtonEmpty size="xs" onClick={this.togglePopover}>
Options
<FormattedMessage id="common.ui.queryBar.optionsButtonLabel" defaultMessage="Options" />
</EuiButtonEmpty>
);

Expand All @@ -67,18 +68,30 @@ export class QueryLanguageSwitcher extends Component<Props, State> {
closePopover={this.closePopover}
withTitle
>
<EuiPopoverTitle>Syntax options</EuiPopoverTitle>
<EuiPopoverTitle>
<FormattedMessage
id="common.ui.queryBar.syntaxOptionsTitle"
defaultMessage="Syntax options"
/>
</EuiPopoverTitle>
<div style={{ width: '350px' }}>
<EuiText>
<p>
Our experimental autocomplete and simple syntax features can help you create your
queries. Just start typing and you’ll see matches related to your data. See docs{' '}
{
<EuiLink href={kueryQuerySyntaxDocs} target="_blank">
here
</EuiLink>
}
.
<FormattedMessage
id="common.ui.queryBar.syntaxOptionsDescription"
defaultMessage="Our experimental autocomplete and simple syntax features can help you create your
queries. Just start typing and you’ll see matches related to your data. See docs {docsLink}."
values={{
docsLink: (
<EuiLink href={kueryQuerySyntaxDocs} target="_blank">
<FormattedMessage
id="common.ui.queryBar.syntaxOptionsDescription.linkText"
Nox911 marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage="here"
/>
</EuiLink>
),
}}
/>
</p>
</EuiText>

Expand All @@ -89,7 +102,12 @@ export class QueryLanguageSwitcher extends Component<Props, State> {
<EuiSwitch
id="queryEnhancementOptIn"
name="popswitch"
label="Turn on query features"
label={
<FormattedMessage
id="common.ui.queryBar.turnOnQueryFeaturesLabel"
defaultMessage="Turn on query features"
/>
}
checked={this.props.language === 'kuery'}
onChange={this.onSwitchChange}
data-test-subj="languageToggle"
Expand All @@ -101,13 +119,20 @@ export class QueryLanguageSwitcher extends Component<Props, State> {

<EuiText size="xs">
<p>
Not ready yet? Find our lucene docs{' '}
{
<EuiLink href={luceneQuerySyntaxDocs} target="_blank">
here
</EuiLink>
}
.
<FormattedMessage
id="common.ui.queryBar.luceneDocsDescription"
defaultMessage="Not ready yet? Find our lucene docs {docsLink}."
values={{
docsLink: (
<EuiLink href={luceneQuerySyntaxDocs} target="_blank">
<FormattedMessage
id="common.ui.queryBar.luceneDocsDescription.linkText"
Nox911 marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage="here"
/>
</EuiLink>
),
}}
/>
</p>
</EuiText>
</div>
Expand Down
34 changes: 17 additions & 17 deletions src/ui/public/query_bar/components/query_bar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ jest.doMock('lodash', () => ({
}));

import { EuiFieldText } from '@elastic/eui';
import { mount, shallow } from 'enzyme';
import React from 'react';
import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';
import { QueryBar } from 'ui/query_bar';
import { QueryLanguageSwitcher } from 'ui/query_bar/components/language_switcher';

Expand Down Expand Up @@ -126,8 +126,8 @@ describe('QueryBar', () => {
});

it('Should render the given query', () => {
const component = shallow(
<QueryBar
const component = shallowWithIntl(
<QueryBar.WrappedComponent
query={kqlQuery}
onSubmit={noop}
appName={'discover'}
Expand All @@ -140,8 +140,8 @@ describe('QueryBar', () => {
});

it('Should pass the query language to the language switcher', () => {
const component = shallow(
<QueryBar
const component = shallowWithIntl(
<QueryBar.WrappedComponent
query={luceneQuery}
onSubmit={noop}
appName={'discover'}
Expand All @@ -154,8 +154,8 @@ describe('QueryBar', () => {
});

it('Should disable autoFocus on EuiFieldText when disableAutoFocus prop is true', () => {
const component = shallow(
<QueryBar
const component = shallowWithIntl(
<QueryBar.WrappedComponent
query={kqlQuery}
onSubmit={noop}
appName={'discover'}
Expand All @@ -169,8 +169,8 @@ describe('QueryBar', () => {
});

it('Should create a unique PersistedLog based on the appName and query language', () => {
shallow(
<QueryBar
shallowWithIntl(
<QueryBar.WrappedComponent
query={kqlQuery}
onSubmit={noop}
appName={'discover'}
Expand All @@ -187,8 +187,8 @@ describe('QueryBar', () => {
const mockStorage = createMockStorage();
const mockCallback = jest.fn();

const component = shallow(
<QueryBar
const component = shallowWithIntl(
<QueryBar.WrappedComponent
query={kqlQuery}
onSubmit={mockCallback}
appName={'discover'}
Expand All @@ -209,8 +209,8 @@ describe('QueryBar', () => {
it('Should call onSubmit with the current query when the user hits enter inside the query bar', () => {
const mockCallback = jest.fn();

const component = mount(
<QueryBar
const component = mountWithIntl(
<QueryBar.WrappedComponent
query={kqlQuery}
onSubmit={mockCallback}
appName={'discover'}
Expand All @@ -234,8 +234,8 @@ describe('QueryBar', () => {
});

it('Should use PersistedLog for recent search suggestions', async () => {
const component = mount(
<QueryBar
const component = mountWithIntl(
<QueryBar.WrappedComponent
query={kqlQuery}
onSubmit={noop}
appName={'discover'}
Expand All @@ -259,8 +259,8 @@ describe('QueryBar', () => {
});

it('Should get suggestions from the autocomplete provider for the current language', () => {
mount(
<QueryBar
mountWithIntl(
<QueryBar.WrappedComponent
query={kqlQuery}
onSubmit={noop}
appName={'discover'}
Expand Down
27 changes: 22 additions & 5 deletions src/ui/public/query_bar/components/query_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import {
EuiOutsideClickDetector,
} from '@elastic/eui';

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

const KEY_CODES = {
LEFT: 37,
UP: 38,
Expand Down Expand Up @@ -83,7 +85,7 @@ interface State {
currentProps?: Props;
}

export class QueryBar extends Component<Props, State> {
class QueryBarUI extends Component<Props, State> {
public static getDerivedStateFromProps(nextProps: Props, prevState: State) {
if (isEqual(prevState.currentProps, nextProps)) {
return null;
Expand Down Expand Up @@ -471,7 +473,10 @@ export class QueryBar extends Component<Props, State> {
<div className="kuiLocalSearchAssistedInput">
<EuiFieldText
className="kuiLocalSearchAssistedInput__input"
placeholder="Search... (e.g. status:200 AND extension:PHP)"
placeholder={this.props.intl.formatMessage({
id: 'common.ui.queryBar.searchInputPlaceholder',
defaultMessage: 'Search… (e.g. status:200 AND extension:PHP)',
})}
value={this.state.query.query}
onKeyDown={this.onKeyDown}
onKeyUp={this.onKeyUp}
Expand All @@ -487,7 +492,10 @@ export class QueryBar extends Component<Props, State> {
autoComplete="off"
spellCheck={false}
icon="console"
aria-label="Search input"
aria-label={this.props.intl.formatMessage({
id: 'common.ui.queryBar.searchInputAriaLabel',
defaultMessage: 'Search input',
})}
type="text"
data-test-subj="queryInput"
aria-autocomplete="list"
Expand Down Expand Up @@ -520,16 +528,25 @@ export class QueryBar extends Component<Props, State> {
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
aria-label="Search"
aria-label={this.props.intl.formatMessage({
id: 'common.ui.queryBar.searchButtonAriaLabel',
defaultMessage: 'Search',
})}
data-test-subj="querySubmitButton"
color={this.isDirty() ? 'secondary' : 'primary'}
fill
onClick={this.onClickSubmitButton}
>
{this.isDirty() ? 'Update' : 'Refresh'}
{this.isDirty() ? (
<FormattedMessage id="common.ui.queryBar.updateLabel" defaultMessage="Update" />
Nox911 marked this conversation as resolved.
Show resolved Hide resolved
) : (
<FormattedMessage id="common.ui.queryBar.refreshLabel" defaultMessage="Refresh" />
Nox911 marked this conversation as resolved.
Show resolved Hide resolved
)}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
);
}
}

export const QueryBar = injectI18n(QueryBarUI);
3 changes: 2 additions & 1 deletion src/ui/public/query_bar/directive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
import 'ngreact';
import { uiModules } from '../../modules';
import { QueryBar } from '../components';
import { injectI18nProvider } from '@kbn/i18n/react';

const app = uiModules.get('app/kibana', ['react']);

app.directive('queryBar', (reactDirective, localStorage) => {
return reactDirective(
QueryBar,
injectI18nProvider(QueryBar),
undefined,
{},
{
Expand Down