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

Multiple notification channels #899

Merged
merged 25 commits into from
Sep 12, 2023
Merged

Conversation

binh-dam-ibigroup
Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup commented May 12, 2023

Description

Requires ibi-group/otp-middleware#185.

This PR adds push notifications as an option, describing the number of push devices registered, and allows setting multiple notification channels.

PR Checklist

  • Does the code follow accessibility standards (WCAG 2.1 AA Compliant)? => aria-describedby used with labels for each notification channel.
  • Are all languages supported (Internationalization/Localization)? => i18n supported but not all languages are filled.
  • Are appropriate Typescript types implemented?
Before After
Before After

onRequestPhoneVerificationCode: PhoneCodeRequestHandler
onSendPhoneVerificationCode: PhoneVerificationSubmitHandler
phoneFormatOptions: {
countryCode: string
}
}

const allowedNotificationChannels = ['email', 'sms', 'none']
const allowedNotificationChannels = ['email', 'sms', 'push']

Choose a reason for hiding this comment

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

Are we to depend on an absence of channels rather than 'none', with this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the value is 'none' as in the current implementation (or no known value is present), no options will be checked. Now, if no options are checked, should we send '' or 'none' to the server?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looking at ibi-group/otp-middleware#185, it seems like either way is possible, however I would side with sending an empty string.

@binh-dam-ibigroup binh-dam-ibigroup marked this pull request as ready for review August 15, 2023 20:39
Copy link
Contributor

@amy-corson-ibigroup amy-corson-ibigroup left a comment

Choose a reason for hiding this comment

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

A couple of small things but largely I think it looks good and seems to work well, pending push notification support from the middleware and mobile apps!

Comment on lines 88 to 90
<label htmlFor={inputId}>
<FormattedMessage id="common.notifications.email" />
) : type === 'sms' ? (
</label>
Copy link
Contributor

@amy-corson-ibigroup amy-corson-ibigroup Aug 22, 2023

Choose a reason for hiding this comment

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

Might be a bit cleaner to move the label out of these blocks, and conditionally render the i18n id (so you only have this once)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea! Updated in 9ae5bfd. It also unveiled an oversight in TripNotificationsPane that I fixe with bf54d58.

const inputId = `notification-channel-${type}`
const inputDescriptionId = `${inputId}-description`
return (
<NotificationOption key={type}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these options be in a <ul>?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The checkboxes are already in a <fieldset>, which is an ARIA group, and it you can simply place input controls in there, see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldset.

Copy link
Contributor

@daniel-heppner-ibigroup daniel-heppner-ibigroup left a comment

Choose a reason for hiding this comment

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

My big question is here is about the push notifications showing up for OTP-RR deployments with no mobile app. I'm worried about the implication of a mobile app existing if a user sees "Register your device using the mobile app" when it doesn't exist for them.

Related to design, I think there is too much vertical space around the phone number options, which makes it easy to miss the push notifications checkbox entirely. I think that's especially the case in your screenshot with more stuff going on. (GitHub won't let me upload a screenshot... will try again later)

@@ -22,91 +21,97 @@ interface Props extends FormikProps<User> {
}
}

const allowedNotificationChannels = ['email', 'sms', 'none']
const allowedNotificationChannels = ['email', 'sms', 'push']
Copy link
Contributor

Choose a reason for hiding this comment

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

If a particular deployment of OTP-RR doesn't have a mobile app, should the push notification option still appear?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very good point. I have added a config parameter in 6954113.

if (
typeof notificationChannel === 'object' &&
typeof notificationChannel.length === 'number'
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There are scenarios where the notificationChannel could be a comma separated string still? Is that in case the user hasn't updated their choice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The selected channels are persisted by OTP-middleware as a comma-separated string, see https://github.com/ibi-group/otp-middleware/blob/be241ed8e284281eb6420adb419a7a030c23d297/src/main/java/org/opentripplanner/middleware/models/OtpUser.java#L43, so compatibility with existing accounts is maintained.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OTP-middleware handles the conversion so it returns an array to the UI.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, sounds good.

@binh-dam-ibigroup
Copy link
Collaborator Author

binh-dam-ibigroup commented Aug 31, 2023

Related to design, I think there is too much vertical space around the phone number options, which makes it easy to miss the push notifications checkbox entirely.

@daniel-heppner-ibigroup I tried adding visual grouping in 344442f. What do you think? (see updated screenshot)

Copy link
Contributor

@daniel-heppner-ibigroup daniel-heppner-ibigroup left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, but this looks good! Thank you!

@binh-dam-ibigroup binh-dam-ibigroup added the BLOCKED Blocked (waiting on another PR to be merged) label Sep 6, 2023
@binh-dam-ibigroup binh-dam-ibigroup merged commit 2ea4ded into dev Sep 12, 2023
5 checks passed
@binh-dam-ibigroup binh-dam-ibigroup deleted the multiple-notification-channels branch September 12, 2023 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLOCKED Blocked (waiting on another PR to be merged)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants