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

John conroy/fix protocols errors HMP-306 #3200

Merged
merged 8 commits into from
Jul 26, 2023

Conversation

john-conroy
Copy link
Collaborator

@john-conroy john-conroy commented Jul 26, 2023

Fixes the handling of loading and errors for protocols.io requests in protocols section. Previously the non-200s were not being treated as errors and the resulting display matches what is shown in https://hms-dbmi.atlassian.net/browse/HMP-306. That being said, the requests were only failing locally due to our out of date app.conf files. Requests on PROD should work.

I'm not sure if the mismatched key passed to protocolsContext in Providers would have caused any issues ( it does not seem like we're using this context anywhere?), but I fixed it to match the types defined in ProctocolAPIContext. Should typescript have picked this up?

I've also added HelpLink to be used throughout the application. I've filed https://hms-dbmi.atlassian.net/browse/HMP-307.

200

Screen Shot 2023-07-26 at 11 21 26 AM

Non-200

Screen Shot 2023-07-26 at 11 21 52 AM

@john-conroy john-conroy changed the title John conroy/fix protocols errors John conroy/fix protocols errors HMP-306 Jul 26, 2023
@john-conroy john-conroy marked this pull request as ready for review July 26, 2023 15:36
@john-conroy
Copy link
Collaborator Author

@NickAkhmetov am I missing any typescript bits in context/app/static/js/shared-styles/Links/HelpLink.tsx?

@NickAkhmetov
Copy link
Collaborator

Great work, I like this approach!

My only idea for potentially improving this further would be to also allow a custom error message function to be passed which would allow us to provide more in-depth error messages depending on the received response; e.g., it might be more informative to the user to display different error messages for 401/403/404s, or handle custom error messages inside response bodies when APIs don’t conform to standard status codes (protocols doesn’t throw 403s for unauthorized access, for example.) However, we can add that functionality at a later time, so it’s not a blocking issue whatsoever.

import React from 'react';
import EmailIconLink from 'js/shared-styles/Links/iconLinks/EmailIconLink';

function HelpLink(props) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

am I missing any typescript bits in context/app/static/js/shared-styles/Links/HelpLink.tsx?

Technically in the future we'd want to define the types for the component props, but since these are being passed through to another component with unknown props, we can leave them as any for the time being and define them once we have a definition for the prop types of EmailIconLink.

I think you could define the prop type for this right now as Omit<typeof React.ComponentProps<EmailIconLink>, 'email'> but I can't be certain on the go :)

@john-conroy john-conroy merged commit 8c39919 into main Jul 26, 2023
8 checks passed
@john-conroy john-conroy deleted the john-conroy/fix-protocols-errors branch July 26, 2023 19:26
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.

2 participants