diff --git a/app/javascript/gabsocial/components/group_header.js b/app/javascript/gabsocial/components/group_header.js index ac90d79e..3134d3c4 100644 --- a/app/javascript/gabsocial/components/group_header.js +++ b/app/javascript/gabsocial/components/group_header.js @@ -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) } diff --git a/app/javascript/gabsocial/components/popover/group_options_popover.js b/app/javascript/gabsocial/components/popover/group_options_popover.js index 222fcea2..569069c0 100644 --- a/app/javascript/gabsocial/components/popover/group_options_popover.js +++ b/app/javascript/gabsocial/components/popover/group_options_popover.js @@ -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, - }, - { - hideArrow: true, - icon: 'star', - title: intl.formatMessage(isShortcut ? messages.remove_from_shortcuts : messages.add_to_shortcuts), - onClick: this.handleOnToggleShortcut, - }, - ] + }) + } + + listItems.push({ + hideArrow: true, + icon: 'star', + title: intl.formatMessage(isShortcut ? messages.remove_from_shortcuts : messages.add_to_shortcuts), + onClick: this.handleOnToggleShortcut, + }) return ( { 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 - } else if (!group && error) { + } else if ((!group && error) || !isAdmin) { return }