diff --git a/webapp/channels/src/components/delete_category_modal/delete_category_modal.tsx b/webapp/channels/src/components/delete_category_modal/delete_category_modal.tsx index 124d5562bb..509cf4e974 100644 --- a/webapp/channels/src/components/delete_category_modal/delete_category_modal.tsx +++ b/webapp/channels/src/components/delete_category_modal/delete_category_modal.tsx @@ -1,17 +1,14 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React from 'react'; -import {FormattedMessage} from 'react-intl'; +import React, {useCallback} from 'react'; +import {FormattedMessage, defineMessages, useIntl} from 'react-intl'; import {GenericModal} from '@mattermost/components'; import type {ChannelCategory} from '@mattermost/types/channel_categories'; import FormattedMarkdownMessage from 'components/formatted_markdown_message'; -import {t} from 'utils/i18n'; -import {localizeMessage} from 'utils/utils'; - import '../category_modal.scss'; type Props = { @@ -22,67 +19,68 @@ type Props = { }; }; -type State = { - show: boolean; -} +export default function DeleteCategoryModal(props: Props) { + const intl = useIntl(); -export default class DeleteCategoryModal extends React.PureComponent { - constructor(props: Props) { - super(props); + const handleConfirm = useCallback(() => { + props.actions.deleteCategory(props.category.id); + }, [props.actions.deleteCategory, props.category]); - this.state = { - show: true, - }; - } - - handleConfirm = () => { - this.props.actions.deleteCategory(this.props.category.id); - }; - - handleCancel = () => { - this.props.onExited(); - }; - - render() { - return ( - - )} - handleCancel={this.handleCancel} - handleConfirm={this.handleConfirm} - confirmButtonText={( - - )} - confirmButtonClassName={'delete'} - > - - - - - ); - } + return ( + + )} + handleCancel={props.onExited} + handleConfirm={handleConfirm} + confirmButtonText={( + + )} + confirmButtonClassName={'delete'} + > + + + + + ); } // TODO MM-52680 These strings are properly defined in @mattermost/components, but the i18n tooling currently can't // find them there, so we've had to redefine them here -t('generic_modal.cancel'); -t('generic_modal.confirm'); -t('footer_pagination.count'); -t('footer_pagination.prev'); -t('footer_pagination.next'); +defineMessages({ + cancel: { + id: 'generic_modal.cancel', + defaultMessage: 'Cancel', + }, + confirm: { + id: 'generic_modal.confirm', + defaultMessage: 'Confirm', + }, + paginationCount: { + id: 'footer_pagination.count', + defaultMessage: 'Showing {startCount, number}-{endCount, number} of {total, number}', + }, + paginationNext: { + id: 'footer_pagination.next', + defaultMessage: 'Next', + }, + paginationPrev: { + id: 'footer_pagination.prev', + defaultMessage: 'Previous', + }, +}); diff --git a/webapp/channels/src/components/error_page/__snapshots__/error_message.test.tsx.snap b/webapp/channels/src/components/error_page/__snapshots__/error_message.test.tsx.snap index 6392927cdf..b0459b1c1c 100644 --- a/webapp/channels/src/components/error_page/__snapshots__/error_message.test.tsx.snap +++ b/webapp/channels/src/components/error_page/__snapshots__/error_message.test.tsx.snap @@ -108,8 +108,12 @@ exports[`components/error_page/ErrorMessage should match snapshot, oauth_missing values={ Object { "link": , } @@ -123,8 +127,12 @@ exports[`components/error_page/ErrorMessage should match snapshot, oauth_missing values={ Object { "link": , } @@ -138,8 +146,12 @@ exports[`components/error_page/ErrorMessage should match snapshot, oauth_missing values={ Object { "link": , } @@ -153,8 +165,12 @@ exports[`components/error_page/ErrorMessage should match snapshot, oauth_missing values={ Object { "link": , } diff --git a/webapp/channels/src/components/error_page/error_link.test.tsx b/webapp/channels/src/components/error_page/error_link.test.tsx index 362cb3b097..c2ebbfa739 100644 --- a/webapp/channels/src/components/error_page/error_link.test.tsx +++ b/webapp/channels/src/components/error_page/error_link.test.tsx @@ -9,8 +9,10 @@ import ErrorLink from 'components/error_page/error_link'; describe('components/error_page/ErrorLink', () => { const baseProps = { url: 'https://docs.mattermost.com/deployment/sso-gitlab.html', - messageId: 'error.oauth_missing_code.gitlab.link', - defaultMessage: 'GitLab', + message: { + id: 'error.oauth_missing_code.gitlab.link', + defaultMessage: 'GitLab', + }, }; test('should match snapshot', () => { diff --git a/webapp/channels/src/components/error_page/error_link.tsx b/webapp/channels/src/components/error_page/error_link.tsx index 4f4a5bbb1d..bc2a081ea0 100644 --- a/webapp/channels/src/components/error_page/error_link.tsx +++ b/webapp/channels/src/components/error_page/error_link.tsx @@ -2,34 +2,29 @@ // See LICENSE.txt for license information. import React from 'react'; +import type {MessageDescriptor} from 'react-intl'; import {FormattedMessage} from 'react-intl'; import ExternalLink from 'components/external_link'; type Props = { url: string; - messageId: string; - defaultMessage: string; + message: MessageDescriptor; } -const ErrorLink: React.FC = ({url, messageId, defaultMessage}: Props) => { +const ErrorLink: React.FC = ({url, message}: Props) => { return ( - + ); }; ErrorLink.defaultProps = { url: '', - messageId: '', - defaultMessage: '', }; export default ErrorLink; diff --git a/webapp/channels/src/components/error_page/error_message.tsx b/webapp/channels/src/components/error_page/error_message.tsx index 6cd8d2cd71..7d7e8f553c 100644 --- a/webapp/channels/src/components/error_page/error_message.tsx +++ b/webapp/channels/src/components/error_page/error_message.tsx @@ -2,10 +2,9 @@ // See LICENSE.txt for license information. import React from 'react'; -import {FormattedMessage} from 'react-intl'; +import {FormattedMessage, defineMessage} from 'react-intl'; import {ErrorPageTypes} from 'utils/constants'; -import {t} from 'utils/i18n'; import ErrorLink from './error_link'; import CloudArchived from './messages/cloud_archived'; @@ -116,8 +115,10 @@ const ErrorMessage: React.FC = ({type, message, service, isGuest}: Props) link: ( ), }} @@ -131,8 +132,10 @@ const ErrorMessage: React.FC = ({type, message, service, isGuest}: Props) link: ( ), }} @@ -146,8 +149,10 @@ const ErrorMessage: React.FC = ({type, message, service, isGuest}: Props) link: ( ), }} @@ -161,8 +166,10 @@ const ErrorMessage: React.FC = ({type, message, service, isGuest}: Props) link: ( ), }} diff --git a/webapp/channels/src/components/integrations/add_incoming_webhook/add_incoming_webhook.tsx b/webapp/channels/src/components/integrations/add_incoming_webhook/add_incoming_webhook.tsx index 4ac3dc4c19..ae0e83c600 100644 --- a/webapp/channels/src/components/integrations/add_incoming_webhook/add_incoming_webhook.tsx +++ b/webapp/channels/src/components/integrations/add_incoming_webhook/add_incoming_webhook.tsx @@ -2,6 +2,7 @@ // See LICENSE.txt for license information. import React, {memo, useCallback, useState} from 'react'; +import {defineMessages} from 'react-intl'; import type {IncomingWebhook} from '@mattermost/types/integrations'; import type {Team} from '@mattermost/types/teams'; @@ -11,11 +12,21 @@ import type {ActionResult} from 'mattermost-redux/types/actions'; import AbstractIncomingWebhook from 'components/integrations/abstract_incoming_webhook'; import {getHistory} from 'utils/browser_history'; -import {t} from 'utils/i18n'; -const HEADER = {id: t('integrations.add'), defaultMessage: 'Add'}; -const FOOTER = {id: t('add_incoming_webhook.save'), defaultMessage: 'Save'}; -const LOADING = {id: t('add_incoming_webhook.saving'), defaultMessage: 'Saving...'}; +const messages = defineMessages({ + footer: { + id: 'add_incoming_webhook.save', + defaultMessage: 'Save', + }, + header: { + id: 'integrations.add', + defaultMessage: 'Add', + }, + loading: { + id: 'add_incoming_webhook.saving', + defaultMessage: 'Saving...', + }, +}); type Props = { @@ -67,9 +78,9 @@ const AddIncomingWebhook = ({ return ( { return ( diff --git a/webapp/channels/src/components/integrations/add_outgoing_webhook/add_outgoing_webhook.tsx b/webapp/channels/src/components/integrations/add_outgoing_webhook/add_outgoing_webhook.tsx index fb3f8b852b..7877efd45d 100644 --- a/webapp/channels/src/components/integrations/add_outgoing_webhook/add_outgoing_webhook.tsx +++ b/webapp/channels/src/components/integrations/add_outgoing_webhook/add_outgoing_webhook.tsx @@ -2,6 +2,7 @@ // See LICENSE.txt for license information. import React, {useState} from 'react'; +import {defineMessages} from 'react-intl'; import {useHistory} from 'react-router-dom'; import type {OutgoingWebhook} from '@mattermost/types/integrations'; @@ -11,11 +12,20 @@ import type {ActionResult} from 'mattermost-redux/types/actions'; import AbstractOutgoingWebhook from 'components/integrations/abstract_outgoing_webhook'; -import {t} from 'utils/i18n'; - -const HEADER = {id: t('integrations.add'), defaultMessage: 'Add'}; -const FOOTER = {id: t('add_outgoing_webhook.save'), defaultMessage: 'Save'}; -const LOADING = {id: t('add_outgoing_webhook.saving'), defaultMessage: 'Saving...'}; +const messages = defineMessages({ + footer: { + id: 'add_outgoing_webhook.save', + defaultMessage: 'Save', + }, + header: { + id: 'integrations.add', + defaultMessage: 'Add', + }, + loading: { + id: 'add_outgoing_webhook.saving', + defaultMessage: 'Saving...', + }, +}); export type Props = { @@ -65,9 +75,9 @@ const AddOutgoingWebhook = ({team, actions, enablePostUsernameOverride, enablePo return ( { return ( @@ -28,6 +29,7 @@ exports[`components/no_results_indicator should match snapshot when expanded 1`] className="no-results__subtitle" > @@ -84,6 +86,7 @@ exports[`components/no_results_indicator should match snapshot with variant Chan className="no-results__title" > @@ -91,6 +94,7 @@ exports[`components/no_results_indicator should match snapshot with variant Chan className="no-results__subtitle" > @@ -112,6 +116,7 @@ exports[`components/no_results_indicator should match snapshot with variant Chan className="no-results__title" > @@ -119,6 +124,7 @@ exports[`components/no_results_indicator should match snapshot with variant Chan className="no-results__subtitle" > @@ -140,6 +146,7 @@ exports[`components/no_results_indicator should match snapshot with variant Chan className="no-results__title" > @@ -147,6 +154,7 @@ exports[`components/no_results_indicator should match snapshot with variant Chan className="no-results__subtitle" > @@ -168,6 +176,7 @@ exports[`components/no_results_indicator should match snapshot with variant Flag className="no-results__title" > @@ -175,6 +184,7 @@ exports[`components/no_results_indicator should match snapshot with variant Flag className="no-results__subtitle" > @@ -196,6 +206,7 @@ exports[`components/no_results_indicator should match snapshot with variant Ment className="no-results__title" > @@ -203,6 +214,7 @@ exports[`components/no_results_indicator should match snapshot with variant Ment className="no-results__subtitle" > @@ -224,6 +236,7 @@ exports[`components/no_results_indicator should match snapshot with variant Pinn className="no-results__title" > @@ -231,6 +244,7 @@ exports[`components/no_results_indicator should match snapshot with variant Pinn className="no-results__subtitle" > diff --git a/webapp/channels/src/components/no_results_indicator/no_results_indicator.tsx b/webapp/channels/src/components/no_results_indicator/no_results_indicator.tsx index b3fce742a8..c42a99e43b 100644 --- a/webapp/channels/src/components/no_results_indicator/no_results_indicator.tsx +++ b/webapp/channels/src/components/no_results_indicator/no_results_indicator.tsx @@ -4,13 +4,10 @@ import classNames from 'classnames'; import React from 'react'; import type {ReactNode, CSSProperties} from 'react'; -import {FormattedMessage} from 'react-intl'; -import type {MessageDescriptor} from 'react-intl'; +import {FormattedMessage, defineMessages} from 'react-intl'; import {SearchSVG, ChannelSearchSVG, MentionsSVG, SavedMessagesSVG, PinSVG, ChannelFilesSVG, UserGroupsSVG, UserGroupMembersSVG} from 'components/common/svg_images_components'; -import {t} from 'utils/i18n'; - import {NoResultsVariant, NoResultsLayout} from './types'; import './no_results_indicator.scss'; @@ -42,77 +39,99 @@ const iconMap: {[key in NoResultsVariant]: React.ReactNode } = { [NoResultsVariant.UserGroupsArchived]: , }; -const titleMap: {[key in NoResultsVariant]: MessageDescriptor} = { +const titleMap = defineMessages({ [NoResultsVariant.Search]: { - id: t('no_results.search.title'), + id: 'no_results.search.title', + defaultMessage: 'No results for “{channelName}”', }, [NoResultsVariant.Files]: { - id: t('no_results.Files.title'), + id: 'no_results.Files.title', + defaultMessage: 'No file results for “{searchTerm}”', }, [NoResultsVariant.ChannelSearch]: { - id: t('no_results.channel_search.title'), + id: 'no_results.channel_search.title', + defaultMessage: 'No results for “{channelName}”', }, [NoResultsVariant.Mentions]: { - id: t('no_results.mentions.title'), + id: 'no_results.mentions.title', + defaultMessage: 'No mentions yet', }, [NoResultsVariant.FlaggedPosts]: { - id: t('no_results.flagged_posts.title'), + id: 'no_results.flagged_posts.title', + defaultMessage: 'No saved messages yet', }, [NoResultsVariant.PinnedPosts]: { - id: t('no_results.pinned_messages.title'), + id: 'no_results.pinned_messages.title', + defaultMessage: 'No pinned messages yet', }, [NoResultsVariant.ChannelFiles]: { - id: t('no_results.channel_files.title'), + id: 'no_results.channel_files.title', + defaultMessage: 'No files yet', }, [NoResultsVariant.ChannelFilesFiltered]: { - id: t('no_results.channel_files_filtered.title'), + id: 'no_results.channel_files_filtered.title', + defaultMessage: 'No files found', }, [NoResultsVariant.UserGroups]: { - id: t('no_results.user_groups.title'), + id: 'no_results.user_groups.title', + defaultMessage: 'No groups yet', }, [NoResultsVariant.UserGroupMembers]: { - id: t('no_results.user_group_members.title'), + id: 'no_results.user_group_members.title', + defaultMessage: 'No members yet', }, [NoResultsVariant.UserGroupsArchived]: { - id: t('no_results.user_groups.archived.title'), + id: 'no_results.user_groups.archived.title', + defaultMessage: 'No archived groups', }, -}; +}); -const subtitleMap: {[key in NoResultsVariant]: MessageDescriptor} = { +const subtitleMap = defineMessages({ [NoResultsVariant.Search]: { - id: t('no_results.search.subtitle'), + id: 'no_results.search.subtitle', + defaultMessage: 'Check the spelling or try another search.', }, [NoResultsVariant.Files]: { - id: t('no_results.Files.subtitle'), + id: 'no_results.Files.subtitle', + defaultMessage: 'Check the spelling or try another search.', }, [NoResultsVariant.ChannelSearch]: { - id: t('no_results.channel_search.subtitle'), + id: 'no_results.channel_search.subtitle', + defaultMessage: 'Check the spelling or try another search.', }, [NoResultsVariant.Mentions]: { - id: t('no_results.mentions.subtitle'), + id: 'no_results.mentions.subtitle', + defaultMessage: 'Messages where someone mentions you or includes your trigger words are saved here.', }, [NoResultsVariant.FlaggedPosts]: { - id: t('no_results.flagged_posts.subtitle'), + id: 'no_results.flagged_posts.subtitle', + defaultMessage: 'To save something for later, open the context menu on a message and choose {buttonText}. Saved messages are only visible to you', }, [NoResultsVariant.PinnedPosts]: { - id: t('no_results.pinned_messages.subtitle'), + id: 'no_results.pinned_messages.subtitle', + defaultMessage: 'To pin important messages, open the context menu on a message and choose {text}. Pinned messages will be visible to everyone in this channel.', }, [NoResultsVariant.ChannelFiles]: { - id: t('no_results.channel_files.subtitle'), + id: 'no_results.channel_files.subtitle', + defaultMessage: 'Files posted in this channel will show here.', }, [NoResultsVariant.ChannelFilesFiltered]: { - id: t('no_results.channel_files_filtered.subtitle'), + id: 'no_results.channel_files_filtered.subtitle', + defaultMessage: "This channel doesn't contains any file with the selected file format.", }, [NoResultsVariant.UserGroups]: { - id: t('no_results.user_groups.subtitle'), + id: 'no_results.user_groups.subtitle', + defaultMessage: 'Groups are a custom collection of users that can be used for mentions and invites.', }, [NoResultsVariant.UserGroupMembers]: { - id: t('no_results.user_group_members.subtitle'), + id: 'no_results.user_group_members.subtitle', + defaultMessage: 'There are currently no members in this group, please add one.', }, [NoResultsVariant.UserGroupsArchived]: { - id: t('no_results.user_groups.archived.subtitle'), + id: 'no_results.user_groups.archived.subtitle', + defaultMessage: 'Groups that are no longer relevant or are not being used can be archived', }, -}; +}); const NoResultsIndicator = ({ expanded, diff --git a/webapp/channels/src/components/search_results/search_results.tsx b/webapp/channels/src/components/search_results/search_results.tsx index 250bbd542e..e76e833728 100644 --- a/webapp/channels/src/components/search_results/search_results.tsx +++ b/webapp/channels/src/components/search_results/search_results.tsx @@ -4,8 +4,7 @@ import classNames from 'classnames'; import React, {useEffect, useRef, useState} from 'react'; import Scrollbars from 'react-custom-scrollbars'; -import {useIntl, FormattedMessage} from 'react-intl'; -import type {MessageDescriptor} from 'react-intl'; +import {useIntl, FormattedMessage, defineMessage} from 'react-intl'; import {useSelector} from 'react-redux'; import type {FileSearchResultItem as FileSearchResultItemType} from '@mattermost/types/files'; @@ -25,7 +24,6 @@ import LoadingSpinner from 'components/widgets/loading/loading_wrapper'; import {searchHintOptions, DataSearchTypes} from 'utils/constants'; import {isFileAttachmentsEnabled} from 'utils/file_utils'; -import {t} from 'utils/i18n'; import * as Utils from 'utils/utils'; import FilesFilterMenu from './files_filter_menu'; @@ -178,7 +176,7 @@ const SearchResults: React.FC = (props: Props): JSX.Element => { let sortedResults: any = results; - const titleDescriptor: MessageDescriptor = {}; + let titleDescriptor; const noResultsProps: NoResultsProps = { variant: NoResultsVariant.ChannelSearch, }; @@ -186,8 +184,10 @@ const SearchResults: React.FC = (props: Props): JSX.Element => { if (isMentionSearch) { noResultsProps.variant = NoResultsVariant.Mentions; - titleDescriptor.id = t('search_header.title2'); - titleDescriptor.defaultMessage = 'Recent Mentions'; + titleDescriptor = defineMessage({ + id: 'search_header.title2', + defaultMessage: 'Recent Mentions', + }); } else if (isFlaggedPosts) { noResultsProps.variant = NoResultsVariant.FlaggedPosts; noResultsProps.subtitleValues = {buttonText: { @@ -195,8 +195,10 @@ const SearchResults: React.FC = (props: Props): JSX.Element => { id: 'flag_post.flag', defaultMessage: 'Save Message'}, )}}; - titleDescriptor.id = t('search_header.title3'); - titleDescriptor.defaultMessage = 'Saved messages'; + titleDescriptor = defineMessage({ + id: 'search_header.title3', + defaultMessage: 'Saved messages', + }); } else if (isPinnedPosts) { noResultsProps.variant = NoResultsVariant.PinnedPosts; noResultsProps.subtitleValues = {text: { @@ -208,8 +210,10 @@ const SearchResults: React.FC = (props: Props): JSX.Element => { sortedResults = [...results]; sortedResults.sort((postA: Post|FileSearchResultItemType, postB: Post|FileSearchResultItemType) => postB.create_at - postA.create_at); - titleDescriptor.id = t('search_header.pinnedMessages'); - titleDescriptor.defaultMessage = 'Pinned messages'; + titleDescriptor = defineMessage({ + id: 'search_header.pinnedMessages', + defaultMessage: 'Pinned messages', + }); } else if (isChannelFiles) { if (searchFilterType === 'all') { noResultsProps.variant = NoResultsVariant.ChannelFiles; @@ -217,24 +221,34 @@ const SearchResults: React.FC = (props: Props): JSX.Element => { noResultsProps.variant = NoResultsVariant.ChannelFilesFiltered; } - titleDescriptor.id = t('search_header.channelFiles'); - titleDescriptor.defaultMessage = 'Files'; + titleDescriptor = defineMessage({ + id: 'search_header.channelFiles', + defaultMessage: 'Files', + }); } else if (isCard) { - titleDescriptor.id = t('search_header.title5'); - titleDescriptor.defaultMessage = 'Extra information'; + titleDescriptor = defineMessage({ + id: 'search_header.title5', + defaultMessage: 'Extra information', + }); } else if (!searchTerms && noResults && noFileResults) { - titleDescriptor.id = t('search_header.search'); - titleDescriptor.defaultMessage = 'Search'; + titleDescriptor = defineMessage({ + id: 'search_header.search', + defaultMessage: 'Search', + }); } else if (searchType === DataSearchTypes.FILES_SEARCH_TYPE && !isChannelFiles) { noResultsProps.variant = NoResultsVariant.Files; noResultsProps.titleValues = {searchTerm: `${searchTerms}`}; - titleDescriptor.id = t('search_header.results'); - titleDescriptor.defaultMessage = 'Search Results'; + titleDescriptor = defineMessage({ + id: 'search_header.results', + defaultMessage: 'Search Results', + }); } else { noResultsProps.titleValues = {channelName: `${searchTerms}`}; - titleDescriptor.id = t('search_header.results'); - titleDescriptor.defaultMessage = 'Search Results'; + titleDescriptor = defineMessage({ + id: 'search_header.results', + defaultMessage: 'Search Results', + }); } const formattedTitle = intl.formatMessage(titleDescriptor); diff --git a/webapp/channels/src/components/sidebar/sidebar_category/__snapshots__/sidebar_category.test.tsx.snap b/webapp/channels/src/components/sidebar/sidebar_category/__snapshots__/sidebar_category.test.tsx.snap index 0ce27fb2f7..65a4b37619 100644 --- a/webapp/channels/src/components/sidebar/sidebar_category/__snapshots__/sidebar_category.test.tsx.snap +++ b/webapp/channels/src/components/sidebar/sidebar_category/__snapshots__/sidebar_category.test.tsx.snap @@ -271,7 +271,7 @@ exports[`components/sidebar/sidebar_category should match snapshot when sorting className="" > { let displayName = category.display_name; if (category.type !== CategoryTypes.CUSTOM) { - displayName = localizeMessage(`sidebar.types.${category.type}`, category.display_name); + const message = categoryNames[category.type as keyof typeof categoryNames]; + displayName = localizeMessage(message.id, message.defaultMessage); } return ( @@ -409,7 +409,17 @@ export default class SidebarCategory extends React.PureComponent { } } -// Adding references to translations for i18n-extract -t('sidebar.types.channels'); -t('sidebar.types.direct_messages'); -t('sidebar.types.favorites'); +const categoryNames = defineMessages({ + channels: { + id: 'sidebar.types.channels', + defaultMessage: 'CHANNELS', + }, + direct_messages: { + id: 'sidebar.types.direct_messages', + defaultMessage: 'DIRECT MESSAGES', + }, + favorites: { + id: 'sidebar.types.favorites', + defaultMessage: 'FAVORITES', + }, +}); diff --git a/webapp/channels/src/components/threading/common/follow_button/follow_button.tsx b/webapp/channels/src/components/threading/common/follow_button/follow_button.tsx index 8a5f604719..6fa8bfcdca 100644 --- a/webapp/channels/src/components/threading/common/follow_button/follow_button.tsx +++ b/webapp/channels/src/components/threading/common/follow_button/follow_button.tsx @@ -6,8 +6,6 @@ import React, {memo} from 'react'; import type {ComponentProps} from 'react'; import {useIntl} from 'react-intl'; -import {t} from 'utils/i18n'; - import Button from '../button'; type Props = { @@ -26,11 +24,11 @@ function FollowButton({ disabled={Boolean(props.disabled)} isActive={isFollowing ?? false} > - {formatMessage(isFollowing ? { - id: t('threading.following'), + {isFollowing ? formatMessage({ + id: 'threading.following', defaultMessage: 'Following', - } : { - id: t('threading.notFollowing'), + }) : formatMessage({ + id: 'threading.notFollowing', defaultMessage: 'Follow', })} diff --git a/webapp/channels/src/components/threading/global_threads/thread_menu/thread_menu.tsx b/webapp/channels/src/components/threading/global_threads/thread_menu/thread_menu.tsx index 73460c6824..5097123976 100644 --- a/webapp/channels/src/components/threading/global_threads/thread_menu/thread_menu.tsx +++ b/webapp/channels/src/components/threading/global_threads/thread_menu/thread_menu.tsx @@ -21,7 +21,6 @@ import {manuallyMarkThreadAsUnread} from 'actions/views/threads'; import Menu from 'components/widgets/menu/menu'; import MenuWrapper from 'components/widgets/menu/menu_wrapper'; -import {t} from 'utils/i18n'; import {getSiteURL} from 'utils/url'; import {copyToClipboard} from 'utils/utils'; @@ -89,20 +88,20 @@ function ThreadMenu({ { @@ -120,22 +119,22 @@ function ThreadMenu({ }, [threadId])} /> { @@ -144,7 +143,7 @@ function ThreadMenu({ /> { diff --git a/webapp/channels/src/components/threading/global_threads/thread_pane/thread_pane.tsx b/webapp/channels/src/components/threading/global_threads/thread_pane/thread_pane.tsx index 03e1ab5262..d73dd0ad63 100644 --- a/webapp/channels/src/components/threading/global_threads/thread_pane/thread_pane.tsx +++ b/webapp/channels/src/components/threading/global_threads/thread_pane/thread_pane.tsx @@ -16,8 +16,6 @@ import {getPost, makeGetPostsForThread} from 'mattermost-redux/selectors/entitie import Header from 'components/widgets/header'; import SimpleTooltip from 'components/widgets/simple_tooltip'; -import {t} from 'utils/i18n'; - import type {GlobalState} from 'types/store'; import Button from '../../common/button'; @@ -124,7 +122,7 @@ const ThreadPane = ({ diff --git a/webapp/channels/src/components/threading/global_threads_link/global_threads_link.tsx b/webapp/channels/src/components/threading/global_threads_link/global_threads_link.tsx index 6dd8eb0ecf..1f29b22100 100644 --- a/webapp/channels/src/components/threading/global_threads_link/global_threads_link.tsx +++ b/webapp/channels/src/components/threading/global_threads_link/global_threads_link.tsx @@ -34,7 +34,6 @@ import Constants, { Preferences, RHSStates, } from 'utils/constants'; -import {t} from 'utils/i18n'; import {Mark} from 'utils/performance_telemetry'; import type {GlobalState} from 'types/store'; @@ -119,7 +118,7 @@ const GlobalThreadsLink = () => {
- {formatMessage({id: t('globalThreads.sidebarLink'), defaultMessage: 'Threads'})} + {formatMessage({id: 'globalThreads.sidebarLink', defaultMessage: 'Threads'})}
{counts?.total_unread_mentions > 0 && ( diff --git a/webapp/channels/src/components/tours/channels_tour_tip.tsx b/webapp/channels/src/components/tours/channels_tour_tip.tsx index 48fc7984e7..32643d1365 100644 --- a/webapp/channels/src/components/tours/channels_tour_tip.tsx +++ b/webapp/channels/src/components/tours/channels_tour_tip.tsx @@ -2,21 +2,27 @@ // See LICENSE.txt for license information. import React from 'react'; -import {FormattedMessage} from 'react-intl'; +import {FormattedMessage, defineMessages} from 'react-intl'; import type {Placement} from 'tippy.js'; import type {PunchOutCoordsHeightAndWidth} from '@mattermost/components'; import {TourTip} from '@mattermost/components'; -import {t} from 'utils/i18n'; - import {useTourTipManager} from './tour_manager'; import {getLastStep} from './utils'; // TODO MM-51399 These strings are properly defined in @mattermost/components, but the i18n tooling currently can't // find them there, so we've had to redefine them here -t('tutorial_tip.out'); -t('tutorial_tip.seen'); +defineMessages({ + optOut: { + id: 'tutorial_tip.out', + defaultMessage: 'Opt out of these tips.', + }, + seenBefore: { + id: 'tutorial_tip.seen', + defaultMessage: 'Seen this before? ', + }, +}); export type ChannelsTourTipProps = { screen: JSX.Element;