Skip to content

Commit

Permalink
Merge pull request #31380 from infinitered/cdanwards/violations/requi…
Browse files Browse the repository at this point in the history
…red-confirmation-list
  • Loading branch information
cead22 authored Nov 20, 2023
2 parents 0913335 + 917fa3e commit 2c00104
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const defaultProps = {
shouldGreyOutWhenDisabled: true,
error: '',
shouldRenderAsHTML: false,
rightLabel: '',
rightComponent: undefined,
shouldShowRightComponent: false,
titleWithTooltips: [],
Expand Down Expand Up @@ -364,6 +365,11 @@ const MenuItem = React.forwardRef((props, ref) => {
/>
</View>
)}
{Boolean(props.rightLabel) && (
<View style={styles.justifyContentCenter}>
<Text style={styles.rightLabelMenuItem}>{props.rightLabel}</Text>
</View>
)}
{Boolean(props.shouldShowRightIcon) && (
<View style={[styles.popoverMenuIcon, styles.pointerEventsAuto, props.disabled && styles.cursorDisabled]}>
<Icon
Expand Down
5 changes: 4 additions & 1 deletion src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import compose from '@libs/compose';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import DistanceRequestUtils from '@libs/DistanceRequestUtils';
Expand Down Expand Up @@ -210,6 +211,7 @@ function MoneyRequestConfirmationList(props) {
const {onSendMoney, onConfirm, onSelectParticipant} = props;
const {translate, toLocaleDigit} = useLocalize();
const transaction = props.isEditingSplitBill ? props.draftTransaction || props.transaction : props.transaction;
const {canUseViolations} = usePermissions();

const isTypeRequest = props.iouType === CONST.IOU.TYPE.REQUEST;
const isSplitBill = props.iouType === CONST.IOU.TYPE.SPLIT;
Expand All @@ -223,7 +225,6 @@ function MoneyRequestConfirmationList(props) {

// A flag for showing the categories field
const shouldShowCategories = props.isPolicyExpenseChat && (props.iouCategory || OptionsListUtils.hasEnabledOptions(_.values(props.policyCategories)));

// A flag and a toggler for showing the rest of the form fields
const [shouldExpandFields, toggleShouldExpandFields] = useReducer((state) => !state, false);

Expand Down Expand Up @@ -715,6 +716,7 @@ function MoneyRequestConfirmationList(props) {
titleStyle={styles.flex1}
disabled={didConfirm}
interactive={!props.isReadOnly}
rightLabel={canUseViolations && Boolean(props.policy.requiresCategory) ? translate('common.required') : ''}
/>
)}
{shouldShowTags && (
Expand All @@ -727,6 +729,7 @@ function MoneyRequestConfirmationList(props) {
style={[styles.moneyRequestMenuItem]}
disabled={didConfirm}
interactive={!props.isReadOnly}
rightLabel={canUseViolations && Boolean(props.policy.requiresTag) ? translate('common.required') : ''}
/>
)}

Expand Down
3 changes: 3 additions & 0 deletions src/components/menuItemPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ const propTypes = {
/** Should render the content in HTML format */
shouldRenderAsHTML: PropTypes.bool,

/** Label to be displayed on the right */
rightLabel: PropTypes.string,

/** Component to be displayed on the right */
rightComponent: PropTypes.node,

Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export default {
tbd: 'TBD',
selectCurrency: 'Select a currency',
card: 'Card',
required: 'Required',
},
location: {
useCurrent: 'Use current location',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export default {
tbd: 'Por determinar',
selectCurrency: 'Selecciona una moneda',
card: 'Tarjeta',
required: 'Obligatorio',
},
location: {
useCurrent: 'Usar ubicación actual',
Expand Down
5 changes: 5 additions & 0 deletions src/styles/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,11 @@ const styles = (theme: ThemeColors) =>
alignItems: 'center',
},

rightLabelMenuItem: {
fontSize: variables.fontSizeLabel,
color: theme.textSupporting,
},

popoverMenuText: {
fontSize: variables.fontSizeNormal,
color: theme.heading,
Expand Down

0 comments on commit 2c00104

Please sign in to comment.