2016-11-24 21:32:29 +01:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-12-04 11:56:41 +01:00
|
|
|
import { Textfield, Dialog, DialogTitle, DialogContent, DialogActions, Button } from 'react-mdl';
|
2016-12-22 14:09:16 +01:00
|
|
|
import dialogPolyfill from 'dialog-polyfill/dialog-polyfill.js';
|
2016-11-24 21:32:29 +01:00
|
|
|
|
2016-11-25 15:37:06 +01:00
|
|
|
class EditUserComponent extends React.Component {
|
2016-11-24 21:32:29 +01:00
|
|
|
static propTypes () {
|
|
|
|
return {
|
|
|
|
user: PropTypes.object.isRequired,
|
|
|
|
updateUserName: PropTypes.func.isRequired,
|
2016-12-20 19:28:45 +01:00
|
|
|
save: PropTypes.func.isRequired,
|
2016-11-24 21:32:29 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-12-22 14:09:16 +01:00
|
|
|
componentDidMount () {
|
|
|
|
this.initPolyfill();
|
|
|
|
}
|
|
|
|
|
2016-11-24 21:32:29 +01:00
|
|
|
handleSubmit = (evt) => {
|
|
|
|
evt.preventDefault();
|
|
|
|
this.props.save();
|
|
|
|
}
|
|
|
|
|
2016-12-22 14:09:16 +01:00
|
|
|
initPolyfill () {
|
|
|
|
const dialogs = document.querySelectorAll('dialog');
|
|
|
|
[].slice.call(dialogs).forEach(dialog => dialogPolyfill.registerDialog(dialog));
|
|
|
|
}
|
|
|
|
|
2016-11-24 21:32:29 +01:00
|
|
|
render () {
|
|
|
|
return (
|
2016-12-04 11:56:41 +01:00
|
|
|
<div>
|
|
|
|
<Dialog open={this.props.user.showDialog}>
|
|
|
|
<DialogTitle>Action required</DialogTitle>
|
|
|
|
<DialogContent>
|
|
|
|
<p>
|
2016-12-17 10:24:46 +01:00
|
|
|
You hav to specify a username to use Unleash. This will allow us to track changes.
|
2016-12-04 11:56:41 +01:00
|
|
|
</p>
|
|
|
|
<form onSubmit={this.handleSubmit}>
|
|
|
|
<Textfield
|
|
|
|
label="USERNAME"
|
|
|
|
name="username"
|
|
|
|
required
|
|
|
|
value={this.props.user.userName}
|
|
|
|
onChange={(e) => this.props.updateUserName(e.target.value)}
|
|
|
|
/>
|
|
|
|
</form>
|
|
|
|
</DialogContent>
|
|
|
|
<DialogActions>
|
|
|
|
<Button onClick={this.props.save}>Save</Button>
|
|
|
|
</DialogActions>
|
|
|
|
</Dialog>
|
|
|
|
</div>
|
2016-11-24 21:32:29 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-25 15:37:06 +01:00
|
|
|
export default EditUserComponent;
|