2016-08-08 11:18:21 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-03-18 10:50:40 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
2016-06-30 12:05:59 +09:00
|
|
|
import { FormattedMessage, intlShape } from 'react-intl';
|
2016-05-25 09:30:29 +02:00
|
|
|
import { Row, Col } from 'react-bootstrap';
|
2016-04-04 10:21:18 +09:00
|
|
|
import NovaForm from "meteor/nova:forms";
|
2016-06-23 15:00:58 +09:00
|
|
|
import Users from 'meteor/nova:users';
|
2016-11-11 18:19:18 +09:00
|
|
|
import { withUsersSingle } from 'meteor/nova:base-containers';
|
2016-03-18 10:50:40 +09:00
|
|
|
|
2016-10-31 17:13:14 +01:00
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2016-11-09 11:55:28 +09:00
|
|
|
const UsersEditForm = (props, context) => {
|
2016-06-30 12:05:59 +09:00
|
|
|
|
2016-11-11 18:19:18 +09:00
|
|
|
if (props.data.loading) {
|
|
|
|
|
|
|
|
return <div className="page users-edit-form"><Telescope.components.Loading/></div>
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const user = props.data.user;
|
|
|
|
return (
|
|
|
|
<Telescope.components.CanDo
|
|
|
|
action="users.edit"
|
|
|
|
document={user}
|
|
|
|
displayNoPermissionMessage={true}
|
|
|
|
>
|
|
|
|
<div className="page users-edit-form">
|
|
|
|
<h2 className="page-title users-edit-form-title"><FormattedMessage id="users.edit_account"/></h2>
|
|
|
|
<NovaForm
|
|
|
|
collection={Users}
|
|
|
|
document={user}
|
|
|
|
mutationName="usersEdit"
|
|
|
|
resultQuery={Users.graphQLQueries.single}
|
|
|
|
successCallback={(user)=>{
|
|
|
|
props.flash(context.intl.formatMessage({id: "users.edit_success"}, {name: Users.getDisplayName(user)}), 'success')
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Telescope.components.CanDo>
|
|
|
|
)
|
|
|
|
}
|
2016-05-25 08:52:04 +02:00
|
|
|
};
|
2016-03-31 13:24:19 -06:00
|
|
|
|
2016-03-17 18:08:03 +09:00
|
|
|
|
2016-11-09 11:55:28 +09:00
|
|
|
UsersEditForm.propTypes = {
|
2016-10-28 13:56:07 +02:00
|
|
|
document: React.PropTypes.object,
|
2016-05-25 08:52:04 +02:00
|
|
|
};
|
2016-02-23 11:34:40 +09:00
|
|
|
|
2016-11-09 11:55:28 +09:00
|
|
|
UsersEditForm.contextTypes = {
|
2016-10-14 08:47:18 +02:00
|
|
|
currentUser: React.PropTypes.object,
|
2016-06-30 12:05:59 +09:00
|
|
|
intl: intlShape
|
2016-06-14 17:03:35 +09:00
|
|
|
};
|
|
|
|
|
2016-11-09 11:55:28 +09:00
|
|
|
UsersEditForm.displayName = "UsersEditForm";
|
2016-05-22 16:42:24 +09:00
|
|
|
|
2016-10-31 17:13:14 +01:00
|
|
|
const mapStateToProps = state => ({ messages: state.messages, });
|
|
|
|
const mapDispatchToProps = dispatch => bindActionCreators(Telescope.actions.messages, dispatch);
|
|
|
|
|
2016-11-11 18:25:47 +09:00
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(withUsersSingle(UsersEditForm));
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(withUsersSingle(UsersEditForm));
|