Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: turn off notification via email#14520

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 9 commits intocoder:mainfromjoobisb:email-notification-disable
Sep 11, 2024

Conversation

joobisb
Copy link
Contributor

@joobisbjoobisb commentedSep 1, 2024
edited
Loading

This PR addresses#14389

As seen in the attached images, users will receive an option sayingStop receiving emails like this. On clicking, the user will be redirected to notification settings and the template of that particular notification type will be disabled.

image
image

@cdr-botcdr-botbot added the communityPull Requests and issues created by the community. labelSep 1, 2024
@github-actionsGitHub Actions
Copy link

github-actionsbot commentedSep 1, 2024
edited
Loading

All contributors have signed the CLA ✍️ ✅
Posted by theCLA Assistant Lite bot.

@joobisb
Copy link
ContributorAuthor

I have read the CLA Document and I hereby sign the CLA

cdrcommunity added a commit to coder/cla that referenced this pull requestSep 1, 2024
@joobisb
Copy link
ContributorAuthor

@dannykopping@stirby could you please have a look at this PR

stirby reacted with thumbs up emoji

Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

This is great work@joobisb 👍

I think we should probably add a frontend test as well, and show a message to the user which template was disabled by highlighting it.

A few notes but nothing major.
Thank you for your contribution! 🎉

joobisb reacted with thumbs up emoji
@joobisb
Copy link
ContributorAuthor

This is great work@joobisb 👍

I think we should probably add a frontend test as well, and show a message to the user which template was disabled by highlighting it.

A few notes but nothing major. Thank you for your contribution! 🎉

@dannykopping I could not see tests related to theNotificationsPage. If there are any, could you point me to where to add them?

Apart from that, the rest of the comments are addressed, please have a look.

@dannykopping
Copy link
Contributor

@dannykopping I could not see tests related to theNotificationsPage. If there are any, could you point me to where to add them?

@BrunoQuaresma can assist with that, I'm not too familiar with our frontend I'm afraid.

joobisb reacted with thumbs up emoji

@@ -60,6 +62,41 @@ export const NotificationsPage: FC = () => {
const updatePreferences = useMutation(
updateUserNotificationPreferences(user.id, queryClient),
);
const [searchParams] = useSearchParams();
const templateId = searchParams.get("disabled");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would rename this to something like 'disabledId' to make it clearer about its usage.

joobisb reacted with thumbs up emoji
Comment on lines 74 to 96
const disableTemplate = async (templateId: string) => {
try {
await updatePreferences.mutateAsync({
template_disabled_map: {
[templateId]: true,
},
});

const allTemplates = Object.values(templatesByGroup.data ?? {}).flat();
const template = allTemplates.find((t) => t.id === templateId);

if (!template) {
throw new Error(`Template with ID ${templateId} not found`);
}

displaySuccess(`${template.name} notification has been disabled`);

queryClient.invalidateQueries(
userNotificationPreferences(user.id).queryKey,
);
} catch (error) {
console.error(error);
displayError("Error on disabling notification");
Copy link
Collaborator

@BrunoQuaresmaBrunoQuaresmaSep 3, 2024
edited
Loading

Choose a reason for hiding this comment

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

I believe that moving thedisableTemplate mutation inside thequeries/notifications would improve the readability of the view. This approach aligns with the pattern we've been using in the UI, where all "server data" is handled in the queries module. Eg.:

constqueryClient=useQueryClient()constdisableMutation=useMutation(disableNotification(userId,queryClient))useEffect(()=>{try{disableMutation.mutateAsync().then(()=>{displaySuccess("...")}).catch(()=>{displayError("...")})}},[...])

joobisb reacted with thumbs up emoji
Copy link
Collaborator

Choose a reason for hiding this comment

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

I need to remember to check for the following scenarios:

  1. When a valid template ID is disabled and the request is successful, check if the success message is displayed. Also, ensure that the UI is updated correctly. Verify if the request is being sent properly. Additionally, confirm if the error message is displayed when the request fails.

  2. When a not found template ID is disabled, check if an error message is displayed.

You can check how we do that usingStorybook interaction tests on theNotificationsPage.stories.tsx.

joobisb reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I have verified these scnearios

Copy link
Contributor

Choose a reason for hiding this comment

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

@joobisb can you add a test please? Manual verification is good but it only helps us know if this works currently, and doesn't catch future degradations.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@joobisb we are close, we just need to automate these tests using the way I shared before. Thanks for your hard work! 🙏

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@BrunoQuaresma the tests needed to be added toNotificationsPage.stories.tsx right ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@joobisb we are close, we just need to automate these tests using the way I shared before. Thanks for your hard work! 🙏

done, please have a look

Copy link
Collaborator

@BrunoQuaresmaBrunoQuaresma left a comment

Choose a reason for hiding this comment

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

@joobisb good work! I just left a few comments but let me know if you need any extra explanation or help. Thank you!

joobi-keyvalue reacted with thumbs up emoji
@stirby
Copy link
Collaborator

@joobisb, thanks for submitting this! The copy looks fine to me. Leaving approval to Danny and Bruno.

joobi-keyvalue reacted with thumbs up emoji

@joobisb
Copy link
ContributorAuthor

@joobisb good work! I just left a few comments but let me know if you need any extra explanation or help. Thank you!

@BrunoQuaresma

I have addressed the comments. Could you please take a look?

@BrunoQuaresma
Copy link
Collaborator

@joobisb great! I will check the chromatic result in a few minutes when it is ready. If everything is okay, I will approve it. ✅

@BrunoQuaresma
Copy link
Collaborator

@joobisb, it seems like the tests you wrote in the storybook are failing. Have you had a chance to check them locally?

@joobisb
Copy link
ContributorAuthor

@joobisb, it seems like the tests you wrote in the storybook are failing. Have you had a chance to check them locally?

@BrunoQuaresma
Yeah, it's failing mostly due to issues with testinguseEffect. I tried a few things, but they didn't work. I'm not that familiar with the front end. Do you have any test cases that I can refer to for such scenarios?

@BrunoQuaresma
Copy link
Collaborator

@joobisb I think we solved some of those errors last week. Could you please update this branch with the main please? 🙏

@BrunoQuaresma
Copy link
Collaborator

I will try to make some time today to look at the code and see how I can help.

joobisb reacted with thumbs up emoji

@joobisb
Copy link
ContributorAuthor

I will try to make some time today to look at the code and see how I can help.

@BrunoQuaresma I've updated the branch with main

@BrunoQuaresma
Copy link
Collaborator

@joobisb we are good! Thanks for all your contributions. I pushed two commits to simplify the effect and messages a bit, and another to fix the stories. Please, let me know if you have any questions about them.

@BrunoQuaresmaBrunoQuaresma merged commit3301212 intocoder:mainSep 11, 2024
29 checks passed
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsSep 11, 2024
@joobisbjoobisb deleted the email-notification-disable branchSeptember 11, 2024 16:21
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dannykoppingdannykoppingdannykopping left review comments

@BrunoQuaresmaBrunoQuaresmaBrunoQuaresma approved these changes

Assignees

@joobisbjoobisb

Labels
communityPull Requests and issues created by the community.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@joobisb@dannykopping@stirby@BrunoQuaresma

[8]ページ先頭

©2009-2025 Movatter.jp