summaryrefslogtreecommitdiffstats
path: root/webapp/components/rhs_root_post.jsx
diff options
context:
space:
mode:
authorAndrei Stanciu <andrei.stanciu@geminisols.ro>2017-02-10 16:56:48 +0200
committerCorey Hulen <corey@hulen.com>2017-02-10 06:56:48 -0800
commit1bbed1cb2bf1248e9ca8a1511cfe8a385c5f21f7 (patch)
treee61c54cc13a6d7975cce69322bae6f6f5c7c9300 /webapp/components/rhs_root_post.jsx
parent1359f7f3918befd2463103379d17bd2eb846654d (diff)
downloadchat-1bbed1cb2bf1248e9ca8a1511cfe8a385c5f21f7.tar.gz
chat-1bbed1cb2bf1248e9ca8a1511cfe8a385c5f21f7.tar.bz2
chat-1bbed1cb2bf1248e9ca8a1511cfe8a385c5f21f7.zip
Add permalink to timestamp (#5206)
* Add permalink to timestamp * Add permalink to timestamp * Add permalink to timestamp * Add permalink to timestamp * fix error with duplicated import * underline permalink on hover
Diffstat (limited to 'webapp/components/rhs_root_post.jsx')
-rw-r--r--webapp/components/rhs_root_post.jsx52
1 files changed, 45 insertions, 7 deletions
diff --git a/webapp/components/rhs_root_post.jsx b/webapp/components/rhs_root_post.jsx
index 5ab0a3956..0c1037501 100644
--- a/webapp/components/rhs_root_post.jsx
+++ b/webapp/components/rhs_root_post.jsx
@@ -11,6 +11,7 @@ import RhsDropdown from 'components/rhs_dropdown.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import UserStore from 'stores/user_store.jsx';
+import TeamStore from 'stores/team_store.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import {flagPost, unflagPost} from 'actions/post_actions.jsx';
@@ -25,6 +26,7 @@ import {Tooltip, OverlayTrigger} from 'react-bootstrap';
import {FormattedMessage} from 'react-intl';
import React from 'react';
+import {Link} from 'react-router/es6';
export default class RhsRootPost extends React.Component {
constructor(props) {
@@ -38,7 +40,23 @@ export default class RhsRootPost extends React.Component {
this.canDelete = false;
this.editDisableAction = new DelayedAction(this.handleEditDisable);
- this.state = {};
+ this.state = {
+ currentTeamDisplayName: TeamStore.getCurrent().name,
+ width: '',
+ height: ''
+ };
+ }
+
+ componentDidMount() {
+ window.addEventListener('resize', () => {
+ Utils.updateWindowDimensions(this);
+ });
+ }
+
+ componentWillUnmount() {
+ window.removeEventListener('resize', () => {
+ Utils.updateWindowDimensions(this);
+ });
}
handlePermalink(e) {
@@ -100,6 +118,31 @@ export default class RhsRootPost extends React.Component {
unflagPost(this.props.post.id);
}
+ timeTag(post, timeOptions) {
+ return (
+ <time
+ className='post__time'
+ dateTime={Utils.getDateForUnixTicks(post.create_at).toISOString()}
+ >
+ {Utils.getDateForUnixTicks(post.create_at).toLocaleString('en', timeOptions)}
+ </time>
+ );
+ }
+
+ renderTimeTag(post, timeOptions) {
+ return Utils.isMobile() ?
+ this.timeTag(post, timeOptions) :
+ (
+ <Link
+ to={`/${this.state.currentTeamDisplayName}/pl/${post.id}`}
+ target='_blank'
+ className='post__permalink'
+ >
+ {this.timeTag(post, timeOptions)}
+ </Link>
+ );
+ }
+
render() {
const post = this.props.post;
const user = this.props.user;
@@ -426,12 +469,7 @@ export default class RhsRootPost extends React.Component {
<li className='col__name'>{userProfile}</li>
{botIndicator}
<li className='col'>
- <time
- className='post__time'
- dateTime={Utils.getDateForUnixTicks(post.create_at).toISOString()}
- >
- {Utils.getDateForUnixTicks(post.create_at).toLocaleString('en', timeOptions)}
- </time>
+ {this.renderTimeTag(post, timeOptions)}
<OverlayTrigger
key={'rootpostflagtooltipkey' + flagVisible}
delayShow={Constants.OVERLAY_TIME_DELAY}