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

feat: same titles for sent email groups #205

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

khudym
Copy link

@khudym khudym commented Jul 3, 2024

Description

  • this PR proposes making the display of mail recipients the same for all places (checkbox labels, Send email alert modal, Scheduled emails table with View Modal, Email Task History)

Related Pull Requests
PR to the open-release/redwood.master branch: #207
PR to the open-release/quince.master branch: #206

Steps to reproduce

click on "Staff/Administrators" checkbox -> complete the form (subject, body) -> options:

  • to see recipients titles in "Caution" modal, click on "Send email" button
  • same if you schedule day and time and click on "Schedule email" button
    (in this modal you can see the difference between recipients titles and selected checkbox label)

-> click "Continue" button -> wait for the "Scheduled emails" table to load and also compare titles in "Send to" column

BEFORE

Example with selected "Staff/Administrators"

Знімок екрана 2023-10-24 о 18 00 15

Знімок екрана 2023-10-24 о 18 00 28

Screenshot 2024-07-03 at 23 57 31

Знімок екрана 2023-10-24 о 18 02 22

Example with selected "All Learners"


Знімок екрана 2023-10-24 о 18 33 10

Знімок екрана 2023-10-24 о 18 32 57

Screenshot 2024-07-04 at 00 28 05

Знімок екрана 2023-10-24 о 18 33 16

AFTER

Screenshot 2024-07-04 at 19 16 46 Screenshot 2024-07-04 at 19 15 34 Screenshot 2024-07-04 at 19 19 17 Screenshot 2024-07-04 at 19 23 00 Screenshot 2024-07-04 at 19 22 31

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 3, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Jul 3, 2024

Thanks for the pull request, @khudym!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/committers-frontend. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@khudym khudym force-pushed the hudym/different-titles-for-email-groups branch from e6c995f to a3da16d Compare July 3, 2024 22:12
Copy link

codecov bot commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.40%. Comparing base (10f906b) to head (62debac).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #205      +/-   ##
==========================================
+ Coverage   83.26%   83.40%   +0.14%     
==========================================
  Files          47       50       +3     
  Lines         693      699       +6     
  Branches      135      134       -1     
==========================================
+ Hits          577      583       +6     
  Misses        116      116              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@khudym khudym marked this pull request as ready for review July 4, 2024 16:42
@mphilbrick211 mphilbrick211 requested a review from a team July 16, 2024 20:22
Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

I'm not very familiar with this code, but I took a pass over this for you. In the future, I'd recommend waiting until the master PR has been reviewed and merged before you open the backport PRs.

@@ -219,7 +220,7 @@ function BulkEmailForm(props) {
<p>{intl.formatMessage(messages.bulkEmailTaskAlertRecipients, { subject: editor.emailSubject })}</p>
<ul className="list-unstyled">
{editor.emailRecipients.map((group) => (
<li key={group}>{group}</li>
<li key={group}>{getDisplayTextFromRecipient(group)}</li>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not going to be internationalized, if I'm understanding this correctly.

You need to either:

  1. Make getDisplayTextFromRecipient(group) return a <FormattedMessage /> component, or
  2. Make getDisplayTextFromRecipient(group) return a MessageDescriptor and then pass that to intl.formatMessage(...) as seen three lines above.

Copy link
Contributor

Choose a reason for hiding this comment

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

I completely agree with you. Correct wrapper for localization has been added.

@@ -41,7 +42,7 @@ export default function BulkEmailRecipient(props) {
<Form.Checkbox key="myself" value="myself" className="mt-2.5 col col-lg-4 col-sm-6 col-12">
<FormattedMessage
id="bulk.email.form.recipients.myself"
defaultMessage="Myself"
defaultMessage={RECIPIENTS_DISPLAY_NAMES.myself}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure but I think setting defaultMessage to a constant like this is going to break the extraction of strings for localization. In addition, it looks confusing because it looks like it's maybe a dynamic defaultMessage. Instead, all parts of this message descriptor (the id, the defaultMessage, and the description) should be put into a messages file and then you can just reference it here as <FormattedMessage {...messages.recipientMyself} />

Copy link
Contributor

Choose a reason for hiding this comment

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

Refactored according to new solution

export const RECIPIENTS_DISPLAY_NAMES = {
myself: 'Myself',
staff: 'Staff and instructors',
learners: 'All students',
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we generally prefer the term "Learner" to "Student" so this seems like a step backwards ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. It should be Learner instead of Student

fireEvent.click(screen.getByRole('checkbox', { name: 'Myself' }));
expect(screen.getByRole('checkbox', { name: 'Myself' })).toBeChecked();
fireEvent.click(screen.getByRole('checkbox', { name: RECIPIENTS_DISPLAY_NAMES.myself }));
expect(screen.getByRole('checkbox', { name: RECIPIENTS_DISPLAY_NAMES.myself })).toBeChecked();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: It's fine to hard-code strings in test files; it makes it easier to see when you've accidentally changed something, like accidentally setting the value of RECIPIENTS_DISPLAY_NAMES.myself to "Learners".

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sense, thank you for notice that. I'll revert these changes for tests.

@@ -44,8 +45,8 @@ function BulkEmailScheduledEmailsTable({ intl }) {
const [currentTask, setCurrentTask] = useState({});

useEffect(() => {
setTableData(flattenScheduledEmailsArray(scheduledEmailsTable.results));
}, [scheduledEmailsTable.results]);
setTableData(flattenScheduledEmailsArray(scheduledEmailsTable.results, courseModes));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the addition of courseModes to this table. It's not mentioned in the PR description nor seems to be used anywhere ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I also didn't find usage of courseModes and remove it here.

@@ -96,7 +97,7 @@ function BulkEmailScheduledEmailsTable({ intl }) {
},
} = row;
const dateTime = new Date(taskDueUTC);
const emailRecipients = targets.replaceAll('-', ':').split(', ');
const emailRecipients = targets.replaceAll('-', ':').split(', ').map(getRecipientFromDisplayText);
Copy link
Contributor

Choose a reason for hiding this comment

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

Reversing the "display text" like this is not a very robust solution. Can you just modify flattenScheduledEmailsArray so that it stores both the email.courseEmail.targets IDs and the display text on row.original ? Then you won't have to do this reversing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Simplified by adding a targetsText values to the flattenScheduledEmailsArray data

@mphilbrick211
Copy link

@khudym hi there! Just checking in to see if this is still in-progress?

@ihor-romaniuk
Copy link
Contributor

@mphilbrick211 The code has been refactored according to the comments after the review. Thank you for your friendly ping.

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

Thanks for those changes. This looks fine to me (besides one last suggestion), but I'm not familiar with this app and don't know how to test it. @mphilbrick211 Is someone else able to finish this review? I was just trying to help with some suggestions, not take on the review myself.

src/components/bulk-email-tool/utils.js Outdated Show resolved Hide resolved
Co-authored-by: Braden MacDonald <mail@bradenm.com>
@mphilbrick211
Copy link

@openedx/committers-frontend - is someone able to finish this review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested open-source-contribution PR author is not from Axim or 2U
Projects
Status: In Eng Review
Development

Successfully merging this pull request may close these issues.

5 participants