This commit is contained in:
Chi Vinh Le
2018-01-30 17:18:09 +01:00
parent b33cde03c3
commit cb5a41f119
11 changed files with 46 additions and 55 deletions
@@ -1,13 +0,0 @@
export const addTag = tag => ({
type: 'ADD_TAG',
tag,
});
export const removeTag = idx => ({
type: 'REMOVE_TAG',
idx,
});
export const clearTags = () => ({
type: 'CLEAR_TAGS',
});
@@ -70,3 +70,17 @@ export const removeCommentClassName = idx => ({
export const setActiveTab = tab => dispatch => {
dispatch({ type: actions.SET_ACTIVE_TAB, tab });
};
export const addCommentBoxTag = tag => ({
type: actions.ADD_COMMENT_BOX_TAG,
tag,
});
export const removeCommentBoxTag = idx => ({
type: actions.REMOVE_COMMENT_BOX_TAG,
idx,
});
export const clearCommentBoxTags = () => ({
type: actions.CLEAR_COMMENT_BOX_TAGS,
});
@@ -1,5 +0,0 @@
const prefix = 'TALK_EMBED_STREAM_COMMENT_BOX';
export const ADD_TAG = `${prefix}_ADD_TAG`;
export const REMOVE_TAG = `${prefix}_REMOVE_TAG`;
export const CLEAR_TAGS = `${prefix}_CLEAR_TAGS`;
@@ -1,3 +1,5 @@
const prefix = 'TALK_EMBED_STREAM';
export const SET_ACTIVE_REPLY_BOX = 'SET_ACTIVE_REPLY_BOX';
export const ADDTL_COMMENTS_ON_LOAD_MORE = 10;
export const VIEW_ALL_COMMENTS = 'VIEW_ALL_COMMENTS';
@@ -7,3 +9,6 @@ export const REMOVE_COMMENT_CLASSNAME = 'REMOVE_COMMENT_CLASSNAME';
export const THREADING_LEVEL = process.env.TALK_THREADING_LEVEL;
export const SET_ACTIVE_TAB = 'CORAL_STREAM_SET_ACTIVE_TAB';
export const SET_SORT = 'CORAL_STREAM_SET_SORT';
export const ADD_COMMENT_BOX_TAG = `${prefix}_COMMENT_BOX_ADD_TAG`;
export const REMOVE_COMMENT_BOX_TAG = `${prefix}_COMMENT_BOX_REMOVE_TAG`;
export const CLEAR_COMMENT_BOX_TAGS = `${prefix}_COMMENT_BOX_CLEAR_TAGS`;
@@ -93,9 +93,6 @@ export default {
name
created_at
}
assigned_by {
id
}
}
user {
id
@@ -1,27 +0,0 @@
import { ADD_TAG, REMOVE_TAG, CLEAR_TAGS } from '../constants/commentBox';
const initialState = {
tags: [],
};
export default function commentBox(state = initialState, action) {
switch (action.type) {
case ADD_TAG:
return {
...state,
tags: [...state.tags, action.tag],
};
case REMOVE_TAG:
return {
...state,
tags: [
...state.tags.slice(0, action.idx),
...state.tags.slice(action.idx + 1),
],
};
case CLEAR_TAGS:
return initialState;
default:
return state;
}
}
@@ -4,12 +4,10 @@ import embed from './embed';
import config from './config';
import configure from './configure';
import stream from './stream';
import commentBox from './commentBox';
export default {
auth,
asset,
commentBox,
embed,
config,
configure,
@@ -25,6 +25,7 @@ const initialState = {
previousTab: '',
sortBy: 'CREATED_AT',
sortOrder: 'DESC',
commentBoxTags: [],
};
export default function stream(state = initialState, action) {
@@ -74,6 +75,24 @@ export default function stream(state = initialState, action) {
sortOrder: action.sortOrder ? action.sortOrder : state.sortOrder,
sortBy: action.sortBy ? action.sortBy : state.sortBy,
};
case actions.ADD_COMMENT_BOX_TAG:
return {
...state,
commentBoxTags: [...state.commentBoxTags, action.tag],
};
case actions.REMOVE_COMMENT_BOX_TAG:
return {
...state,
commentBoxTags: [
...state.commentBoxTags.slice(0, action.idx),
...state.commentBoxTags.slice(action.idx + 1),
],
};
case actions.CLEAR_COMMENT_BOX_TAGS:
return {
...state,
commentBoxTags: [],
};
default:
return state;
}
@@ -71,7 +71,7 @@ class CommentBox extends React.Component {
asset_id: assetId,
parent_id: parentId,
body: this.state.body,
...this.props.commentBox,
tags: this.props.tags,
};
// Execute preSubmit Hooks
@@ -203,9 +203,11 @@ CommentBox.propTypes = {
isReply: PropTypes.bool.isRequired,
canPost: PropTypes.bool,
notify: PropTypes.func.isRequired,
commentBox: PropTypes.object,
tags: PropTypes.array,
};
const mapStateToProps = ({ commentBox }) => ({ commentBox });
const mapStateToProps = state => ({
tags: state.stream.commentBoxTags,
});
export default connect(mapStateToProps, null)(CommentBox);
+2 -1
View File
@@ -1,5 +1,6 @@
export { addTag, removeTag } from 'coral-embed-stream/src/actions/commentBox';
export {
addCommentClassName,
removeCommentClassName,
addCommentBoxTag as addTag,
removeCommentBoxTag as removeTag,
} from 'coral-embed-stream/src/actions/stream';
+1 -1
View File
@@ -1,3 +1,3 @@
export const commentBoxTagsSelector = state => state.commentBox.tags;
export const commentBoxTagsSelector = state => state.stream.commentBoxTags;
export const commentClassNamesSelector = state =>
state.stream.commentClassNames;