import { Fragment } from 'react' import { defineMessages, injectIntl } from 'react-intl' import ImmutablePureComponent from 'react-immutable-pure-component' import ImmutablePropTypes from 'react-immutable-proptypes' import moment from 'moment-mini' import { shortNumberFormat } from '../../utils/numbers' import PanelLayout from './panel_layout' import Button from '../button' import Divider from '../divider' import Heading from '../heading' import Icon from '../icon' import Text from '../text' import DotTextSeperator from '../dot_text_seperator' import ProfileInfoPanelPlaceholder from '../placeholder/profile_info_panel_placeholder' const messages = defineMessages({ title: { id: 'about', defaultMessage: 'About' }, members: { id: 'members', defaultMessage: 'Members' }, created: { id: 'created', defaultMessage: 'Created' }, category: { id: 'category', defaultMessage: 'Category' }, tags: { id: 'tags', defaultMessage: 'Tags' }, privateGroup: { id: 'group.private', defaultMessage: 'Private' }, publicGroup: { id: 'group.public', defaultMessage: 'Public' }, visibleGroup: { id: 'group.visible', defaultMessage: 'Visible' }, invisibleGroup: { id: 'group.invisible', defaultMessage: 'Invisible' }, }) const mapStateToProps = (state, { group }) => { const groupId = group ? group.get('id') : -1 const relationships = group === -1 ? null : state.getIn(['group_relationships', groupId]) return { relationships } } export default @injectIntl @connect(mapStateToProps) class GroupInfoPanel extends ImmutablePureComponent { static propTypes = { group: ImmutablePropTypes.map.isRequired, intl: PropTypes.object.isRequired, noPanel: PropTypes.bool, relationships: ImmutablePropTypes.map, } render() { const { intl, group, noPanel, relationships, } = this.props if (!group && !noPanel) { return (
) } const isAdmin = relationships ? relationships.get('admin') : false const groupId = !!group ? group.get('id') : '' const slug = !!group ? !!group.get('slug') ? `g/${group.get('slug')}` : undefined : undefined const isPrivate = !!group ? group.get('is_private') : false const isVisible = !!group ? group.get('is_visible') : false const tags = !!group ? group.get('tags') : [] if (noPanel) { return (
{ !!group && {group.get('title')} { !!slug && {slug} } {group.get('description')}
{intl.formatMessage(isPrivate ? messages.privateGroup : messages.publicGroup)} {shortNumberFormat(group.get('member_count'))}   {intl.formatMessage(messages.members)}
}
) } return ( { !!group && {group.get('description')} General {moment(group.get('created_at')).format('LL')} { !!tags &&
{ tags.map((tag) => (
{tag}
)) }
}
}
) } } class GroupInfoPanelRow extends PureComponent { static propTypes = { icon: PropTypes.string, title: PropTypes.string.isRequired, } render() { const { icon, title } = this.props return (
{title}
{this.props.children}
) } }