Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/27544 Incorrect Old Dot comment formatting when viewed on New Dot #30193

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
482d001
Wrap ReportActionItemFragment inside a Text component
Victor-Nyagudi Oct 9, 2023
b591c52
Restore grey color and regular font weight to APPROVED/SUBMITTED mess…
Victor-Nyagudi Oct 23, 2023
51a4f16
Conditionally surround ReportActionItemFragment with Text component
Victor-Nyagudi Oct 23, 2023
c108645
Remove return statement surrounding ReportActionItemFragment
Victor-Nyagudi Oct 23, 2023
9c06778
Surround 'props.fragment.text' in curly braces
Victor-Nyagudi Oct 24, 2023
9165187
Describe function using JS Docs syntax & use inline ternary statement
Victor-Nyagudi Oct 24, 2023
89baf40
Revert "Surround 'props.fragment.text' in curly braces"
Victor-Nyagudi Oct 24, 2023
64d204b
Merge branch 'Expensify:main' into fix/27544-incorrect-OD-comment-for…
Victor-Nyagudi Oct 25, 2023
286ed53
Reword comment explaining reason for wrapping ReportActionItemFragmen…
Victor-Nyagudi Oct 26, 2023
2802633
Merge branch 'Expensify:main' into fix/27544-incorrect-OD-comment-for…
Victor-Nyagudi Oct 26, 2023
1d698f3
Pass isApprovedOrSubmittedReportActionType prop instead of actionName…
Victor-Nyagudi Oct 26, 2023
533fbf7
Remove unused import statement
Victor-Nyagudi Oct 26, 2023
20e26f0
Wrap initial ReportActionItemFragments in Text
Victor-Nyagudi Oct 26, 2023
11d669e
Ran prettier again so linter is happy
Victor-Nyagudi Oct 26, 2023
ae375de
Create helper method to replace inline stlyes
Victor-Nyagudi Oct 26, 2023
244dabf
Rename isApprovedOrSubmittedReportActionType
Victor-Nyagudi Oct 26, 2023
50b852a
Merge branch 'Expensify:main' into fix/27544-incorrect-OD-comment-for…
Victor-Nyagudi Oct 28, 2023
dbe5c08
Move styling helper method to StyleUtils
Victor-Nyagudi Oct 28, 2023
5dda804
Conditionally wrap fragment text in a tooltip
Victor-Nyagudi Oct 28, 2023
9935001
Merge branch 'main' into fix/27544-incorrect-OD-comment-formatting
Victor-Nyagudi Oct 29, 2023
cb548eb
Run pretteir to fix diffs
Victor-Nyagudi Oct 29, 2023
68e20f7
Merge branch 'main' into fix/27544-incorrect-OD-comment-formatting
Victor-Nyagudi Oct 31, 2023
53796b6
Remove check in getApprovedOrSubmittedReportTextStyles
Victor-Nyagudi Oct 31, 2023
cf00603
Merge branch 'Expensify:main' into fix/27544-incorrect-OD-comment-for…
Victor-Nyagudi Nov 1, 2023
8afe93c
Merge branch 'Expensify:main' into fix/27544-incorrect-OD-comment-for…
Victor-Nyagudi Nov 2, 2023
f669405
Conditionally wrap report action fragments in Text and account for RT…
Victor-Nyagudi Nov 2, 2023
ffb1e9a
Rename shouldConvertToLTR prop to isFragmentContainingDisplayName
Victor-Nyagudi Nov 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ const propTypes = {
/** Whether the comment is a thread parent message/the first message in a thread */
isThreadParentMessage: PropTypes.bool,

/** Whether the report action type is 'APPROVED' or 'SUBMITTED'. Used to style system messages from Old Dot */
isApprovedOrSubmittedReportAction: PropTypes.bool,

/** Used to format RTL display names in Old Dot system messages e.g. Arabic */
isFragmentContainingDisplayName: PropTypes.bool,

...windowDimensionsPropTypes,

/** localization props */
Expand All @@ -86,6 +92,8 @@ const defaultProps = {
delegateAccountID: 0,
actorIcon: {},
isThreadParentMessage: false,
isApprovedOrSubmittedReportAction: false,
isFragmentContainingDisplayName: false,
displayAsGroup: false,
};

Expand Down Expand Up @@ -152,8 +160,15 @@ function ReportActionItemFragment(props) {
</Text>
);
}
case 'TEXT':
return (
case 'TEXT': {
return props.isApprovedOrSubmittedReportAction ? (
<Text
numberOfLines={props.isSingleLine ? 1 : undefined}
style={[styles.chatItemMessage, styles.colorMuted]}
Victor-Nyagudi marked this conversation as resolved.
Show resolved Hide resolved
>
{props.isFragmentContainingDisplayName ? convertToLTR(props.fragment.text) : props.fragment.text}
</Text>
) : (
<UserDetailsTooltip
accountID={props.accountID}
delegateAccountID={props.delegateAccountID}
Expand All @@ -167,6 +182,7 @@ function ReportActionItemFragment(props) {
</Text>
</UserDetailsTooltip>
);
}
case 'LINK':
return <Text>LINK</Text>;
case 'INTEGRATION_COMMENT':
Expand Down
51 changes: 37 additions & 14 deletions src/pages/home/report/ReportActionItemMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import styles from '@styles/styles';
import CONST from '@src/CONST';
import ReportActionItemFragment from './ReportActionItemFragment';
import reportActionPropTypes from './reportActionPropTypes';

Expand Down Expand Up @@ -47,23 +48,45 @@ function ReportActionItemMessage(props) {
}
}

const isApprovedOrSubmittedReportAction = _.contains([CONST.REPORT.ACTIONS.TYPE.APPROVED, CONST.REPORT.ACTIONS.TYPE.SUBMITTED], props.action.actionName);

/**
* Get the ReportActionItemFragments
* @param {Boolean} shouldWrapInText determines whether the fragments are wrapped in a Text component
* @returns {Object} report action item fragments
*/
const renderReportActionItemFragments = (shouldWrapInText) => {
const reportActionItemFragments = _.map(messages, (fragment, index) => (
<ReportActionItemFragment
key={`actionFragment-${props.action.reportActionID}-${index}`}
fragment={fragment}
iouMessage={iouMessage}
isThreadParentMessage={ReportActionsUtils.isThreadParentMessage(props.action, props.reportID)}
attachmentInfo={props.action.attachmentInfo}
pendingAction={props.action.pendingAction}
source={lodashGet(props.action, 'originalMessage.source')}
accountID={props.action.actorAccountID}
style={props.style}
displayAsGroup={props.displayAsGroup}
isApprovedOrSubmittedReportAction={isApprovedOrSubmittedReportAction}
// Since system messages from Old Dot begin with the person who performed the action,
// the first fragment will contain the person's display name and their email. We'll use this
// to decide if the fragment should be from left to right for RTL display names e.g. Arabic for proper
// formatting.
isFragmentContainingDisplayName={index === 0}
/>
));

// Approving or submitting reports in oldDot results in system messages made up of multiple fragments of `TEXT` type
// which we need to wrap in `<Text>` to prevent them rendering on separate lines.

return shouldWrapInText ? <Text style={styles.ltr}>{reportActionItemFragments}</Text> : reportActionItemFragments;
};

return (
<View style={[styles.chatItemMessage, !props.displayAsGroup && isAttachment ? styles.mt2 : {}, ...props.style]}>
{!props.isHidden ? (
_.map(messages, (fragment, index) => (
<ReportActionItemFragment
key={`actionFragment-${props.action.reportActionID}-${index}`}
fragment={fragment}
iouMessage={iouMessage}
isThreadParentMessage={ReportActionsUtils.isThreadParentMessage(props.action, props.reportID)}
attachmentInfo={props.action.attachmentInfo}
pendingAction={props.action.pendingAction}
source={lodashGet(props.action, 'originalMessage.source')}
accountID={props.action.actorAccountID}
style={props.style}
displayAsGroup={props.displayAsGroup}
/>
))
renderReportActionItemFragments(isApprovedOrSubmittedReportAction)
) : (
<Text style={[styles.textLabelSupporting, styles.lh20]}>{props.translate('moderation.flaggedContent')}</Text>
)}
Expand Down
Loading