From f740698dbe06816921d2a20eea876c9ca7b515ed Mon Sep 17 00:00:00 2001 From: David Meza Date: Mon, 31 Jul 2017 07:24:13 -0500 Subject: PLT-6486 Add an `@username` button to the profile popover, that puts the username in the post when clicked (#6349) * PLT-6486 Add an `@username` button to the profile popover, that puts the username in the post when clicked * PLT-6486 Display `@username` mention on the right text area on center or RHS. * Disable @mentions from profile popover on searches, mentions and pinned posts. Fix js errors. * Control undefined post in SearchStore that causes an exception. --- webapp/components/profile_popover.jsx | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'webapp/components/profile_popover.jsx') diff --git a/webapp/components/profile_popover.jsx b/webapp/components/profile_popover.jsx index 3c57f41b6..9e7d7636a 100644 --- a/webapp/components/profile_popover.jsx +++ b/webapp/components/profile_popover.jsx @@ -24,6 +24,7 @@ export default class ProfilePopover extends React.Component { this.initWebrtc = this.initWebrtc.bind(this); this.handleShowDirectChannel = this.handleShowDirectChannel.bind(this); + this.handleMentionKeyClick = this.handleMentionKeyClick.bind(this); this.state = { currentUserId: UserStore.getCurrentId(), loadingDMChannel: -1 @@ -103,6 +104,18 @@ export default class ProfilePopover extends React.Component { } } + handleMentionKeyClick(e) { + e.preventDefault(); + + if (!this.props.user) { + return; + } + if (this.props.hide) { + this.props.hide(); + } + GlobalActions.emitPopoverMentionKeyClick(this.props.isRHS, this.props.user.username); + } + render() { const popoverProps = Object.assign({}, this.props); delete popoverProps.user; @@ -110,6 +123,8 @@ export default class ProfilePopover extends React.Component { delete popoverProps.status; delete popoverProps.isBusy; delete popoverProps.hide; + delete popoverProps.isRHS; + delete popoverProps.hasMention; let webrtc; const userMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; @@ -179,6 +194,7 @@ export default class ProfilePopover extends React.Component { delayShow={Constants.WEBRTC_TIME_DELAY} placement='top' overlay={{fullname}} + key='user-popover-fullname' >
{title}; + } + return ( {dataContent} @@ -259,11 +280,18 @@ export default class ProfilePopover extends React.Component { } } +ProfilePopover.defaultProps = { + isRHS: false, + hasMention: false +}; + ProfilePopover.propTypes = Object.assign({ src: PropTypes.string.isRequired, user: PropTypes.object.isRequired, status: PropTypes.string, isBusy: PropTypes.bool, - hide: PropTypes.func + hide: PropTypes.func, + isRHS: PropTypes.bool, + hasMention: PropTypes.bool }, Popover.propTypes); delete ProfilePopover.propTypes.id; -- cgit v1.2.3-1-g7c22