Skip to content
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

[No QA] Remove Permissions.canUseFreePlan #8966

Merged
merged 5 commits into from
May 12, 2022
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
31 changes: 0 additions & 31 deletions src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import _ from 'underscore';
import React from 'react';
import {Keyboard} from 'react-native';
import {DrawerActions, getPathFromState, StackActions} from '@react-navigation/native';
import PropTypes from 'prop-types';
import Onyx from 'react-native-onyx';
import Log from '../Log';
import linkTo from './linkTo';
Expand Down Expand Up @@ -188,42 +186,13 @@ function isActiveRoute(routePath) {
return getActiveRoute().substring(1) === routePath;
}

/**
* Alternative to the `Navigation.dismissModal()` function that we can use inside
* the render function of other components to avoid breaking React rules about side-effects.
*
* Example:
* ```jsx
* if (!Permissions.canUseFreePlan(this.props.betas)) {
* return <Navigation.DismissModal />;
* }
* ```
*/
class DismissModal extends React.Component {
componentDidMount() {
dismissModal(this.props.shouldOpenDrawer);
}

render() {
return null;
}
}

DismissModal.propTypes = {
shouldOpenDrawer: PropTypes.bool,
};
DismissModal.defaultProps = {
shouldOpenDrawer: false,
};

export default {
canNavigate,
navigate,
dismissModal,
isActiveRoute,
getActiveRoute,
goBack,
DismissModal,
closeDrawer,
getDefaultDrawerState,
setDidTapNotification,
Expand Down
9 changes: 0 additions & 9 deletions src/libs/Permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ function canUsePayWithExpensify(betas) {
return _.contains(betas, CONST.BETAS.PAY_WITH_EXPENSIFY) || canUseAllBetas(betas);
}

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

/**
* @param {Array<String>} betas
* @returns {Boolean}
Expand Down Expand Up @@ -98,7 +90,6 @@ export default {
canUseChronos,
canUseIOU,
canUsePayWithExpensify,
canUseFreePlan,
canUseDefaultRooms,
canUseInternationalization,
canUseIOUSend,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/sidebar/SidebarScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class SidebarScreen extends Component {
onSelected: () => Navigation.navigate(ROUTES.IOU_BILL),
},
] : []),
...(!this.props.isCreatingWorkspace && Permissions.canUseFreePlan(this.props.betas) && !Policy.isAdminOfFreePolicy(this.props.allPolicies) ? [
...(!this.props.isCreatingWorkspace && !Policy.isAdminOfFreePolicy(this.props.allPolicies) ? [
{
icon: Expensicons.NewWorkspace,
iconWidth: 46,
Expand Down
12 changes: 0 additions & 12 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import Str from 'expensify-common/lib/str';
import Log from '../../libs/Log';
import styles from '../../styles/styles';
import ONYXKEYS from '../../ONYXKEYS';
import HeaderWithCloseButton from '../../components/HeaderWithCloseButton';
Expand All @@ -22,7 +21,6 @@ import Text from '../../components/Text';
import ROUTES from '../../ROUTES';
import ConfirmModal from '../../components/ConfirmModal';
import personalDetailsPropType from '../personalDetailsPropType';
import Permissions from '../../libs/Permissions';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/withWindowDimensions';
import OptionRow from '../../components/OptionRow';
import CheckboxWithTooltip from '../../components/CheckboxWithTooltip';
Expand All @@ -31,9 +29,6 @@ import withFullPolicy, {fullPolicyPropTypes, fullPolicyDefaultProps} from './wit
import CONST from '../../CONST';

const propTypes = {
/** List of betas */
betas: PropTypes.arrayOf(PropTypes.string).isRequired,

/** The personal details of the person who is logged in */
personalDetails: personalDetailsPropType.isRequired,

Expand Down Expand Up @@ -241,10 +236,6 @@ class WorkspaceMembersPage extends React.Component {
}

render() {
if (!Permissions.canUseFreePlan(this.props.betas)) {
Log.info('Not showing workspace people page because user is not on free plan beta');
return <Navigation.DismissModal />;
}
const policyEmployeeList = lodashGet(this.props, 'policy.employeeList', []);
const removableMembers = _.without(this.props.policy.employeeList, this.props.session.email, this.props.policy.owner);
const data = _.chain(policyEmployeeList)
Expand Down Expand Up @@ -334,8 +325,5 @@ export default compose(
session: {
key: ONYXKEYS.SESSION,
},
betas: {
key: ONYXKEYS.BETAS,
},
}),
)(WorkspaceMembersPage);
17 changes: 0 additions & 17 deletions src/pages/workspace/WorkspaceSettingsPage.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import _ from 'underscore';
import Log from '../../libs/Log';
import ONYXKEYS from '../../ONYXKEYS';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
import Navigation from '../../libs/Navigation/Navigation';
import Permissions from '../../libs/Permissions';
import styles from '../../styles/styles';
import Button from '../../components/Button';
import Text from '../../components/Text';
Expand All @@ -32,17 +28,12 @@ const propTypes = {
/** Information about the network from Onyx */
network: networkPropTypes.isRequired,

/** List of betas */
betas: PropTypes.arrayOf(PropTypes.string),

...fullPolicyPropTypes,

...withLocalizePropTypes,
};

const defaultProps = {
betas: [],

...fullPolicyDefaultProps,
};

Expand Down Expand Up @@ -127,11 +118,6 @@ class WorkspaceSettingsPage extends React.Component {
}

render() {
if (!Permissions.canUseFreePlan(this.props.betas)) {
Log.info('Not showing workspace editor page because user is not on free plan beta');
return <Navigation.DismissModal />;
}

if (_.isEmpty(this.props.policy)) {
return <FullScreenLoadingIndicator />;
}
Expand Down Expand Up @@ -208,9 +194,6 @@ WorkspaceSettingsPage.defaultProps = defaultProps;
export default compose(
withFullPolicy,
withOnyx({
betas: {
key: ONYXKEYS.BETAS,
},
currencyList: {key: ONYXKEYS.CURRENCY_LIST},
}),
withLocalize,
Expand Down