mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 09:23:13 +01:00
Clean up AlertDismissable and move to root components folder
This commit is contained in:
parent
d5469b3efa
commit
61779e5535
39
js/components/alert_dismissable.js
Normal file
39
js/components/alert_dismissable.js
Normal file
@ -0,0 +1,39 @@
|
||||
import React from 'react';
|
||||
|
||||
import Alert from 'react-bootstrap/lib/Alert';
|
||||
|
||||
|
||||
const { node } = React.PropTypes;
|
||||
|
||||
const AlertDismissable = React.createClass({
|
||||
propTypes: {
|
||||
error: node.isRequired
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
alertVisible: true
|
||||
};
|
||||
},
|
||||
|
||||
show() {
|
||||
this.setState({ alertVisible: true });
|
||||
},
|
||||
|
||||
hide() {
|
||||
this.setState({ alertVisible: false });
|
||||
},
|
||||
|
||||
render() {
|
||||
const { error } = this.props;
|
||||
const { alertVisible } = this.state;
|
||||
|
||||
return alertVisible ? (
|
||||
<Alert bsStyle='danger' onDismiss={this.hide}>
|
||||
{error}
|
||||
</Alert>
|
||||
) : null;
|
||||
}
|
||||
});
|
||||
|
||||
export default AlertDismissable;
|
@ -1,39 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
import React from 'react';
|
||||
import Alert from 'react-bootstrap/lib/Alert';
|
||||
|
||||
let AlertDismissable = React.createClass({
|
||||
propTypes: {
|
||||
error: React.PropTypes.array.isRequired
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
alertVisible: true
|
||||
};
|
||||
},
|
||||
|
||||
show() {
|
||||
this.setState({alertVisible: true});
|
||||
},
|
||||
|
||||
hide() {
|
||||
this.setState({alertVisible: false});
|
||||
},
|
||||
|
||||
render() {
|
||||
if (this.state.alertVisible) {
|
||||
return (
|
||||
<Alert bsStyle='danger' onDismiss={this.hide}>
|
||||
{this.props.error}
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<span />
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
export default AlertDismissable;
|
Loading…
Reference in New Issue
Block a user