summaryrefslogtreecommitdiffstats
path: root/webapp/components
diff options
context:
space:
mode:
authorJonathan <jonfritz@gmail.com>2017-08-30 08:06:29 -0400
committerSaturnino Abril <saturnino.abril@gmail.com>2017-08-30 20:06:29 +0800
commit4c1f4674425ffeb430aa07f3fccbb09837f36a34 (patch)
tree9357f09211afc3d380857730a9dc2b6c61089292 /webapp/components
parent213a072b38d29d3c3ec8e150584685b1144a7d6a (diff)
downloadchat-4c1f4674425ffeb430aa07f3fccbb09837f36a34.tar.gz
chat-4c1f4674425ffeb430aa07f3fccbb09837f36a34.tar.bz2
chat-4c1f4674425ffeb430aa07f3fccbb09837f36a34.zip
PLT-7379: Timestamp on deleted, ephemeral, or pending post is a permalink (#7295)
* Removed permalink from system messages, general cleanup * Removed permalink from deleted messages * Removed permalink from pending messages * Fixed post_info tests * Changed permalink logic to remove permalinks from ephemeral messages, but leave them in place for system messages. * Fixed check style
Diffstat (limited to 'webapp/components')
-rw-r--r--webapp/components/post_view/post_info/post_info.jsx15
-rw-r--r--webapp/components/post_view/post_time.jsx11
2 files changed, 19 insertions, 7 deletions
diff --git a/webapp/components/post_view/post_info/post_info.jsx b/webapp/components/post_view/post_info/post_info.jsx
index 2c5b98c69..cc3133764 100644
--- a/webapp/components/post_view/post_info/post_info.jsx
+++ b/webapp/components/post_view/post_info/post_info.jsx
@@ -9,6 +9,7 @@ import DotMenu from 'components/dot_menu';
import * as Utils from 'utils/utils.jsx';
import * as PostUtils from 'utils/post_utils.jsx';
+import * as ReduxPostUtils from 'mattermost-redux/utils/post_utils';
import {emitEmojiPosted} from 'actions/post_actions.jsx';
import Constants from 'utils/constants.jsx';
import {Posts} from 'mattermost-redux/constants';
@@ -77,7 +78,7 @@ export default class PostInfo extends React.PureComponent {
*/
addReaction: PropTypes.func.isRequired
}).isRequired
- }
+ };
constructor(props) {
super(props);
@@ -96,12 +97,12 @@ export default class PostInfo extends React.PureComponent {
this.setState({showEmojiPicker});
this.props.handleDropdownOpened(showEmojiPicker);
- }
+ };
hideEmojiPicker = () => {
this.setState({showEmojiPicker: false});
this.props.handleDropdownOpened(false);
- }
+ };
removePost() {
this.props.actions.removePost(this.props.post);
@@ -131,7 +132,7 @@ export default class PostInfo extends React.PureComponent {
getDotMenu = () => {
return this.refs.dotMenu;
- }
+ };
render() {
const post = this.props.post;
@@ -242,10 +243,16 @@ export default class PostInfo extends React.PureComponent {
);
}
+ // timestamp should not be a permalink if the post has been deleted, is ephemeral message, or is pending
+ const isPermalink = !(isEphemeral ||
+ Posts.POST_DELETED === this.props.post.state ||
+ ReduxPostUtils.isPostPendingOrFailed(this.props.post));
+
return (
<div className='post__header--info'>
<div className='col'>
<PostTime
+ isPermalink={isPermalink}
eventTime={post.create_at}
useMilitaryTime={this.props.useMilitaryTime}
postId={post.id}
diff --git a/webapp/components/post_view/post_time.jsx b/webapp/components/post_view/post_time.jsx
index 133b6b5a3..2619c6807 100644
--- a/webapp/components/post_view/post_time.jsx
+++ b/webapp/components/post_view/post_time.jsx
@@ -13,6 +13,11 @@ export default class PostTime extends React.PureComponent {
static propTypes = {
/*
+ * If true, time will be rendered as a permalink to the post
+ */
+ isPermalink: PropTypes.bool.isRequired,
+
+ /*
* The time to display
*/
eventTime: PropTypes.number.isRequired,
@@ -26,12 +31,12 @@ export default class PostTime extends React.PureComponent {
* The post id of posting being rendered
*/
postId: PropTypes.string
- }
+ };
static defaultProps = {
eventTime: 0,
useMilitaryTime: false
- }
+ };
constructor(props) {
super(props);
@@ -74,7 +79,7 @@ export default class PostTime extends React.PureComponent {
}
render() {
- if (isMobile()) {
+ if (isMobile() || !this.props.isPermalink) {
return this.renderTimeTag();
}