mattermost-mobile/app/components/post_header/index.js
Jesús Espino ee93e4fa59
Adding guest accounts feature (#2990)
* MM-15059: Restict the permissions for guests (#2791)

* MM-15057: Adding guest badge to identify guest users (#2774)

* MM-15057: Adding guest badge to identify guest users

* Adding Guest tags in the channel title

* Adding i18n translations

* Adding DM and GM guest warnings

* Fixing check-style

* Adding and fixing tests

* Adding i18n text

* Only showing the subtitle when there is enough space

* Addressing new design changes

* Fixing eslint

* Addressing PR comments

* Moving getChannelStats to the handleSelectChannel action

* Adding the guest info in android landscape channel headers

* simplified the guest warning text generation

* Fixing i18n

* Fixing leaving channel behavior for guests (#2989)

* Fixing leaving channel behavior for guests

* Fixing tests and adding a new one

* fixing typo

* Addressing PR comments

* Addressing PR comments

* Fixing tests
2019-07-22 22:14:39 +02:00

55 lines
2.7 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {connect} from 'react-redux';
import {Preferences} from 'mattermost-redux/constants';
import {makeGetCommentCountForPost} from 'mattermost-redux/selectors/entities/posts';
import {getBool, getTeammateNameDisplaySetting, getTheme} from 'mattermost-redux/selectors/entities/preferences';
import {isTimezoneEnabled} from 'mattermost-redux/selectors/entities/timezone';
import {getUser, getCurrentUser} from 'mattermost-redux/selectors/entities/users';
import {isPostPendingOrFailed, isSystemMessage} from 'mattermost-redux/utils/post_utils';
import {getUserCurrentTimezone} from 'mattermost-redux/utils/timezone_utils';
import {displayUsername} from 'mattermost-redux/utils/user_utils';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {fromAutoResponder} from 'app/utils/general';
import {isGuest} from 'app/utils/users';
import PostHeader from './post_header';
function makeMapStateToProps() {
const getCommentCountForPost = makeGetCommentCountForPost();
return function mapStateToProps(state, ownProps) {
const config = getConfig(state);
const post = ownProps.post;
const commentedOnUser = getUser(state, ownProps.commentedOnUserId);
const user = getUser(state, post.user_id) || {};
const currentUser = getCurrentUser(state);
const teammateNameDisplay = getTeammateNameDisplaySetting(state);
const militaryTime = getBool(state, Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time');
const enableTimezone = isTimezoneEnabled(state);
const userTimezone = enableTimezone ? getUserCurrentTimezone(currentUser.timezone) : '';
return {
commentedOnDisplayName: ownProps.commentedOnUserId ? displayUsername(commentedOnUser, teammateNameDisplay) : '',
commentCount: getCommentCountForPost(state, {post}),
createAt: post.create_at,
displayName: displayUsername(user, teammateNameDisplay),
enablePostUsernameOverride: config.EnablePostUsernameOverride === 'true',
fromWebHook: post?.props?.from_webhook === 'true', // eslint-disable-line camelcase
militaryTime,
isPendingOrFailedPost: isPostPendingOrFailed(post),
isSystemMessage: isSystemMessage(post),
fromAutoResponder: fromAutoResponder(post),
overrideUsername: post?.props?.override_username, // eslint-disable-line camelcase
theme: getTheme(state),
username: user.username,
isBot: user.is_bot || false,
isGuest: isGuest(user),
userTimezone,
};
};
}
export default connect(makeMapStateToProps)(PostHeader);