Viewing Options state and name conventions

This commit is contained in:
Belen Curcio
2017-06-07 09:53:53 -03:00
parent e24f6ca9f1
commit 4725f07757
10 changed files with 44 additions and 36 deletions
@@ -6,9 +6,9 @@ import {
removeCommentClassName
} from 'coral-embed-stream/src/actions/comment';
import OffTopicFilter from '../components/OffTopicFilter';
import {closeViewingOptions} from 'coral-embed-stream/src/actions/stream';
import {closeViewingOptions} from 'plugins/coral-plugin-viewing-options/client/actions';
const mapStateToProps = ({comment, offTopic}) => ({
const mapStateToProps = ({comment, ['coral-plugin-offtopic'] : offTopic}) => ({
commentClassNames: comment.commentClassNames,
checked: offTopic.checked
});
@@ -0,0 +1,9 @@
import {OPEN_VIEWING_OPTIONS, CLOSE_VIEWING_OPTIONS} from './constants';
export const openViewingOptions = () => ({
type: OPEN_VIEWING_OPTIONS
});
export const closeViewingOptions = () => ({
type: CLOSE_VIEWING_OPTIONS
});
@@ -0,0 +1,2 @@
export const OPEN_VIEWING_OPTIONS = 'OPEN_VIEWING_OPTIONS';
export const CLOSE_VIEWING_OPTIONS = 'CLOSE_VIEWING_OPTIONS';
@@ -2,9 +2,9 @@ import React from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import ViewingOptions from '../components/ViewingOptions';
import {openViewingOptions, closeViewingOptions} from 'coral-embed-stream/src/actions/stream';
import {openViewingOptions, closeViewingOptions} from '../actions';
const mapStateToProps = ({stream}) => ({open: stream.viewingOption.open});
const mapStateToProps = ({['coral-plugin-viewing-options']: state}) => ({open: state.open});
const mapDispatchToProps = (dispatch) =>
bindActionCreators({openViewingOptions, closeViewingOptions}, dispatch);
@@ -1,6 +1,8 @@
import ViewingOptions from './containers/ViewingOptions';
import reducer from './reducer';
export default {
reducer,
slots: {
streamBox: [ViewingOptions]
}
@@ -0,0 +1,22 @@
import {OPEN_VIEWING_OPTIONS, CLOSE_VIEWING_OPTIONS} from './constants';
const initialState = {
open: false
};
export default function offTopic (state = initialState, action) {
switch (action.type) {
case OPEN_VIEWING_OPTIONS:
return {
...state,
open: true
};
case CLOSE_VIEWING_OPTIONS:
return {
...state,
open: false
};
default :
return state;
}
}