Skip to content

Commit

Permalink
Restore release 0.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkus Decker committed Apr 4, 2016
1 parent 4c3dd6f commit d29455c
Show file tree
Hide file tree
Showing 14 changed files with 403 additions and 79 deletions.
4 changes: 3 additions & 1 deletion src/components/home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ function selectState(state) {
const boxHeader = state.boxHeader
const sendTo = {...state.sendTo, defaultFeed: user.username}

const totalRequestsCount = state.groupRequestsCount + state.userRequestsCount
const totalRequestsCount = state.groupRequestsCount +
state.userRequestsCount +
state.sentRequestsCount

return {
user, authenticated,
Expand Down
30 changes: 16 additions & 14 deletions src/components/manage-subscribers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ const ManageSubscribersHandler = (props) => {
}

return (
<div className='box'>
<div className='box-header-timeline'>
<div className="box">
<div className="box-header-timeline">
{props.boxHeader}
</div>
<div className='box-body'>
<div className="box-body">
<div className="row">
<div className="col-md-6">
<Link to={`/${props.groupName}`}>{props.groupName}</Link> › Manage subscribers
Expand All @@ -31,34 +31,36 @@ const ManageSubscribersHandler = (props) => {
<Link to={`/${props.groupName}/subscribers`}>Browse subscribers</Link>
</div>
</div>
<div className='manage-subscribers-body'>
<div className="manage-subscribers-body">
{props.users ? (
<div>
<h3>Subscribers</h3>

{props.users.length == 0 ? (
<div>There's not a single one subscriber yet. You might invite some friends to change that.</div>
) : (
<SubsList users={props.users}
makeAdmin={makeAdmin}
remove={remove}/>
<SubsList
users={props.users}
makeAdmin={makeAdmin}
remove={remove}/>
)}
</div>
) : false}
) : false}

<div className='manage-subscribers-admins'>
<div className="manage-subscribers-admins">
<h3>Admins</h3>

{props.amILastGroupAdmin ? (
<div>You are the only Admin for this group. Before you can drop administrative privileges
or leave this group, you have to promote another group member to Admin first.</div>
or leave this group, you have to promote another group member to Admin first.</div>
) : (
<AdminsList users={props.groupAdmins}
removeAdminRights={removeAdminRights}/>
<AdminsList
users={props.groupAdmins}
removeAdminRights={removeAdminRights}/>
)}
</div>

</div>
</div>
<div className='box-footer'></div>
</div>
)
}
Expand Down
11 changes: 6 additions & 5 deletions src/components/post-comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ export default class PostComment extends React.Component{
}
}

