From 58f4346e5d93b60e6c69b09a3928b4bf1cca2992 Mon Sep 17 00:00:00 2001 From: Martin Kraft Date: Wed, 17 Apr 2019 10:45:29 -0400 Subject: [PATCH] =?UTF-8?q?MM-14417:=20Add=20messaging=20for=20channel=20m?= =?UTF-8?q?entions=20of=20users=20not=20in=20constrai=E2=80=A6=20(#2711)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * MM-14417: Add messaging for channel mentions of users not in constrained groups. * MM-14417: Reorder translation. * MM-14417: Update for new mobile app with old server install. --- .../post_add_channel_member.js | 96 +++++++++++++------ app/components/post_body/post_body.js | 15 ++- assets/base/i18n/en.json | 3 +- 3 files changed, 80 insertions(+), 34 deletions(-) diff --git a/app/components/post_add_channel_member/post_add_channel_member.js b/app/components/post_add_channel_member/post_add_channel_member.js index 1c4b89cbf..3a8dba028 100644 --- a/app/components/post_add_channel_member/post_add_channel_member.js +++ b/app/components/post_add_channel_member/post_add_channel_member.js @@ -30,6 +30,7 @@ export default class PostAddChannelMember extends React.PureComponent { postId: PropTypes.string.isRequired, userIds: PropTypes.array.isRequired, usernames: PropTypes.array.isRequired, + noGroupsUsernames: PropTypes.array, navigator: PropTypes.object.isRequired, onPostPress: PropTypes.func, textStyles: PropTypes.object, @@ -78,7 +79,7 @@ export default class PostAddChannelMember extends React.PureComponent { } } - generateAtMentions(usernames = []) { + generateAtMentions(usernames = [], textStyles) { if (usernames.length === 1) { return ( ); } @@ -134,7 +136,7 @@ export default class PostAddChannelMember extends React.PureComponent { } render() { - const {channelType, baseTextStyle, postId, usernames} = this.props; + const {channelType, baseTextStyle, postId, usernames, noGroupsUsernames} = this.props; if (!postId || !channelType) { return null; @@ -150,43 +152,75 @@ export default class PostAddChannelMember extends React.PureComponent { linkText = 'add them to the channel'; } - let messageId; - let messageText; + let outOfChannelMessageID; + let outOfChannelMessageText; + const outOfChannelAtMentions = this.generateAtMentions(usernames, baseTextStyle); if (usernames.length === 1) { - messageId = t('post_body.check_for_out_of_channel_mentions.message.one'); - messageText = 'was mentioned but is not in the channel. Would you like to '; + outOfChannelMessageID = t('post_body.check_for_out_of_channel_mentions.message.one'); + outOfChannelMessageText = 'was mentioned but is not in the channel. Would you like to '; } else if (usernames.length > 1) { - messageId = t('post_body.check_for_out_of_channel_mentions.message.multiple'); - messageText = 'were mentioned but they are not in the channel. Would you like to '; + outOfChannelMessageID = t('post_body.check_for_out_of_channel_mentions.message.multiple'); + outOfChannelMessageText = 'were mentioned but they are not in the channel. Would you like to '; } - const atMentions = this.generateAtMentions(usernames); + let outOfGroupsMessageID; + let outOfGroupsMessageText; + const outOfGroupsAtMentions = this.generateAtMentions(noGroupsUsernames, baseTextStyle); + if (noGroupsUsernames?.length) { + outOfGroupsMessageID = t('post_body.check_for_out_of_channel_groups_mentions.message'); + outOfGroupsMessageText = 'did not get notified by this mention because they are not in the channel. They are also not a member of the groups linked to this channel.'; + } - return ( - - {atMentions} - {' '} - - + let outOfChannelMessage = null; + if (usernames.length) { + outOfChannelMessage = ( + + {outOfChannelAtMentions} + {' '} + + + + - - + ); + } + + let outOfGroupsMessage = null; + if (noGroupsUsernames?.length) { + outOfGroupsMessage = ( + + {outOfGroupsAtMentions} + {' '} + + + ); + } + + return ( + <> + {outOfChannelMessage} + {outOfGroupsMessage} + ); } } diff --git a/app/components/post_body/post_body.js b/app/components/post_body/post_body.js index 344fdf43e..62d22b763 100644 --- a/app/components/post_body/post_body.js +++ b/app/components/post_body/post_body.js @@ -194,6 +194,16 @@ export default class PostBody extends PureComponent { PostAddChannelMember = require('app/components/post_add_channel_member').default; } + let userIds = postProps.add_channel_member.not_in_channel_user_ids; + let usernames = postProps.add_channel_member.not_in_channel_usernames; + + if (!userIds) { + userIds = postProps.add_channel_member.user_ids; + } + if (!usernames) { + usernames = postProps.add_channel_member.usernames; + } + return ( ); }; diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json index 40ea8508f..bd8dae740 100644 --- a/assets/base/i18n/en.json +++ b/assets/base/i18n/en.json @@ -462,6 +462,7 @@ "password_send.link": "If the account exists, a password reset email will be sent to:", "password_send.reset": "Reset my password", "permalink.error.access": "Permalink belongs to a deleted message or to a channel to which you do not have access.", + "post_body.check_for_out_of_channel_groups_mentions.message": "did not get notified by this mention because they are not in the channel. They are also not a member of the groups linked to this channel.", "post_body.check_for_out_of_channel_mentions.link.and": " and ", "post_body.check_for_out_of_channel_mentions.link.private": "add them to this private channel", "post_body.check_for_out_of_channel_mentions.link.public": "add them to the channel", @@ -552,4 +553,4 @@ "user.settings.push_notification.offline": "Offline", "user.settings.push_notification.online": "Online, away or offline", "web.root.signup_info": "All team communication in one place, searchable and accessible anywhere" -} +} \ No newline at end of file