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

Errors: Banner message for error loading data on My Store dashboard #4704

Merged
merged 14 commits into from
Aug 3, 2021

Conversation

rachelmcr
Copy link
Contributor

@rachelmcr rachelmcr commented Jul 30, 2021

Resolves: #4382

Description

To improve our error states, we are introducing a top banner that can be used whenever there is a problem loading data. The banner is collapsed by default and on select, users can read our troubleshooting tips or contact support directly.

This PR sets up the banner and adds it to the top of the My Store screen. (This banner replaces the "Unable to load content" notice we displayed before.)

Changes

  • Adds the error banner to DashboardViewController. A quick overview of the changes there:
    • Currently we display the store name in a stack view at the top of the screen, as long as shouldShowStoreNameAsSubtitle is true. The store name is now embedded inside another stack view, to retain its leading margin. (That margin is now defined with a constant equivalent to the margins it had before.)
    • If shouldShowStoreNameAsSubtitle is false, the stack view is added when the banner is displayed, with all necessary constraints. (Those constraints are otherwise set when the subtitle is configured and the dashboard UI is added below it).
  • The error banner is displayed when there is a syncing error, and hidden when the screen refreshes.
My Store - no errors My Store - error banner collapsed My Store - error banner expanded
Simulator Screen Shot - iPhone 11 Pro - 2021-07-30 at 13 14 40 Simulator Screen Shot - iPhone 11 Pro - 2021-07-30 at 13 14 49 Simulator Screen Shot - iPhone 11 Pro - 2021-07-30 at 13 14 51

Testing

  1. Build and run the app.
  2. Disconnect your internet connection. (This is so you will trigger a sync error; you can also disrupt your store's Jetpack connection for a more realistic scenario.)
  3. Pull to refresh the My Store screen.
  4. Notice the error banner appears at the top of the screen, below your store name, and remains on screen when you scroll.
  5. Reconnect to the internet.
  6. Expand the banner and confirm the "Troubleshoot" button opens a troubleshooting doc, and "Contact support" opens a new support ticket in the app.
  7. Pull to refresh or navigate to another tab and back to refresh the My Store screen. Notice the error banner disappears on refresh.

Submitter Checklist

Update release notes:

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@rachelmcr rachelmcr added type: enhancement A request for an enhancement. feature: stats Related to stats, including Top Performers. labels Jul 30, 2021
@rachelmcr rachelmcr added this to the 7.3 milestone Jul 30, 2021
@peril-woocommerce
Copy link

peril-woocommerce bot commented Jul 30, 2021

You can trigger an installable build for these changes by visiting CircleCI here.

@peril-woocommerce
Copy link

peril-woocommerce bot commented Jul 30, 2021

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@rachelmcr rachelmcr marked this pull request as ready for review July 30, 2021 15:31
@rachelmcr rachelmcr requested a review from a team July 30, 2021 15:31
@itsmeichigo itsmeichigo self-assigned this Aug 2, 2021
Copy link
Contributor

@itsmeichigo itsmeichigo left a comment

Choose a reason for hiding this comment

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

Thank you for handling this issue! Overall everything works as expected for happy cases, however I have a few nits and comments below.

///
private lazy var innerStackView: UIStackView = {
let view = UIStackView()
view.layoutMargins = UIEdgeInsets(top: 0, left: Constants.leadingMargin, bottom: 0, right: 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd better if there's margin for the right inset too - this could cause missing margin for users using right-to-left languages like Arabic:

Copy link
Contributor Author

@rachelmcr rachelmcr Aug 2, 2021

Choose a reason for hiding this comment

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

Good catch, thanks! I added a margin for the right inset in cd48e49. I thought about using directionalLayoutMargins to add the inset to the leading edge specifically (not left/right) but I realized it would be good to have insets on both sides anyway in case of very long store names.

}()

/// A stack view for views displayed between the navigation bar and content (e.g. store name subtitle, top banner)
///
private lazy var stackView: UIStackView = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it might be necessary to update the name of this property to mainStackView or headerStackView to make it clearer?

})
}()

private lazy var spacerView: UIView = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a comment for this property can be helpful to understand its purpose - WDYT?

private lazy var stackView: UIStackView = {
let view = UIStackView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .listForeground
view.layoutMargins = UIEdgeInsets(top: 0, left: navigationController?.navigationBar.directionalLayoutMargins.leading ?? 0, bottom: 0, right: 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

This line seems to have caused an issue with the margin when app is launched in landscape mode - removing this seems to have fixed the issue. Bravo 🎉

///
func hideTopBannerView() {
topBannerView.removeFromSuperview()
spacerView.removeFromSuperview()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's no need for adding and removing topBannerView and spacerView when showing / hiding the banner view. The great thing about stack view is that it can collapse or expand when showing / hiding its subviews.

Therefore, I'd suggest that you add these as arranged subviews right after adding the innerStackView, and hide them by default. When showing or hiding the banner view, all you need to do is show / hide these subviews and it should still work as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a great approach that I didn't think of, thanks! In 92e6c6c I changed how these views are configured, and it simplifies the way the constraints are set, too. Now the header stack view is configured up front with all the arranged subviews added, and as you suggested the methods to show or hide the banner just show/hide those subviews.

@@ -9,7 +9,7 @@ protocol DashboardUI: UIViewController {
var scrollDelegate: DashboardUIScrollDelegate? { get set }

/// Called when the Dashboard should display syncing error
var displaySyncingErrorNotice: () -> Void { get set }
var displaySyncingError: () -> Void { get set }
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for renaming this too! 💯

@rachelmcr rachelmcr requested a review from itsmeichigo August 2, 2021 11:44
@rachelmcr
Copy link
Contributor Author

Thanks for the review and suggestions, @itsmeichigo! This is ready for another look when you have a chance.

Copy link
Contributor

@itsmeichigo itsmeichigo left a comment

Choose a reason for hiding this comment

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

This looks great, thanks for updating! :shipit:

@rachelmcr rachelmcr merged commit 14bf9f5 into develop Aug 3, 2021
@rachelmcr rachelmcr deleted the issue/4382-my-store-error-banner branch August 3, 2021 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: stats Related to stats, including Top Performers. type: enhancement A request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors: Banner message for error loading data on Home screen, Product List, Order List, Review List
2 participants