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 = () => { handleOnOpenGroupOptions = () => {
const { relationships } = this.props 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) 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 groupId = group.get('id')
const listItems = [ const listItems = []
{ if (isAdmin) {
listItems.push({
hideArrow: true, hideArrow: true,
icon: 'group', icon: 'group',
title: intl.formatMessage(messages.groupMembers), title: intl.formatMessage(messages.groupMembers),
onClick: this.handleOnClosePopover, onClick: this.handleOnClosePopover,
to: `/groups/${groupId}/members`, to: `/groups/${groupId}/members`,
isHidden: !isAdmin, isHidden: !isAdmin,
}, })
{ listItems.push({
hideArrow: true, hideArrow: true,
icon: 'block', icon: 'block',
title: intl.formatMessage(messages.removedMembers), title: intl.formatMessage(messages.removedMembers),
onClick: this.handleOnClosePopover, onClick: this.handleOnClosePopover,
to: `/groups/${groupId}/removed-accounts`, to: `/groups/${groupId}/removed-accounts`,
isHidden: !isAdmin, isHidden: !isAdmin,
}, })
{ listItems.push({
hideArrow: true, hideArrow: true,
icon: 'pencil', icon: 'pencil',
title: intl.formatMessage(messages.editGroup), title: intl.formatMessage(messages.editGroup),
onClick: this.handleOnClosePopover, onClick: this.handleOnClosePopover,
to: `/groups/${groupId}/edit`, to: `/groups/${groupId}/edit`,
isHidden: !isAdmin, isHidden: !isAdmin,
}, })
{ }
hideArrow: true,
icon: 'star', listItems.push({
title: intl.formatMessage(isShortcut ? messages.remove_from_shortcuts : messages.add_to_shortcuts), hideArrow: true,
onClick: this.handleOnToggleShortcut, icon: 'star',
}, title: intl.formatMessage(isShortcut ? messages.remove_from_shortcuts : messages.add_to_shortcuts),
] onClick: this.handleOnToggleShortcut,
})
return ( return (
<PopoverLayout <PopoverLayout

View File

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