Skip to content

Commit

Permalink
Merge pull request #863 from coralproject/optimization
Browse files Browse the repository at this point in the history
Front-End Optimizations
  • Loading branch information
kgardnr authored Aug 21, 2017
2 parents c3884ed + f7b06dc commit 7c7fe1b
Show file tree
Hide file tree
Showing 41 changed files with 1,053 additions and 388 deletions.
8 changes: 4 additions & 4 deletions client/coral-admin/src/components/UserDetail.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import Comment from './UserDetailComment';
import Comment from '../containers/UserDetailComment';
import styles from './UserDetail.css';
import {Icon, Button, Drawer, Spinner} from 'coral-ui';
import {Slot} from 'coral-framework/components';
Expand Down Expand Up @@ -60,6 +60,7 @@ export default class UserDetail extends React.Component {

renderLoaded() {
const {
root,
root: {
user,
totalComments,
Expand Down Expand Up @@ -98,7 +99,7 @@ export default class UserDetail extends React.Component {
{new Date(user.created_at).toLocaleString()}
</li>

{user.profiles.map(({id}) =>
{user.profiles.map(({id}) =>
<li key={id}>
<Icon name="email"/>
<span className={styles.userDetailItem}>Email:</span>
Expand Down Expand Up @@ -132,8 +133,7 @@ export default class UserDetail extends React.Component {
<Slot
fill="userProfile"
data={this.props.data}
root={this.props.root}
user={user}
queryData={root, user}
/>

<hr/>
Expand Down
2 changes: 1 addition & 1 deletion client/coral-admin/src/containers/UserDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class UserDetailContainer extends React.Component {
return null;
}

const loading = [1, 2, 4].indexOf(this.props.data.networkStatus) >= 0;
const loading = this.props.data.loading;

return <UserDetail
bulkReject={this.bulkReject}
Expand Down
81 changes: 47 additions & 34 deletions client/coral-admin/src/routes/Moderation/components/Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,31 @@ import t, {timeago} from 'coral-framework/services/i18n';

class Comment extends React.Component {

showSuspendUserDialog = () => {
const {comment, showSuspendUserDialog} = this.props;
return showSuspendUserDialog({
userId: comment.user.id,
username: comment.user.username,
commentId: comment.id,
commentStatus: comment.status,
});
};

showBanUserDialog = () => {
const {comment, showBanUserDialog} = this.props;
return showBanUserDialog({
userId: comment.user.id,
username: comment.user.username,
commentId: comment.id,
commentStatus: comment.status,
});
};

viewUserDetail = () => {
const {viewUserDetail, comment} = this.props;
return viewUserDetail(comment.user.id);
};

render() {
const {
actions = [],
Expand All @@ -29,7 +54,12 @@ class Comment extends React.Component {
bannedWords,
selected,
className,
...props
data,
root,
currentUserId,
currentAsset,
acceptComment,
rejectComment,
} = this.props;

const flagActionSummaries = getActionSummary('FlagActionSummary', comment);
Expand All @@ -38,19 +68,7 @@ class Comment extends React.Component {

let selectionStateCSS = selected ? 'mdl-shadow--16dp' : 'mdl-shadow--2dp';

const showSuspenUserDialog = () => props.showSuspendUserDialog({
userId: comment.user.id,
username: comment.user.username,
commentId: comment.id,
commentStatus: comment.status,
});

const showBanUserDialog = () => props.showBanUserDialog({
userId: comment.user.id,
username: comment.user.username,
commentId: comment.id,
commentStatus: comment.status,
});
const queryData = {root, comment, asset: comment.asset};

return (
<li
Expand All @@ -62,7 +80,7 @@ class Comment extends React.Component {
<div className={styles.author}>
{
(
<span className={styles.username} onClick={() => viewUserDetail(comment.user.id)}>
<span className={styles.username} onClick={this.viewUserDetail}>
{comment.user.username}
</span>
)
Expand All @@ -75,35 +93,33 @@ class Comment extends React.Component {
? <span>&nbsp;<span className={styles.editedMarker}>({t('comment.edited')})</span></span>
: null
}
{props.currentUserId !== comment.user.id &&
{currentUserId !== comment.user.id &&
<ActionsMenu icon="not_interested">
<ActionsMenuItem
disabled={comment.user.status === 'BANNED'}
onClick={showSuspenUserDialog}>
onClick={this.showSuspendUserDialog}>
Suspend User</ActionsMenuItem>
<ActionsMenuItem
disabled={comment.user.status === 'BANNED'}
onClick={showBanUserDialog}>
onClick={this.showBanUserDialog}>
Ban User
</ActionsMenuItem>
</ActionsMenu>
}
<div className={styles.adminCommentInfoBar}>
<CommentType type={commentType} className={styles.commentType}/>
<Slot
data={props.data}
root={props.root}
comment={comment}
asset={comment.asset}
fill="adminCommentInfoBar"
data={data}
queryData={queryData}
/>
</div>
</div>
</div>

<div className={styles.moderateArticle}>
Story: {comment.asset.title}
{!props.currentAsset &&
{!currentAsset &&
<Link to={`/admin/moderate/${comment.asset.id}`}>{t('modqueue.moderate')}</Link>}
</div>
<CommentAnimatedEdit body={comment.body}>
Expand All @@ -124,10 +140,9 @@ class Comment extends React.Component {
</a>
</p>
<Slot
data={props.data}
root={props.root}
fill="adminCommentContent"
comment={comment}
data={data}
queryData={queryData}
/>
<div className={styles.sideActions}>
<IfHasLink text={comment.body}>
Expand All @@ -150,30 +165,28 @@ class Comment extends React.Component {
acceptComment={() =>
(comment.status === 'ACCEPTED'
? null
: props.acceptComment({commentId: comment.id}))}
: acceptComment({commentId: comment.id}))}
rejectComment={() =>
(comment.status === 'REJECTED'
? null
: props.rejectComment({commentId: comment.id}))}
: rejectComment({commentId: comment.id}))}
/>
);
})}
</div>
<Slot
data={props.data}
root={props.root}
fill="adminSideActions"
comment={comment}
data={data}
queryData={queryData}
/>
</div>
</div>
</CommentAnimatedEdit>
</div>
<Slot
data={props.data}
root={props.root}
fill="adminCommentDetailArea"
comment={comment}
data={data}
queryData={queryData}
/>
{flagActions && flagActions.length
? <FlagBox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ export default class Moderation extends Component {

<Slot
data={data}
root={root}
assset={asset}
queryData={{root, asset}}
activeTab={activeTab}
handleCommentChange={handleCommentChange}
fill='adminModeration'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import IgnoredCommentTombstone from './IgnoredCommentTombstone';
import NewCount from './NewCount';
import {TransitionGroup} from 'react-transition-group';
import {forEachError} from 'coral-framework/utils';
import Comment from '../components/Comment';
import Comment from '../containers/Comment';

const hasComment = (nodes, id) => nodes.some((node) => node.id === id);

Expand Down
Loading

0 comments on commit 7c7fe1b

Please sign in to comment.