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

Migrate off paragon modal deprecated component #95

Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { Button, Modal } from '@edx/paragon';
import { ActionRow, Button, ModalDialog } from '@edx/paragon';
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import messages from './messages';
import { BulkEmailContext } from '../bulk-email-context';
Expand All @@ -12,10 +12,13 @@ function ViewEmailModal({
const [, dispatch] = useContext(BulkEmailContext);
return (
<div>
<Modal
open={isOpen}
title=""
body={(
<ModalDialog
isOpen={isOpen}
onClose={() => setModalOpen(false)}
hasCloseButton
>
<ModalDialog.Body>

<div>
<div className="d-flex flex-row">
<p>{intl.formatMessage(messages.modalMessageSubject)}</p>
Expand All @@ -40,24 +43,30 @@ function ViewEmailModal({
<div dangerouslySetInnerHTML={{ __html: messageContent.email.html_message }} />
</div>
</div>
)}
onClose={() => setModalOpen(false)}
buttons={[
<Button
onClick={() => {
dispatch(
copyToEditor({
emailBody: messageContent.email.html_message,
emailSubject: messageContent.subject,
}),
);
setModalOpen(false);
}}
>
<FormattedMessage id="bulk.email.tool.copy.message.button" defaultMessage="Copy to editor" />
</Button>,
]}
/>
</ModalDialog.Body>
<ModalDialog.Footer>
<ActionRow>
<ModalDialog.CloseButton variant="link">
<FormattedMessage id="bulk.email.tool.close.modalDialog.button" defaultMessage="Close" />
</ModalDialog.CloseButton>
<Button
onClick={() => {
dispatch(
copyToEditor({
emailBody: messageContent.email.html_message,
emailSubject: messageContent.subject,
}),
);
setModalOpen(false);
}}
variant="primary"
>
<FormattedMessage id="bulk.email.tool.copy.message.button" defaultMessage="Copy to editor" />

</Button>
</ActionRow>
</ModalDialog.Footer>
</ModalDialog>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const messages = defineMessages({
id: 'bulk.email.content.history.table.modal.messageBody',
defaultMessage: 'Message:',
},
modalCloseButton: {
id: 'bulk.email.tool.close.modalDialog.button',
defaultMessage: 'Close',
},
emailHistoryTableViewMessageInstructions: {
id: 'bulk.email.content.history.table.viewMessageInstructions',
defaultMessage: 'To read a sent email message, click the `View Message` button within the table.',
Expand Down