File size: 2,698 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
// @flow
import React, { Component } from 'react';
import compose from 'recompose/compose';
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import AvatarImage from 'src/components/avatar/image';
import { Link } from 'react-router-dom';
import { Button, OutlineButton } from 'src/components/button';
import renderTextWithLinks from 'src/helpers/render-text-with-markdown-links';
import type { GetChannelType } from 'shared/graphql/queries/channel/getChannel';
import type { Dispatch } from 'redux';
import { withCurrentUser } from 'src/components/withCurrentUser';
import {
HoverWrapper,
ProfileCard,
ChannelCommunityRow,
ChannelCommunityLabel,
Content,
Title,
Description,
Actions,
} from './style';
type ProfileProps = {
channel: GetChannelType,
dispatch: Dispatch<Object>,
currentUser: ?Object,
ref: (?HTMLElement) => void,
style: CSSStyleDeclaration,
};
class HoverProfile extends Component<ProfileProps> {
render() {
const { channel, ref, style } = this.props;
const {
isOwner: isChannelOwner,
isMember: isChannelMember,
} = channel.channelPermissions;
const { communityPermissions } = channel.community;
const {
isOwner: isCommunityOwner,
isModerator: isCommunityModerator,
} = communityPermissions;
const isGlobalOwner = isChannelOwner || isCommunityOwner;
const isGlobalModerator = isCommunityModerator;
return (
<HoverWrapper popperStyle={style} ref={ref}>
<ProfileCard>
<ChannelCommunityRow to={`/${channel.community.slug}`}>
<AvatarImage
size={24}
src={channel.community.profilePhoto}
type={'community'}
alt={channel.community.name}
/>
<ChannelCommunityLabel>
{channel.community.name}
</ChannelCommunityLabel>
</ChannelCommunityRow>
<Content>
<Link to={`/${channel.community.slug}/${channel.slug}`}>
<Title>{channel.name}</Title>
</Link>
{channel.description && (
<Description>
{renderTextWithLinks(channel.description)}
</Description>
)}
</Content>
<Actions>
{(isGlobalModerator || isGlobalOwner) && (
<Link to={`/${channel.community.slug}/${channel.slug}/settings`}>
<OutlineButton icon={'settings'}>Settings</OutlineButton>
</Link>
)}
</Actions>
</ProfileCard>
</HoverWrapper>
);
}
}
export default compose(
withCurrentUser,
withRouter,
connect()
)(HoverProfile);
|