mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 11:01:59 +08:00
Change reducer property names
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import * as actions from 'constants/moderation';
|
||||
import * as actions from 'constants/userDetail';
|
||||
|
||||
export const viewUserDetail = (userId) => ({type: actions.VIEW_USER_DETAIL, userId});
|
||||
export const hideUserDetail = () => ({type: actions.HIDE_USER_DETAIL});
|
||||
|
||||
@@ -10,7 +10,7 @@ import ClickOutside from 'coral-framework/components/ClickOutside';
|
||||
export default class UserDetail extends React.Component {
|
||||
|
||||
static propTypes = {
|
||||
id: PropTypes.string.isRequired,
|
||||
userId: PropTypes.string.isRequired,
|
||||
hideUserDetail: PropTypes.func.isRequired,
|
||||
root: PropTypes.object.isRequired,
|
||||
bannedWords: PropTypes.array.isRequired,
|
||||
@@ -62,7 +62,7 @@ export default class UserDetail extends React.Component {
|
||||
comments: {nodes}
|
||||
},
|
||||
activeTab,
|
||||
selectedIds,
|
||||
selectedCommentIds,
|
||||
bannedWords,
|
||||
suspectWords,
|
||||
toggleSelect,
|
||||
@@ -119,7 +119,7 @@ export default class UserDetail extends React.Component {
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
selectedIds.length === 0
|
||||
selectedCommentIds.length === 0
|
||||
? (
|
||||
<ul className={styles.commentStatuses}>
|
||||
<li className={activeTab === 'all' ? styles.active : ''} onClick={this.showAll}>All</li>
|
||||
@@ -140,7 +140,7 @@ export default class UserDetail extends React.Component {
|
||||
cStyle='reject'
|
||||
icon='close'>
|
||||
</Button>
|
||||
{`${selectedIds.length} comments selected`}
|
||||
{`${selectedCommentIds.length} comments selected`}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export default class UserDetail extends React.Component {
|
||||
{
|
||||
nodes.map((comment) => {
|
||||
const status = comment.action_summaries ? 'FLAGGED' : comment.status;
|
||||
const selected = selectedIds.indexOf(comment.id) !== -1;
|
||||
const selected = selectedCommentIds.indexOf(comment.id) !== -1;
|
||||
return <Comment
|
||||
key={comment.id}
|
||||
user={user}
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
export const TOGGLE_MODAL = 'TOGGLE_MODAL';
|
||||
export const SINGLE_VIEW = 'SINGLE_VIEW';
|
||||
export const HIDE_SHORTCUTS_NOTE = 'HIDE_SHORTCUTS_NOTE';
|
||||
export const VIEW_USER_DETAIL = 'VIEW_USER_DETAIL';
|
||||
export const HIDE_USER_DETAIL = 'HIDE_USER_DETAIL';
|
||||
export const SET_SORT_ORDER = 'MODERATION_SET_SORT_ORDER';
|
||||
export const CHANGE_USER_DETAIL_STATUSES = 'CHANGE_USER_DETAIL_STATUSES';
|
||||
export const SELECT_USER_DETAIL_COMMENT = 'SELECT_USER_DETAIL_COMMENT';
|
||||
export const UNSELECT_USER_DETAIL_COMMENT = 'UNSELECT_USER_DETAIL_COMMENT';
|
||||
export const CLEAR_USER_DETAIL_SELECTIONS = 'CLEAR_USER_DETAIL_SELECTIONS';
|
||||
export const SHOW_STORY_SEARCH = 'SHOW_STORY_SEARCH';
|
||||
export const HIDE_STORY_SEARCH = 'HIDE_STORY_SEARCH';
|
||||
export const STORY_SEARCH_CHANGE_VALUE = 'STORY_SEARCH_CHANGE_VALUE';
|
||||
|
||||
@@ -35,7 +35,7 @@ class UserDetailContainer extends React.Component {
|
||||
|
||||
// status can be 'ACCEPTED' or 'REJECTED'
|
||||
bulkSetCommentStatus = (status) => {
|
||||
const changes = this.props.selectedIds.map((commentId) => {
|
||||
const changes = this.props.selectedCommentIds.map((commentId) => {
|
||||
return this.props.setCommentStatus({commentId, status});
|
||||
});
|
||||
|
||||
@@ -62,11 +62,11 @@ class UserDetailContainer extends React.Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
if (!this.props.id) {
|
||||
if (!this.props.userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const loading = !('user' in this.props.root) || this.props.root.user.id !== this.props.id;
|
||||
const loading = !('user' in this.props.root) || this.props.root.user.id !== this.props.userId;
|
||||
|
||||
return <UserDetail
|
||||
bulkReject={this.bulkReject}
|
||||
@@ -104,19 +104,19 @@ export const withUserDetailQuery = withQuery(gql`
|
||||
}
|
||||
${commentConnectionFragment}
|
||||
`, {
|
||||
options: ({id, statuses}) => {
|
||||
options: ({userId, statuses}) => {
|
||||
return {
|
||||
variables: {author_id: id, statuses}
|
||||
variables: {author_id: userId, statuses}
|
||||
};
|
||||
},
|
||||
skip: (ownProps) => !ownProps.id,
|
||||
skip: (ownProps) => !ownProps.userId,
|
||||
});
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
id: state.userDetail.userDetailId,
|
||||
selectedIds: state.userDetail.userDetailSelectedIds,
|
||||
statuses: state.userDetail.userDetailStatuses,
|
||||
activeTab: state.userDetail.userDetailActiveTab,
|
||||
userId: state.userDetail.userId,
|
||||
selectedCommentIds: state.userDetail.selectedCommentIds,
|
||||
statuses: state.userDetail.statuses,
|
||||
activeTab: state.userDetail.activeTab,
|
||||
bannedWords: state.settings.toJS().wordlist.banned,
|
||||
suspectWords: state.settings.toJS().wordlist.suspect,
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as actions from '../constants/userDetail';
|
||||
|
||||
const initialState = {
|
||||
userDetailId: null,
|
||||
userDetailActiveTab: 'all',
|
||||
userDetailStatuses: ['NONE', 'ACCEPTED', 'REJECTED', 'PREMOD'],
|
||||
userDetailSelectedIds: [],
|
||||
userId: null,
|
||||
activeTab: 'all',
|
||||
statuses: ['NONE', 'ACCEPTED', 'REJECTED', 'PREMOD'],
|
||||
selectedCommentIds: [],
|
||||
};
|
||||
|
||||
export default function banUserDialog(state = initialState, action) {
|
||||
@@ -12,34 +12,34 @@ export default function banUserDialog(state = initialState, action) {
|
||||
case actions.VIEW_USER_DETAIL:
|
||||
return {
|
||||
...state,
|
||||
userDetailId: action.userId,
|
||||
userId: action.userId,
|
||||
};
|
||||
case actions.HIDE_USER_DETAIL:
|
||||
return {
|
||||
...state,
|
||||
userDetailId: null,
|
||||
userDetailSelectedIds: [],
|
||||
userId: null,
|
||||
selectedCommentIds: [],
|
||||
};
|
||||
case actions.CLEAR_USER_DETAIL_SELECTIONS:
|
||||
return {
|
||||
...state,
|
||||
userDetailSelectedIds: [],
|
||||
selectedCommentIds: [],
|
||||
};
|
||||
case actions.CHANGE_USER_DETAIL_STATUSES:
|
||||
return {
|
||||
...state,
|
||||
userDetailActiveTab: action.tab,
|
||||
userDetailStatuses: action.statuses,
|
||||
activeTab: action.tab,
|
||||
statuses: action.statuses,
|
||||
};
|
||||
case actions.SELECT_USER_DETAIL_COMMENT:
|
||||
return {
|
||||
...state,
|
||||
userDetailSelectedIds: [...state.userDetailSelectedIds, action.id],
|
||||
selectedCommentIds: [...state.selectedCommentIds, action.id],
|
||||
};
|
||||
case actions.UNSELECT_USER_DETAIL_COMMENT:
|
||||
return {
|
||||
...state,
|
||||
userDetailSelectedIds: state.userDetailSelectedIds.filter((id) => id !== action.id),
|
||||
selectedCommentIds: state.selectedCommentIds.filter((id) => id !== action.id),
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
|
||||
Reference in New Issue
Block a user