MM-14417: Add messaging for channel mentions of users not in constrai… (#2711)
* 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.
This commit is contained in:
parent
c769b536ae
commit
58f4346e5d
3 changed files with 80 additions and 34 deletions
|
|
@ -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 (
|
||||
<AtMention
|
||||
|
|
@ -95,6 +96,7 @@ export default class PostAddChannelMember extends React.PureComponent {
|
|||
key={key}
|
||||
id={'post_body.check_for_out_of_channel_mentions.link.and'}
|
||||
defaultMessage={' and '}
|
||||
style={textStyles}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -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 (
|
||||
<Text>
|
||||
{atMentions}
|
||||
{' '}
|
||||
<FormattedText
|
||||
id={messageId}
|
||||
defaultMessage={messageText}
|
||||
style={baseTextStyle}
|
||||
/>
|
||||
<Text
|
||||
style={this.props.textStyles.link}
|
||||
id='add_channel_member_link'
|
||||
onPress={this.handleAddChannelMember}
|
||||
>
|
||||
let outOfChannelMessage = null;
|
||||
if (usernames.length) {
|
||||
outOfChannelMessage = (
|
||||
<Text>
|
||||
{outOfChannelAtMentions}
|
||||
{' '}
|
||||
<FormattedText
|
||||
id={linkId}
|
||||
defaultMessage={linkText}
|
||||
id={outOfChannelMessageID}
|
||||
defaultMessage={outOfChannelMessageText}
|
||||
style={baseTextStyle}
|
||||
/>
|
||||
<Text
|
||||
style={this.props.textStyles.link}
|
||||
id='add_channel_member_link'
|
||||
onPress={this.handleAddChannelMember}
|
||||
>
|
||||
<FormattedText
|
||||
id={linkId}
|
||||
defaultMessage={linkText}
|
||||
/>
|
||||
</Text>
|
||||
<FormattedText
|
||||
id={'post_body.check_for_out_of_channel_mentions.message_last'}
|
||||
defaultMessage={'? They will have access to all message history.'}
|
||||
style={baseTextStyle}
|
||||
/>
|
||||
</Text>
|
||||
<FormattedText
|
||||
id={'post_body.check_for_out_of_channel_mentions.message_last'}
|
||||
defaultMessage={'? They will have access to all message history.'}
|
||||
style={baseTextStyle}
|
||||
/>
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
let outOfGroupsMessage = null;
|
||||
if (noGroupsUsernames?.length) {
|
||||
outOfGroupsMessage = (
|
||||
<Text>
|
||||
{outOfGroupsAtMentions}
|
||||
{' '}
|
||||
<FormattedText
|
||||
id={outOfGroupsMessageID}
|
||||
defaultMessage={outOfGroupsMessageText}
|
||||
style={baseTextStyle}
|
||||
/>
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{outOfChannelMessage}
|
||||
{outOfGroupsMessage}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<PostAddChannelMember
|
||||
baseTextStyle={messageStyle}
|
||||
|
|
@ -201,8 +211,9 @@ export default class PostBody extends PureComponent {
|
|||
onPostPress={onPress}
|
||||
textStyles={textStyles}
|
||||
postId={postProps.add_channel_member.post_id}
|
||||
userIds={postProps.add_channel_member.user_ids}
|
||||
usernames={postProps.add_channel_member.usernames}
|
||||
userIds={userIds}
|
||||
usernames={usernames}
|
||||
noGroupsUsernames={postProps.add_channel_member.not_in_groups_usernames}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue