Updated GroupMembers functionality

• Updated:
- GroupMembers functionality to include actions for admin to remove account and make account admin

• Added:
- GroupMemberOptionsPopover
This commit is contained in:
mgabdev
2020-06-10 23:27:03 -04:00
parent aa220c08e4
commit 36b7dc71af
6 changed files with 104 additions and 26 deletions

View File

@@ -0,0 +1,69 @@
import { closePopover } from '../../actions/popover'
import {
updateRole,
createRemovedAccount,
} from '../../actions/groups'
import PopoverLayout from './popover_layout'
import List from '../list'
const mapDispatchToProps = (dispatch) => ({
onUpdateRole(groupId, accountId, type) {
dispatch(closePopover())
dispatch(updateRole(groupId, accountId, type))
},
onCreateRemovedAccount(groupId, accountId) {
dispatch(closePopover())
dispatch(createRemovedAccount(groupId, accountId))
},
})
export default
@connect(null, mapDispatchToProps)
class GroupMemberOptionsPopover extends PureComponent {
static defaultProps = {
accountId: PropTypes.string.isRequired,
groupId: PropTypes.string.isRequired,
isXS: PropTypes.bool,
onUpdateRole: PropTypes.func.isRequired,
onCreateRemovedAccount: PropTypes.func.isRequired,
}
handleOnRemoveFromGroup = () => {
this.props.onCreateRemovedAccount(this.props.groupId, this.props.accountId)
}
handleOnMakeAdmin = () => {
this.props.onUpdateRole(this.props.groupId, this.props.accountId, 'admin')
}
render() {
const { isXS } = this.props
const listItems = [
{
hideArrow: true,
icon: 'block',
title: 'Remove from group',
onClick: this.handleOnRemoveFromGroup,
},
{
hideArrow: true,
icon: 'groups',
title: 'Make group admin',
onClick: this.handleOnMakeAdmin,
},
]
return (
<PopoverLayout width={210} isXS={isXS}>
<List
scrollKey='group_options'
items={listItems}
size='large'
/>
</PopoverLayout>
)
}
}

View File

@@ -3,6 +3,7 @@ import {
POPOVER_COMMENT_SORTING_OPTIONS,
POPOVER_DATE_PICKER,
POPOVER_EMOJI_PICKER,
POPOVER_GROUP_MEMBER_OPTIONS,
POPOVER_GROUP_OPTIONS,
POPOVER_NAV_SETTINGS,
POPOVER_PROFILE_OPTIONS,
@@ -17,6 +18,7 @@ import {
CommentSortingOptionsPopover,
DatePickerPopover,
EmojiPickerPopover,
GroupMemberOptionsPopover,
GroupOptionsPopover,
NavSettingsPopover,
ProfileOptionsPopover,
@@ -40,6 +42,7 @@ const POPOVER_COMPONENTS = {}
POPOVER_COMPONENTS[POPOVER_COMMENT_SORTING_OPTIONS] = CommentSortingOptionsPopover
POPOVER_COMPONENTS[POPOVER_DATE_PICKER] = DatePickerPopover
POPOVER_COMPONENTS[POPOVER_EMOJI_PICKER] = EmojiPickerPopover
POPOVER_COMPONENTS[POPOVER_GROUP_MEMBER_OPTIONS] = GroupMemberOptionsPopover
POPOVER_COMPONENTS[POPOVER_GROUP_OPTIONS] = GroupOptionsPopover
POPOVER_COMPONENTS[POPOVER_NAV_SETTINGS] = NavSettingsPopover
POPOVER_COMPONENTS[POPOVER_PROFILE_OPTIONS] = ProfileOptionsPopover