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
(fix) O3-2768: Display error in case there are no locations #906
base: main
Are you sure you want to change the base?
(fix) O3-2768: Display error in case there are no locations #906
Conversation
This looks ok. Instead of manually rendering a toast (which ends up with a slightly weird UX, use the framework's |
@ibacher I have applied the changes as requested and also updated the video above to show the current state of things. |
packages/apps/esm-login-app/src/location-picker/location-picker.component.tsx
Outdated
Show resolved
Hide resolved
packages/apps/esm-login-app/src/location-picker/location-picker.component.tsx
Outdated
Show resolved
Hide resolved
packages/apps/esm-login-app/src/location-picker/location-picker.component.tsx
Outdated
Show resolved
Hide resolved
packages/apps/esm-login-app/src/location-picker/location-picker.component.tsx
Outdated
Show resolved
Hide resolved
0c4b494
to
20b5222
Compare
packages/apps/esm-login-app/src/location-picker/location-picker.component.tsx
Outdated
Show resolved
Hide resolved
packages/apps/esm-login-app/src/location-picker/location-picker.component.tsx
Outdated
Show resolved
Hide resolved
packages/apps/esm-login-app/src/location-picker/location-picker.component.tsx
Outdated
Show resolved
Hide resolved
packages/apps/esm-login-app/src/location-picker/location-picker.component.tsx
Outdated
Show resolved
Hide resolved
Done with the changes as requested @ibacher |
Sorry I'm getting to this late @trevor-james-nangosha @ibacher, but this is a mockup that Ciaran's thrown together for what this error notification could look like: You could imagine this appearing in place of the search bar in case no locations are configured. Should we just show a subtitle instead of the reload button with something along the lines of |
Maybe have a subtitle that says "If the issue persists please contact your administrator" and leave the refresh button? |
Would clicking the |
Presumably we could just call the mutator for SWR rather than doing a full page reload? This isn't a "component is broken" error, just a "data is missing error". @trevor-james-nangosha To answer you're question from Slack, the image is just a sketch to show the inline notification. Leave the rest of the elements on the page. |
packages/apps/esm-login-app/src/location-picker/location-picker.component.tsx
Outdated
Show resolved
Hide resolved
Isn't the fallback for no locations is to Login without a location? As I can remember that's how the location picker was written. |
title: t('error', 'Error'), | ||
kind: 'error', | ||
description: 'No locations were found for this system. Please contact your administrator', | ||
}); | ||
changeLocation(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to call this function, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, did not see that. Will remove it!! Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jayasanka-sack @vasharma05 What's up with this, should we remove this function call?
I think that was what was originally implemented just to get something in. Most of the code in various places assumes that there's a session location and, while the backend technically supports logins without locations, the RefApp hasn't since O2. Looking at this from a slightly different angle: we can either stop the user up-front with no locations or we can write tests for every place that accesses the session location to ensure they continue to function if there is no location available. |
I do think this may be worth a follow-up discussion to confirm that we definitely want to make session location required in esm-core and the location picker, rather than just configured to be required within the refapp implementation of O3. |
use showToast instead of showNotification for error
5488a67
to
23727dd
Compare
Great job @trevor-james-nangosha but I think I think if the locations don't load the confirm button should not show neither should the checker for remember my location. |
@@ -16,6 +16,7 @@ import { useLoginLocations } from '../login.resource'; | |||
import styles from './location-picker.scss'; | |||
import { useDefaultLocation } from './location-picker.resource'; | |||
import type { ConfigSchema } from '../config-schema'; | |||
import { Snackbar } from '@openmrs/esm-styleguide/src/snackbars/snackbar.component'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { showSnackbar } from "@openmrs/esm-framework"
|
||
const referrer = state?.referrer; | ||
const returnToUrl = new URLSearchParams(location?.search).get('returnToUrl'); | ||
|
||
const sessionDefined = locationUuid ? setSessionLocation(locationUuid, new AbortController()) : Promise.resolve(); | ||
const sessionDefined = locationUuid ? setSessionLocation(locationUuid, new AbortController()) : Promise.reject(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have the check above for undefined/null locationUuid, why add this unnecessary promise here?
<Snackbar | ||
snackbar={{ | ||
id: 1, | ||
actionButtonLabel: t('reload', 'Reload'), | ||
onActionButtonClick: () => mutate(), | ||
kind: 'error', | ||
title: t('locationsFailedToLoad', 'Locations failed to load'), | ||
subtitle: t( | ||
'locationIssueContactAdministrator', | ||
'If the issue persists please contact your administrator', | ||
), | ||
}} | ||
closeSnackbar={() => {}} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snackbar is a notification, it's not a component to be shown in place of search.
Please read here for more info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use an ActionableSnackbar, using the props actionButtonLabel
and onActionButtonClick
in the showSnackbar
. Learn more about showSnackbar
here:
export function showSnackbar(snackbar: SnackbarDescriptor) { |
if (!locations?.length) { | ||
changeLocation(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!error && !locations?.length) {
changeLocation();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibacher, do we have any implementation at all where there are no locations?
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not impossible, but I would say that that's a configuration error. Every functioning OMRS system should have at least one location.
…into issueO3_2768
Re-requesting review from @ibacher @samuelmale @denniskigen. |
@@ -20,6 +20,7 @@ export const coreTranslations = { | |||
change: 'Change', | |||
close: 'Close', | |||
confirm: 'Confirm', | |||
contactAdministratorIfIssuePersists: 'If the problem persists contact your system administrator.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contactAdministratorIfIssuePersists: 'If the problem persists contact your system administrator.', | |
contactAdministratorIfIssuePersists: 'Contact your system administrator if the problem persists.', |
I thought the design there was just a sketch of the notification, not a full screen preview. I kind of prefer it with the "Welcome" block because it makes it look more like what it is (an unexpected error in one part of the system) rather than just a basically blank page. |
That makes sense, thanks @ibacher . I think you're right. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have only minor feedback; feel free to ship this when you feel happy with it @vasharma05 .
Requirements
feat
,fix
, orchore
, among others). See existing PR titles for inspiration.For changes to apps
If applicable
Summary
This issue makes sure that an error is shown when no locations are returned from the backend on the location-selection screen
Screenshots
This is a small video that shows what happens in the aforementioned case. I would like to know if I am on the right track, or if I could possibly make some changes. @denniskigen
OpenMRS.-.Google.Chrome.2024-02-02.15-27-28.mp4
Related Issue
Issue is here
Other