[MM-10341] Remove "Add Reaction" on posts of flagged, recent mentions and search results (#1631)

* remove "Add Reaction" on posts of flagged, recent mentions and search results

* set default props to true for showAddReaction
This commit is contained in:
Saturnino Abril 2018-04-27 09:01:26 +08:00 committed by Elias Nahum
parent ffa62528f1
commit 79a35d25ad
5 changed files with 11 additions and 4 deletions

View file

@ -60,6 +60,7 @@ export default class Post extends PureComponent {
canDelete: PropTypes.bool.isRequired,
onPermalinkPress: PropTypes.func,
shouldRenderReplyButton: PropTypes.bool,
showAddReaction: PropTypes.bool,
showFullDate: PropTypes.bool,
showLongPost: PropTypes.bool,
theme: PropTypes.object.isRequired,
@ -70,6 +71,7 @@ export default class Post extends PureComponent {
static defaultProps = {
isSearchResult: false,
showAddReaction: true,
showLongPost: false,
channelIsReadOnly: false,
};
@ -386,6 +388,7 @@ export default class Post extends PureComponent {
post,
renderReplies,
shouldRenderReplyButton,
showAddReaction,
showFullDate,
showLongPost,
theme,
@ -461,6 +464,7 @@ export default class Post extends PureComponent {
managedConfig={managedConfig}
isFlagged={isFlagged}
isReplyPost={isReplyPost}
showAddReaction={showAddReaction}
showLongPost={showLongPost}
/>
</View>

View file

@ -35,6 +35,7 @@ export default class PostBody extends PureComponent {
flagPost: PropTypes.func.isRequired,
unflagPost: PropTypes.func.isRequired,
}).isRequired,
canAddReaction: PropTypes.bool,
canDelete: PropTypes.bool,
canEdit: PropTypes.bool,
channelIsReadOnly: PropTypes.bool.isRequired,
@ -54,7 +55,6 @@ export default class PostBody extends PureComponent {
managedConfig: PropTypes.object,
message: PropTypes.string,
navigator: PropTypes.object.isRequired,
canAddReaction: PropTypes.bool,
onAddReaction: PropTypes.func,
onCopyPermalink: PropTypes.func,
onCopyText: PropTypes.func,
@ -66,6 +66,7 @@ export default class PostBody extends PureComponent {
postId: PropTypes.string.isRequired,
postProps: PropTypes.object,
renderReplyBar: PropTypes.func,
showAddReaction: PropTypes.bool,
showLongPost: PropTypes.bool.isRequired,
theme: PropTypes.object,
toggleSelected: PropTypes.func,
@ -128,13 +129,14 @@ export default class PostBody extends PureComponent {
onCopyText,
onPostDelete,
onPostEdit,
showAddReaction,
} = this.props;
const actions = [];
const isPendingOrFailedPost = isPending || isFailed;
// we should check for the user roles and permissions
if (!isPendingOrFailedPost && !isSystemMessage && !isPostEphemeral) {
if (canAddReaction && !channelIsReadOnly) {
if (showAddReaction && canAddReaction && !channelIsReadOnly) {
actions.push({
text: formatMessage({id: 'mobile.post_info.add_reaction', defaultMessage: 'Add Reaction'}),
onPress: this.props.onAddReaction,

View file

@ -9,7 +9,7 @@ import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
export default class ChannelDisplayName extends PureComponent {
static propTypes = {
displayName: PropTypes.string.isRequired,
displayName: PropTypes.string,
theme: PropTypes.object.isRequired,
};

View file

@ -16,7 +16,7 @@ function makeMapStateToProps() {
const channel = getChannel(state, {id: post.channel_id});
return {
displayName: channel.display_name,
displayName: channel ? channel.display_name : '',
theme: getTheme(state),
};
};

View file

@ -40,6 +40,7 @@ export default class SearchResultPost extends PureComponent {
postId={this.props.postId}
{...postComponentProps}
isSearchResult={true}
showAddReaction={false}
showFullDate={this.props.showFullDate}
navigator={this.props.navigator}
/>