diff --git a/src/CONST.js b/src/CONST.js index e8c1c270fc4b..9a7f7ef637f3 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -87,6 +87,7 @@ const CONST = { PAY_WITH_EXPENSIFY: 'payWithExpensify', FREE_PLAN: 'freePlan', DEFAULT_ROOMS: 'defaultRooms', + BETA_EXPENSIFY_WALLET: 'expensifyWallet', }, BUTTON_STATES: { DEFAULT: 'default', diff --git a/src/libs/Permissions.js b/src/libs/Permissions.js index 7063273b245c..86fd6a5fa394 100644 --- a/src/libs/Permissions.js +++ b/src/libs/Permissions.js @@ -51,10 +51,19 @@ function canUseDefaultRooms(betas) { return _.contains(betas, CONST.BETAS.DEFAULT_ROOMS) || canUseAllBetas(betas); } +/** + * @param {Array} betas + * @returns {Boolean} + */ +function canUseWallet(betas) { + return _.contains(betas, CONST.BETAS.BETA_EXPENSIFY_WALLET || canUseAllBetas(betas)); +} + export default { canUseChronos, canUseIOU, canUsePayWithExpensify, canUseFreePlan, canUseDefaultRooms, + canUseWallet, }; diff --git a/src/pages/settings/InitialPage.js b/src/pages/settings/InitialPage.js index f806b55d0696..834420ee204f 100755 --- a/src/pages/settings/InitialPage.js +++ b/src/pages/settings/InitialPage.js @@ -28,6 +28,7 @@ import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize import compose from '../../libs/compose'; import CONST from '../../CONST'; import DateUtils from '../../libs/DateUtils'; +import Permissions from '../../libs/Permissions'; const propTypes = { /* Onyx Props */ @@ -74,6 +75,9 @@ const propTypes = { availableBalance: PropTypes.number, }), + /** List of betas available to current user */ + betas: PropTypes.arrayOf(PropTypes.string), + ...withLocalizePropTypes, }; @@ -85,6 +89,7 @@ const defaultProps = { userWallet: { availableBalance: 0, }, + betas: [], }; const defaultMenuItems = [ @@ -131,6 +136,7 @@ const InitialSettingsPage = ({ policies, translate, userWallet, + betas, }) => { const walletBalance = numberFormat( userWallet.availableBalance, @@ -207,7 +213,7 @@ const InitialSettingsPage = ({ iconStyles={item.iconStyles} iconFill={item.iconFill} shouldShowRightIcon - badgeText={isPaymentItem ? walletBalance : undefined} + badgeText={(isPaymentItem && Permissions.canUseWallet(betas)) ? walletBalance : undefined} /> ); })} @@ -239,5 +245,8 @@ export default compose( userWallet: { key: ONYXKEYS.USER_WALLET, }, + betas: { + key: ONYXKEYS.BETAS, + }, }), )(InitialSettingsPage); diff --git a/src/pages/settings/Payments/PaymentsPage.js b/src/pages/settings/Payments/PaymentsPage.js index 0958973677e8..92202ca6f6a6 100644 --- a/src/pages/settings/Payments/PaymentsPage.js +++ b/src/pages/settings/Payments/PaymentsPage.js @@ -1,5 +1,7 @@ import React from 'react'; import {View} from 'react-native'; +import {withOnyx} from 'react-native-onyx'; +import PropTypes from 'prop-types'; import PaymentMethodList from './PaymentMethodList'; import ROUTES from '../../../ROUTES'; import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton'; @@ -16,15 +18,20 @@ import {PayPal} from '../../../components/Icon/Expensicons'; import MenuItem from '../../../components/MenuItem'; import getClickedElementLocation from '../../../libs/getClickedElementLocation'; import CurrentWalletBalance from '../../../components/CurrentWalletBalance'; +import ONYXKEYS from '../../../ONYXKEYS'; +import Permissions from '../../../libs/Permissions'; const PAYPAL = 'payPalMe'; const propTypes = { ...withLocalizePropTypes, + + /** List of betas available to current user */ + betas: PropTypes.arrayOf(PropTypes.string), }; const defaultProps = { - payPalMeUsername: '', + betas: [], }; class PaymentsPage extends React.Component { @@ -103,7 +110,9 @@ class PaymentsPage extends React.Component { onCloseButtonPress={() => Navigation.dismissModal(true)} /> - + { + Permissions.canUseWallet(this.props.betas) && + } @@ -141,4 +150,9 @@ PaymentsPage.displayName = 'PaymentsPage'; export default compose( withLocalize, + withOnyx({ + betas: { + key: ONYXKEYS.BETAS, + }, + }), )(PaymentsPage);