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

Feat/toast notification errors #281

Merged
merged 10 commits into from
Dec 7, 2020
Merged

Conversation

kwajiehao
Copy link
Contributor

@kwajiehao kwajiehao commented Dec 3, 2020

Overview

This PR resolves issue #279 by rendering error toast notifications, which first appeared in #247, when a user-triggered API call fails. The error toasts serve as a form of feedback to let the user know that their action has failed and informs them of other possible actions they could take (reload the page, check internet connection etc.).

Previously, we displayed error toasts when a user attempted to create/save a file but there already existed another file with the same file name (PR #247). This PR expands on that to display error toasts for all errors, not just for the cases where there is a file name conflict.

This PR also performs a minor bug fix where we attempt to access the status attribute of an error (err.response.status) in an attempt to display an error toast. This status attribute might not exist if the error object is not an HTTP error, which leads to an undefined attribute exception. This is resolved by using optional chaining.

The following list identifies the components and operations where the error toast notification gets displayed.

Components

ComponentSettingsModal

  • When a user changes the category dropdown (this triggers an API call to retrieve third nav options)
  • When a user attempts to save page settings
  • When a user attempts to delete the page

FolderCard

  • When a user attempts to delete a folder

FolderModal

  • When a user attempts to rename a folder

MediaSettingsModal

  • When a user attempts to save media (image/file)
  • When a user attempts to delete media

OverviewCard

  • When a user attempts to move a file
  • When a user attempts to delete a file

Layouts

EditHomepage

  • When a user attempts to save their homepage data

EditPage

  • When a user attempts to save page content
  • When a user attempts to delete page

Settings

  • When a user attempts to save their settings

Jie Hao Kwa added 10 commits December 3, 2020 23:43
This commit adds error toast notifications when the api call to
save or delete an image or file fails.
This commit adds error toast notifications when the api call to
save a repo's setting config fails.
This commit adds error toast notifications when the api call to rename
or to delete a folder (collection or resource category) fails
This commit adds error toast notifications when the api call to delete
or to move a page (normal page, collection page, or resource page) fails
This commit adds error toast notifications when the ComponentSettingsModal
tries but fails to retrieve page setting information. It also modifies the
component so that an error toast is displayed when the api call to save
page settings or to delete the page fails.
This commit adds an error toast when we fail to retrieve third nav
options in the ComponentSettingsModal
This commit adds error toasts when the api calls to save EditHomepage
fails, or when the api calls to save or delete the EditPage fails.
When handling errors in some cases, we attempt to check for a http
error response status. However, since the error might not come from
a http error, the `status` attribute might not be present in the error
object, which leads to an undefined attribute exception.

This commit fixes that bug by using optional chaining.
This commit modifies all applicable existing usage of the Toast
component to use the default error toast message that is now
defined as a constant in the main utils file. This is so that if
we need to reword our error message, we only need to do it in one
place, instead of in every single file.
Copy link
Contributor

@alexanderleegs alexanderleegs left a comment

Choose a reason for hiding this comment

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

lgtm

@kwajiehao kwajiehao merged commit 380e6b5 into staging Dec 7, 2020
@kwajiehao kwajiehao deleted the feat/toast-notification-errors branch December 7, 2020 05:36
@kwajiehao kwajiehao linked an issue Dec 7, 2020 that may be closed by this pull request
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.

Error-handling: toast notifications
2 participants