Skip to content

Commit

Permalink
[MM-60861] Replace FormattedMarkdownMessage in 'webapp/channels/src/c…
Browse files Browse the repository at this point in the history
…omponents/notify_confirm_modal.tsx' with FormattedMessage (mattermost#28772)
  • Loading branch information
Camillarhi authored Oct 21, 2024
1 parent 64677dd commit aa450f2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
49 changes: 27 additions & 22 deletions webapp/channels/src/components/notify_confirm_modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import React from 'react';
import {FormattedMessage, defineMessages} from 'react-intl';

import ConfirmModalRedux from 'components/confirm_modal_redux';
import FormattedMarkdownMessage from 'components/formatted_markdown_message';

type Props = {
mentions: string[];
Expand All @@ -31,21 +30,23 @@ export default class NotifyConfirmModal extends React.PureComponent<Props> {
if (channelTimezoneCount > 0) {
const message = mentions.length === 1 && mentions[0] === '@here' ? messages.atHereTimezones : messages.atAllTimezones;
notifyAllMessage = (
<FormattedMarkdownMessage
<FormattedMessage
{...message}
values={{
totalMembers: memberNotifyCount,
timezones: channelTimezoneCount,
b: (chunks: string) => <b>{chunks}</b>,
}}
/>
);
} else {
const message = mentions.length === 1 && mentions[0] === '@here' ? messages.atHere : messages.atAll;
notifyAllMessage = (
<FormattedMarkdownMessage
<FormattedMessage
{...message}
values={{
totalMembers: memberNotifyCount,
b: (chunks: string) => <b>{chunks}</b>,
}}
/>
);
Expand All @@ -61,50 +62,54 @@ export default class NotifyConfirmModal extends React.PureComponent<Props> {
if (mentions.length === 1) {
if (channelTimezoneCount > 0) {
notifyAllMessage = (
<FormattedMarkdownMessage
id='notify_all.question_timezone_one_group'
defaultMessage='By using **{mention}** you are about to send notifications of up to **{totalMembers} people** in **{timezones, number} {timezones, plural, one {timezone} other {timezones}}**. Are you sure you want to do this?'
<FormattedMessage
id='notifyAll.question_timezone_oneGroup'
defaultMessage='By using <b>{mention}</b> you are about to send notifications to at least <b>{totalMembers} people</b> in <b>{timezones, number} {timezones, plural, one {timezone} other {timezones}}</b>. Are you sure you want to do this?'
values={{
mention: mentions[0],
totalMembers: memberNotifyCount,
timezones: channelTimezoneCount,
b: (chunks: string) => <b>{chunks}</b>,
}}
/>
);
} else {
notifyAllMessage = (
<FormattedMarkdownMessage
id='notify_all.question_one_group'
defaultMessage='By using **{mention}** you are about to send notifications of up to **{totalMembers} people**. Are you sure you want to do this?'
<FormattedMessage
id='notifyAll.question_oneGroup'
defaultMessage='By using <b>{mention}</b> you are about to send notifications to at least <b>{totalMembers} people</b>. Are you sure you want to do this?'
values={{
mention: mentions[0],
totalMembers: memberNotifyCount,
b: (chunks: string) => <b>{chunks}</b>,
}}
/>
);
}
} else if (channelTimezoneCount > 0) {
notifyAllMessage = (
<FormattedMarkdownMessage
id='notify_all.question_timezone_groups'
defaultMessage='By using **{mentions}** and **{finalMention}** you are about to send notifications of up to **{totalMembers} people** in **{timezones, number} {timezones, plural, one {timezone} other {timezones}}**. Are you sure you want to do this?'
<FormattedMessage
id='notifyAll.question_timezoneGroups'
defaultMessage='By using <b>{mentions}</b> and <b>{finalMention}</b> you are about to send notifications to at least <b>{totalMembers} people</b> in <b>{timezones, number} {timezones, plural, one {timezone} other {timezones}}</b>. Are you sure you want to do this?'
values={{
mentions: mentions.slice(0, -1).join(', '),
finalMention: mentions[mentions.length - 1],
totalMembers: memberNotifyCount,
timezones: channelTimezoneCount,
b: (chunks: string) => <b>{chunks}</b>,
}}
/>
);
} else {
notifyAllMessage = (
<FormattedMarkdownMessage
id='notify_all.question_groups'
defaultMessage='By using **{mentions}** and **{finalMention}** you are about to send notifications of up to **{totalMembers} people**. Are you sure you want to do this?'
<FormattedMessage
id='notifyAll.question_groups'
defaultMessage='By using <b>{mentions}</b> and <b>{finalMention}</b> you are about to send notifications to at least <b>{totalMembers} people</b>. Are you sure you want to do this?'
values={{
mentions: mentions.slice(0, -1).join(', '),
finalMention: mentions[mentions.length - 1],
totalMembers: memberNotifyCount,
b: (chunks: string) => <b>{chunks}</b>,
}}
/>
);
Expand Down Expand Up @@ -132,19 +137,19 @@ export default class NotifyConfirmModal extends React.PureComponent<Props> {

const messages = defineMessages({
atAll: {
id: 'notify_all.question',
defaultMessage: 'By using **@all** or **@channel** you are about to send notifications to **{totalMembers} people**. Are you sure you want to do this?',
id: 'notifyAll.question',
defaultMessage: 'By using <b>@all</b> or <b>@channel</b> you are about to send notifications to <b>{totalMembers} people</b>. Are you sure you want to do this?',
},
atAllTimezones: {
id: 'notify_all.question_timezone',
defaultMessage: 'By using **@all** or **@channel** you are about to send notifications to **{totalMembers} people** in **{timezones, number} {timezones, plural, one {timezone} other {timezones}}**. Are you sure you want to do this?',
id: 'notifyAll.questionTimezone',
defaultMessage: 'By using <b>@all</b> or <b>@channel</b> you are about to send notifications to <b>{totalMembers} people</b> in <b>{timezones, number} {timezones, plural, one {timezone} other {timezones}}</b>. Are you sure you want to do this?',
},
atHere: {
id: 'notify_here.question',
defaultMessage: 'By using **@here** you are about to send notifications to up to **{totalMembers} other people**. Are you sure you want to do this?',
defaultMessage: 'By using <b>@here</b> you are about to send notifications to at least <b>{totalMembers} other people</b>. Are you sure you want to do this?',
},
atHereTimezones: {
id: 'notify_here.question_timezone',
defaultMessage: 'By using **@here** you are about to send notifications to up to **{totalMembers} other people** in **{timezones, number} {timezones, plural, one {timezone} other {timezones}}**. Are you sure you want to do this?',
id: 'notifyHere.question_timezone',
defaultMessage: 'By using <b>@here</b> you are about to send notifications to at least <b>{totalMembers} other people</b> in <b>{timezones, number} {timezones, plural, one {timezone} other {timezones}}</b>. Are you sure you want to do this?',
},
});
16 changes: 8 additions & 8 deletions webapp/channels/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4443,16 +4443,16 @@
"notification.crt": "Reply in {title}",
"notification.dm": "Direct Message",
"notify_all.confirm": "Confirm",
"notify_all.question": "By using **@all** or **@channel** you are about to send notifications to **{totalMembers} people**. Are you sure you want to do this?",
"notify_all.question_groups": "By using **{mentions}** and **{finalMention}** you are about to send notifications to at least **{totalMembers} people**. Are you sure you want to do this?",
"notify_all.question_one_group": "By using **{mention}** you are about to send notifications to **{totalMembers} people**. Are you sure you want to do this?",
"notify_all.question_timezone": "By using **@all** or **@channel** you are about to send notifications to **{totalMembers} people** in **{timezones, number} {timezones, plural, one {timezone} other {timezones}}**. Are you sure you want to do this?",
"notify_all.question_timezone_groups": "By using **{mentions}** and **{finalMention}** you are about to send notifications to at least **{totalMembers} people** in **{timezones, number} {timezones, plural, one {timezone} other {timezones}}**. Are you sure you want to do this?",
"notify_all.question_timezone_one_group": "By using **{mention}** you are about to send notifications to **{totalMembers} people** in **{timezones, number} {timezones, plural, one {timezone} other {timezones}}**. Are you sure you want to do this?",
"notify_all.title.confirm": "Confirm Sending Notifications to Entire Channel",
"notify_all.title.confirm_groups": "Confirm sending notifications to groups",
"notify_here.question": "By using **@here** you are about to send notifications to up to **{totalMembers} other people**. Are you sure you want to do this?",
"notify_here.question_timezone": "By using **@here** you are about to send notifications to up to **{totalMembers} other people** in **{timezones, number} {timezones, plural, one {timezone} other {timezones}}**. Are you sure you want to do this?",
"notify_here.question": "By using <b>@here</b> you are about to send notifications to at least <b>{totalMembers} other people</b>. Are you sure you want to do this?",
"notifyAll.question": "By using <b>@all</b> or <b>@channel</b> you are about to send notifications to <b>{totalMembers} people</b>. Are you sure you want to do this?",
"notifyAll.question_groups": "By using <b>{mentions}</b> and <b>{finalMention}</b> you are about to send notifications to at least <b>{totalMembers} people</b>. Are you sure you want to do this?",
"notifyAll.question_oneGroup": "By using <b>{mention}</b> you are about to send notifications to at least <b>{totalMembers} people</b>. Are you sure you want to do this?",
"notifyAll.question_timezone_oneGroup": "By using <b>{mention}</b> you are about to send notifications to at least <b>{totalMembers} people</b> in <b>{timezones, number} {timezones, plural, one {timezone} other {timezones}}</b>. Are you sure you want to do this?",
"notifyAll.question_timezoneGroups": "By using <b>{mentions}</b> and <b>{finalMention}</b> you are about to send notifications to at least <b>{totalMembers} people</b> in <b>{timezones, number} {timezones, plural, one {timezone} other {timezones}}</b>. Are you sure you want to do this?",
"notifyAll.questionTimezone": "By using <b>@all</b> or <b>@channel</b> you are about to send notifications to <b>{totalMembers} people</b> in <b>{timezones, number} {timezones, plural, one {timezone} other {timezones}}</b>. Are you sure you want to do this?",
"notifyHere.question_timezone": "By using <b>@here</b> you are about to send notifications to at least <b>{totalMembers} other people</b> in <b>{timezones, number} {timezones, plural, one {timezone} other {timezones}}</b>. Are you sure you want to do this?",
"numMembers": "{num, number} {num, plural, one {member} other {members}}",
"onboarding_wizard.invite_members_cloud.title": "Invite your team members",
"onboarding_wizard.invite_members.copied_link": "Link Copied",
Expand Down

0 comments on commit aa450f2

Please sign in to comment.