This commit is contained in:
Belen Curcio
2016-11-29 13:56:26 -03:00
parent 55afe36e3b
commit 86faf504bb
7 changed files with 22 additions and 55 deletions
+21 -9
View File
@@ -4,7 +4,6 @@ import {
Notification,
notificationActions,
authActions,
embedStream
} from '../../coral-framework';
import {connect} from 'react-redux';
import CommentBox from '../../coral-plugin-commentbox/CommentBox';
@@ -26,15 +25,13 @@ import SettingsContainer from '../../coral-settings/containers/SettingsContainer
const {addItem, updateItem, postItem, getStream, postAction, deleteAction, appendItemArray} = itemActions;
const {addNotification, clearNotification} = notificationActions;
const {logout} = authActions;
const {changeTab} = embedStream;
const mapStateToProps = (state) => {
return {
config: state.config.toJS(),
items: state.items.toJS(),
notification: state.notification.toJS(),
auth: state.auth.toJS(),
embedStream: state.embedStream.toJS()
auth: state.auth.toJS()
};
};
@@ -52,11 +49,26 @@ const mapDispatchToProps = (dispatch) => ({
appendItemArray: (item, property, value, addToFront, itemType) =>
dispatch(appendItemArray(item, property, value, addToFront, itemType)),
logout: () => dispatch(logout()),
changeTab: activeTab => dispatch(changeTab(activeTab))
});
class CommentStream extends Component {
constructor (props) {
super(props);
this.state = {
activeTab: 0
};
this.changeTab = this.changeTab.bind(this);
}
changeTab (tab) {
this.setState({
activeTab: tab
});
}
static propTypes = {
items: PropTypes.object.isRequired,
addItem: PropTypes.func.isRequired,
@@ -96,13 +108,13 @@ class CommentStream extends Component {
const rootItem = this.props.items.assets && this.props.items.assets[rootItemId];
const {actions, users, comments} = this.props.items;
const {loggedIn, user, showSignInDialog} = this.props.auth;
const {activeTab} = this.props.embedStream;
const {activeTab} = this.state;
return <div className={showSignInDialog ? 'expandForSignin' : ''}>
{
rootItem
? <div>
<TabBar onChange={this.props.changeTab} activeTab={activeTab}>
<TabBar onChange={this.changeTab} activeTab={activeTab}>
<Tab><Count id={rootItemId} items={this.props.items}/></Tab>
<Tab>Settings</Tab>
</TabBar>
@@ -235,9 +247,9 @@ class CommentStream extends Component {
notification={this.props.notification}
/>
</TabContent>
<ContentBox show={activeTab === 1}>
<TabContent show={activeTab === 1}>
<SettingsContainer/>
</ContentBox>
</TabContent>
</div>
: 'Loading'
}
@@ -1,22 +0,0 @@
import {base, handleResp, getInit} from '../helpers/response';
import * as actions from '../constants/embedStream';
export const changeTab = activeTab => dispatch =>
dispatch({
type: actions.CHANGE_TAB,
activeTab
});
const userBioRequest = () => ({type: actions.FETCH_USER_BIO_REQUEST});
const userBioSuccess = userBio => ({type: actions.FETCH_USER_BIO_SUCCESS, userBio});
const userBioFailure = error => ({type: actions.FETCH_USER_BIO_FAILURE, error});
export const fetchUserBio = () => dispatch => {
dispatch(userBioRequest());
fetch(`${base}/bio`, getInit('GET'))
.then(handleResp)
.then(({bio}) => {
dispatch(userBioSuccess(bio));
})
.catch(() => dispatch(userBioFailure()));
};
@@ -1 +0,0 @@
export const CHANGE_TAB = 'CHANGE_VIEW';
-2
View File
@@ -5,7 +5,6 @@ import * as itemActions from './actions/items';
import I18n from './modules/i18n/i18n';
import * as notificationActions from './actions/notification';
import * as authActions from './actions/auth';
import * as embedStream from './actions/embedStream';
export {
Notification,
@@ -15,5 +14,4 @@ export {
I18n,
notificationActions,
authActions,
embedStream
};
@@ -1,16 +0,0 @@
import {Map} from 'immutable';
import * as actions from '../constants/embedStream';
const initialState = Map({
activeTab: 0
});
export default function embedStream (state = initialState, action) {
switch (action.type) {
case actions.CHANGE_TAB :
return state
.set('activeTab', action.activeTab);
default :
return state;
}
}
-2
View File
@@ -5,7 +5,6 @@ import config from './config';
import items from './items';
import notification from './notification';
import auth from './auth';
import embedStream from './embedStream';
/**
* Expose the combined main reducer
@@ -16,5 +15,4 @@ export default combineReducers({
items,
notification,
auth,
embedStream
});
@@ -1,7 +1,6 @@
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {} from '../../coral-framework/actions/embedStream';
import {TabBar, Tab} from '../../coral-ui';
import Bio from '../components/Bio';
@@ -46,8 +45,7 @@ class SignInContainer extends Component {
}
}
const mapStateToProps = state => ({
embedStream: state.embedStream.toJS()
const mapStateToProps = () => ({
});
const mapDispatchToProps = dispatch => ({