Merge remote-tracking branch 'refs/remotes/origin/graphql'

Conflicts:
	client/coral-embed-stream/src/Embed.js
This commit is contained in:
Riley Davis
2017-01-20 15:56:03 -07:00
4 changed files with 19 additions and 39 deletions
+10 -17
View File
@@ -92,17 +92,16 @@ class Embed extends Component {
}
render () {
console.log(this.props)
// const rootItemId = this.props.items.assets && Object.keys(this.props.items.assets)[0];
// const rootItem = this.props.items.assets && this.props.items.assets[rootItemId];
// const {actions, users, comments} = this.props.items;
const {isAdmin, showSignInDialog, loggedIn} = this.props.auth;
const {loggedIn, isAdmin, user, showSignInDialog, signInOffset} = this.props.auth;
const {activeTab} = this.state;
// const banned = (this.props.userData.status === 'banned');
const {loading, asset, currentUser, refetch} = this.props.data;
const {loading, asset, refetch} = this.props.data;
// const {status, moderation, closedMessage, charCount, charCountEnable} = asset.settings;
@@ -119,7 +118,7 @@ class Embed extends Component {
<Tab>Settings</Tab>
<Tab restricted={!isAdmin}>Configure Stream</Tab>
</TabBar>
{currentUser && <UserBox user={currentUser} logout={this.props.logout} />}
{loggedIn && <UserBox user={user} logout={this.props.logout} />}
<TabContent show={activeTab === 0}>
{
asset.closedAt === null
@@ -139,28 +138,22 @@ class Embed extends Component {
reply={false}
currentUser={this.props.auth.user}
banned={false}
author={currentUser}
author={user}
charCount={asset.settings.charCountEnable && asset.settings.charCount}/>
</RestrictedContent>
</div>
: <p>{asset.settings.closedMessage}</p>
}
{
!currentUser && <SignInContainer
refetch={refetch}
showSignInDialog={showSignInDialog}/>
}
<Stream
asset={asset}
currentUser={currentUser}
comments={asset.comments} />
{
<Notification
notifLength={4500}
clearNotification={this.props.clearNotification}
notification={{text: null}}
/>
}
{!loggedIn && <SignInContainer offset={signInOffset}/>}
<Notification
notifLength={4500}
clearNotification={this.props.clearNotification}
notification={{text: null}}
/>
</TabContent>
<TabContent show={activeTab === 1}>
<SettingsContainer
@@ -38,9 +38,5 @@ query AssetQuery($asset_url: String!) {
...commentView
}
}
},
currentUser: me {
id,
displayName
}
}
+8 -12
View File
@@ -20,21 +20,17 @@ export const cleanState = () => ({type: actions.CLEAN_STATE});
// Sign In Actions
const signInRequest = () => ({type: actions.FETCH_SIGNIN_REQUEST});
const signInSuccess = (user, isAdmin) => ({type: actions.FETCH_SIGNIN_SUCCESS, user, isAdmin});
const signInFailure = error => ({type: actions.FETCH_SIGNIN_FAILURE, error});
export const fetchSignIn = (formData) => (dispatch) => {
dispatch(signInRequest());
return coralApi('/auth/local', {method: 'POST', body: formData})
.then((user) => {
coralApi('/auth/local', {method: 'POST', body: formData})
.then(({user}) => {
const isAdmin = !!user.roles.filter(i => i === 'admin').length;
dispatch(signInSuccess(user, isAdmin));
// dispatch(hideSignInDialog());
// dispatch(addItem(user, 'users'));
dispatch(hideSignInDialog());
dispatch(addItem(user, 'users'));
})
.catch(() => dispatch(signInFailure(lang.t('error.emailPasswordError'))));
};
@@ -79,7 +75,7 @@ const signUpFailure = error => ({type: actions.FETCH_SIGNUP_FAILURE, error});
export const fetchSignUp = formData => (dispatch) => {
dispatch(signUpRequest());
return coralApi('/users', {method: 'POST', body: formData})
coralApi('/users', {method: 'POST', body: formData})
.then(({user}) => {
dispatch(signUpSuccess(user));
setTimeout(() =>{
@@ -99,7 +95,7 @@ const forgotPassowordFailure = () => ({type: actions.FETCH_FORGOT_PASSWORD_FAILU
export const fetchForgotPassword = email => (dispatch) => {
dispatch(forgotPassowordRequest(email));
return coralApi('/account/password/reset', {method: 'POST', body: {email}})
coralApi('/account/password/reset', {method: 'POST', body: {email}})
.then(() => dispatch(forgotPassowordSuccess()))
.catch(error => dispatch(forgotPassowordFailure(error)));
};
@@ -112,7 +108,7 @@ const logOutFailure = () => ({type: actions.LOGOUT_FAILURE});
export const logout = () => dispatch => {
dispatch(logOutRequest());
return coralApi('/auth', {method: 'DELETE'})
coralApi('/auth', {method: 'DELETE'})
.then(() => dispatch(logOutSuccess()))
.catch(error => dispatch(logOutFailure(error)));
};
@@ -130,7 +126,7 @@ const checkLoginFailure = error => ({type: actions.CHECK_LOGIN_FAILURE, error});
export const checkLogin = () => dispatch => {
dispatch(checkLoginRequest());
return coralApi('/auth')
coralApi('/auth')
.then((result) => {
if (!result.user) {
throw new Error('Not logged in');
@@ -121,12 +121,7 @@ class SignInContainer extends Component {
handleSignIn(e) {
e.preventDefault();
this.props.fetchSignIn(this.state.formData)
// Using refetch to get data after the user has logged in.
// This is the equivalent of a page reload, we may want to use a more speficic mustation here.
// Also, we may want to find a way for this logic to live elsewhere.
.then(() => this.props.refetch());
this.props.fetchSignIn(this.state.formData);
}
handleClose() {