From 0e371b010e04f494e09c9cd9436a664db762632f Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 3 May 2023 15:06:47 -0400 Subject: [PATCH] MM-52258 Replace usage of localizeAndFormatMessage (#23009) * MM-52258 Replace usage of localizeAndFormatMessage * Remove unused import * Update snapshot --- webapp/channels/src/actions/command.ts | 21 +++++++++----- .../feature_discovery.test.tsx.snap | 3 +- .../feature_discovery/feature_discovery.tsx | 28 ++++++++++++++----- .../profile_popover/profile_popover.tsx | 10 ++++++- webapp/channels/src/i18n/en.json | 2 ++ webapp/channels/src/utils/utils.tsx | 3 ++ 6 files changed, 50 insertions(+), 17 deletions(-) diff --git a/webapp/channels/src/actions/command.ts b/webapp/channels/src/actions/command.ts index 8b86ec2f43..2dacdbc393 100644 --- a/webapp/channels/src/actions/command.ts +++ b/webapp/channels/src/actions/command.ts @@ -21,7 +21,7 @@ import * as GlobalActions from 'actions/global_actions'; import * as PostActions from 'actions/post_actions'; import {isUrlSafe, getSiteURL} from 'utils/url'; -import {localizeMessage, getUserIdFromChannelName, localizeAndFormatMessage} from 'utils/utils'; +import {localizeMessage, getUserIdFromChannelName} from 'utils/utils'; import * as UserAgent from 'utils/user_agent'; import {Constants, ModalIdentifiers} from 'utils/constants'; import {getHistory} from 'utils/browser_history'; @@ -34,7 +34,6 @@ import KeyboardShortcutsModal from 'components/keyboard_shortcuts/keyboard_short import {GlobalState} from 'types/store'; -import {t} from 'utils/i18n'; import MarketplaceModal from 'components/plugin_marketplace/marketplace_modal'; import WorkTemplateModal from 'components/work_templates'; import {haveICurrentTeamPermission} from 'mattermost-redux/selectors/entities/roles'; @@ -194,14 +193,22 @@ export function executeCommand(message: string, args: CommandArgs): ActionFunc { case AppCallResponseTypes.NAVIGATE: return {data: true}; default: - return createErrorMessage(localizeAndFormatMessage( - t('apps.error.responses.unknown_type'), - 'App response type not supported. Response type: {type}.', - {type: callResp.type}, + return createErrorMessage(intlShim.formatMessage( + { + id: 'apps.error.responses.unknown_type', + defaultMessage: 'App response type not supported. Response type: {type}.', + }, + { + type: callResp.type, + }, )); } } catch (err: any) { - return createErrorMessage(err.message || localizeMessage('apps.error.unknown', 'Unknown error occurred.')); + const message = err.message || intlShim.formatMessage({ + id: 'apps.error.unknown', + defaultMessage: 'Unknown error occurred.', + }); + return createErrorMessage(message); } } } diff --git a/webapp/channels/src/components/admin_console/feature_discovery/__snapshots__/feature_discovery.test.tsx.snap b/webapp/channels/src/components/admin_console/feature_discovery/__snapshots__/feature_discovery.test.tsx.snap index 08bf045383..024bb3b9e5 100644 --- a/webapp/channels/src/components/admin_console/feature_discovery/__snapshots__/feature_discovery.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/feature_discovery/__snapshots__/feature_discovery.test.tsx.snap @@ -90,9 +90,8 @@ exports[`components/feature_discovery FeatureDiscovery should match snapshot whe id="translation.test.copy" /> - // if all conditions are set for being able to request a cloud trial, then show the cta start cloud trial button if (canRequestCloudFreeTrial) { ctaPrimaryButton = ( - @@ -440,3 +435,22 @@ export default class FeatureDiscovery extends React.PureComponent ); } } + +function FeatureDiscoveryCloudStartTrialButton(props: Omit, 'message'>) { + const message = useIntl().formatMessage( + { + id: 'admin.ldap_feature_discovery.call_to_action.primary.cloudFree', + defaultMessage: 'Try free for {trialLength} days', + }, + { + trialLength: FREEMIUM_TO_ENTERPRISE_TRIAL_LENGTH_DAYS, + }, + ); + + return ( + + ); +} diff --git a/webapp/channels/src/components/profile_popover/profile_popover.tsx b/webapp/channels/src/components/profile_popover/profile_popover.tsx index de8d5d753e..642f77e563 100644 --- a/webapp/channels/src/components/profile_popover/profile_popover.tsx +++ b/webapp/channels/src/components/profile_popover/profile_popover.tsx @@ -892,7 +892,15 @@ class ProfilePopover extends React.PureComponent