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

[dashboard] Implemented notification settings #3513

Merged
merged 1 commit into from
Mar 20, 2021

Conversation

svenefftinge
Copy link
Member

Fixes #3398

Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

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

Smoooooth! 🍦

Thanks @svenefftinge! The specs included a toast component for visual feedback on every change of the notifications settings, see #3398. Do we skip this for now?


function CheckBox(props: {title: string, desc: string, checked: boolean, onChange: () => void}) {
return <div className="flex mt-4">
<input className={"focus:ring-0 mt-1 rounded-sm cursor-pointer "+(props.checked?'bg-gray-800':'')} type="checkbox" checked={props.checked} onChange={props.onChange}/>
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Minor checkbox style. We're going to need hover, focus, and active states for the checkboxes and many other elements but let's leave this out of the scope of this iteration.

Suggested change
<input className={"focus:ring-0 mt-1 rounded-sm cursor-pointer "+(props.checked?'bg-gray-800':'')} type="checkbox" checked={props.checked} onChange={props.onChange}/>
<input className={"focus:ring-0 mt-1 rounded cursor-pointer border-2 "+(props.checked?'bg-gray-800':'')} type="checkbox" checked={props.checked} onChange={props.onChange}/>


function CheckBox(props: {title: string, desc: string, checked: boolean, onChange: () => void}) {
return <div className="flex mt-4">
<input className={"focus:ring-0 mt-1 rounded-sm cursor-pointer "+(props.checked?'bg-gray-800':'')} type="checkbox" checked={props.checked} onChange={props.onChange}/>
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: The checkbox should be 24x24 but this one suffices for now. Feel free to leave this as is.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried it, but it somehow looks way too large. Maybe something else is off in relation.

return <div>
<SettingsPage title='Notifications' subtitle='Email notification preferences'>
<h3>Notifications</h3>
<SettingsPage title='Notifications' subtitle='Choose when to be notified'>
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Minor punctuation update to align with the rest of the pages.

Suggested change
<SettingsPage title='Notifications' subtitle='Choose when to be notified'>
<SettingsPage title='Notifications' subtitle='Choose when to be notified.'>

function CheckBox(props: {title: string, desc: string, checked: boolean, onChange: () => void}) {
return <div className="flex mt-4">
<input className={"focus:ring-0 mt-1 rounded-sm cursor-pointer "+(props.checked?'bg-gray-800':'')} type="checkbox" checked={props.checked} onChange={props.onChange}/>
<div className="flex flex-col ml-2">
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Thanks for getting the margin in here!

Copy link
Contributor

@jankeromnes jankeromnes left a comment

Choose a reason for hiding this comment

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

Looks good to me! 🚀

Except the user should probably be (re-)fetched in the checkbox handlers (otherwise you risk overwriting other additionalData changes, see below).

components/dashboard/src/settings/Notifications.tsx Outdated Show resolved Hide resolved
<SettingsPage title='Notifications' subtitle='Email notification preferences'>
<h3>Notifications</h3>
<SettingsPage title='Notifications' subtitle='Choose when to be notified'>
<h3>Email Notification Preferences</h3>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<h3>Email Notification Preferences</h3>
<h3>Email notification preferences</h3>

Copy link
Contributor

@gtsiolis gtsiolis Mar 19, 2021

Choose a reason for hiding this comment

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

I think we are moving forward with Title Case, right? We can consider switching to Sentence case in the future. 🌽

Comment on lines +7 to +12
const ctx = useContext(UserContext);
const user = ctx.user;
const isTransactionalMail = !user?.additionalData?.emailNotificationSettings?.disallowTransactionalEmails;
const toggleTransactionalMail = async ()=>{
if (user) {
user.additionalData = {
Copy link
Contributor

@jankeromnes jankeromnes Mar 19, 2021

Choose a reason for hiding this comment

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

Maybe get user.additionalData inside the handlers?

Getting it outside of it means that you will overwrite any additionalData changes that happened between:

  • This component was rendered
  • A checkbox was ticked

Proof of concept: https://youtu.be/bYD8s3yivEw (my IDE change gets overwritten)

Copy link
Member Author

Choose a reason for hiding this comment

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

The user is cached within the app. So in order to solve the (unlikely) case that someone changes settings in two browser tabs, we'd need to fetch the user from the server before altering it.

@svenefftinge svenefftinge merged commit cd4d4e1 into dashboard-v2 Mar 20, 2021
@svenefftinge svenefftinge deleted the se/notifications branch March 20, 2021 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants