diff --git a/src/pages/home/report/ReportActionItemFragment.js b/src/pages/home/report/ReportActionItemFragment.js deleted file mode 100644 index a31bd5e64d44..000000000000 --- a/src/pages/home/report/ReportActionItemFragment.js +++ /dev/null @@ -1,187 +0,0 @@ -import PropTypes from 'prop-types'; -import React, {memo} from 'react'; -import avatarPropTypes from '@components/avatarPropTypes'; -import {withNetwork} from '@components/OnyxProvider'; -import RenderHTML from '@components/RenderHTML'; -import Text from '@components/Text'; -import UserDetailsTooltip from '@components/UserDetailsTooltip'; -import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; -import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions'; -import useThemeStyles from '@hooks/useThemeStyles'; -import compose from '@libs/compose'; -import convertToLTR from '@libs/convertToLTR'; -import * as ReportUtils from '@libs/ReportUtils'; -import CONST from '@src/CONST'; -import AttachmentCommentFragment from './comment/AttachmentCommentFragment'; -import TextCommentFragment from './comment/TextCommentFragment'; -import reportActionFragmentPropTypes from './reportActionFragmentPropTypes'; - -const propTypes = { - /** Users accountID */ - accountID: PropTypes.number.isRequired, - - /** The message fragment needing to be displayed */ - fragment: reportActionFragmentPropTypes.isRequired, - - /** If this fragment is attachment than has info? */ - attachmentInfo: PropTypes.shape({ - /** The file name of attachment */ - name: PropTypes.string, - - /** The file size of the attachment in bytes. */ - size: PropTypes.number, - - /** The MIME type of the attachment. */ - type: PropTypes.string, - - /** Attachment's URL represents the specified File object or Blob object */ - source: PropTypes.string, - }), - - /** Message(text) of an IOU report action */ - iouMessage: PropTypes.string, - - /** The reportAction's source */ - source: PropTypes.oneOf(['Chronos', 'email', 'ios', 'android', 'web', 'email', '']), - - /** Should this fragment be contained in a single line? */ - isSingleLine: PropTypes.bool, - - // Additional styles to add after local styles - style: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]), - - /** The accountID of the copilot who took this action on behalf of the user */ - delegateAccountID: PropTypes.number, - - /** icon */ - actorIcon: avatarPropTypes, - - /** Whether the comment is a thread parent message/the first message in a thread */ - isThreadParentMessage: PropTypes.bool, - - /** Moderation decision of the report action */ - moderationDecision: PropTypes.string, - - /** Should the comment have the appearance of being grouped with the previous comment? */ - displayAsGroup: 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 */ - ...withLocalizePropTypes, -}; - -const defaultProps = { - attachmentInfo: { - name: '', - size: 0, - type: '', - source: '', - }, - iouMessage: '', - isSingleLine: false, - source: '', - style: [], - delegateAccountID: 0, - actorIcon: {}, - isThreadParentMessage: false, - moderationDecision: '', - isApprovedOrSubmittedReportAction: false, - isFragmentContainingDisplayName: false, - displayAsGroup: false, -}; - -function ReportActionItemFragment(props) { - const styles = useThemeStyles(); - const fragment = props.fragment; - - switch (fragment.type) { - case 'COMMENT': { - const isPendingDelete = props.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; - - // Threaded messages display "[Deleted message]" instead of being hidden altogether. - // While offline we display the previous message with a strikethrough style. Once online we want to - // immediately display "[Deleted message]" while the delete action is pending. - - if ((!props.network.isOffline && props.isThreadParentMessage && isPendingDelete) || props.fragment.isDeletedParentAction) { - return ${props.translate('parentReportAction.deletedMessage')}`} />; - } - - if (props.isThreadParentMessage && props.moderationDecision === CONST.MODERATION.MODERATOR_DECISION_PENDING_REMOVE) { - return ${props.translate('parentReportAction.hiddenMessage')}`} />; - } - - if (ReportUtils.isReportMessageAttachment(fragment)) { - return ( - - ); - } - - return ( - - ); - } - case 'TEXT': { - return props.isApprovedOrSubmittedReportAction ? ( - - {props.isFragmentContainingDisplayName ? convertToLTR(props.fragment.text) : props.fragment.text} - - ) : ( - - - {fragment.text} - - - ); - } - case 'LINK': - return LINK; - case 'INTEGRATION_COMMENT': - return REPORT_LINK; - case 'REPORT_LINK': - return REPORT_LINK; - case 'POLICY_LINK': - return POLICY_LINK; - - // If we have a message fragment type of OLD_MESSAGE this means we have not yet converted this over to the - // new data structure. So we simply set this message as inner html and render it like we did before. - // This wil allow us to convert messages over to the new structure without needing to do it all at once. - case 'OLD_MESSAGE': - return OLD_MESSAGE; - default: - return props.fragment.text; - } -} - -ReportActionItemFragment.propTypes = propTypes; -ReportActionItemFragment.defaultProps = defaultProps; -ReportActionItemFragment.displayName = 'ReportActionItemFragment'; - -export default compose(withWindowDimensions, withLocalize, withNetwork())(memo(ReportActionItemFragment));