Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
Profile popover new component: DM, calendar, whober, @mentions
Browse files Browse the repository at this point in the history
* UCHAT-181 Add button to DM a user from their profile preview popover tile, UCHAT-76 Add link to user's whober profile from their profile preview popover tile, UCHAT-342 Redesign profile hovercard to match whober style spec

* UCHAT-562 Show @username button on profile popover (#26)

* UCHAT-562 add tooltip to popover mention button

* UCHAT-76 Add Tooltip to link to whober profile in profile popover (#32)

* UCHAT-361 Add calendar link to profile hovercard

UCHAT-1854 Display position in user hovecard under name
  • Loading branch information
David Meza authored and Siva Samudrala committed May 16, 2019
1 parent 24fc1d4 commit c0999fc
Show file tree
Hide file tree
Showing 17 changed files with 591 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ exports[`components/AddUsersToTeam should match when renderOption is called 1`]
onClick={[Function]}
>
<ProfilePicture
disablePopover={false}
hasMention={false}
height="32"
isRHS={false}
Expand Down Expand Up @@ -136,6 +137,7 @@ exports[`components/AddUsersToTeam should match when renderOption is called 2`]
onClick={[Function]}
>
<ProfilePicture
disablePopover={false}
hasMention={false}
height="32"
isRHS={false}
Expand Down
14 changes: 7 additions & 7 deletions components/at_mention/__snapshots__/at_mention.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exports[`components/AtMention should match snapshot when mentioning current user
rootClose={true}
show={false}
>
<Connect(InjectIntl(ProfilePopover))
<Connect(InjectIntl(ProfilePopoverUchat))
hasMention={false}
hide={[Function]}
isRHS={false}
Expand All @@ -47,7 +47,7 @@ exports[`components/AtMention should match snapshot when mentioning user 1`] = `
rootClose={true}
show={false}
>
<Connect(InjectIntl(ProfilePopover))
<Connect(InjectIntl(ProfilePopoverUchat))
hasMention={false}
hide={[Function]}
isRHS={false}
Expand All @@ -73,7 +73,7 @@ exports[`components/AtMention should match snapshot when mentioning user contain
rootClose={true}
show={false}
>
<Connect(InjectIntl(ProfilePopover))
<Connect(InjectIntl(ProfilePopoverUchat))
hasMention={false}
hide={[Function]}
isRHS={false}
Expand All @@ -100,7 +100,7 @@ exports[`components/AtMention should match snapshot when mentioning user contain
rootClose={true}
show={false}
>
<Connect(InjectIntl(ProfilePopover))
<Connect(InjectIntl(ProfilePopoverUchat))
hasMention={false}
hide={[Function]}
isRHS={false}
Expand All @@ -126,7 +126,7 @@ exports[`components/AtMention should match snapshot when mentioning user followe
rootClose={true}
show={false}
>
<Connect(InjectIntl(ProfilePopover))
<Connect(InjectIntl(ProfilePopoverUchat))
hasMention={false}
hide={[Function]}
isRHS={false}
Expand All @@ -153,7 +153,7 @@ exports[`components/AtMention should match snapshot when mentioning user with di
rootClose={true}
show={false}
>
<Connect(InjectIntl(ProfilePopover))
<Connect(InjectIntl(ProfilePopoverUchat))
hasMention={false}
hide={[Function]}
isRHS={false}
Expand All @@ -179,7 +179,7 @@ exports[`components/AtMention should match snapshot when mentioning user with mi
rootClose={true}
show={false}
>
<Connect(InjectIntl(ProfilePopover))
<Connect(InjectIntl(ProfilePopoverUchat))
hasMention={false}
hide={[Function]}
isRHS={false}
Expand Down
2 changes: 1 addition & 1 deletion components/at_mention/at_mention.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Overlay} from 'react-bootstrap';
import {Client4} from 'mattermost-redux/client';
import {displayUsername} from 'mattermost-redux/utils/user_utils';

import ProfilePopover from 'components/profile_popover';
import ProfilePopover from 'components/profile_popover_uchat';

import {popOverOverlayPosition} from 'utils/position_utils.jsx';
const spaceRequiredForPopOver = 300;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exports[`components/MoreDirectChannels should match renderOption snapshot 1`] =
onClick={[Function]}
>
<ProfilePicture
disablePopover={false}
hasMention={false}
height="32"
isRHS={false}
Expand Down
6 changes: 4 additions & 2 deletions components/profile_picture.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {OverlayTrigger} from 'react-bootstrap';

import * as PostUtils from 'utils/post_utils.jsx';

import ProfilePopover from 'components/profile_popover';
import ProfilePopover from 'components/profile_popover_uchat';
import StatusIcon from 'components/status_icon';

export default class ProfilePicture extends React.PureComponent {
Expand All @@ -17,6 +17,7 @@ export default class ProfilePicture extends React.PureComponent {
height: '36',
isRHS: false,
hasMention: false,
disablePopover: false,
};

static propTypes = {
Expand All @@ -30,6 +31,7 @@ export default class ProfilePicture extends React.PureComponent {
isRHS: PropTypes.bool,
hasMention: PropTypes.bool,
post: PropTypes.object,
disablePopover: PropTypes.bool,
};

hideProfilePopover = () => {
Expand All @@ -41,7 +43,7 @@ export default class ProfilePicture extends React.PureComponent {
if (this.props.post) {
isSystemMessage = PostUtils.isSystemMessage(this.props.post);
}
if (this.props.userId) {
if (this.props.userId && !this.props.disablePopover) {
return (
<OverlayTrigger
ref='overlay'
Expand Down
75 changes: 75 additions & 0 deletions components/profile_popover_uchat/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';

import {getCurrentUserId, getStatusForUserId, getUser} from 'mattermost-redux/selectors/entities/users';
import {
getCurrentTeam,
getCurrentRelativeTeamUrl,
getTeamMember,
} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentChannel, getChannelMembersInChannels} from 'mattermost-redux/selectors/entities/channels';
import {loadBot} from 'mattermost-redux/actions/bots';
import {getBotAccounts} from 'mattermost-redux/selectors/entities/bots';

import {openDirectChannelToUserId} from 'actions/channel_actions.jsx';
import {getMembershipForCurrentEntities} from 'actions/views/profile_popover';
import {openModal} from 'actions/views/modals';
import {areTimezonesEnabledAndSupported} from 'selectors/general';
import {getSelectedPost, getRhsState} from 'selectors/rhs';

import ProfilePopoverUChat from './profile_popover_uchat.jsx';

function mapStateToProps(state, ownProps) {
const userId = ownProps.userId;
const team = getCurrentTeam(state);
const teamMember = getTeamMember(state, team.id, userId);

let isTeamAdmin = false;
if (teamMember && teamMember.scheme_admin) {
isTeamAdmin = true;
}

const selectedPost = getSelectedPost(state);
const currentChannel = getCurrentChannel(state);

let channelId;
if (selectedPost.exists === false) {
channelId = currentChannel.id;
} else {
channelId = selectedPost.channel_id;
}

const channelMember = getChannelMembersInChannels(state)[channelId][userId];

let isChannelAdmin = false;
if (getRhsState(state) !== 'search' && channelMember != null && channelMember.scheme_admin) {
isChannelAdmin = true;
}

return {
enableTimezone: areTimezonesEnabledAndSupported(state),
currentUserId: getCurrentUserId(state),
isTeamAdmin,
isChannelAdmin,
status: getStatusForUserId(state, userId),
teamUrl: getCurrentRelativeTeamUrl(state),
user: getUser(state, userId),
bot: getBotAccounts(state)[userId],
};
}

function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
openDirectChannelToUserId,
openModal,
getMembershipForCurrentEntities,
loadBot,
}, dispatch),
};
}

export default connect(mapStateToProps, mapDispatchToProps)(ProfilePopoverUChat);
Loading

0 comments on commit c0999fc

Please sign in to comment.