Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/CONST.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/libs/Permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,19 @@ function canUseDefaultRooms(betas) {
return _.contains(betas, CONST.BETAS.DEFAULT_ROOMS) || canUseAllBetas(betas);
}

/**
* @param {Array<String>} betas
* @returns {Boolean}
*/
function canUseWallet(betas) {
return _.contains(betas, CONST.BETAS.BETA_EXPENSIFY_WALLET || canUseAllBetas(betas));
}

export default {
canUseChronos,
canUseIOU,
canUsePayWithExpensify,
canUseFreePlan,
canUseDefaultRooms,
canUseWallet,
};
11 changes: 10 additions & 1 deletion src/pages/settings/InitialPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -74,6 +75,9 @@ const propTypes = {
availableBalance: PropTypes.number,
}),

/** List of betas available to current user */
betas: PropTypes.arrayOf(PropTypes.string),

...withLocalizePropTypes,
};

Expand All @@ -85,6 +89,7 @@ const defaultProps = {
userWallet: {
availableBalance: 0,
},
betas: [],
};

const defaultMenuItems = [
Expand Down Expand Up @@ -131,6 +136,7 @@ const InitialSettingsPage = ({
policies,
translate,
userWallet,
betas,
}) => {
const walletBalance = numberFormat(
userWallet.availableBalance,
Expand Down Expand Up @@ -207,7 +213,7 @@ const InitialSettingsPage = ({
iconStyles={item.iconStyles}
iconFill={item.iconFill}
shouldShowRightIcon
badgeText={isPaymentItem ? walletBalance : undefined}
badgeText={(isPaymentItem && Permissions.canUseWallet(betas)) ? walletBalance : undefined}
/>
);
})}
Expand Down Expand Up @@ -239,5 +245,8 @@ export default compose(
userWallet: {
key: ONYXKEYS.USER_WALLET,
},
betas: {
key: ONYXKEYS.BETAS,
},
}),
)(InitialSettingsPage);
18 changes: 16 additions & 2 deletions src/pages/settings/Payments/PaymentsPage.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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: '',

@deetergp deetergp Sep 7, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: Was this deletion intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah afaict it isn't used in that file. Did i miss it somewhere?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it doesn't look like we're passing this component any props whatsoever.

betas: [],
};

class PaymentsPage extends React.Component {
Expand Down Expand Up @@ -103,7 +110,9 @@ class PaymentsPage extends React.Component {
onCloseButtonPress={() => Navigation.dismissModal(true)}
/>
<View>
<CurrentWalletBalance />
{
Permissions.canUseWallet(this.props.betas) && <CurrentWalletBalance />
}
<Text
style={[styles.ph5, styles.formLabel]}
>
Expand Down Expand Up @@ -141,4 +150,9 @@ PaymentsPage.displayName = 'PaymentsPage';

export default compose(
withLocalize,
withOnyx({
betas: {
key: ONYXKEYS.BETAS,
},
}),
)(PaymentsPage);