Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,17 @@ final class SiteAssemblyWizardContent: UIViewController {
case .success(let domain):
self.contentView.siteName = domain
self.contentView.isFreeDomain = false
case .failure:
self.contentView.status = .succeeded
case .failure(let error):
self.contentView.isFreeDomain = true
// TODO: We should discuss how to handle domain purchasing errors
break
switch error {
case .unsupportedRedirect, .internal, .invalidInput, .other:
self.installDomainCheckoutErrorStateViewController(domain: domain, site: site)
self.contentView.status = .failed
case .canceled:
self.contentView.status = .succeeded
}
}
self.contentView.status = .succeeded
}
}

Expand All @@ -185,30 +190,63 @@ final class SiteAssemblyWizardContent: UIViewController {
private func installErrorStateViewController(with type: ErrorStateViewType) {
var configuration = ErrorStateViewConfiguration.configuration(type: type)

configuration.contactSupportActionHandler = { [weak self] in
configuration.retryActionHandler = { [weak self] in
guard let self = self else {
return
}
self.contactSupportTapped()
self.retryTapped()
}

self.installErrorStateViewController(with: configuration)
}

private func installDomainCheckoutErrorStateViewController(domain: DomainSuggestion, site: Blog) {
var configuration = ErrorStateViewConfiguration.configuration(type: .domainCheckoutFailed)

configuration.retryActionHandler = { [weak self] in
guard let self = self else {
guard let self else {
return
}
self.retryTapped()
self.contentView.status = .inProgress
self.attemptDomainPurchasing(domain: domain, site: site)
}

configuration.dismissalActionHandler = { [weak self] in
guard let self = self else {
return
self.installErrorStateViewController(with: configuration)
}

private func installErrorStateViewController(with configuration: ErrorStateViewConfiguration) {
var configuration = configuration

if configuration.contactSupportActionHandler == nil {
configuration.contactSupportActionHandler = { [weak self] in
guard let self = self else {
return
}
self.contactSupportTapped()
}
self.dismissTapped()
}

if configuration.dismissalActionHandler == nil {
configuration.dismissalActionHandler = { [weak self] in
guard let self = self else {
return
}
self.dismissTapped()
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code above sets default dismissal and contact support action handlers if those closures are nil.

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 the explanation.


// Remove previous error state view controller
if let errorStateViewController {
errorStateViewController.willMove(toParent: nil)
errorStateViewController.view?.removeFromSuperview()
errorStateViewController.removeFromParent()
errorStateViewController.didMove(toParent: nil)
}

// Install new error state view controller
let errorStateViewController = ErrorStateViewController(with: configuration)

contentView.errorStateView = errorStateViewController.view
self.contentView.errorStateView = errorStateViewController.view

errorStateViewController.willMove(toParent: self)
addChild(errorStateViewController)
Expand All @@ -223,9 +261,8 @@ final class SiteAssemblyWizardContent: UIViewController {
private extension SiteAssemblyWizardContent {
func contactSupportTapped() {
// TODO : capture analytics event via #10335

let supportVC = SupportTableViewController()
supportVC.showFromTabBar()
supportVC.show(from: self)
}

func dismissTapped(viaDone: Bool = false, completion: (() -> Void)? = nil) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum ErrorStateViewType {
case general
case networkUnreachable
case siteLoading
case domainCheckoutFailed
}

// MARK: ErrorViewConfiguration
Expand Down Expand Up @@ -53,7 +54,7 @@ struct ErrorStateViewConfiguration {
extension ErrorStateViewType {
var localizedTitle: String {
switch self {
case .general, .siteLoading:
case .general, .siteLoading, .domainCheckoutFailed:
return NSLocalizedString("There was a problem",
comment: "This primary message message is displayed if a user encounters a general error.")
case .networkUnreachable:
Expand All @@ -69,6 +70,12 @@ extension ErrorStateViewType {
comment: "This secondary message is displayed if a user encounters a general error.")
case .networkUnreachable:
return nil
case .domainCheckoutFailed:
return NSLocalizedString(
"site.creation.assembly.step.domain.checkout.error.subtitle",
value: "Your website has been created successfully, but we encountered an issue while preparing your custom domain for checkout. Please try again or contact support for assistance.",
comment: "The error message to show in the 'Site Creation > Assembly Step' when the domain checkout fails for unknown reasons."
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ class SupportTableViewController: UITableViewController {
createUserActivity()
}

func show(from presentingViewController: UIViewController) {
let navigationController = UINavigationController.init(rootViewController: self)

if WPDeviceIdentification.isiPad() {
navigationController.modalTransitionStyle = .crossDissolve
navigationController.modalPresentationStyle = .formSheet
}

presentingViewController.present(navigationController, animated: true)
}

// TODO: Refactor this method to use the general `show(from:)` method
@objc func showFromTabBar() {
let navigationController = UINavigationController.init(rootViewController: self)

Expand Down