Vulcan/packages/nova-base-components/lib/users/UsersEditForm.jsx

48 lines
1.7 KiB
React
Raw Normal View History

2016-08-08 11:18:21 +09:00
import Telescope from 'meteor/nova:lib';
import React, { PropTypes, Component } from 'react';
import { FormattedMessage, intlShape } from 'react-intl';
import { Row, Col } from 'react-bootstrap';
import NovaForm from "meteor/nova:forms";
2016-06-23 15:00:58 +09:00
import Users from 'meteor/nova:users';
import { ShowIf, withCurrentUser } from 'meteor/nova:core';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
2016-11-09 11:55:28 +09:00
const UsersEditForm = (props, context) => {
return (
<ShowIf
check={Users.options.mutations.edit.check}
document={{_id: props.userId}} // note: cannot handle slug atm
failureComponent={<FormattedMessage id="app.noPermission"/>}
>
<div className="page users-edit-form">
<h2 className="page-title users-edit-form-title"><FormattedMessage id="users.edit_account"/></h2>
<NovaForm
collection={Users}
documentId={props.userId} // note: cannot handle slug atm
queryToUpdate="usersSingleQuery"
successCallback={(user)=>{
props.flash(context.intl.formatMessage({id: "users.edit_success"}, {name: Users.getDisplayName(user)}), 'success')
}}
showRemove={false}
/>
</div>
</ShowIf>
);
};
2016-11-09 11:55:28 +09:00
UsersEditForm.propTypes = {
document: React.PropTypes.object,
};
2016-02-23 11:34:40 +09:00
2016-11-09 11:55:28 +09:00
UsersEditForm.contextTypes = {
intl: intlShape
};
2016-11-09 11:55:28 +09:00
UsersEditForm.displayName = "UsersEditForm";
const mapStateToProps = state => ({ messages: state.messages, });
const mapDispatchToProps = dispatch => bindActionCreators(Telescope.actions.messages, dispatch);
Telescope.registerComponent('UsersEditForm', UsersEditForm, withCurrentUser, connect(mapStateToProps, mapDispatchToProps));