1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-01 00:08:27 +01:00
unleash.unleash/packages/unleash-frontend/public/js/components/ErrorMessages.jsx

41 lines
866 B
React
Raw Normal View History

2016-06-18 21:53:18 +02:00
'use strict';
2016-10-26 10:43:11 +02:00
2016-06-18 21:53:18 +02:00
const React = require('react');
const Ui = require('./ErrorMessages.ui');
const ErrorStore = require('../stores/ErrorStore');
const ErrorActions = require('../stores/ErrorActions');
2014-10-30 18:25:38 +01:00
2016-06-18 21:53:18 +02:00
const ErrorMessages = React.createClass({
2016-07-02 11:54:50 +02:00
getInitialState () {
2016-06-18 21:55:46 +02:00
return {
errors: ErrorStore.getErrors(),
};
2015-03-17 20:29:03 +01:00
},
2016-07-02 11:54:50 +02:00
onStoreChange () {
2016-06-18 21:55:46 +02:00
this.setState({
errors: ErrorStore.getErrors(),
});
2015-03-17 20:29:03 +01:00
},
2016-07-02 11:54:50 +02:00
componentDidMount () {
2016-06-18 21:55:46 +02:00
this.unsubscribe = ErrorStore.listen(this.onStoreChange);
2015-03-17 20:29:03 +01:00
},
2014-10-30 18:25:38 +01:00
2016-07-02 11:54:50 +02:00
componentWillUnmount () {
2016-06-18 21:55:46 +02:00
this.unsubscribe();
2015-03-17 20:29:03 +01:00
},
2014-10-30 18:25:38 +01:00
2016-07-02 11:54:50 +02:00
onClearErrors () {
2015-03-17 20:29:03 +01:00
ErrorActions.clear();
},
2016-07-02 11:54:50 +02:00
render () {
2014-10-30 18:25:38 +01:00
return (
2016-06-18 22:23:19 +02:00
<Ui errors={this.state.errors} onClearErrors={this.onClearErrors} />
2014-10-30 18:25:38 +01:00
);
2016-06-18 21:55:46 +02:00
},
2014-10-30 18:25:38 +01:00
});
2014-10-31 10:30:23 +01:00
module.exports = ErrorMessages;