[i18n] Translate ML - Jobs - Components (#27781)

* Translate jobs -> components and breadcrumbs

* Update snapshots

* Resolve issues from review comments

* Update snapshot

* Resolve issues from review comments
This commit is contained in:
Nox911 2019-01-09 11:30:04 +03:00 committed by GitHub
parent 045f12aca6
commit bd294c8ef2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 561 additions and 127 deletions

View file

@ -6,6 +6,7 @@
import { ML_BREADCRUMB } from '../breadcrumbs';
import { i18n } from '@kbn/i18n';
export function getJobManagementBreadcrumbs() {
@ -20,7 +21,9 @@ export function getCreateJobBreadcrumbs() {
return [
ML_BREADCRUMB,
{
text: 'Create job',
text: i18n.translate('xpack.ml.jobsBreadcrumbs.createJobLabel', {
defaultMessage: 'Create job'
}),
href: '#/jobs/new_job'
}
];
@ -30,7 +33,9 @@ export function getCreateSingleMetricJobBreadcrumbs() {
return [
...getCreateJobBreadcrumbs(),
{
text: 'Single metric',
text: i18n.translate('xpack.ml.jobsBreadcrumbs.singleMetricLabel', {
defaultMessage: 'Single metric'
}),
href: ''
}
];
@ -40,7 +45,9 @@ export function getCreateMultiMetricJobBreadcrumbs() {
return [
...getCreateJobBreadcrumbs(),
{
text: 'Multi metric',
text: i18n.translate('xpack.ml.jobsBreadcrumbs.multiMetricLabel', {
defaultMessage: 'Multi metric'
}),
href: ''
}
];
@ -50,7 +57,9 @@ export function getCreatePopulationJobBreadcrumbs() {
return [
...getCreateJobBreadcrumbs(),
{
text: 'Population',
text: i18n.translate('xpack.ml.jobsBreadcrumbs.populationLabel', {
defaultMessage: 'Population'
}),
href: ''
}
];
@ -60,7 +69,9 @@ export function getAdvancedJobConfigurationBreadcrumbs() {
return [
...getCreateJobBreadcrumbs(),
{
text: 'Advanced configuration',
text: i18n.translate('xpack.ml.jobsBreadcrumbs.advancedConfigurationLabel', {
defaultMessage: 'Advanced configuration'
}),
href: ''
}
];
@ -80,7 +91,9 @@ export function getDataVisualizerIndexOrSearchBreadcrumbs() {
return [
ML_BREADCRUMB,
{
text: 'Select index or search',
text: i18n.translate('xpack.ml.jobsBreadcrumbs.selectIndexOrSearchLabel', {
defaultMessage: 'Select index or search'
}),
href: ''
}
];

View file

@ -7,7 +7,11 @@ exports[`CustomUrlEditor renders the editor for a dashboard type URL with a labe
textTransform="none"
>
<h4>
Create new custom URL
<FormattedMessage
defaultMessage="Create new custom URL"
id="xpack.ml.customUrlsEditor.createNewCustomUrlTitle"
values={Object {}}
/>
</h4>
</EuiTitle>
<EuiSpacer
@ -24,7 +28,13 @@ exports[`CustomUrlEditor renders the editor for a dashboard type URL with a labe
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Label"
label={
<FormattedMessage
defaultMessage="Label"
id="xpack.ml.customUrlsEditor.labelLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={true}
@ -40,7 +50,13 @@ exports[`CustomUrlEditor renders the editor for a dashboard type URL with a labe
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Link to"
label={
<FormattedMessage
defaultMessage="Link to"
id="xpack.ml.customUrlsEditor.linkToLabel"
values={Object {}}
/>
}
>
<EuiRadioGroup
className="url-link-to-radio"
@ -69,7 +85,13 @@ exports[`CustomUrlEditor renders the editor for a dashboard type URL with a labe
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Dashboard name"
label={
<FormattedMessage
defaultMessage="Dashboard name"
id="xpack.ml.customUrlsEditor.dashboardNameLabel"
values={Object {}}
/>
}
>
<EuiSelect
compressed={true}
@ -96,7 +118,13 @@ exports[`CustomUrlEditor renders the editor for a dashboard type URL with a labe
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Query entities"
label={
<FormattedMessage
defaultMessage="Query entities"
id="xpack.ml.customUrlsEditor.queryEntitiesLabel"
values={Object {}}
/>
}
>
<EuiComboBox
compressed={false}
@ -134,7 +162,13 @@ exports[`CustomUrlEditor renders the editor for a dashboard type URL with a labe
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Time range"
label={
<FormattedMessage
defaultMessage="Time range"
id="xpack.ml.customUrlsEditor.timeRangeLabel"
values={Object {}}
/>
}
>
<EuiSelect
compressed={true}
@ -170,7 +204,11 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with an enti
textTransform="none"
>
<h4>
Create new custom URL
<FormattedMessage
defaultMessage="Create new custom URL"
id="xpack.ml.customUrlsEditor.createNewCustomUrlTitle"
values={Object {}}
/>
</h4>
</EuiTitle>
<EuiSpacer
@ -187,7 +225,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with an enti
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Label"
label={
<FormattedMessage
defaultMessage="Label"
id="xpack.ml.customUrlsEditor.labelLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={true}
@ -203,7 +247,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with an enti
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Link to"
label={
<FormattedMessage
defaultMessage="Link to"
id="xpack.ml.customUrlsEditor.linkToLabel"
values={Object {}}
/>
}
>
<EuiRadioGroup
className="url-link-to-radio"
@ -232,7 +282,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with an enti
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Index pattern"
label={
<FormattedMessage
defaultMessage="Index pattern"
id="xpack.ml.customUrlsEditor.indexPatternLabel"
values={Object {}}
/>
}
>
<EuiSelect
compressed={true}
@ -259,7 +315,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with an enti
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Query entities"
label={
<FormattedMessage
defaultMessage="Query entities"
id="xpack.ml.customUrlsEditor.queryEntitiesLabel"
values={Object {}}
/>
}
>
<EuiComboBox
compressed={false}
@ -303,7 +365,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with an enti
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Time range"
label={
<FormattedMessage
defaultMessage="Time range"
id="xpack.ml.customUrlsEditor.timeRangeLabel"
values={Object {}}
/>
}
>
<EuiSelect
compressed={true}
@ -343,7 +411,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with an enti
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={true}
label="Interval"
label={
<FormattedMessage
defaultMessage="Interval"
id="xpack.ml.customUrlsEditor.intervalLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={true}
@ -367,7 +441,11 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with valid t
textTransform="none"
>
<h4>
Create new custom URL
<FormattedMessage
defaultMessage="Create new custom URL"
id="xpack.ml.customUrlsEditor.createNewCustomUrlTitle"
values={Object {}}
/>
</h4>
</EuiTitle>
<EuiSpacer
@ -384,7 +462,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with valid t
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Label"
label={
<FormattedMessage
defaultMessage="Label"
id="xpack.ml.customUrlsEditor.labelLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={true}
@ -400,7 +484,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with valid t
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Link to"
label={
<FormattedMessage
defaultMessage="Link to"
id="xpack.ml.customUrlsEditor.linkToLabel"
values={Object {}}
/>
}
>
<EuiRadioGroup
className="url-link-to-radio"
@ -429,7 +519,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with valid t
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Index pattern"
label={
<FormattedMessage
defaultMessage="Index pattern"
id="xpack.ml.customUrlsEditor.indexPatternLabel"
values={Object {}}
/>
}
>
<EuiSelect
compressed={true}
@ -456,7 +552,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with valid t
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Query entities"
label={
<FormattedMessage
defaultMessage="Query entities"
id="xpack.ml.customUrlsEditor.queryEntitiesLabel"
values={Object {}}
/>
}
>
<EuiComboBox
compressed={false}
@ -500,7 +602,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with valid t
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Time range"
label={
<FormattedMessage
defaultMessage="Time range"
id="xpack.ml.customUrlsEditor.timeRangeLabel"
values={Object {}}
/>
}
>
<EuiSelect
compressed={true}
@ -536,7 +644,13 @@ exports[`CustomUrlEditor renders the editor for a discover type URL with valid t
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Interval"
label={
<FormattedMessage
defaultMessage="Interval"
id="xpack.ml.customUrlsEditor.intervalLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={true}
@ -560,7 +674,11 @@ exports[`CustomUrlEditor renders the editor for a new dashboard type URL with no
textTransform="none"
>
<h4>
Create new custom URL
<FormattedMessage
defaultMessage="Create new custom URL"
id="xpack.ml.customUrlsEditor.createNewCustomUrlTitle"
values={Object {}}
/>
</h4>
</EuiTitle>
<EuiSpacer
@ -581,7 +699,13 @@ exports[`CustomUrlEditor renders the editor for a new dashboard type URL with no
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={true}
label="Label"
label={
<FormattedMessage
defaultMessage="Label"
id="xpack.ml.customUrlsEditor.labelLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={true}
@ -597,7 +721,13 @@ exports[`CustomUrlEditor renders the editor for a new dashboard type URL with no
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Link to"
label={
<FormattedMessage
defaultMessage="Link to"
id="xpack.ml.customUrlsEditor.linkToLabel"
values={Object {}}
/>
}
>
<EuiRadioGroup
className="url-link-to-radio"
@ -626,7 +756,13 @@ exports[`CustomUrlEditor renders the editor for a new dashboard type URL with no
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Dashboard name"
label={
<FormattedMessage
defaultMessage="Dashboard name"
id="xpack.ml.customUrlsEditor.dashboardNameLabel"
values={Object {}}
/>
}
>
<EuiSelect
compressed={true}
@ -653,7 +789,13 @@ exports[`CustomUrlEditor renders the editor for a new dashboard type URL with no
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Query entities"
label={
<FormattedMessage
defaultMessage="Query entities"
id="xpack.ml.customUrlsEditor.queryEntitiesLabel"
values={Object {}}
/>
}
>
<EuiComboBox
compressed={false}
@ -691,7 +833,13 @@ exports[`CustomUrlEditor renders the editor for a new dashboard type URL with no
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Time range"
label={
<FormattedMessage
defaultMessage="Time range"
id="xpack.ml.customUrlsEditor.timeRangeLabel"
values={Object {}}
/>
}
>
<EuiSelect
compressed={true}
@ -727,7 +875,11 @@ exports[`CustomUrlEditor renders the editor for other type of URL with duplicate
textTransform="none"
>
<h4>
Create new custom URL
<FormattedMessage
defaultMessage="Create new custom URL"
id="xpack.ml.customUrlsEditor.createNewCustomUrlTitle"
values={Object {}}
/>
</h4>
</EuiTitle>
<EuiSpacer
@ -748,7 +900,13 @@ exports[`CustomUrlEditor renders the editor for other type of URL with duplicate
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={true}
label="Label"
label={
<FormattedMessage
defaultMessage="Label"
id="xpack.ml.customUrlsEditor.labelLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={true}
@ -764,7 +922,13 @@ exports[`CustomUrlEditor renders the editor for other type of URL with duplicate
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Link to"
label={
<FormattedMessage
defaultMessage="Link to"
id="xpack.ml.customUrlsEditor.linkToLabel"
values={Object {}}
/>
}
>
<EuiRadioGroup
className="url-link-to-radio"
@ -793,7 +957,13 @@ exports[`CustomUrlEditor renders the editor for other type of URL with duplicate
describedByIds={Array []}
fullWidth={true}
hasEmptyLabelSpace={false}
label="URL"
label={
<FormattedMessage
defaultMessage="URL"
id="xpack.ml.customUrlsEditor.urlLabel"
values={Object {}}
/>
}
>
<EuiTextArea
compressed={true}
@ -815,7 +985,11 @@ exports[`CustomUrlEditor renders the editor for other type of URL with unique la
textTransform="none"
>
<h4>
Create new custom URL
<FormattedMessage
defaultMessage="Create new custom URL"
id="xpack.ml.customUrlsEditor.createNewCustomUrlTitle"
values={Object {}}
/>
</h4>
</EuiTitle>
<EuiSpacer
@ -832,7 +1006,13 @@ exports[`CustomUrlEditor renders the editor for other type of URL with unique la
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Label"
label={
<FormattedMessage
defaultMessage="Label"
id="xpack.ml.customUrlsEditor.labelLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={true}
@ -848,7 +1028,13 @@ exports[`CustomUrlEditor renders the editor for other type of URL with unique la
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Link to"
label={
<FormattedMessage
defaultMessage="Link to"
id="xpack.ml.customUrlsEditor.linkToLabel"
values={Object {}}
/>
}
>
<EuiRadioGroup
className="url-link-to-radio"
@ -877,7 +1063,13 @@ exports[`CustomUrlEditor renders the editor for other type of URL with unique la
describedByIds={Array []}
fullWidth={true}
hasEmptyLabelSpace={false}
label="URL"
label={
<FormattedMessage
defaultMessage="URL"
id="xpack.ml.customUrlsEditor.urlLabel"
values={Object {}}
/>
}
>
<EuiTextArea
compressed={true}

View file

@ -22,7 +22,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Label"
label={
<FormattedMessage
defaultMessage="Label"
id="xpack.ml.customUrlEditorList.labelLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={false}
@ -42,7 +48,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="URL"
label={
<FormattedMessage
defaultMessage="URL"
id="xpack.ml.customUrlEditorList.urlLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={false}
@ -63,7 +75,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Time range"
label={
<FormattedMessage
defaultMessage="Time range"
id="xpack.ml.customUrlEditorList.timeRangeLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={false}
@ -86,7 +104,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
hasEmptyLabelSpace={true}
>
<EuiToolTip
content="Test custom URL"
content={
<FormattedMessage
defaultMessage="Test custom URL"
id="xpack.ml.customUrlEditorList.testCustomUrlTooltip"
values={Object {}}
/>
}
delay="regular"
position="top"
>
@ -112,7 +136,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
hasEmptyLabelSpace={true}
>
<EuiToolTip
content="Delete custom URL"
content={
<FormattedMessage
defaultMessage="Delete custom URL"
id="xpack.ml.customUrlEditorList.deleteCustomUrlTooltip"
values={Object {}}
/>
}
delay="regular"
position="top"
>
@ -149,7 +179,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Label"
label={
<FormattedMessage
defaultMessage="Label"
id="xpack.ml.customUrlEditorList.labelLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={false}
@ -169,7 +205,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="URL"
label={
<FormattedMessage
defaultMessage="URL"
id="xpack.ml.customUrlEditorList.urlLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={false}
@ -190,7 +232,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Time range"
label={
<FormattedMessage
defaultMessage="Time range"
id="xpack.ml.customUrlEditorList.timeRangeLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={false}
@ -213,7 +261,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
hasEmptyLabelSpace={true}
>
<EuiToolTip
content="Test custom URL"
content={
<FormattedMessage
defaultMessage="Test custom URL"
id="xpack.ml.customUrlEditorList.testCustomUrlTooltip"
values={Object {}}
/>
}
delay="regular"
position="top"
>
@ -239,7 +293,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
hasEmptyLabelSpace={true}
>
<EuiToolTip
content="Delete custom URL"
content={
<FormattedMessage
defaultMessage="Delete custom URL"
id="xpack.ml.customUrlEditorList.deleteCustomUrlTooltip"
values={Object {}}
/>
}
delay="regular"
position="top"
>
@ -276,7 +336,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Label"
label={
<FormattedMessage
defaultMessage="Label"
id="xpack.ml.customUrlEditorList.labelLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={false}
@ -296,7 +362,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="URL"
label={
<FormattedMessage
defaultMessage="URL"
id="xpack.ml.customUrlEditorList.urlLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={false}
@ -317,7 +389,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
fullWidth={false}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Time range"
label={
<FormattedMessage
defaultMessage="Time range"
id="xpack.ml.customUrlEditorList.timeRangeLabel"
values={Object {}}
/>
}
>
<EuiFieldText
compressed={false}
@ -340,7 +418,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
hasEmptyLabelSpace={true}
>
<EuiToolTip
content="Test custom URL"
content={
<FormattedMessage
defaultMessage="Test custom URL"
id="xpack.ml.customUrlEditorList.testCustomUrlTooltip"
values={Object {}}
/>
}
delay="regular"
position="top"
>
@ -366,7 +450,13 @@ exports[`CustomUrlList renders a list of custom URLs 1`] = `
hasEmptyLabelSpace={true}
>
<EuiToolTip
content="Delete custom URL"
content={
<FormattedMessage
defaultMessage="Delete custom URL"
id="xpack.ml.customUrlEditorList.deleteCustomUrlTooltip"
values={Object {}}
/>
}
delay="regular"
position="top"
>

View file

@ -30,6 +30,8 @@ import {
import { isValidCustomUrlSettingsTimeRange } from '../../../jobs/components/custom_url_editor/utils';
import { isValidLabel } from '../../../util/custom_url_utils';
import { i18n } from '@kbn/i18n';
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
import {
TIME_RANGE_TYPE,
@ -39,17 +41,31 @@ import {
function getLinkToOptions() {
return [{
id: URL_TYPE.KIBANA_DASHBOARD,
label: 'Kibana dashboard',
label: i18n.translate('xpack.ml.customUrlEditor.kibanaDashboardLabel', {
defaultMessage: 'Kibana dashboard'
}),
}, {
id: URL_TYPE.KIBANA_DISCOVER,
label: 'Discover',
label: i18n.translate('xpack.ml.customUrlEditor.discoverLabel', {
defaultMessage: 'Discover'
}),
}, {
id: URL_TYPE.OTHER,
label: 'Other',
label: i18n.translate('xpack.ml.customUrlEditor.otherLabel', {
defaultMessage: 'Other'
}),
}];
}
export class CustomUrlEditor extends Component {
export const CustomUrlEditor = injectI18n(class CustomUrlEditor extends Component {
static propTypes = {
customUrl: PropTypes.object,
setEditCustomUrl: PropTypes.func.isRequired,
savedCustomUrls: PropTypes.array.isRequired,
dashboards: PropTypes.array.isRequired,
indexPatterns: PropTypes.array.isRequired,
queryEntityFieldNames: PropTypes.array.isRequired,
};
constructor(props) {
super(props);
@ -150,6 +166,7 @@ export class CustomUrlEditor extends Component {
dashboards,
indexPatterns,
queryEntityFieldNames,
intl
} = this.props;
if (customUrl === undefined) {
@ -184,20 +201,38 @@ export class CustomUrlEditor extends Component {
});
const isInvalidLabel = !isValidLabel(label, savedCustomUrls);
const invalidLabelError = (isInvalidLabel === true) ? ['A unique label must be supplied'] : [];
const invalidLabelError = (isInvalidLabel === true) ? [
intl.formatMessage({
id: 'xpack.ml.customUrlsEditor.invalidLabelErrorMessage',
defaultMessage: 'A unique label must be supplied'
})
] : [];
const isInvalidTimeRange = !isValidCustomUrlSettingsTimeRange(timeRange);
const invalidIntervalError = (isInvalidTimeRange === true) ? ['Invalid interval format'] : [];
const invalidIntervalError = (isInvalidTimeRange === true) ? [
intl.formatMessage({
id: 'xpack.ml.customUrlsList.invalidIntervalFormatErrorMessage',
defaultMessage: 'Invalid interval format'
})
] : [];
return (
<React.Fragment>
<EuiTitle size="xs">
<h4>Create new custom URL</h4>
<h4>
<FormattedMessage
id="xpack.ml.customUrlsEditor.createNewCustomUrlTitle"
defaultMessage="Create new custom URL"
/>
</h4>
</EuiTitle>
<EuiSpacer size="m" />
<EuiForm className="ml-edit-url-form">
<EuiFormRow
label="Label"
label={<FormattedMessage
id="xpack.ml.customUrlsEditor.labelLabel"
defaultMessage="Label"
/>}
className="url-label"
error={invalidLabelError}
isInvalid={isInvalidLabel}
@ -211,7 +246,10 @@ export class CustomUrlEditor extends Component {
/>
</EuiFormRow>
<EuiFormRow
label="Link to"
label={<FormattedMessage
id="xpack.ml.customUrlsEditor.linkToLabel"
defaultMessage="Link to"
/>}
compressed
>
<EuiRadioGroup
@ -224,7 +262,10 @@ export class CustomUrlEditor extends Component {
{type === URL_TYPE.KIBANA_DASHBOARD &&
<EuiFormRow
label="Dashboard name"
label={<FormattedMessage
id="xpack.ml.customUrlsEditor.dashboardNameLabel"
defaultMessage="Dashboard name"
/>}
compressed
>
<EuiSelect
@ -238,7 +279,10 @@ export class CustomUrlEditor extends Component {
{type === URL_TYPE.KIBANA_DISCOVER &&
<EuiFormRow
label="Index pattern"
label={<FormattedMessage
id="xpack.ml.customUrlsEditor.indexPatternLabel"
defaultMessage="Index pattern"
/>}
compressed
>
<EuiSelect
@ -253,10 +297,16 @@ export class CustomUrlEditor extends Component {
{(type === URL_TYPE.KIBANA_DASHBOARD || type === URL_TYPE.KIBANA_DISCOVER) &&
entityOptions.length > 0 &&
<EuiFormRow
label="Query entities"
label={<FormattedMessage
id="xpack.ml.customUrlsEditor.queryEntitiesLabel"
defaultMessage="Query entities"
/>}
>
<EuiComboBox
placeholder="Select entities"
placeholder={intl.formatMessage({
id: 'xpack.ml.customUrlsEditor.selectEntitiesPlaceholder',
defaultMessage: 'Select entities'
})}
options={entityOptions}
selectedOptions={selectedEntityOptions}
onChange={this.onQueryEntitiesChange}
@ -269,7 +319,10 @@ export class CustomUrlEditor extends Component {
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiFormRow
label="Time range"
label={<FormattedMessage
id="xpack.ml.customUrlsEditor.timeRangeLabel"
defaultMessage="Time range"
/>}
className="url-time-range"
compressed
>
@ -284,7 +337,10 @@ export class CustomUrlEditor extends Component {
{(timeRange.type === TIME_RANGE_TYPE.INTERVAL) &&
<EuiFlexItem>
<EuiFormRow
label="Interval"
label={<FormattedMessage
id="xpack.ml.customUrlsEditor.intervalLabel"
defaultMessage="Interval"
/>}
className="url-time-range"
error={invalidIntervalError}
isInvalid={isInvalidTimeRange}
@ -304,7 +360,10 @@ export class CustomUrlEditor extends Component {
{type === URL_TYPE.OTHER &&
<EuiFormRow
label="URL"
label={<FormattedMessage
id="xpack.ml.customUrlsEditor.urlLabel"
defaultMessage="URL"
/>}
compressed
fullWidth={true}
>
@ -323,14 +382,4 @@ export class CustomUrlEditor extends Component {
</React.Fragment>
);
}
}
CustomUrlEditor.propTypes = {
customUrl: PropTypes.object,
setEditCustomUrl: PropTypes.func.isRequired,
savedCustomUrls: PropTypes.array.isRequired,
dashboards: PropTypes.array.isRequired,
indexPatterns: PropTypes.array.isRequired,
queryEntityFieldNames: PropTypes.array.isRequired,
};
});

View file

@ -7,7 +7,7 @@
// Mock the mlJobService that is used for testing custom URLs.
jest.mock('../../../services/job_service.js', () => 'mlJobService');
import { shallow } from 'enzyme';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import React from 'react';
import { CustomUrlEditor } from './editor';
@ -61,8 +61,8 @@ function prepareTest(customUrl, setEditCustomUrlFn) {
queryEntityFieldNames,
};
const wrapper = shallow(
<CustomUrlEditor {...props} />
const wrapper = shallowWithIntl(
<CustomUrlEditor.WrappedComponent {...props} />
);
return wrapper;

View file

@ -31,6 +31,7 @@ import { getTestUrl } from '../../../jobs/components/custom_url_editor/utils';
import { parseInterval } from '../../../../common/util/parse_interval';
import { TIME_RANGE_TYPE } from './constants';
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
function isValidTimeRange(timeRange) {
@ -43,7 +44,12 @@ function isValidTimeRange(timeRange) {
return (interval !== null);
}
export class CustomUrlList extends Component {
export const CustomUrlList = injectI18n(class CustomUrlList extends Component {
static propTypes = {
job: PropTypes.object.isRequired,
customUrls: PropTypes.array.isRequired,
setCustomUrls: PropTypes.func.isRequired,
}
constructor(props) {
super(props);
@ -105,13 +111,19 @@ export class CustomUrlList extends Component {
})
.catch((resp) => {
console.log('Error obtaining URL for test:', resp);
toastNotifications.addDanger('An error occurred obtaining the URL to test the configuration');
toastNotifications.addDanger(
this.props.intl.formatMessage({
id: 'xpack.ml.customUrlEditorList.obtainingUrlToTestConfigurationErrorMessage',
defaultMessage: 'An error occurred obtaining the URL to test the configuration'
})
);
});
}
};
render() {
const customUrls = this.props.customUrls;
const { intl } = this.props;
// TODO - swap URL input to a textarea on focus / blur.
const customUrlRows = customUrls.map((customUrl, index) => {
@ -121,18 +133,31 @@ export class CustomUrlList extends Component {
const otherUrls = [...customUrls];
otherUrls.splice(index, 1); // Don't compare label with itself.
const isInvalidLabel = !isValidLabel(label, otherUrls);
const invalidLabelError = (isInvalidLabel === true) ? ['A unique label must be supplied'] : [];
const invalidLabelError = (isInvalidLabel === true) ? [
intl.formatMessage({
id: 'xpack.ml.customUrlEditorList.labelIsNotUniqueErrorMessage',
defaultMessage: 'A unique label must be supplied'
})
] : [];
// Validate the time range.
const timeRange = customUrl.time_range;
const isInvalidTimeRange = !(isValidTimeRange(timeRange));
const invalidIntervalError = (isInvalidTimeRange === true) ? ['Invalid format'] : [];
const invalidIntervalError = (isInvalidTimeRange === true) ? [
intl.formatMessage({
id: 'xpack.ml.customUrlEditorList.invalidTimeRangeFormatErrorMessage',
defaultMessage: 'Invalid format'
})
] : [];
return (
<EuiFlexGroup key={`url_${index}`}>
<EuiFlexItem grow={false}>
<EuiFormRow
label="Label"
label={<FormattedMessage
id="xpack.ml.customUrlEditorList.labelLabel"
defaultMessage="Label"
/>}
isInvalid={isInvalidLabel}
error={invalidLabelError}
>
@ -144,7 +169,12 @@ export class CustomUrlList extends Component {
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem>
<EuiFormRow label="URL">
<EuiFormRow
label={<FormattedMessage
id="xpack.ml.customUrlEditorList.urlLabel"
defaultMessage="URL"
/>}
>
<EuiFieldText
value={customUrl.url_value}
onChange={(e) => this.onUrlValueChange(e, index)}
@ -153,7 +183,10 @@ export class CustomUrlList extends Component {
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFormRow
label="Time range"
label={<FormattedMessage
id="xpack.ml.customUrlEditorList.timeRangeLabel"
defaultMessage="Time range"
/>}
error={invalidIntervalError}
isInvalid={isInvalidTimeRange}
>
@ -168,14 +201,20 @@ export class CustomUrlList extends Component {
<EuiFlexItem grow={false}>
<EuiFormRow hasEmptyLabelSpace>
<EuiToolTip
content="Test custom URL"
content={<FormattedMessage
id="xpack.ml.customUrlEditorList.testCustomUrlTooltip"
defaultMessage="Test custom URL"
/>}
>
<EuiButtonIcon
size="s"
color="primary"
onClick={() => this.onTestButtonClick(index)}
iconType="popout"
aria-label="Test custom URL"
aria-label={intl.formatMessage({
id: 'xpack.ml.customUrlEditorList.testCustomUrlAriaLabel',
defaultMessage: 'Test custom URL'
})}
/>
</EuiToolTip>
</EuiFormRow>
@ -183,14 +222,20 @@ export class CustomUrlList extends Component {
<EuiFlexItem grow={false}>
<EuiFormRow hasEmptyLabelSpace>
<EuiToolTip
content="Delete custom URL"
content={<FormattedMessage
id="xpack.ml.customUrlEditorList.deleteCustomUrlTooltip"
defaultMessage="Delete custom URL"
/>}
>
<EuiButtonIcon
size="s"
color="danger"
onClick={() => this.onDeleteButtonClick(index)}
iconType="trash"
aria-label="Delete custom URL"
aria-label={intl.formatMessage({
id: 'xpack.ml.customUrlEditorList.deleteCustomUrlAriaLabel',
defaultMessage: 'Delete custom URL'
})}
/>
</EuiToolTip>
</EuiFormRow>
@ -205,11 +250,4 @@ export class CustomUrlList extends Component {
</React.Fragment>
);
}
}
CustomUrlList.propTypes = {
job: PropTypes.object.isRequired,
customUrls: PropTypes.array.isRequired,
setCustomUrls: PropTypes.func.isRequired,
};
});

View file

@ -7,7 +7,7 @@
// Mock the mlJobService that is used for testing custom URLs.
jest.mock('../../../services/job_service.js', () => 'mlJobService');
import { shallow } from 'enzyme';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import React from 'react';
import { CustomUrlList } from './list';
@ -42,8 +42,8 @@ function prepareTest(setCustomUrlsFn) {
setCustomUrls: setCustomUrlsFn,
};
const wrapper = shallow(
<CustomUrlList {...props} />
const wrapper = shallowWithIntl(
<CustomUrlList.WrappedComponent {...props} />
);
return wrapper;

View file

@ -1,6 +1,12 @@
<div class="job-timepicker-modal">
<ml-message-bar ></ml-message-bar>
<h1 tooltip="Start datafeed for {{jobId}}" class="euiTitle">Start datafeed for {{jobId}}</h1>
<h1
tooltip="Start datafeed for {{jobId}}"
class="euiTitle"
i18n-id="xpack.ml.jobTimePickerModal.startDatafeedForJobTitle"
i18n-default-message="Start datafeed for {jobId}"
i18n-values="{ jobId }"
></h1>
<div class="euiSpacer euiSpacer--s"></div>
@ -13,18 +19,22 @@
(+ui.startRadio <= 1 && ui.endRadio === '0') ||
(ui.startRadio === '2' && +ui.endRadio <= 1)
}">
<label class="kuiFormLabel">Search start time</label>
<label
class="kuiFormLabel"
i18n-id="xpack.ml.jobTimePickerModal.searchStartTimeLabel"
i18n-default-message="Search start time"
></label>
<div class="ml-timepicker-radios" >
<ul class="nav nav-pills nav-stacked">
<li ng-class="{ active: ui.startRadio === '1' }">
<a ng-click="ui.startRadio = '1'" >{{ ( isNew?"Start at beginning of data" : "Continue from " + ui.lastTime ) }}</a>
<a ng-click="ui.startRadio = '1'" >{{ ( isNew ? startAtBeginningOfDataLabel : continueFromLastTimeLabel ) }}</a>
</li>
<li ng-class="{ active: ui.startRadio === '0' }">
<a ng-click="ui.startRadio = '0'">{{ ( isNew?"Start now" : "Continue from now" ) }}</a>
<a ng-click="ui.startRadio = '0'">{{ ( isNew ? startNowLabel : continueFromNowLabel ) }}</a>
</li>
<li ng-class="{ active: ui.startRadio === '2' }">
<a ng-click="ui.startRadio = '2'" ng-class="{'ml-timepicker-radio-bottom': ui.startRadio === '2'}">{{ ( isNew?"Specify start time" : "Continue from specified time" ) }}</a>
<a ng-click="ui.startRadio = '2'" ng-class="{'ml-timepicker-radio-bottom': ui.startRadio === '2'}">{{ ( isNew ? specifyStartTimeLabel : continueFromSpecifiedTimeLabel ) }}</a>
</li>
</ul>
</div>
@ -47,14 +57,27 @@
'ml-timepicker-left-border':
(+ui.startRadio <= 1 && ui.endRadio === '1')
}">
<label class="kuiFormLabel">Search end time</label>
<label
class="kuiFormLabel"
i18n-id="xpack.ml.jobTimePickerModal.searchEndTimeLabel"
i18n-default-message="Search end time"
></label>
<div class="ml-timepicker-radios" >
<ul class="nav nav-pills nav-stacked">
<li ng-class="{ active: ui.endRadio === '0' }">
<a ng-click="ui.endRadio = '0'">No end time (Real-time search)</a>
<a
ng-click="ui.endRadio = '0'"
i18n-id="xpack.ml.jobTimePickerModal.noEndTimeLinkText"
i18n-default-message="No end time (Real-time search)"
></a>
</li>
<li ng-class="{ active: ui.endRadio === '1' }">
<a ng-click="ui.endRadio = '1'" ng-class="{'ml-timepicker-radio-bottom': ui.endRadio === '1'}">Specify end time</a>
<a
ng-click="ui.endRadio = '1'"
ng-class="{'ml-timepicker-radio-bottom': ui.endRadio === '1'}"
i18n-id="xpack.ml.jobTimePickerModal.specifyEndTimeLinkText"
i18n-default-message="Specify end time"
></a>
</li>
</ul>
</div>
@ -79,9 +102,11 @@
<hr class="euiHorizontalRule euiHorizontalRule--full euiHorizontalRule--marginMedium">
<label class='kuiCheckBoxLabel kuiVerticalRhythm'>
<input ng-model='ui.createWatch' type="checkbox" class='kuiCheckBox'/>
<span class="kuiCheckBoxLabel__text">
Create watch after datafeed has started
</span>
<span
class="kuiCheckBoxLabel__text"
i18n-id="xpack.ml.jobTimePickerModal.createWatchAfterDatafeedHasStartedLabel"
i18n-default-message="Create watch after datafeed has started"
></span>
</label>
</div>
<div class="clearfix"></div>
@ -95,15 +120,17 @@
( ui.startRadio==='2' && ui.timepicker.from==='' ) ||
( ui.endRadio==='1' && ui.timepicker.to==='' )
)"
class="kuiButton kuiButton--primary" >
Start
</button>
class="kuiButton kuiButton--primary"
i18n-id="xpack.ml.jobTimePickerModal.startButtonLabel"
i18n-default-message="Start"
></button>
<button
ng-click="cancel()"
ng-disabled="(saveLock === true)"
class="kuiButton kuiButton--primary"
aria-label="Cancel">
Cancel
</button>
aria-label="{{ ::'xpack.ml.jobTimePickerModal.cancelButtonAriaLabel' | i18n: {defaultMessage: 'Cancel'} }}"
i18n-id="xpack.ml.jobTimePickerModal.cancelButtonLabel"
i18n-default-message="Cancel"
></button>
</div>

View file

@ -21,7 +21,8 @@ module.controller('MlJobTimepickerModal', function (
$rootScope,
$modalInstance,
params,
Private) {
Private,
i18n) {
const msgs = mlMessageBarService;
$scope.saveLock = false;
const xpackFeature = Private(xpackFeatureProvider);
@ -43,6 +44,26 @@ module.controller('MlJobTimepickerModal', function (
$scope.isNew = (job.data_counts && job.data_counts.input_record_count > 0) ? false : true;
$scope.startAtBeginningOfDataLabel = i18n('xpack.ml.jobTimePickerModal.startAtBeginningOfDataLabel', {
defaultMessage: 'Start at beginning of data'
});
$scope.continueFromLastTime = i18n('xpack.ml.jobTimePickerModal.continueFromLastTimeLabel', {
defaultMessage: 'Continue from {lastTime}',
values: { lastTime }
});
$scope.startNowLabel = i18n('xpack.ml.jobTimePickerModal.startNowLabel', {
defaultMessage: 'Start now'
});
$scope.continueFromNowLabel = i18n('xpack.ml.jobTimePickerModal.continueFromNowLabel', {
defaultMessage: 'Continue from now'
});
$scope.specifyStartTimeLabel = i18n('xpack.ml.jobTimePickerModal.specifyStartTimeLabel', {
defaultMessage: 'Specify start time'
});
$scope.continueFromSpecifiedTimeLabel = i18n('xpack.ml.jobTimePickerModal.continueFromSpecifiedTimeLabel', {
defaultMessage: 'Continue from specified time'
});
$scope.ui = {
lastTime: lastTime,
startDateText: '',
@ -95,6 +116,10 @@ module.controller('MlJobTimepickerModal', function (
doStart();
})
.catch((resp) => {
const couldNotOpenJobErrorMessage = i18n('xpack.ml.jobTimePickerModal.couldNotOpenJobErrorMessage', {
defaultMessage: 'Could not open {jobId}',
values: { jobId: $scope.jobId }
});
if (resp.statusCode === 409) {
doStart();
} else {
@ -102,11 +127,11 @@ module.controller('MlJobTimepickerModal', function (
if (doStartCalled === false) {
// doStart hasn't been called yet, this 500 has returned before 10s,
// so it's not due to a timeout
msgs.error(`Could not open ${$scope.jobId}`, resp);
msgs.error(couldNotOpenJobErrorMessage, resp);
}
} else {
// console.log(resp);
msgs.error(`Could not open ${$scope.jobId}`, resp);
msgs.error(couldNotOpenJobErrorMessage, resp);
}
$scope.saveLock = false;
}