Updated group admin functionality

• Updated:
- group admin functionality
This commit is contained in:
mgabdev 2020-08-08 13:21:18 -05:00
parent 4a8cd0b585
commit eb99d187fc
3 changed files with 21 additions and 16 deletions

View File

@ -70,7 +70,7 @@ class GroupHeader extends ImmutablePureComponent {
handleOnOpenGroupOptions = () => {
const { relationships } = this.props
const isAdmin = relationships ? relationships.get('admin') : false
const isAdmin = !!relationships ? relationships.get('admin') : false
this.props.onOpenGroupOptions(this.infoBtn, this.props.group, isAdmin)
}

View File

@ -78,38 +78,40 @@ class GroupOptionsPopover extends ImmutablePureComponent {
const groupId = group.get('id')
const listItems = [
{
const listItems = []
if (isAdmin) {
listItems.push({
hideArrow: true,
icon: 'group',
title: intl.formatMessage(messages.groupMembers),
onClick: this.handleOnClosePopover,
to: `/groups/${groupId}/members`,
isHidden: !isAdmin,
},
{
})
listItems.push({
hideArrow: true,
icon: 'block',
title: intl.formatMessage(messages.removedMembers),
onClick: this.handleOnClosePopover,
to: `/groups/${groupId}/removed-accounts`,
isHidden: !isAdmin,
},
{
})
listItems.push({
hideArrow: true,
icon: 'pencil',
title: intl.formatMessage(messages.editGroup),
onClick: this.handleOnClosePopover,
to: `/groups/${groupId}/edit`,
isHidden: !isAdmin,
},
{
})
}
listItems.push({
hideArrow: true,
icon: 'star',
title: intl.formatMessage(isShortcut ? messages.remove_from_shortcuts : messages.add_to_shortcuts),
onClick: this.handleOnToggleShortcut,
},
]
})
return (
<PopoverLayout

View File

@ -65,6 +65,7 @@ const mapStateToProps = (state, { params }) => {
return {
group,
groupId,
isAdmin,
error: (groupId && !group) || (group && !isAdmin),
titleValue: state.getIn(['group_editor', 'title']),
descriptionValue: state.getIn(['group_editor', 'description']),
@ -150,6 +151,7 @@ class GroupCreate extends ImmutablePureComponent {
onSetGroup: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,
isSubmitting: PropTypes.bool,
isAdmin: PropTypes.bool,
onClose: PropTypes.func,
idValue: PropTypes.string.isRequired,
tags: PropTypes.string.isRequired,
@ -220,11 +222,12 @@ class GroupCreate extends ImmutablePureComponent {
isVisible,
groupId,
categories,
isAdmin,
} = this.props
if (!group && groupId) {
return <ColumnIndicator type='loading' />
} else if (!group && error) {
} else if ((!group && error) || !isAdmin) {
return <ColumnIndicator type='missing' />
}