group accounts improvements
This commit is contained in:
@@ -8,14 +8,18 @@ import LoadingIndicator from '../../../components/loading_indicator';
|
||||
import {
|
||||
fetchMembers,
|
||||
expandMembers,
|
||||
updateRole,
|
||||
createRemovedAccount,
|
||||
} from '../../../actions/groups';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import AccountContainer from '../../../containers/account_container';
|
||||
import Column from '../../ui/components/column';
|
||||
import ScrollableList from '../../../components/scrollable_list';
|
||||
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
|
||||
|
||||
const mapStateToProps = (state, { params: { id } }) => ({
|
||||
group: state.getIn(['groups', id]),
|
||||
relationships: state.getIn(['group_relationships', id]),
|
||||
accountIds: state.getIn(['user_lists', 'groups', id, 'items']),
|
||||
hasMore: !!state.getIn(['user_lists', 'groups', id, 'next']),
|
||||
});
|
||||
@@ -47,9 +51,9 @@ class GroupMembers extends ImmutablePureComponent {
|
||||
}, 300, { leading: true });
|
||||
|
||||
render () {
|
||||
const { accountIds, hasMore, group } = this.props;
|
||||
|
||||
if (!group || !accountIds) {
|
||||
const { accountIds, hasMore, group, relationships, dispatch } = this.props;
|
||||
|
||||
if (!group || !accountIds || !relationships) {
|
||||
return (
|
||||
<Column>
|
||||
<LoadingIndicator />
|
||||
@@ -65,7 +69,23 @@ class GroupMembers extends ImmutablePureComponent {
|
||||
onLoadMore={this.handleLoadMore}
|
||||
emptyMessage={<FormattedMessage id='group.members.empty' defaultMessage='This group does not has any members.' />}
|
||||
>
|
||||
{accountIds.map(id => <AccountContainer key={id} id={id} withNote={false} />)}
|
||||
{accountIds.map(id => {
|
||||
let menu = [];
|
||||
|
||||
if (relationships.get('admin')) {
|
||||
menu = [
|
||||
{ text: 'Remove from group', action: () => dispatch(createRemovedAccount(group.get('id'), id)) },
|
||||
{ text: 'Make administrator', action: () => dispatch(updateRole(group.get('id'), id, 'admin')) },
|
||||
]
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="group-account-wrapper" key={id}>
|
||||
<AccountContainer id={id} withNote={false} actionIcon="none" onActionClick={() => true} />
|
||||
{menu.length > 0 && <DropdownMenuContainer items={menu} icon='ellipsis-h' size={18} direction='right' />}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</ScrollableList>
|
||||
</Column>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user