-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[NoQA] feat: show next steps for draft reports #29309
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b4b68f8
feat: show next steps for draft reports
BeeMargarida b6a9476
fix: text wrap in native devices
BeeMargarida 8c71c20
Merge branch 'main' into feat/28767-next-steps
BeeMargarida a1467e6
fix: remove brackets
BeeMargarida 4db6a9e
refactor: prettier
BeeMargarida 536ca6f
refactor: break into newlines
BeeMargarida 6dd690c
fix: resolve conflicts
koko57 fa77838
fix: apply requested changes
koko57 c2ca6b0
fix: minor style fix
koko57 127ccff
fix: minor fix
koko57 fdc60fb
fix: minor style fix
koko57 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, {useMemo} from 'react'; | ||
import {Text, View} from 'react-native'; | ||
import _ from 'underscore'; | ||
import styles from '../styles/styles'; | ||
import * as NextStepUtils from '../libs/NextStepUtils'; | ||
import useLocalize from '../hooks/useLocalize'; | ||
import nextStepPropTypes from '../pages/nextStepPropTypes'; | ||
import RenderHTML from './RenderHTML'; | ||
|
||
const propTypes = { | ||
/** The next step for the report */ | ||
nextStep: nextStepPropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
nextStep: {}, | ||
}; | ||
|
||
function MoneyReportHeaderStatusBar({nextStep}) { | ||
const {translate} = useLocalize(); | ||
|
||
const messageContent = useMemo(() => { | ||
const messageArray = _.isEmpty(nextStep.expenseMessage) ? nextStep.message : nextStep.expenseMessage; | ||
return NextStepUtils.parseMessage(messageArray); | ||
}, [nextStep.expenseMessage, nextStep.message]); | ||
|
||
return ( | ||
<View style={[styles.dFlex, styles.flexRow, styles.alignItemsCenter, styles.overflowHidden, styles.w100]}> | ||
<View style={styles.moneyRequestHeaderStatusBarBadge}> | ||
<Text style={[styles.textStrong, styles.textLabel]}>{translate('iou.nextSteps')}</Text> | ||
</View> | ||
<View style={[styles.dFlex, styles.flexRow, styles.flexShrink1]}> | ||
<RenderHTML html={messageContent} /> | ||
</View> | ||
</View> | ||
); | ||
} | ||
|
||
MoneyReportHeaderStatusBar.displayName = 'MoneyReportHeaderStatusBar'; | ||
MoneyReportHeaderStatusBar.propTypes = propTypes; | ||
MoneyReportHeaderStatusBar.defaultProps = defaultProps; | ||
|
||
export default MoneyReportHeaderStatusBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import _ from 'underscore'; | ||
import Str from 'expensify-common/lib/str'; | ||
|
||
function parseMessage(messageToParse) { | ||
let nextStepHTML = ''; | ||
|
||
_.each(messageToParse, (part) => { | ||
const tagType = part.type || 'span'; | ||
nextStepHTML += `<${tagType}>${Str.safeEscape(part.text)}</${tagType}>`; | ||
}); | ||
|
||
return nextStepHTML | ||
.replace(/%expenses/g, 'this expense') | ||
.replace(/%Expenses/g, 'This expense') | ||
.replace(/%tobe/g, 'is'); | ||
} | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export {parseMessage}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
const messagePropType = PropTypes.shape({ | ||
text: PropTypes.string, | ||
type: PropTypes.string, | ||
action: PropTypes.string, | ||
}); | ||
|
||
export default PropTypes.shape({ | ||
/** The message parts of the next step */ | ||
message: PropTypes.arrayOf(messagePropType), | ||
|
||
/** The title for the next step */ | ||
title: PropTypes.string, | ||
|
||
/** Whether the user should take some sort of action in order to unblock the report */ | ||
requiresUserAction: PropTypes.bool, | ||
|
||
/** The type of next step */ | ||
type: PropTypes.oneOf(['neutral', 'alert', null]), | ||
|
||
/** If the "Undo submit" button should be visible */ | ||
showUndoSubmit: PropTypes.bool, | ||
|
||
/** Deprecated - If the next step should be displayed on mobile, related to OldApp */ | ||
showForMobile: PropTypes.bool, | ||
|
||
/** If the next step should be displayed at the expense level */ | ||
showForExpense: PropTypes.bool, | ||
|
||
/** An optional alternate message to display on expenses instead of what is provided in the "message" field */ | ||
expenseMessage: PropTypes.arrayOf(messagePropType), | ||
|
||
/** The next person in the approval chain of the report */ | ||
nextReceiver: PropTypes.string, | ||
|
||
/** An array of buttons to be displayed next to the next step */ | ||
buttons: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
text: PropTypes.string, | ||
tooltip: PropTypes.string, | ||
disabled: PropTypes.bool, | ||
hidden: PropTypes.bool, | ||
// eslint-disable-next-line react/forbid-prop-types | ||
data: PropTypes.array, | ||
}), | ||
), | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last nitpick 🤓 @koko57 This leads to double bottom border if there is no next steps: