Start Publish and API, open Publish, kill API, navigate to any collection list or document; you should see an error message.
Restart API and click "Try again" or navigate elsewhere and back; the collection/document loads.
Kill API and refresh Publish; you get the error message instead of the sign in screen.
Notes/explanations:
I tried to reuse mechanisms that exist or have existed in the code at some point, e.g. window.__api__window.__error__ and the api reducer to convey the API error from the backend to the frontend.
When you get a backend error (backend failed to connect in the first place), the "Try again" button reloads the page so that the backend gets a chance to load the data from API.
On frontend error (API failure while navigating to a collection/document) the "Try again" button didn't trigger refetch of data—it navigates to the same page it's already on, so the only thing that changes is the React Router location hash key. I refetch the data if the key changes. Edit: As per discussion with @eduardoboucas, the "Try again" button now flags the document or document list as dirty, forcing refetch.
ErrorView in App.js has to be wrapped in Router to be able to use the Link component.
I fixed an error where trying to delete documents while the API was down triggered a notification falsely informing of successful deletion.
Closes #713
To try out the fix:
Notes/explanations:
window.__api__
window.__error__
and theapi
reducer to convey the API error from the backend to the frontend.it navigates to the same page it's already on, so the only thing that changes is the React Router location hash key. I refetch the data if the key changes.Edit: As per discussion with @eduardoboucas, the "Try again" button now flags the document or document list as dirty, forcing refetch.App.js
has to be wrapped in Router to be able to use the Link component.