Skip to content

Commit 2b830da

Browse files
committed
Merge branch 'trunk' into feat/3157-search-sku
* trunk: Fix unit tests build failures. Simplify code using map. DI `LoggedOutAppSettingsProtocol` to `Authentication.initialize` to freeze the value for feature carousel visibility. Remove extra space from release notes. Update release notes. Pass in custom help center `Screen` value for the help button in `FancyAlertViewController` Create `CustomHelpCenterContent` for help screen when screen is non nil. Take `CustomHelpCenterContent.Screen` as optional param. Take `CustomHelpCenterContent` as optional param and use custom init to initialise `HelpAndSupportViewController`
2 parents d9ae276 + 66f8e13 commit 2b830da

File tree

10 files changed

+34
-22
lines changed

10 files changed

+34
-22
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-----
55

66
- [*] Fixed a rare crash when selecting a store in the store picker. [https://github.com/woocommerce/woocommerce-ios/pull/7765]
7-
- [*] Help center: Added help center web page with FAQs for "Not a WooCommerce site" error screen. [https://github.com/woocommerce/woocommerce-ios/pull/7767]
7+
- [*] Help center: Added help center web page with FAQs for "Not a WooCommerce site" and "Wrong WordPress.com account" error screens. [https://github.com/woocommerce/woocommerce-ios/pull/7767, https://github.com/woocommerce/woocommerce-ios/pull/7769]
88

99
10.5
1010
-----

WooCommerce/Classes/Authentication/AuthenticationManager.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ class AuthenticationManager: Authentication {
4343

4444
/// Initializes the WordPress Authenticator.
4545
///
46-
func initialize() {
46+
func initialize(loggedOutAppSettings: LoggedOutAppSettingsProtocol) {
4747
let isWPComMagicLinkPreferredToPassword = ServiceLocator.featureFlagService.isFeatureFlagEnabled(.loginMagicLinkEmphasis)
4848
let isWPComMagicLinkShownAsSecondaryActionOnPasswordScreen = ServiceLocator.featureFlagService.isFeatureFlagEnabled(.loginMagicLinkEmphasisM2)
4949
let continueWithSiteAddressFirst = ABTest.loginPrologueButtonOrder.variation == .control
50+
let isFeatureCarouselShown = ServiceLocator.featureFlagService.isFeatureFlagEnabled(.loginPrologueOnboarding) == false
51+
|| loggedOutAppSettings.hasFinishedOnboarding == true
5052
let configuration = WordPressAuthenticatorConfiguration(wpcomClientId: ApiCredentials.dotcomAppId,
5153
wpcomSecret: ApiCredentials.dotcomSecret,
5254
wpcomScheme: ApiCredentials.dotcomAuthScheme,
@@ -97,7 +99,8 @@ class AuthenticationManager: Authentication {
9799
navBarImage: StyleManager.navBarImage,
98100
navBarBadgeColor: .primary,
99101
navBarBackgroundColor: .appBar,
100-
prologueTopContainerChildViewController: LoginPrologueViewController(),
102+
prologueTopContainerChildViewController:
103+
LoginPrologueViewController(isFeatureCarouselShown: isFeatureCarouselShown),
101104
statusBarStyle: .default)
102105

103106
let displayStrings = WordPressAuthenticatorDisplayStrings(emailLoginInstructions: AuthenticationConstants.emailInstructions,

WooCommerce/Classes/Authentication/Navigation Exceptions/WrongAccountErrorViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ final class WrongAccountErrorViewModel: ULAccountMismatchViewModel {
156156
}
157157

158158
func didTapAuxiliaryButton(in viewController: UIViewController?) {
159-
let fancyAlert = FancyAlertViewController.makeNeedHelpFindingEmailAlertController()
159+
let fancyAlert = FancyAlertViewController.makeNeedHelpFindingEmailAlertController(screen: .wrongAccountError)
160160
fancyAlert.modalPresentationStyle = .custom
161161
fancyAlert.transitioningDelegate = AppDelegate.shared.tabBarController
162162
viewController?.present(fancyAlert, animated: true)

WooCommerce/Classes/Authentication/Prologue/LoginPrologueViewController.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import Experiments
88
///
99
final class LoginPrologueViewController: UIViewController {
1010
private let isNewToWooCommerceButtonShown: Bool
11-
private let isOnboardingFeatureShown: Bool
11+
/// The feature carousel is not shown right after finishing the onboarding.
12+
private let isFeatureCarouselShown: Bool
1213
private let analytics: Analytics
1314

1415
/// Background View, to be placed surrounding the bottom area.
@@ -36,10 +37,10 @@ final class LoginPrologueViewController: UIViewController {
3637
// MARK: - Overridden Methods
3738

3839
init(analytics: Analytics = ServiceLocator.analytics,
39-
loggedOutAppSettings: LoggedOutAppSettingsProtocol = LoggedOutAppSettings(userDefaults: .standard),
40+
isFeatureCarouselShown: Bool,
4041
featureFlagService: FeatureFlagService = ServiceLocator.featureFlagService) {
4142
isNewToWooCommerceButtonShown = featureFlagService.isFeatureFlagEnabled(.newToWooCommerceLinkInLoginPrologue)
42-
isOnboardingFeatureShown = featureFlagService.isFeatureFlagEnabled(.loginPrologueOnboarding) && loggedOutAppSettings.hasFinishedOnboarding == false
43+
self.isFeatureCarouselShown = isFeatureCarouselShown
4344
self.analytics = analytics
4445
super.init(nibName: nil, bundle: nil)
4546
}
@@ -91,8 +92,8 @@ private extension LoginPrologueViewController {
9192
/// This is contained in a child view so that this view's background doesn't scroll.
9293
///
9394
func setupCarousel(isNewToWooCommerceButtonShown: Bool) {
94-
let pageTypes: [LoginProloguePageType] = isOnboardingFeatureShown ? [.getStarted] : [.stats, .orderManagement, .products, .reviews]
95-
let carousel = LoginProloguePageViewController(pageTypes: pageTypes, showsSubtitle: isOnboardingFeatureShown)
95+
let pageTypes: [LoginProloguePageType] = isFeatureCarouselShown ? [.stats, .orderManagement, .products, .reviews]: [.getStarted]
96+
let carousel = LoginProloguePageViewController(pageTypes: pageTypes, showsSubtitle: !isFeatureCarouselShown)
9697
carousel.view.translatesAutoresizingMaskIntoConstraints = false
9798

9899
addChild(carousel)

WooCommerce/Classes/ServiceLocator/Authentication.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protocol Authentication {
2828

2929
/// Initializes the WordPress Authenticator.
3030
///
31-
func initialize()
31+
func initialize(loggedOutAppSettings: LoggedOutAppSettingsProtocol)
3232

3333
/// Injects `loggedOutAppSettings`
3434
///

WooCommerce/Classes/ViewRelated/AppCoordinator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private extension AppCoordinator {
155155

156156
/// Configures the WPAuthenticator for usage in both logged-in and logged-out states.
157157
func configureAuthenticator() {
158-
authenticationManager.initialize()
158+
authenticationManager.initialize(loggedOutAppSettings: loggedOutAppSettings)
159159
appleIDCredentialChecker.observeLoggedInStateForAppleIDObservations()
160160
}
161161

WooCommerce/Classes/ViewRelated/Fancy Alerts/FancyAlertViewController+UnifiedLogin.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import WordPressUI
22
import SafariServices
3+
import WordPressAuthenticator
34

45
extension FancyAlertViewController {
56
static func makeWhatIsJetpackAlertController(analytics: Analytics) -> FancyAlertViewController {
@@ -21,9 +22,10 @@ extension FancyAlertViewController {
2122
return controller
2223
}
2324

24-
static func makeNeedHelpFindingEmailAlertController() -> FancyAlertViewController {
25+
static func makeNeedHelpFindingEmailAlertController(screen: CustomHelpCenterContent.Screen? = nil) -> FancyAlertViewController {
2526
let dismissButton = makeDismissButtonConfig()
26-
let moreHelpButton = makeNeedMoreHelpButton()
27+
let customHelpCenterContent = screen.map { CustomHelpCenterContent(screen: $0, flow: AuthenticatorAnalyticsTracker.shared.state.lastFlow) }
28+
let moreHelpButton = makeNeedMoreHelpButton(customHelpCenterContent: customHelpCenterContent)
2729
let config = FancyAlertViewController.Config(titleText: Localization.whatEmailDoIUse,
2830
bodyText: Localization.whatEmailDoIUseLongDescription,
2931
headerImage: nil,
@@ -108,14 +110,20 @@ private extension FancyAlertViewController {
108110
}
109111
}
110112

111-
static func makeNeedMoreHelpButton() -> FancyAlertViewController.Config.ButtonConfig {
113+
static func makeNeedMoreHelpButton(customHelpCenterContent: CustomHelpCenterContent? = nil) -> FancyAlertViewController.Config.ButtonConfig {
112114
return FancyAlertViewController.Config.ButtonConfig(Localization.needMoreHelp) { controller, _ in
113115
let identifier = HelpAndSupportViewController.classNameWithoutNamespaces
114-
guard let supportViewController = UIStoryboard
115-
.dashboard
116-
.instantiateViewController(withIdentifier: identifier) as? HelpAndSupportViewController else {
117-
return
118-
}
116+
let supportViewController = UIStoryboard.dashboard.instantiateViewController(identifier: identifier,
117+
creator: { coder -> HelpAndSupportViewController? in
118+
guard let customHelpCenterContent = customHelpCenterContent else {
119+
/// Returning nil as we don't need to customise the HelpAndSupportViewController
120+
/// In this case `instantiateViewController` method will use the default `HelpAndSupportViewController` created from storyboard.
121+
///
122+
return nil
123+
}
124+
125+
return HelpAndSupportViewController(customHelpCenterContent: customHelpCenterContent, coder: coder)
126+
})
119127

120128
supportViewController.displaysDismissAction = true
121129

WooCommerce/WooCommerceTests/AppCoordinatorTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class AppCoordinatorTests: XCTestCase {
2323
stores = MockStoresManager(sessionManager: sessionManager)
2424
storageManager = MockStorageManager()
2525
authenticationManager = AuthenticationManager()
26-
authenticationManager.initialize()
26+
authenticationManager.initialize(loggedOutAppSettings: MockLoggedOutAppSettings())
2727
}
2828

2929
override func tearDown() {

WooCommerce/WooCommerceTests/Mocks/MockAuthentication.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class MockAuthentication: Authentication {
2323
UIViewController()
2424
}
2525

26-
func initialize() {
26+
func initialize(loggedOutAppSettings: LoggedOutAppSettingsProtocol) {
2727
// no-op
2828
}
2929

WooCommerce/WooCommerceTests/ViewRelated/CardPresentPayments/CardPresentPaymentsModalViewControllerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ final class CardPresentPaymentsModalViewControllerTests: XCTestCase {
55
override func setUp() {
66
super.setUp()
77
// The NUX buttons require WordPressAuthenticator to be initialized
8-
AuthenticationManager().initialize()
8+
AuthenticationManager().initialize(loggedOutAppSettings: MockLoggedOutAppSettings())
99
}
1010

1111
func test_viewcontroller_presents_top_title_provided_by_viewmodel() throws {

0 commit comments

Comments
 (0)