From 2df7bb151badc14a80002de1851a46c11d152692 Mon Sep 17 00:00:00 2001 From: Salim Braksa Date: Wed, 26 Apr 2023 23:45:06 +0100 Subject: [PATCH 1/6] Add localized strings for domain checkout failure --- .../Shared/ErrorStates/ErrorStateViewConfiguration.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Shared/ErrorStates/ErrorStateViewConfiguration.swift b/WordPress/Classes/ViewRelated/Site Creation/Shared/ErrorStates/ErrorStateViewConfiguration.swift index 7dd9b61d5d03..143cc5f0c91b 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Shared/ErrorStates/ErrorStateViewConfiguration.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Shared/ErrorStates/ErrorStateViewConfiguration.swift @@ -13,6 +13,7 @@ enum ErrorStateViewType { case general case networkUnreachable case siteLoading + case domainCheckoutFailed } // MARK: ErrorViewConfiguration @@ -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: @@ -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." + ) } } } From d5c08b38de26505cbf3b3da9bc35cf7c59f38855 Mon Sep 17 00:00:00 2001 From: Salim Braksa Date: Wed, 26 Apr 2023 23:45:30 +0100 Subject: [PATCH 2/6] Show error message when domain checkout fails --- .../Final Assembly/SiteAssemblyWizardContent.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift b/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift index 23308ad3e444..5b1229250cf0 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift @@ -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.installErrorStateViewController(with: .domainCheckoutFailed) + self.contentView.status = .failed + case .canceled: + self.contentView.status = .succeeded + } } - self.contentView.status = .succeeded } } From 2dfea2266dadba4ed36158a75d45768e918a6c83 Mon Sep 17 00:00:00 2001 From: Salim Braksa Date: Thu, 27 Apr 2023 00:12:12 +0100 Subject: [PATCH 3/6] Add ability to retry domain checkout if it fails --- .../SiteAssemblyWizardContent.swift | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift b/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift index 5b1229250cf0..2a91f092eb4a 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift @@ -164,7 +164,7 @@ final class SiteAssemblyWizardContent: UIViewController { self.contentView.isFreeDomain = true switch error { case .unsupportedRedirect, .internal, .invalidInput, .other: - self.installErrorStateViewController(with: .domainCheckoutFailed) + self.installDomainCheckoutErrorStateViewController(domain: domain, site: site) self.contentView.status = .failed case .canceled: self.contentView.status = .succeeded @@ -190,30 +190,53 @@ 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.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() + } + } + + if configuration.dismissalActionHandler == nil { + configuration.dismissalActionHandler = { [weak self] in + guard let self = self else { + return + } + self.dismissTapped() } - self.dismissTapped() } let errorStateViewController = ErrorStateViewController(with: configuration) - contentView.errorStateView = errorStateViewController.view + self.contentView.errorStateView = errorStateViewController.view errorStateViewController.willMove(toParent: self) addChild(errorStateViewController) From 238e0a4006749434ce1d474fb2b2118118a44be8 Mon Sep 17 00:00:00 2001 From: Salim Braksa Date: Thu, 27 Apr 2023 00:29:58 +0100 Subject: [PATCH 4/6] Move to progress state when retrying domain purchasing --- .../Site Creation/Final Assembly/SiteAssemblyWizardContent.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift b/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift index 2a91f092eb4a..aae93b401d51 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift @@ -207,6 +207,7 @@ final class SiteAssemblyWizardContent: UIViewController { guard let self else { return } + self.contentView.status = .inProgress self.attemptDomainPurchasing(domain: domain, site: site) } From bf6fc4b7bdf191d2dde98eaa1ae95ce3b618b2ce Mon Sep 17 00:00:00 2001 From: Salim Braksa Date: Thu, 27 Apr 2023 00:30:16 +0100 Subject: [PATCH 5/6] Fix contact support was not displaying --- .../Final Assembly/SiteAssemblyWizardContent.swift | 3 +-- .../Support/SupportTableViewController.swift | 12 ++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift b/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift index aae93b401d51..7371c425f4b2 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift @@ -252,9 +252,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) { diff --git a/WordPress/Classes/ViewRelated/Support/SupportTableViewController.swift b/WordPress/Classes/ViewRelated/Support/SupportTableViewController.swift index f6a34a5be7ad..e5fd018e0cab 100644 --- a/WordPress/Classes/ViewRelated/Support/SupportTableViewController.swift +++ b/WordPress/Classes/ViewRelated/Support/SupportTableViewController.swift @@ -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) From 8318bd36d19797c4c83202c710b67a69b3c4846a Mon Sep 17 00:00:00 2001 From: Salim Braksa Date: Thu, 27 Apr 2023 00:32:39 +0100 Subject: [PATCH 6/6] Resolve an issue that was causing multiple error state views to be displayed --- .../Final Assembly/SiteAssemblyWizardContent.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift b/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift index 7371c425f4b2..dd40bb58336b 100644 --- a/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift +++ b/WordPress/Classes/ViewRelated/Site Creation/Final Assembly/SiteAssemblyWizardContent.swift @@ -235,6 +235,15 @@ final class SiteAssemblyWizardContent: UIViewController { } } + // 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) self.contentView.errorStateView = errorStateViewController.view