Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Pass in isEmailAllowed for Email modals on CreateDestination page (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
qreshi authored Oct 26, 2020
1 parent 3dda54b commit 63801b8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import ManageEmailGroups from '../ManageEmailGroups';
import { validateEmailRecipients } from './utils/validate';
import { RECIPIENT_TYPE } from './utils/constants';
import getEmailGroups from './utils/helpers';
import { getAllowList } from '../../../utils/helpers';
import { DESTINATION_TYPE } from '../../../utils/constants';

export default class EmailRecipients extends React.Component {
constructor(props) {
Expand All @@ -33,13 +35,18 @@ export default class EmailRecipients extends React.Component {
recipientOptions: [],
isLoading: true,
showManageEmailGroupsModal: false,
allowList: [],
};

this.onClickManageEmailGroups = this.onClickManageEmailGroups.bind(this);
this.onClickCancel = this.onClickCancel.bind(this);
}

componentDidMount() {
async componentDidMount() {
const { httpClient } = this.props;
const allowList = await getAllowList(httpClient);
this.setState({ allowList });

this.loadData();
}

Expand Down Expand Up @@ -88,6 +95,11 @@ export default class EmailRecipients extends React.Component {
});
};

isEmailAllowed = () => {
const { allowList } = this.state;
return allowList.includes(DESTINATION_TYPE.EMAIL);
};

render() {
const { httpClient, type } = this.props;
const { recipientOptions, isLoading, showManageEmailGroupsModal } = this.state;
Expand Down Expand Up @@ -143,6 +155,7 @@ export default class EmailRecipients extends React.Component {

<ManageEmailGroups
httpClient={httpClient}
isEmailAllowed={this.isEmailAllowed()}
isVisible={showManageEmailGroupsModal}
onClickCancel={this.onClickCancel}
onClickSave={this.onClickSave}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { validateEmailSender } from './utils/validate';
import { isInvalid, hasError } from '../../../../../utils/validate';
import ManageSenders from '../ManageSenders';
import getSenders from './utils/helpers';
import { getAllowList } from '../../../utils/helpers';
import { DESTINATION_TYPE } from '../../../utils/constants';

export default class EmailSender extends React.Component {
constructor(props) {
Expand All @@ -31,14 +33,19 @@ export default class EmailSender extends React.Component {
senderOptions: [],
loadingSenders: true,
showManageSendersModal: false,
allowList: [],
};

this.onClickManageSenders = this.onClickManageSenders.bind(this);
this.onClickCancel = this.onClickCancel.bind(this);
this.onClickSave = this.onClickSave.bind(this);
}

componentDidMount() {
async componentDidMount() {
const { httpClient } = this.props;
const allowList = await getAllowList(httpClient);
this.setState({ allowList });

this.loadSenders();
}

Expand Down Expand Up @@ -72,6 +79,11 @@ export default class EmailSender extends React.Component {
});
};

isEmailAllowed = () => {
const { allowList } = this.state;
return allowList.includes(DESTINATION_TYPE.EMAIL);
};

render() {
const { httpClient, type } = this.props;
const { senderOptions, loadingSenders, showManageSendersModal } = this.state;
Expand Down Expand Up @@ -121,6 +133,7 @@ export default class EmailSender extends React.Component {

<ManageSenders
httpClient={httpClient}
isEmailAllowed={this.isEmailAllowed()}
isVisible={showManageSendersModal}
onClickCancel={this.onClickCancel}
onClickSave={this.onClickSave}
Expand Down

0 comments on commit 63801b8

Please sign in to comment.