-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[QBD] Handle errors gracefully if the setup link cannot be obtained #51850
[QBD] Handle errors gracefully if the setup link cannot be obtained #51850
Conversation
if (response.jsonCode === CONST.JSON_CODE.SUCCESS) { | ||
setCodatSetupLink(String(response?.setupUrl ?? '')); | ||
} else { | ||
setConnectionError(policyID, CONST.POLICY.CONNECTIONS.NAME.QBD, translate('workspace.qbd.setupPage.setupErrorTitle')); |
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.
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.
Hi @hoangzinh, we do not send via Pusher this error, it is returned instead in the response's body on the PHP side.
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.
Then, I guess I have to set optimistic error here
setupErrorTitle: '¡Ups! Ha ocurrido un error', | ||
setupErrorBody1: 'La conexión con QuickBooks Desktop no está funcionando en este momento. Por favor, inténtalo de nuevo más tarde o', | ||
setupErrorBody2: 'si el problema persiste.', | ||
setupErrorBodyContactConcierge: 'contacta con Concierge', |
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.
Translation confirmation: https://expensify.slack.com/archives/C01GTK53T8Q/p1730714116839409
@ZhenjaHorbach Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@lakchote currently, I have to mock the response body in order to test this PR. If you can give us a test in your local with a real mock BE error response, that would be great. |
Reviewer Checklist
Screenshots/VideosAndroid: NativeNA Android: mWeb ChromeNA iOS: NativeNA iOS: mWeb SafariNA MacOS: Chrome / Safariweb.movMacOS: Desktop2024-11-06.10.01.35.mov |
You have what is being returned e.g a real response in the related issue. Is that what you meant? |
@hoangzinh 2024-11-05.17.44.09.movAnd I suppose we shouldn't have access to options (import, export, advanced) |
connections: { | ||
[connectionName]: { | ||
lastSync: { | ||
isSuccessful: false, |
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 think we can add isConnected
: false or changeisSuccessful
toisConnected
here to not show options
App/src/libs/actions/connections/index.ts
Lines 314 to 328 in 955872a
function isConnectionUnverified(policy: OnyxEntry<Policy>, connectionName: PolicyConnectionName): boolean { | |
// A verified connection is one that has been successfully synced at least once | |
// We'll always err on the side of considering a connection as verified connected even if we can't find a lastSync property saying as such | |
// i.e. this is a property that is explicitly set to false, not just missing | |
if (connectionName === CONST.POLICY.CONNECTIONS.NAME.NETSUITE) { | |
return !(policy?.connections?.[CONST.POLICY.CONNECTIONS.NAME.NETSUITE]?.verified ?? true); | |
} | |
// If the connection has no lastSync property, we'll consider it unverified | |
if (isEmptyObject(policy?.connections?.[connectionName]?.lastSync)) { | |
return true; | |
} | |
return !(policy?.connections?.[connectionName]?.lastSync?.isConnected ?? true); | |
} |
const shouldHideConfigurationOptions = isConnectionUnverified(policy, connectedIntegration); |
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.
@ZhenjaHorbach do you mean BE (Pusher event) sent isConnected=true
in your case?
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.
No
When we have an error
We don't receive anything
But in case an error we save in Onyx this using setConnectionError
lastSync: {
"isSuccessful": false,
"errorDate": "2024-11-06T06:20:52.757Z",
"errorMessage": "Something went wrong"
}
As result we return false here
App/src/libs/actions/connections/index.ts
Lines 314 to 328 in 955872a
function isConnectionUnverified(policy: OnyxEntry<Policy>, connectionName: PolicyConnectionName): boolean { | |
// A verified connection is one that has been successfully synced at least once | |
// We'll always err on the side of considering a connection as verified connected even if we can't find a lastSync property saying as such | |
// i.e. this is a property that is explicitly set to false, not just missing | |
if (connectionName === CONST.POLICY.CONNECTIONS.NAME.NETSUITE) { | |
return !(policy?.connections?.[CONST.POLICY.CONNECTIONS.NAME.NETSUITE]?.verified ?? true); | |
} | |
// If the connection has no lastSync property, we'll consider it unverified | |
if (isEmptyObject(policy?.connections?.[connectionName]?.lastSync)) { | |
return true; | |
} | |
return !(policy?.connections?.[connectionName]?.lastSync?.isConnected ?? true); | |
} |
and show options
const shouldHideConfigurationOptions = isConnectionUnverified(policy, connectedIntegration); |
...(isEmptyObject(policy?.connections) || shouldHideConfigurationOptions ? [] : configurationOptions), |
For example when we have correct response with setupLink we save "isConnected": false in Onyx and don't show options because shouldHideConfigurationOptions === true
lastSync: {
"errorDate": "",
"errorMessage": "",
"isAuthenticationError": false,
"isConnected": false,
"isSuccessful": false,
"source": "",
"successfulDate": ""
}
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.
ah I see. Good catch
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.
Updated here 1dc585e
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.
Thanks !
@lakchote Not really, I mean, somehow hard-coded 666 error (setup URL not found) in the local BE, to test if it shows correctly in the FE. |
@ZhenjaHorbach it's weird. If the syncConnection hasn't been called yet, it won't be showed something like that. |
Now everything looks good ! 2024-11-06.10.01.35.mov |
LGTM ! |
Tests well too. Thanks @hoangzinh @ZhenjaHorbach. Screen.Recording.2024-11-06.at.10.17.00.mov |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/lakchote in version: 9.0.59-0 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 9.0.59-3 🚀
|
Explanation of Change
Fixed Issues
$ #51640
PROPOSAL:
Tests
Offline tests
QA Steps
Same as above
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
N/A
Android: mWeb Chrome
N/A
iOS: Native
N/A
iOS: mWeb Safari
N/A
MacOS: Chrome / Safari
Screen.Recording.2024-11-05.at.17.44.11.mov
MacOS: Desktop
Screen.Recording.2024-11-05.at.17.54.44.mov