Skip to content

Commit

Permalink
Merge pull request #8065 from mollfpr/feature/add-workspace-name
Browse files Browse the repository at this point in the history
Add workspace name as subtitle in individual modal screens
  • Loading branch information
Luke9389 authored Mar 14, 2022
2 parents c1bb574 + 173d234 commit 90e5af4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/pages/workspace/WorkspaceBankAccountPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React from 'react';
import {ScrollView} from 'react-native';
import {withOnyx} from 'react-native-onyx';
Expand All @@ -19,11 +20,17 @@ import Section from '../../components/Section';
import WorkspaceResetBankAccountModal from './WorkspaceResetBankAccountModal';
import styles from '../../styles/styles';
import CONST from '../../CONST';
import withFullPolicy from './withFullPolicy';

const propTypes = {
/** ACH data for the withdrawal account actively being set up */
reimbursementAccount: reimbursementAccountPropTypes,

/** Policy values needed in the component */
policy: PropTypes.shape({
name: PropTypes.string,
}).isRequired,

...withLocalizePropTypes,
};

Expand All @@ -43,6 +50,10 @@ class WorkspaceBankAccountPage extends React.Component {

componentDidMount() {
this.unsubscribe = this.props.navigation.addListener('focus', this.onScreenFocus);

if (!this.getShouldShowPage()) {
this.navigateToBankAccountRoute();
}
}

componentWillUnmount() {
Expand Down Expand Up @@ -82,15 +93,13 @@ class WorkspaceBankAccountPage extends React.Component {
}

render() {
if (!this.getShouldShowPage()) {
this.navigateToBankAccountRoute();
return null;
}
const policyName = lodashGet(this.props.policy, 'name');

return (
<ScreenWrapper>
<HeaderWithCloseButton
title={this.props.translate('workspace.common.bankAccount')}
subtitle={policyName}
onCloseButtonPress={Navigation.dismissModal}
onBackButtonPress={() => Navigation.navigate(ROUTES.getWorkspaceInitialRoute(this.props.route.params.policyID))}
shouldShowGetAssistanceButton
Expand Down Expand Up @@ -137,4 +146,5 @@ export default compose(
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
},
}),
withFullPolicy,
)(WorkspaceBankAccountPage);
3 changes: 3 additions & 0 deletions src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,15 @@ class WorkspaceInvitePage extends React.Component {
Boolean(this.state.userToInvite),
this.state.searchValue,
);
const policyName = lodashGet(this.props.policy, 'name');

return (
<ScreenWrapper>
{({didScreenTransitionEnd}) => (
<KeyboardAvoidingView>
<HeaderWithCloseButton
title={this.props.translate('workspace.invite.invitePeople')}
subtitle={policyName}
onCloseButtonPress={() => {
this.clearErrors();
Navigation.dismissModal();
Expand Down
2 changes: 2 additions & 0 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ class WorkspaceMembersPage extends React.Component {
.sortBy(person => person.displayName.toLowerCase())
.value();
const policyID = lodashGet(this.props.route, 'params.policyID');
const policyName = lodashGet(this.props.policy, 'name');

return (
<ScreenWrapper style={[styles.defaultModalContainer]}>
<HeaderWithCloseButton
title={this.props.translate('workspace.common.members')}
subtitle={policyName}
onCloseButtonPress={() => Navigation.dismissModal()}
onBackButtonPress={() => Navigation.navigate(ROUTES.getWorkspaceInitialRoute(policyID))}
shouldShowGetAssistanceButton
Expand Down
9 changes: 9 additions & 0 deletions src/pages/workspace/WorkspacePageWithSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import BankAccount from '../../libs/models/BankAccount';
import reimbursementAccountPropTypes from '../ReimbursementAccount/reimbursementAccountPropTypes';
import userPropTypes from '../settings/userPropTypes';
import KeyboardAvoidingView from '../../components/KeyboardAvoidingView';
import withFullPolicy from './withFullPolicy';

const propTypes = {
/** The text to display in the header */
Expand Down Expand Up @@ -46,6 +47,11 @@ const propTypes = {
/** The guides call task ID to associate with the workspace page being shown */
guidesCallTaskID: PropTypes.string,

/** Policy values needed in the component */
policy: PropTypes.shape({
name: PropTypes.string,
}).isRequired,

...withLocalizePropTypes,
};

Expand All @@ -68,12 +74,14 @@ class WorkspacePageWithSections extends React.Component {
const hasVBA = achState === BankAccount.STATE.OPEN;
const isUsingECard = lodashGet(this.props.user, 'isUsingExpensifyCard', false);
const policyID = lodashGet(this.props.route, 'params.policyID');
const policyName = lodashGet(this.props.policy, 'name');

return (
<ScreenWrapper>
<KeyboardAvoidingView>
<HeaderWithCloseButton
title={this.props.headerText}
subtitle={policyName}
shouldShowGetAssistanceButton
guidesCallTaskID={this.props.guidesCallTaskID}
shouldShowBackButton
Expand Down Expand Up @@ -109,4 +117,5 @@ export default compose(
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
},
}),
withFullPolicy,
)(WorkspacePageWithSections);

0 comments on commit 90e5af4

Please sign in to comment.