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
@@ -38,11 +38,3 @@ export const viewAllComments = () => {
return {type: actions.VIEW_ALL_COMMENTS};
};
export const openViewingOptions = () => ({
type: actions.OPEN_VIEWING_OPTIONS
});
export const closeViewingOptions = () => ({
type: actions.CLOSE_VIEWING_OPTIONS
});
@@ -3,5 +3,3 @@ export const SET_COMMENT_COUNT_CACHE = 'SET_COMMENT_COUNT_CACHE';
export const ADDTL_COMMENTS_ON_LOAD_MORE = 10;
export const NEW_COMMENT_COUNT_POLL_INTERVAL = 20000;
export const VIEW_ALL_COMMENTS = 'VIEW_ALL_COMMENTS';
export const OPEN_VIEWING_OPTIONS = 'OPEN_VIEWING_OPTIONS';
export const CLOSE_VIEWING_OPTIONS = 'CLOSE_VIEWING_OPTIONS';
@@ -20,27 +20,10 @@ const initialState = {
assetId: getQueryVariable('asset_id'),
assetUrl: getQueryVariable('asset_url'),
commentId: getQueryVariable('comment_id'),
viewingOption: {
open: false
}
};
export default function stream(state = initialState, action) {
switch (action.type) {
case actions.OPEN_VIEWING_OPTIONS:
return {
...state,
viewingOption: {
open: true
}
};
case actions.CLOSE_VIEWING_OPTIONS:
return {
...state,
viewingOption: {
open: false
}
};
case actions.SET_ACTIVE_REPLY_BOX:
return {
...state,
+5 -5
View File
@@ -1,17 +1,17 @@
import React from 'react';
import merge from 'lodash/merge';
import flatten from 'lodash/flatten';
import flattenDeep from 'lodash/flattenDeep';
import uniq from 'lodash/uniq';
import pick from 'lodash/pick';
import merge from 'lodash/merge';
import plugins from 'pluginsConfig';
import {getDefinitionName, mergeDocuments} from 'coral-framework/utils';
import flatten from 'lodash/flatten';
import flattenDeep from 'lodash/flattenDeep';
import {loadTranslations} from 'coral-framework/services/i18n';
import {getDefinitionName, mergeDocuments} from 'coral-framework/utils';
export const pluginReducers = merge(
...plugins
.filter((o) => o.module.reducer)
.map((o) => ({[o.module.reducer.name] : o.module.reducer}))
.map((o) => ({[o.plugin] : o.module.reducer}))
);
/**
@@ -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;
}
}