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

withFullPolicy refactor redux #11155

Merged
merged 5 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions src/components/AvatarWithIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import policyMemberPropType from '../pages/policyMemberPropType';
import bankAccountPropTypes from './bankAccountPropTypes';
import cardPropTypes from './cardPropTypes';
import userWalletPropTypes from '../pages/EnablePayments/userWalletPropTypes';
import {fullPolicyPropTypes} from '../pages/workspace/withFullPolicy';
import {policyPropTypes} from '../pages/workspace/withPolicy';
import walletTermsPropTypes from '../pages/EnablePayments/walletTermsPropTypes';
import * as PolicyUtils from '../libs/PolicyUtils';
import * as PaymentMethods from '../libs/actions/PaymentMethods';
Expand All @@ -30,7 +30,7 @@ const propTypes = {
policiesMemberList: PropTypes.objectOf(policyMemberPropType),

/** All the user's policies (from Onyx via withFullPolicy) */
policies: PropTypes.objectOf(fullPolicyPropTypes.policy),
policies: PropTypes.objectOf(policyPropTypes.policy),

/** List of bank accounts */
bankAccountList: PropTypes.objectOf(bankAccountPropTypes),
Expand Down
4 changes: 0 additions & 4 deletions src/components/RoomNameInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import CONST from '../CONST';
import ONYXKEYS from '../ONYXKEYS';
import compose from '../libs/compose';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import withFullPolicy, {fullPolicyDefaultProps, fullPolicyPropTypes} from '../pages/workspace/withFullPolicy';
import TextInput from './TextInput';

const propTypes = {
Expand All @@ -22,7 +21,6 @@ const propTypes = {
errorText: PropTypes.string,

...withLocalizePropTypes,
...fullPolicyPropTypes,

/* Onyx Props */

Expand Down Expand Up @@ -53,7 +51,6 @@ const defaultProps = {
value: '',
disabled: false,
errorText: '',
...fullPolicyDefaultProps,
forwardedRef: () => {},
};

Expand Down Expand Up @@ -114,7 +111,6 @@ RoomNameInput.defaultProps = defaultProps;

export default compose(
withLocalize,
withFullPolicy,
withOnyx({
reports: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be out of scope of this PR but I'm curious, are these Onyx keys needed in this components?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't look like it. I'll remove those too since its a quick improvement

key: ONYXKEYS.COLLECTION.REPORT,
Expand Down
15 changes: 0 additions & 15 deletions src/pages/ReportSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import Text from '../components/Text';
import Button from '../components/Button';
import RoomNameInput from '../components/RoomNameInput';
import Picker from '../components/Picker';
import withFullPolicy, {fullPolicyDefaultProps, fullPolicyPropTypes} from './workspace/withFullPolicy';
import * as ValidationUtils from '../libs/ValidationUtils';
import OfflineWithFeedback from '../components/OfflineWithFeedback';

Expand All @@ -31,7 +30,6 @@ const propTypes = {
}),
}).isRequired,

...fullPolicyPropTypes,
...withLocalizePropTypes,

/* Onyx Props */
Expand Down Expand Up @@ -79,17 +77,6 @@ const propTypes = {
}).isRequired,
};

const defaultProps = {
...fullPolicyDefaultProps,
report: {
reportID: 0,
reportName: '',
policyID: '',
notificationPreference: '',
visibility: '',
},
};

class ReportSettingsPage extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -282,11 +269,9 @@ class ReportSettingsPage extends Component {
}

ReportSettingsPage.propTypes = propTypes;
ReportSettingsPage.defaultProps = defaultProps;

export default compose(
withLocalize,
withFullPolicy,
withOnyx({
report: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID}`,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/WorkspaceBankAccountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Section from '../../components/Section';
import WorkspaceResetBankAccountModal from './WorkspaceResetBankAccountModal';
import styles from '../../styles/styles';
import CONST from '../../CONST';
import withFullPolicy from './withFullPolicy';
import withPolicy from './withPolicy';
import Button from '../../components/Button';
import MenuItem from '../../components/MenuItem';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';
Expand Down Expand Up @@ -131,5 +131,5 @@ export default compose(
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
},
}),
withFullPolicy,
withPolicy,
)(WorkspaceBankAccountPage);
8 changes: 4 additions & 4 deletions src/pages/workspace/WorkspaceInitialPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import HeaderWithCloseButton from '../../components/HeaderWithCloseButton';
import compose from '../../libs/compose';
import Avatar from '../../components/Avatar';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';
import withFullPolicy, {fullPolicyPropTypes, fullPolicyDefaultProps} from './withFullPolicy';
import withPolicy, {policyPropTypes, policyDefaultProps} from './withPolicy';
import * as Policy from '../../libs/actions/Policy';
import * as PolicyUtils from '../../libs/PolicyUtils';
import CONST from '../../CONST';
Expand All @@ -30,15 +30,15 @@ import policyMemberPropType from '../policyMemberPropType';
import OfflineWithFeedback from '../../components/OfflineWithFeedback';

const propTypes = {
...fullPolicyPropTypes,
...policyPropTypes,
...withLocalizePropTypes,

/** The employee list of this policy (coming from Onyx) */
policyMemberList: PropTypes.objectOf(policyMemberPropType),
};

const defaultProps = {
...fullPolicyDefaultProps,
...policyDefaultProps,
policyMemberList: {},
};

Expand Down Expand Up @@ -249,7 +249,7 @@ WorkspaceInitialPage.defaultProps = defaultProps;

export default compose(
withLocalize,
withFullPolicy,
withPolicy,
withOnyx({
policyMemberList: {
key: ({policy}) => `${ONYXKEYS.COLLECTION.POLICY_MEMBER_LIST}${policy.id}`,
Expand Down
8 changes: 4 additions & 4 deletions src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import CONST from '../../CONST';
import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator';
import * as Link from '../../libs/actions/Link';
import Text from '../../components/Text';
import withFullPolicy, {fullPolicyPropTypes, fullPolicyDefaultProps} from './withFullPolicy';
import withPolicy, {policyPropTypes, policyDefaultProps} from './withPolicy';
import {withNetwork} from '../../components/OnyxProvider';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';
import networkPropTypes from '../../components/networkPropTypes';
Expand Down Expand Up @@ -53,12 +53,12 @@ const propTypes = {
}),
}).isRequired,

...fullPolicyPropTypes,
...policyPropTypes,
...withLocalizePropTypes,
...networkPropTypes,
};

const defaultProps = fullPolicyDefaultProps;
const defaultProps = policyDefaultProps;

class WorkspaceInvitePage extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -352,7 +352,7 @@ WorkspaceInvitePage.defaultProps = defaultProps;

export default compose(
withLocalize,
withFullPolicy,
withPolicy,
withNetwork(),
withOnyx({
personalDetails: {
Expand Down
8 changes: 4 additions & 4 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/
import OptionRow from '../../components/OptionRow';
import CheckboxWithTooltip from '../../components/CheckboxWithTooltip';
import Hoverable from '../../components/Hoverable';
import withFullPolicy, {fullPolicyPropTypes, fullPolicyDefaultProps} from './withFullPolicy';
import withPolicy, {policyPropTypes, policyDefaultProps} from './withPolicy';
import CONST from '../../CONST';
import OfflineWithFeedback from '../../components/OfflineWithFeedback';
import {withNetwork} from '../../components/OnyxProvider';
Expand All @@ -45,13 +45,13 @@ const propTypes = {
}),
}).isRequired,

...fullPolicyPropTypes,
...policyPropTypes,
...withLocalizePropTypes,
...windowDimensionsPropTypes,
...networkPropTypes,
};

const defaultProps = fullPolicyDefaultProps;
const defaultProps = policyDefaultProps;

class WorkspaceMembersPage extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -367,7 +367,7 @@ WorkspaceMembersPage.defaultProps = defaultProps;
export default compose(
withLocalize,
withWindowDimensions,
withFullPolicy,
withPolicy,
withNetwork(),
withOnyx({
personalDetails: {
Expand Down
4 changes: 0 additions & 4 deletions src/pages/workspace/WorkspaceNewRoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {ScrollView, View} from 'react-native';
import _ from 'underscore';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import withFullPolicy, {fullPolicyDefaultProps, fullPolicyPropTypes} from './withFullPolicy';
import * as Report from '../../libs/actions/Report';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
import compose from '../../libs/compose';
Expand Down Expand Up @@ -38,12 +37,10 @@ const propTypes = {
/** List of betas available to current user */
betas: PropTypes.arrayOf(PropTypes.string),

...fullPolicyPropTypes,
...withLocalizePropTypes,
};
const defaultProps = {
betas: [],
...fullPolicyDefaultProps,
};

class WorkspaceNewRoomPage extends React.Component {
Expand Down Expand Up @@ -198,7 +195,6 @@ WorkspaceNewRoomPage.propTypes = propTypes;
WorkspaceNewRoomPage.defaultProps = defaultProps;

export default compose(
withFullPolicy,
withOnyx({
betas: {
key: ONYXKEYS.BETAS,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/WorkspacePageWithSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as BankAccounts from '../../libs/actions/BankAccounts';
import BankAccount from '../../libs/models/BankAccount';
import reimbursementAccountPropTypes from '../ReimbursementAccount/reimbursementAccountPropTypes';
import userPropTypes from '../settings/userPropTypes';
import withFullPolicy from './withFullPolicy';
import withPolicy from './withPolicy';
import {withNetwork} from '../../components/OnyxProvider';
import networkPropTypes from '../../components/networkPropTypes';

Expand Down Expand Up @@ -131,6 +131,6 @@ export default compose(
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
},
}),
withFullPolicy,
withPolicy,
withNetwork(),
)(WorkspacePageWithSections);
8 changes: 4 additions & 4 deletions src/pages/workspace/WorkspaceSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ import Picker from '../../components/Picker';
import TextInput from '../../components/TextInput';
import FixedFooter from '../../components/FixedFooter';
import WorkspacePageWithSections from './WorkspacePageWithSections';
import withFullPolicy, {fullPolicyPropTypes, fullPolicyDefaultProps} from './withFullPolicy';
import withPolicy, {policyPropTypes, policyDefaultProps} from './withPolicy';
import {withNetwork} from '../../components/OnyxProvider';
import OfflineWithFeedback from '../../components/OfflineWithFeedback';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';

const propTypes = {
...fullPolicyPropTypes,
...policyPropTypes,
...withLocalizePropTypes,
};

const defaultProps = {
...fullPolicyDefaultProps,
...policyDefaultProps,
};

class WorkspaceSettingsPage extends React.Component {
Expand Down Expand Up @@ -162,7 +162,7 @@ WorkspaceSettingsPage.propTypes = propTypes;
WorkspaceSettingsPage.defaultProps = defaultProps;

export default compose(
withFullPolicy,
withPolicy,
withOnyx({
currencyList: {key: ONYXKEYS.CURRENCY_LIST},
}),
Expand Down
12 changes: 9 additions & 3 deletions src/pages/workspace/reimburse/WorkspaceReimbursePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import withLocalize, {withLocalizePropTypes} from '../../../components/withLocal
import WorkspaceReimburseView from './WorkspaceReimburseView';
import WorkspacePageWithSections from '../WorkspacePageWithSections';
import CONST from '../../../CONST';
import compose from '../../../libs/compose';
import withPolicy, {policyPropTypes} from '../withPolicy';

const propTypes = {
/** The route object passed to this page from the navigator */
Expand All @@ -15,6 +17,7 @@ const propTypes = {
}).isRequired,
}).isRequired,

...policyPropTypes,
...withLocalizePropTypes,
};

Expand All @@ -24,13 +27,16 @@ const WorkspaceReimbursePage = props => (
route={props.route}
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_REIMBURSE}
>
{(hasVBA, policyID) => (
<WorkspaceReimburseView policyID={policyID} hasVBA={hasVBA} />
{hasVBA => (
<WorkspaceReimburseView policy={props.policy} hasVBA={hasVBA} />
)}
</WorkspacePageWithSections>
);

WorkspaceReimbursePage.propTypes = propTypes;
WorkspaceReimbursePage.displayName = 'WorkspaceReimbursePage';

export default withLocalize(WorkspaceReimbursePage);
export default compose(
withPolicy,
withLocalize,
)(WorkspaceReimbursePage);
Loading