Skip to content

Commit

Permalink
Feature/translate ml - jobs(part 2) (elastic#25528)
Browse files Browse the repository at this point in the history
Translate ml -> jobs - jobs-list(part_2)
  • Loading branch information
Nox911 authored and pavel06081991 committed Dec 10, 2018
1 parent 2167c5b commit 3a6a00c
Show file tree
Hide file tree
Showing 7 changed files with 292 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ import { toastNotifications } from 'ui/notify';
import { loadFullJob } from '../utils';
import { mlCreateWatchService } from '../../../../jobs/new_job/simple/components/watcher/create_watch_service';
import { CreateWatch } from '../../../../jobs/new_job/simple/components/watcher/create_watch_view';
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';


function getSuccessToast(id, url) {
function getSuccessToast(id, url, intl) {
return {
title: `Watch ${id} created successfully`,
title: intl.formatMessage({
id: 'xpack.ml.jobsList.createWatchFlyout.watchCreatedSuccessfullyNotificationMessage',
defaultMessage: 'Watch {id} created successfully' },
{ id }
),
text: (
<React.Fragment>
<EuiFlexGroup justifyContent="flexEnd" gutterSize="s">
Expand All @@ -41,7 +46,10 @@ function getSuccessToast(id, url) {
target="_blank"
iconType="link"
>
Edit watch
{intl.formatMessage({
id: 'xpack.ml.jobsList.createWatchFlyout.editWatchButtonLabel',
defaultMessage: 'Edit watch' }
)}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
Expand All @@ -50,7 +58,7 @@ function getSuccessToast(id, url) {
};
}

export class CreateWatchFlyout extends Component {
class CreateWatchFlyoutUI extends Component {
constructor(props) {
super(props);

Expand Down Expand Up @@ -95,13 +103,17 @@ export class CreateWatchFlyout extends Component {
}

save = () => {
const { intl } = this.props;
mlCreateWatchService.createNewWatch(this.state.jobId)
.then((resp) => {
toastNotifications.addSuccess(getSuccessToast(resp.id, resp.url));
toastNotifications.addSuccess(getSuccessToast(resp.id, resp.url, intl));
this.closeFlyout();
})
.catch((error) => {
toastNotifications.addDanger(`Could not save watch`);
toastNotifications.addDanger(intl.formatMessage({
id: 'xpack.ml.jobsList.createWatchFlyout.watchNotSavedErrorNotificationMessage',
defaultMessage: 'Could not save watch'
}));
console.error(error);
});
}
Expand All @@ -125,7 +137,11 @@ export class CreateWatchFlyout extends Component {
<EuiFlyoutHeader>
<EuiTitle>
<h2>
Create watch for {jobId}
<FormattedMessage
id="xpack.ml.jobsList.createWatchFlyout.pageTitle"
defaultMessage="Create watch for {jobId}"
values={{ jobId }}
/>
</h2>
</EuiTitle>
</EuiFlyoutHeader>
Expand All @@ -145,15 +161,21 @@ export class CreateWatchFlyout extends Component {
onClick={this.closeFlyout}
flush="left"
>
Close
<FormattedMessage
id="xpack.ml.jobsList.createWatchFlyout.closeButtonLabel"
defaultMessage="Close"
/>
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
onClick={this.save}
fill
>
Save
<FormattedMessage
id="xpack.ml.jobsList.createWatchFlyout.saveButtonLabel"
defaultMessage="Save"
/>
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
Expand All @@ -169,8 +191,9 @@ export class CreateWatchFlyout extends Component {

}
}
CreateWatchFlyout.propTypes = {
CreateWatchFlyoutUI.propTypes = {
setShowFunction: PropTypes.func.isRequired,
unsetShowFunction: PropTypes.func.isRequired,
};

export const CreateWatchFlyout = injectI18n(CreateWatchFlyoutUI);
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { detectorToString } from 'plugins/ml/util/string_utils';
import { formatValues, filterObjects } from './format_values';
import { i18n } from '@kbn/i18n';

export function extractJobDetails(job) {

Expand All @@ -15,14 +16,18 @@ export function extractJobDetails(job) {
}

const general = {
title: 'General',
title: i18n.translate('xpack.ml.jobsList.jobDetails.generalTitle', {
defaultMessage: 'General'
}),
position: 'left',
items: filterObjects(job, true).map(formatValues)
};


const customUrl = {
title: 'Custom URLs',
title: i18n.translate('xpack.ml.jobsList.jobDetails.customUrlsTitle', {
defaultMessage: 'Custom URLs'
}),
position: 'right',
items: []
};
Expand All @@ -31,7 +36,9 @@ export function extractJobDetails(job) {
}

const node = {
title: 'Node',
title: i18n.translate('xpack.ml.jobsList.jobDetails.nodeTitle', {
defaultMessage: 'Node'
}),
position: 'right',
items: []
};
Expand All @@ -40,7 +47,9 @@ export function extractJobDetails(job) {
}

const detectors = {
title: 'Detectors',
title: i18n.translate('xpack.ml.jobsList.jobDetails.detectorsTitle', {
defaultMessage: 'Detectors'
}),
position: 'left',
items: []
};
Expand All @@ -55,31 +64,41 @@ export function extractJobDetails(job) {
}

const influencers = {
title: 'Influencers',
title: i18n.translate('xpack.ml.jobsList.jobDetails.influencersTitle', {
defaultMessage: 'Influencers'
}),
position: 'left',
items: job.analysis_config.influencers.map(i => ['', i])
};

const analysisConfig = {
title: 'Analysis config',
title: i18n.translate('xpack.ml.jobsList.jobDetails.analysisConfigTitle', {
defaultMessage: 'Analysis config'
}),
position: 'left',
items: filterObjects(job.analysis_config)
};

const analysisLimits = {
title: 'Analysis limits',
title: i18n.translate('xpack.ml.jobsList.jobDetails.analysisLimitsTitle', {
defaultMessage: 'Analysis limits'
}),
position: 'left',
items: filterObjects(job.analysis_limits)
};

const dataDescription = {
title: 'Data description',
title: i18n.translate('xpack.ml.jobsList.jobDetails.dataDescriptionTitle', {
defaultMessage: 'Data description'
}),
position: 'right',
items: filterObjects(job.data_description)
};

const datafeed = {
title: 'Datafeed',
title: i18n.translate('xpack.ml.jobsList.jobDetails.datafeedTitle', {
defaultMessage: 'Datafeed'
}),
position: 'left',
items: filterObjects(job.datafeed_config, true, true)
};
Expand All @@ -88,13 +107,17 @@ export function extractJobDetails(job) {
}

const counts = {
title: 'Counts',
title: i18n.translate('xpack.ml.jobsList.jobDetails.countsTitle', {
defaultMessage: 'Counts'
}),
position: 'left',
items: filterObjects(job.data_counts).map(formatValues)
};

const modelSizeStats = {
title: 'Model size stats',
title: i18n.translate('xpack.ml.jobsList.jobDetails.modelSizeStatsTitle', {
defaultMessage: 'Model size stats'
}),
position: 'right',
items: filterObjects(job.model_size_stats).map(formatValues)
};
Expand Down
Loading

0 comments on commit 3a6a00c

Please sign in to comment.