Merge pull request #799 from coralproject/prefix-redux-actions-plugins

Prefix redux constants in plugins
This commit is contained in:
Belén Curcio
2017-07-26 15:21:35 -03:00
committed by GitHub
6 changed files with 23 additions and 18 deletions
@@ -1,9 +1,9 @@
import {VIEWING_OPTIONS_OPEN, VIEWING_OPTIONS_CLOSE} from './constants';
import {OPEN_MENU, CLOSE_MENU} from './constants';
export const openViewingOptions = () => ({
type: VIEWING_OPTIONS_OPEN
export const openMenu = () => ({
type: OPEN_MENU,
});
export const closeViewingOptions = () => ({
type: VIEWING_OPTIONS_CLOSE
export const closeMenu = () => ({
type: CLOSE_MENU,
});
@@ -8,15 +8,15 @@ import {Slot, ClickOutside} from 'plugin-api/beta/client/components';
const ViewingOptions = (props) => {
const toggleOpen = () => {
if (!props.open) {
props.openViewingOptions();
props.openMenu();
} else {
props.closeViewingOptions();
props.closeMenu();
}
};
const handleClickOutside = () => {
if (props.open) {
props.closeViewingOptions();
props.closeMenu();
}
};
@@ -1,2 +1,5 @@
export const VIEWING_OPTIONS_OPEN = 'VIEWING_OPTIONS_OPEN';
export const VIEWING_OPTIONS_CLOSE = 'VIEWING_OPTIONS_CLOSE';
const prefix = 'TALK_VIEWING_OPTIONS';
export const OPEN_MENU = `${prefix}_OPEN_MENU`;
export const CLOSE_MENU = `${prefix}_CLOSE_MENU`;
@@ -1,13 +1,13 @@
import {connect} from 'plugin-api/beta/client/hocs';
import {bindActionCreators} from 'redux';
import ViewingOptions from '../components/ViewingOptions';
import {openViewingOptions, closeViewingOptions} from '../actions';
import {openMenu, closeMenu} from '../actions';
const mapStateToProps = ({coralPluginViewingOptions: state}) => ({
open: state.open
});
const mapDispatchToProps = (dispatch) =>
bindActionCreators({openViewingOptions, closeViewingOptions}, dispatch);
bindActionCreators({openMenu, closeMenu}, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(ViewingOptions);
@@ -1,17 +1,17 @@
import {VIEWING_OPTIONS_OPEN, VIEWING_OPTIONS_CLOSE} from './constants';
import {OPEN_MENU, CLOSE_MENU} from './constants';
const initialState = {
open: false
};
export default function offTopic (state = initialState, action) {
export default function reducer(state = initialState, action) {
switch (action.type) {
case VIEWING_OPTIONS_OPEN:
case OPEN_MENU:
return {
...state,
open: true
};
case VIEWING_OPTIONS_CLOSE:
case CLOSE_MENU:
return {
...state,
open: false
@@ -1,2 +1,4 @@
export const SHOW_TOOLTIP = 'SHOW_TOOLTIP';
export const HIDE_TOOLTIP = 'HIDE_TOOLTIP';
const prefix = 'TALK_FEATURED_COMMENTS';
export const SHOW_TOOLTIP = `${prefix}_SHOW_TOOLTIP`;
export const HIDE_TOOLTIP = `${prefix}_HIDE_TOOLTIP`;