Skip to content

Commit

Permalink
[ML] Fixing empty validation list in wizards (elastic#48553) (elastic…
Browse files Browse the repository at this point in the history
…#48623)

* [ML] Fixing empty validation list in wizards

* updating translations

* updating snapshot
  • Loading branch information
jgowdyelastic authored Oct 18, 2019
1 parent 82a349a commit 6658922
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 23 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


import PropTypes from 'prop-types';
import { i18n } from '@kbn/i18n';

import React, {
Component,
Expand Down Expand Up @@ -111,6 +112,35 @@ Message.propTypes = {
})
};

const MessageList = ({ messages, idFilterList }) => {
const callouts = messages
.filter(m => idFilterList.includes(m.id) === false)
.map((m, i) => (
<Callout key={`${m.id}_${i}`} message={m} />
));

// there could be no error or success messages due to the
// idFilterList being applied. so rather than showing nothing,
// show a message saying all passed
const allPassedCallout = (<Callout message={{
text: i18n.translate('xpack.ml.validateJob.allPassed', {
defaultMessage: 'All validation checks passed successfully',
}),
status: VALIDATION_STATUS.SUCCESS
}}
/>);

return (
<React.Fragment>
{callouts.length ? callouts : allPassedCallout}
</React.Fragment>
);
};
MessageList.propTypes = {
messages: PropTypes.array,
idFilterList: PropTypes.array,
};


const Callout = ({ message }) => (
<React.Fragment>
Expand Down Expand Up @@ -272,11 +302,8 @@ export class ValidateJob extends Component {
values={{ title: this.state.title }}
/>}
>
{
this.state.data.messages
.filter(m => idFilterList.includes(m.id) === false)
.map((m, i) => <Callout key={`${m.id}_${i}`} message={m} />)
}
<MessageList messages={this.state.data.messages} idFilterList={idFilterList} />

<EuiText>
<FormattedMessage
id="xpack.ml.validateJob.modal.jobValidationDescriptionText"
Expand Down Expand Up @@ -305,13 +332,7 @@ export class ValidateJob extends Component {
</div>
}
{embedded === true &&
<div>
{
this.state.data.messages
.filter(m => idFilterList.includes(m.id) === false)
.map((m, i) => <Callout key={`${m.id}_${i}`} message={m} />)
}
</div>
<MessageList messages={this.state.data.messages} idFilterList={idFilterList} />
}
</Fragment>
);
Expand Down
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/ml/public/services/job_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ class JobService {
// return the promise chain
return ml.validateJob(obj)
.then((messages) => {
console.log('validate job', messages);
return { success: true, messages };
}).catch((err) => {
msgs.error(i18n.translate('xpack.ml.jobService.jobValidationErrorMessage', {
Expand Down

0 comments on commit 6658922

Please sign in to comment.