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 8 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
11 changes: 10 additions & 1 deletion src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'underscore';
import React, {memo} from 'react';
import PropTypes from 'prop-types';
import Str from 'expensify-common/lib/str';
Expand Down Expand Up @@ -63,6 +64,9 @@ const propTypes = {
/** Whether the comment is a thread parent message/the first message in a thread */
isThreadParentMessage: PropTypes.bool,

/** The report's action name/type e.g. APPROVED, SUBMITTED, etc. */
actionName: PropTypes.string,
Victor-Nyagudi marked this conversation as resolved.
Show resolved Hide resolved

...windowDimensionsPropTypes,

/** localization props */
Expand All @@ -86,6 +90,7 @@ const defaultProps = {
delegateAccountID: 0,
actorIcon: {},
isThreadParentMessage: false,
actionName: '',
displayAsGroup: false,
};

Expand Down Expand Up @@ -161,7 +166,11 @@ function ReportActionItemFragment(props) {
>
<Text
numberOfLines={props.isSingleLine ? 1 : undefined}
style={[styles.chatItemMessageHeaderSender, props.isSingleLine ? styles.pre : styles.preWrap]}
style={[
styles.chatItemMessageHeaderSender,
props.isSingleLine ? styles.pre : styles.preWrap,
_.contains([CONST.REPORT.ACTIONS.TYPE.APPROVED, CONST.REPORT.ACTIONS.TYPE.SUBMITTED], props.actionName) && {color: styles.colorMuted.color, fontWeight: 'normal'},
Victor-Nyagudi marked this conversation as resolved.
Show resolved Hide resolved
]}
>
{props.fragment.text}
</Text>
Expand Down
50 changes: 34 additions & 16 deletions src/pages/home/report/ReportActionItemMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as ReportUtils from '../../../libs/ReportUtils';
import * as ReportActionsUtils from '../../../libs/ReportActionsUtils';
import reportActionPropTypes from './reportActionPropTypes';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import CONST from '../../../CONST';

const propTypes = {
/** The report action */
Expand Down Expand Up @@ -47,25 +48,42 @@ function ReportActionItemMessage(props) {
}
}

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

const flaggedContentText = <Text style={[styles.textLabelSupporting, styles.lh20]}>{props.translate('moderation.flaggedContent')}</Text>;

/**
* Get a ReportActionItemFragment
* @param {Object} fragment the current message fragment
* @param {Number} index the current message fragment's index
* @returns {Object} report action item fragment
*/
const renderReportActionItemFragment = (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}
actionName={props.action.actionName}
/>
);

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}
/>
))
{isApprovedOrSubmittedReportActionType ? (
Victor-Nyagudi marked this conversation as resolved.
Show resolved Hide resolved
// Wrapping 'ReportActionItemFragment' inside '<Text>' so that text isn't broken up into separate lines when
// there are multiple messages of type 'TEXT', as seen when a report is submitted/approved from a
// policy on Old Dot and then viewed on New Dot.
Victor-Nyagudi marked this conversation as resolved.
Show resolved Hide resolved

<Text>{!props.isHidden ? _.map(messages, (fragment, index) => renderReportActionItemFragment(fragment, index)) : flaggedContentText}</Text>
) : (
<Text style={[styles.textLabelSupporting, styles.lh20]}>{props.translate('moderation.flaggedContent')}</Text>
<>{!props.isHidden ? _.map(messages, (fragment, index) => renderReportActionItemFragment(fragment, index)) : flaggedContentText}</>
)}
</View>
);
Expand Down
Loading