componentWillReceiveProps(newProps){
const justSaved = this.props.isSaving && !newProps.isSaving
const noError = !newProps.errorString
const shouldClearText = justSaved && noError
if (shouldClearText){
componentWillReceiveProps(newProps) {
const wasCommentJustSaved = this.props.isSaving && !newProps.isSaving
const wasThereNoError = !newProps.errorString
const isItSinglePostAddingComment = newProps.isSinglePost
const shouldClearText = (wasCommentJustSaved && wasThereNoError && isItSinglePostAddingComment)
if (shouldClearText) {
this.setState({editText: ''})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/post-comments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default (props) => {
{last ? commentMapper(last) : false}
{canAddComment
? (props.post.isCommenting
? renderAddingComment(props, openAnsweringComment)
? renderAddingComment(props)
: renderAddCommentLink(props, disabledForOthers))
: false}
</div>
Expand Down
31 changes: 23 additions & 8 deletions src/components/requests.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import {connect} from 'react-redux'
import {Link} from 'react-router'

import {acceptGroupRequest, rejectGroupRequest,
acceptUserRequest, rejectUserRequest} from '../redux/action-creators'
import {tileUserListFactory, WITH_REQUEST_HANDLES} from './tile-user-list'
acceptUserRequest, rejectUserRequest,
revokeSentRequest} from '../redux/action-creators'
import {tileUserListFactory, WITH_REQUEST_HANDLES, WITH_REVOKE_SENT_REQUEST} from './tile-user-list'

const TileList = tileUserListFactory({type: WITH_REQUEST_HANDLES})
const TileListWithAcceptAndReject = tileUserListFactory({type: WITH_REQUEST_HANDLES})
const TileListWithRevoke = tileUserListFactory({type: WITH_REVOKE_SENT_REQUEST})

const renderRequestsToGroup = (accept, reject) => (groupRequests) => {
const acceptGroupRequest = (userName) => accept(groupRequests.username, userName)
Expand All @@ -15,7 +17,7 @@ const renderRequestsToGroup = (accept, reject) => (groupRequests) => {
return (
<div key={groupRequests.id}>
<h3>{groupRequests.screenName}</h3>
<TileList
<TileListWithAcceptAndReject
users={groupRequests.requests}
acceptRequest={acceptGroupRequest}
rejectRequest={rejectGroupRequest}/>
Expand All @@ -40,7 +42,7 @@ const RequestsHandler = (props) => {
{props.feedRequests && props.feedRequests.length ? (
<div>
<h3>Requests to your feed</h3>
<TileList
<TileListWithAcceptAndReject
users={props.feedRequests}
acceptRequest={props.acceptUserRequest}
rejectRequest={props.rejectUserRequest}/>
Expand All @@ -52,6 +54,15 @@ const RequestsHandler = (props) => {
{groupRequests}
</div>
) : false}

{props.sentRequests && props.sentRequests.length ? (
<div>
<h3>Sent requests</h3>
<TileListWithRevoke
users={props.sentRequests}
revokeSentRequest={props.revokeSentRequest}/>
</div>
) : false}
</div>
)}
</div>
Expand All @@ -63,20 +74,24 @@ function selectState(state, ownProps) {
const boxHeader = state.boxHeader
const username = ownProps.params.userName

const overallRequestsCount = state.userRequestsCount + state.groupRequestsCount
const overallRequestsCount = state.userRequestsCount +
state.groupRequestsCount +
state.sentRequestsCount

const feedRequests = state.userRequests
const groupRequests = state.managedGroups.filter(group => group.requests.length) || []
const sentRequests = state.sentRequests

return {boxHeader, username, feedRequests, groupRequests, overallRequestsCount}
return {boxHeader, username, feedRequests, groupRequests, sentRequests, overallRequestsCount}
}

function selectActions(dispatch) {
return {
acceptGroupRequest: (...args) => dispatch(acceptGroupRequest(...args)),
rejectGroupRequest: (...args) => dispatch(rejectGroupRequest(...args)),
acceptUserRequest: (...args) => dispatch(acceptUserRequest(...args)),
rejectUserRequest: (...args) => dispatch(rejectUserRequest(...args))
rejectUserRequest: (...args) => dispatch(rejectUserRequest(...args)),
revokeSentRequest: (...args) => dispatch(revokeSentRequest(...args))
}
}

Expand Down
56 changes: 37 additions & 19 deletions src/components/tile-user-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,48 @@ import {Link} from 'react-router'
import classnames from 'classnames'
import _ from 'lodash'

import {preventDefault} from '../utils'
import UserName from './user-name'
import {confirmFirst} from '../utils'

const renderUsers = (type) => (user) => {
return (
<li key={user.id}>
<Link to={`/${user.username}`}>
<div className="avatar">
<div className="avatar">
<Link to={`/${user.username}`}>
<img src={user.profilePictureUrl}/>
</div>
<span>{user.screenName}</span>
</Link>
</Link>
</div>

<UserName user={user}/>

{type == WITH_REQUEST_HANDLES ? (
<div className='user-actions'>
<a onClick={preventDefault(() => user.acceptRequest(user.username))}>Accept</a>
<span> | </span>
<a onClick={preventDefault(() => user.rejectRequest(user.username))}>Reject</a>
<div className="user-actions">
<a onClick={() => user.acceptRequest(user.username)}>Accept</a>
<span> - </span>
<a onClick={() => user.rejectRequest(user.username)}>Reject</a>
</div>
) : false}

{type == WITH_REMOVE_AND_MAKE_ADMIN_HANDLES ? (
<div className='user-actions'>
<a onClick={preventDefault(() => user.remove(user.username))}>Remove</a>
<br/>
<a onClick={preventDefault(() => user.makeAdmin(user))}>Make admin</a>
<div className="user-actions">
<a onClick={() => user.makeAdmin(user)} title="Promote user to admin">Promote</a>
<span> - </span>
<a onClick={confirmFirst(() => user.remove(user.username))} title="Unsubscribe user from the group">Unsub</a>
</div>
) : false}

{type == WITH_REMOVE_ADMIN_RIGHTS ? (
<div className='user-actions'>
<a onClick={preventDefault(() => user.removeAdminRights(user))}>Remove admin rights</a>
<div className="user-actions">
<a onClick={() => user.removeAdminRights(user)} title="Demote user from admin">Demote</a>
</div>
) : false}


{type == WITH_REVOKE_SENT_REQUEST ? (
<div className="user-actions">
<a onClick={() => user.revokeSentRequest(user.username)} title="Revoke sent request">Revoke</a>
</div>
) : false}

</li>
)
}
Expand All @@ -45,6 +53,7 @@ export const PLAIN = 'PLAIN'
export const WITH_REQUEST_HANDLES = 'WITH_REQUEST_HANDLES'
export const WITH_REMOVE_AND_MAKE_ADMIN_HANDLES = 'WITH_REMOVE_AND_MAKE_ADMIN_HANDLES'
export const WITH_REMOVE_ADMIN_RIGHTS = 'WITH_REMOVE_ADMIN_RIGHTS'
export const WITH_REVOKE_SENT_REQUEST = 'WITH_REVOKE_SENT_REQUEST'

function pickActions(type, props) {
switch (type) {
Expand All @@ -57,6 +66,9 @@ function pickActions(type, props) {
case WITH_REMOVE_ADMIN_RIGHTS: {
return { removeAdminRights: props.removeAdminRights }
}
case WITH_REVOKE_SENT_REQUEST: {
return { revokeSentRequest: props.revokeSentRequest }
}
}

return {}
Expand All @@ -66,7 +78,12 @@ export const tileUserListFactory = (config) => (props) => {
const usersData = props.users.map(user => {
return {
..._.pick(user, ['id', 'screenName', 'username']),
profilePictureUrl: (config.size === 'large') ? user.profilePictureLargeUrl : user.profilePictureMediumUrl,
profilePictureUrl:
(user.profilePictureUrl
? user.profilePictureUrl
: (config.size === 'large'
? user.profilePictureLargeUrl
: user.profilePictureMediumUrl)),
...pickActions(config.type, props)
}
})
Expand All @@ -75,7 +92,8 @@ export const tileUserListFactory = (config) => (props) => {

const listClasses = classnames({
'tile-list': true,
'large-pics': config.size === 'large'
'large-pics': config.size === 'large',
'with-actions': config.type !== PLAIN
})

return (
Expand Down
103 changes: 103 additions & 0 deletions src/components/user-card.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import React from 'react'
import {Link} from 'react-router'
import {connect} from 'react-redux'

import {userActions} from './select-utils'

const UserCard = (props) => {
const unsubscribe = () => {
if (props.amIGroupAdmin) {
alert('You are the Admin for this group. If you want to unsubscribe please drop administrative privileges first.')
} else {
props.unsubscribe({username: props.user.username})
}
}

return (!props.user.id ? (
<div className="user-card">
<div className="user-card-info">
<i>No information.</i>
</div>
</div>
) : (
<div className="user-card">
<div className="user-card-info">
<Link to={`/${props.user.username}`} className="userpic">
<img src={props.user.profilePictureLargeUrl} width="75" height="75"/>
</Link>

<div className="names">
<Link to={`/${props.user.username}`} className="display-name">{props.user.screenName}</Link><br/>

{props.user.screenName !== props.user.username ? (
<span className="username">@{props.user.username}</span>
) : false}
</div>

<div className="description">
{props.isItMe ? (
"It's you!"
) : props.user.type === 'user' && props.user.isPrivate === '1' ? (
'Private feed'
) : props.user.type === 'user' && props.user.isPrivate === '0' ? (
'Public feed'
) : props.user.type === 'group' && props.user.isPrivate === '1' ? (
'Private group'
) : props.user.type === 'group' && props.user.isPrivate === '0' ? (
'Public group'
) : false}
</div>
</div>

{props.blocked ? (
<div className="user-card-actions">
<span>Blocked user - </span>
<a onClick={()=>props.unban({username: props.user.username, id: props.user.id})}>Un-block</a>
</div>
) : !props.isItMe ? (
<div className="user-card-actions">
{props.user.isPrivate === '1' && !props.subscribed ? (
props.hasRequestBeenSent ? (
<span>Subscription request sent</span>
) : (
<a onClick={()=>props.sendSubscriptionRequest({username: props.user.username, id: props.user.id})}>Request a subscription</a>
)
) : (
props.subscribed ? (
<a onClick={unsubscribe}>Unsubscribe</a>
) : (
<a onClick={()=>props.subscribe({username: props.user.username})}>Subscribe</a>
)
)}

{props.user.type !== 'group' && !props.subscribed ? (
<span> - <a onClick={()=>props.ban({username: props.user.username, id: props.user.id})}>Block</a></span>
) : props.amIGroupAdmin ? (
<span> - <Link to={`/${props.user.username}/settings`}>Settings</Link></span>
) : false}

</div>
) : false}
</div>
))
}

const mapStateToProps = (state, ownProps) => {
const me = state.user
const user = (_.find(state.users, {'username': ownProps.username}) || {})

return {
user,
isItMe: (me.username === user.username),
subscribed: ((me.subscriptions || []).indexOf(user.id) > -1),
hasRequestBeenSent: ((me.pendingSubscriptionRequests || []).indexOf(user.id) > -1),
blocked: ((me.banIds || []).indexOf(user.id) > -1),
amIGroupAdmin: (user.type === 'group' && (user.administrators || []).indexOf(me.id) > -1)
}
}

function mapDispatchToProps(dispatch) {
return userActions(dispatch)
}

export default connect(mapStateToProps, mapDispatchToProps)(UserCard)
Loading

0 comments on commit d29455c

Please sign in to comment.