import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import ImmutablePureComponent from 'react-immutable-pure-component' import ImmutablePropTypes from 'react-immutable-proptypes' import { defineMessages, injectIntl } from 'react-intl' import { addShortcut, removeShortcut, } from '../../actions/shortcuts' import { closePopover } from '../../actions/popover' import PopoverLayout from './popover_layout' import List from '../list' class GroupOptionsPopover extends ImmutablePureComponent { handleOnClosePopover = () => { this.props.onClosePopover() } handleOnToggleShortcut = () => { this.handleOnClosePopover() if (this.props.isShortcut) { this.props.onRemoveShortcut(this.props.group.get('id')) } else { this.props.onAddShortcut(this.props.group.get('id')) } } render() { const { group, intl, isAdmin, isShortcut, isXS, } = this.props if (!group) return
const groupId = group.get('id') 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 (