[MM-66839] (#9365)
* [MM-66839] * i18n-extract * Address feedback * Fix lint
This commit is contained in:
parent
cb3fcc9651
commit
c0fc0c868f
6 changed files with 62 additions and 18 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Text} from 'react-native';
|
import {Text} from 'react-native';
|
||||||
|
|
||||||
|
import {logError} from '@utils/log';
|
||||||
import {makeStyleSheetFromTheme} from '@utils/theme';
|
import {makeStyleSheetFromTheme} from '@utils/theme';
|
||||||
import {typography} from '@utils/typography';
|
import {typography} from '@utils/typography';
|
||||||
|
|
||||||
|
|
@ -33,7 +34,8 @@ class ErrorBoundary extends React.PureComponent<Props, State> {
|
||||||
this.state = {hasError: false};
|
this.state = {hasError: false};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidCatch() {
|
componentDidCatch(error: unknown) {
|
||||||
|
logError('Error in ErrorBoundary:', error);
|
||||||
this.setState({hasError: true});
|
this.setState({hasError: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -571,7 +571,7 @@ const Markdown = ({
|
||||||
return (
|
return (
|
||||||
<FormattedText
|
<FormattedText
|
||||||
id='markdown.max_nodes.error'
|
id='markdown.max_nodes.error'
|
||||||
defaultMessage='This message is too long to by shown fully on a mobile device. Please view it on desktop or contact an admin to increase this limit.'
|
defaultMessage='This message is too long to be shown fully on a mobile device. Please view it on desktop or contact an admin to increase this limit.'
|
||||||
style={styles}
|
style={styles}
|
||||||
testID='max_nodes_warning'
|
testID='max_nodes_warning'
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -219,9 +219,15 @@ class MarkdownTable extends PureComponent<MarkdownTableProps, MarkdownTableState
|
||||||
const tableStyle = this.getTableStyle(isFullView);
|
const tableStyle = this.getTableStyle(isFullView);
|
||||||
|
|
||||||
let rows = React.Children.toArray(this.props.children) as React.ReactElement[];
|
let rows = React.Children.toArray(this.props.children) as React.ReactElement[];
|
||||||
|
|
||||||
|
if (!rows.length) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (isPreview) {
|
if (isPreview) {
|
||||||
const {maxPreviewColumns} = this.state;
|
const {maxPreviewColumns} = this.state;
|
||||||
const prevRowLength = rows.length;
|
const prevRowLength = rows.length;
|
||||||
|
|
||||||
const prevColLength = React.Children.toArray(rows[0].props.children).length;
|
const prevColLength = React.Children.toArray(rows[0].props.children).length;
|
||||||
|
|
||||||
rows = rows.slice(0, maxPreviewColumns).map((row) => {
|
rows = rows.slice(0, maxPreviewColumns).map((row) => {
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,13 @@
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React, {useCallback, useMemo, useState} from 'react';
|
import React, {useCallback, useMemo, useState} from 'react';
|
||||||
|
import {useIntl} from 'react-intl';
|
||||||
import {type LayoutChangeEvent, type StyleProp, View, type ViewStyle} from 'react-native';
|
import {type LayoutChangeEvent, type StyleProp, View, type ViewStyle} from 'react-native';
|
||||||
|
|
||||||
import Files from '@components/files';
|
import Files from '@components/files';
|
||||||
import FormattedText from '@components/formatted_text';
|
import FormattedText from '@components/formatted_text';
|
||||||
import JumboEmoji from '@components/jumbo_emoji';
|
import JumboEmoji from '@components/jumbo_emoji';
|
||||||
|
import ErrorBoundary from '@components/markdown/error_boundary';
|
||||||
import {Screens} from '@constants';
|
import {Screens} from '@constants';
|
||||||
import {THREAD} from '@constants/screens';
|
import {THREAD} from '@constants/screens';
|
||||||
import StatusUpdatePost from '@playbooks/components/status_update_post';
|
import StatusUpdatePost from '@playbooks/components/status_update_post';
|
||||||
|
|
@ -91,6 +93,7 @@ const Body = ({
|
||||||
isCRTEnabled, isEphemeral, isFirstReply, isJumboEmoji, isLastReply, isPendingOrFailed, isPostAcknowledgementEnabled, isPostAddChannelMember,
|
isCRTEnabled, isEphemeral, isFirstReply, isJumboEmoji, isLastReply, isPendingOrFailed, isPostAcknowledgementEnabled, isPostAddChannelMember,
|
||||||
location, post, searchPatterns, showAddReaction, theme,
|
location, post, searchPatterns, showAddReaction, theme,
|
||||||
}: BodyProps) => {
|
}: BodyProps) => {
|
||||||
|
const intl = useIntl();
|
||||||
const style = getStyleSheet(theme);
|
const style = getStyleSheet(theme);
|
||||||
const isEdited = postEdited(post);
|
const isEdited = postEdited(post);
|
||||||
const isFailed = isPostFailed(post);
|
const isFailed = isPostFailed(post);
|
||||||
|
|
@ -229,19 +232,24 @@ const Body = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<ErrorBoundary
|
||||||
style={style.messageContainerWithReplyBar}
|
error={intl.formatMessage({id: 'post.error', defaultMessage: 'There has been an error rendering this post.'})}
|
||||||
onLayout={onLayout}
|
theme={theme}
|
||||||
>
|
>
|
||||||
<View style={replyBarStyle}/>
|
<View
|
||||||
{body}
|
style={style.messageContainerWithReplyBar}
|
||||||
{isFailed &&
|
onLayout={onLayout}
|
||||||
<Failed
|
>
|
||||||
post={post}
|
<View style={replyBarStyle}/>
|
||||||
theme={theme}
|
{body}
|
||||||
/>
|
{isFailed &&
|
||||||
}
|
<Failed
|
||||||
</View>
|
post={post}
|
||||||
|
theme={theme}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
</View>
|
||||||
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,16 @@
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React, {useCallback} from 'react';
|
import React, {useCallback} from 'react';
|
||||||
import {Platform, ScrollView, StyleSheet, View} from 'react-native';
|
import {useIntl} from 'react-intl';
|
||||||
|
import {Platform, ScrollView, Text, View} from 'react-native';
|
||||||
import {SafeAreaView} from 'react-native-safe-area-context';
|
import {SafeAreaView} from 'react-native-safe-area-context';
|
||||||
|
|
||||||
|
import {useTheme} from '@context/theme';
|
||||||
import useAndroidHardwareBackHandler from '@hooks/android_back_handler';
|
import useAndroidHardwareBackHandler from '@hooks/android_back_handler';
|
||||||
import SecurityManager from '@managers/security_manager';
|
import SecurityManager from '@managers/security_manager';
|
||||||
import {popTopScreen} from '@screens/navigation';
|
import {popTopScreen} from '@screens/navigation';
|
||||||
|
import {makeStyleSheetFromTheme} from '@utils/theme';
|
||||||
|
import {typography} from '@utils/typography';
|
||||||
|
|
||||||
import type {AvailableScreens} from '@typings/screens/navigation';
|
import type {AvailableScreens} from '@typings/screens/navigation';
|
||||||
|
|
||||||
|
|
@ -18,7 +22,7 @@ type Props = {
|
||||||
width: number;
|
width: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
|
|
@ -35,18 +39,40 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
});
|
noTableText: {
|
||||||
|
color: theme.dndIndicator,
|
||||||
|
...typography('Body', 200, 'Regular'),
|
||||||
|
},
|
||||||
|
noTableContainer: {
|
||||||
|
padding: 24,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
const Table = ({componentId, renderAsFlex, renderRows, width}: Props) => {
|
const Table = ({componentId, renderAsFlex, renderRows, width}: Props) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const styles = getStyleSheet(theme);
|
||||||
const content = renderRows(true);
|
const content = renderRows(true);
|
||||||
const viewStyle = renderAsFlex ? styles.displayFlex : {width};
|
const viewStyle = renderAsFlex ? styles.displayFlex : {width};
|
||||||
|
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
const close = useCallback(() => {
|
const close = useCallback(() => {
|
||||||
popTopScreen(componentId);
|
popTopScreen(componentId);
|
||||||
}, [componentId]);
|
}, [componentId]);
|
||||||
|
|
||||||
useAndroidHardwareBackHandler(componentId, close);
|
useAndroidHardwareBackHandler(componentId, close);
|
||||||
|
|
||||||
|
if (!content) {
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={styles.noTableContainer}
|
||||||
|
nativeID={SecurityManager.getShieldScreenId(componentId)}
|
||||||
|
>
|
||||||
|
<Text style={styles.noTableText}>{intl.formatMessage({id: 'table.cannot_display_table', defaultMessage: 'Cannot display table'})}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (Platform.OS === 'android') {
|
if (Platform.OS === 'android') {
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
|
|
|
||||||
|
|
@ -522,7 +522,7 @@
|
||||||
"magic_link.already_logged_in_error.ok": "OK",
|
"magic_link.already_logged_in_error.ok": "OK",
|
||||||
"magic_link.already_logged_in_error.title": "Already logged in",
|
"magic_link.already_logged_in_error.title": "Already logged in",
|
||||||
"markdown.latex.error": "Latex render error",
|
"markdown.latex.error": "Latex render error",
|
||||||
"markdown.max_nodes.error": "This message is too long to by shown fully on a mobile device. Please view it on desktop or contact an admin to increase this limit.",
|
"markdown.max_nodes.error": "This message is too long to be shown fully on a mobile device. Please view it on desktop or contact an admin to increase this limit.",
|
||||||
"markdown.parse_error": "An error occurred while parsing this text",
|
"markdown.parse_error": "An error occurred while parsing this text",
|
||||||
"markdown.render_error": "An error occurred while rendering this text",
|
"markdown.render_error": "An error occurred while rendering this text",
|
||||||
"mentions.empty.paragraph": "You'll see messages here when someone mentions you or uses terms you're monitoring.",
|
"mentions.empty.paragraph": "You'll see messages here when someone mentions you or uses terms you're monitoring.",
|
||||||
|
|
@ -1207,6 +1207,7 @@
|
||||||
"post_priority.picker.label.standard": "Standard",
|
"post_priority.picker.label.standard": "Standard",
|
||||||
"post_priority.picker.label.urgent": "Urgent",
|
"post_priority.picker.label.urgent": "Urgent",
|
||||||
"post_priority.picker.title": "Message priority",
|
"post_priority.picker.title": "Message priority",
|
||||||
|
"post.error": "There has been an error rendering this post.",
|
||||||
"post.options.title": "Options",
|
"post.options.title": "Options",
|
||||||
"post.reactions.title": "Reactions",
|
"post.reactions.title": "Reactions",
|
||||||
"postList.scrollToBottom.newMessages": "New messages",
|
"postList.scrollToBottom.newMessages": "New messages",
|
||||||
|
|
@ -1470,6 +1471,7 @@
|
||||||
"system_notice.remind_me": "Remind Me Later",
|
"system_notice.remind_me": "Remind Me Later",
|
||||||
"system_notice.title.gm_as_dm": "Updates to Group Messages",
|
"system_notice.title.gm_as_dm": "Updates to Group Messages",
|
||||||
"system_noticy.body.gm_as_dm": "You will now be notified for all activity in your group messages along with a notification badge for every new message.\n\nYou can configure this in notification preferences for each group message.",
|
"system_noticy.body.gm_as_dm": "You will now be notified for all activity in your group messages along with a notification badge for every new message.\n\nYou can configure this in notification preferences for each group message.",
|
||||||
|
"table.cannot_display_table": "Cannot display table",
|
||||||
"team_list.no_other_teams.description": "To join another team, ask a Team Admin for an invitation, or create your own team.",
|
"team_list.no_other_teams.description": "To join another team, ask a Team Admin for an invitation, or create your own team.",
|
||||||
"team_list.no_other_teams.title": "No additional teams to join",
|
"team_list.no_other_teams.title": "No additional teams to join",
|
||||||
"terms_of_service.acceptButton": "Accept",
|
"terms_of_service.acceptButton": "Accept",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue