Refactor Community

This commit is contained in:
Chi Vinh Le
2018-01-18 19:10:32 +01:00
parent 40539bf3b7
commit 7d022ed380
6 changed files with 15 additions and 30 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ import { Router, Route, IndexRedirect, IndexRoute } from 'react-router';
import Configure from 'routes/Configure';
import Install from 'routes/Install';
import Stories from 'routes/Stories';
import Community from 'routes/Community/containers/Community';
import Community from 'routes/Community';
import { ModerationLayout, Moderation } from 'routes/Moderation';
import Layout from 'containers/Layout';
@@ -3,33 +3,22 @@ import PropTypes from 'prop-types';
import styles from './Community.css';
import People from '../containers/People';
import CommunityMenu from '../containers/CommunityMenu';
import RejectUsernameDialog from './RejectUsernameDialog';
import RejectUsernameDialog from '../containers/RejectUsernameDialog';
import FlaggedAccounts from '../containers/FlaggedAccounts';
class Community extends Component {
renderTab() {
const { route, community, ...props } = this.props;
const { route } = this.props;
const activeTab = route.path === ':id' ? 'flagged' : route.path;
if (activeTab === 'people') {
return (
<People
community={community}
data={this.props.data}
root={this.props.root}
/>
);
return <People />;
}
return (
<div>
<FlaggedAccounts data={this.props.data} root={this.props.root} />
<RejectUsernameDialog
user={community.user}
open={community.rejectUsernameDialog}
rejectUsername={props.rejectUsername}
handleClose={props.hideRejectUsernameDialog}
/>
<FlaggedAccounts />
<RejectUsernameDialog />
</div>
);
}
@@ -46,11 +35,6 @@ class Community extends Component {
Community.propTypes = {
route: PropTypes.object,
community: PropTypes.object,
rejectUsername: PropTypes.func.isRequired,
hideRejectUsernameDialog: PropTypes.func.isRequired,
data: PropTypes.object,
root: PropTypes.object,
};
export default Community;
@@ -94,7 +94,7 @@ class RejectUsernameDialog extends Component {
{/* {
// Suspension Message: This functionality it's not entirely done on the BE - It will be released soon.
// Suspension Message: This functionality it's not entirely done on the BE - It will be released soon.
stage === 1 &&
<div className={styles.writeContainer}>
<div className={styles.emailMessage}>{t('reject_username.write_message')}</div>
@@ -115,7 +115,6 @@ class PeopleContainer extends React.Component {
}
PeopleContainer.propTypes = {
community: PropTypes.object,
setUserRole: PropTypes.func.isRequired,
unbanUser: PropTypes.func.isRequired,
unsuspendUser: PropTypes.func.isRequired,
@@ -1,18 +1,19 @@
import RejectUsernameDialog from '../components/RejectUsernameDialog';
import { withRejectUsername } from 'coral-framework/graphql/mutations';
import { hideRejectUsernameDialog } from '../../../actions/community';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { compose } from 'react-apollo';
import { withRejectUsername } from 'coral-framework/graphql/mutations';
import { hideRejectUsernameDialog } from '../../../actions/community';
import Community from '../components/Community';
const mapStateToProps = state => ({
community: state.community,
user: state.community.user,
open: state.community.rejectUsernameDialog,
});
const mapDispatchToProps = dispatch =>
bindActionCreators(
{
hideRejectUsernameDialog,
handleClose: hideRejectUsernameDialog,
},
dispatch
);
@@ -20,4 +21,4 @@ const mapDispatchToProps = dispatch =>
export default compose(
connect(mapStateToProps, mapDispatchToProps),
withRejectUsername
)(Community);
)(RejectUsernameDialog);
@@ -0,0 +1 @@
export { default } from './components/Community';