diff --git a/client/coral-embed-stream/src/actions/commentBox.js b/client/coral-embed-stream/src/actions/commentBox.js deleted file mode 100644 index 7a6aa3249..000000000 --- a/client/coral-embed-stream/src/actions/commentBox.js +++ /dev/null @@ -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', -}); diff --git a/client/coral-embed-stream/src/actions/stream.js b/client/coral-embed-stream/src/actions/stream.js index 8af2dfef2..bc31c90e9 100644 --- a/client/coral-embed-stream/src/actions/stream.js +++ b/client/coral-embed-stream/src/actions/stream.js @@ -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, +}); diff --git a/client/coral-embed-stream/src/constants/commentBox.js b/client/coral-embed-stream/src/constants/commentBox.js deleted file mode 100644 index 51130d6c0..000000000 --- a/client/coral-embed-stream/src/constants/commentBox.js +++ /dev/null @@ -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`; diff --git a/client/coral-embed-stream/src/constants/stream.js b/client/coral-embed-stream/src/constants/stream.js index b4deb24e1..09d069851 100644 --- a/client/coral-embed-stream/src/constants/stream.js +++ b/client/coral-embed-stream/src/constants/stream.js @@ -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`; diff --git a/client/coral-embed-stream/src/graphql/index.js b/client/coral-embed-stream/src/graphql/index.js index dcded6b45..db4f92671 100644 --- a/client/coral-embed-stream/src/graphql/index.js +++ b/client/coral-embed-stream/src/graphql/index.js @@ -93,9 +93,6 @@ export default { name created_at } - assigned_by { - id - } } user { id diff --git a/client/coral-embed-stream/src/reducers/commentBox.js b/client/coral-embed-stream/src/reducers/commentBox.js deleted file mode 100644 index 9621f1447..000000000 --- a/client/coral-embed-stream/src/reducers/commentBox.js +++ /dev/null @@ -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; - } -} diff --git a/client/coral-embed-stream/src/reducers/index.js b/client/coral-embed-stream/src/reducers/index.js index 0152c837d..ac581557b 100644 --- a/client/coral-embed-stream/src/reducers/index.js +++ b/client/coral-embed-stream/src/reducers/index.js @@ -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, diff --git a/client/coral-embed-stream/src/reducers/stream.js b/client/coral-embed-stream/src/reducers/stream.js index b5afddafc..42af4453a 100644 --- a/client/coral-embed-stream/src/reducers/stream.js +++ b/client/coral-embed-stream/src/reducers/stream.js @@ -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; } diff --git a/client/coral-embed-stream/src/tabs/stream/containers/CommentBox.js b/client/coral-embed-stream/src/tabs/stream/containers/CommentBox.js index 9c04801c6..b280ce741 100644 --- a/client/coral-embed-stream/src/tabs/stream/containers/CommentBox.js +++ b/client/coral-embed-stream/src/tabs/stream/containers/CommentBox.js @@ -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); diff --git a/plugin-api/alpha/client/actions/index.js b/plugin-api/alpha/client/actions/index.js index 9de7b5de3..9ef89f11b 100644 --- a/plugin-api/alpha/client/actions/index.js +++ b/plugin-api/alpha/client/actions/index.js @@ -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'; diff --git a/plugin-api/alpha/client/selectors/index.js b/plugin-api/alpha/client/selectors/index.js index 988155308..214a07d0c 100644 --- a/plugin-api/alpha/client/selectors/index.js +++ b/plugin-api/alpha/client/selectors/index.js @@ -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;