Skip to content

Commit 9479aa0

Browse files
committed
Merge branch 'issue/7440-change-navigation-ipp-orders' of https://github.com/woocommerce/woocommerce-ios into issue/7440-change-navigation-ipp-orders
2 parents 40d0897 + 0178dbf commit 9479aa0

21 files changed

+232
-84
lines changed

Experiments/Experiments/ABTest.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ public enum ABTest: String, CaseIterable {
1212
///
1313
case aaTest202208 = "woocommerceios_explat_aa_test_202208"
1414

15+
/// A/A test to make sure there is no bias in the logged out state.
16+
/// Experiment ref: pbxNRc-1S0-p2
17+
case aaTestLoggedOut202208 = "woocommerceios_explat_aa_test_logged_out_202208"
18+
1519
/// Returns a variation for the given experiment
16-
var variation: Variation {
17-
return ExPlat.shared?.experiment(self.rawValue) ?? .control
20+
public var variation: Variation {
21+
ExPlat.shared?.experiment(rawValue) ?? .control
1822
}
1923
}
2024

Experiments/Experiments/DefaultFeatureFlagService.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
5555
return buildConfig == .localDeveloper || buildConfig == .alpha
5656
case .loginPrologueOnboardingSurvey:
5757
return true
58+
case .loginMagicLinkEmphasis:
59+
return true
5860
default:
5961
return true
6062
}

Experiments/Experiments/FeatureFlag.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,8 @@ public enum FeatureFlag: Int {
113113
/// Whether to show a survey at the end of the login onboarding screen after feature carousel
114114
///
115115
case loginPrologueOnboardingSurvey
116+
117+
/// Whether to prefer magic link to password in the login flow
118+
///
119+
case loginMagicLinkEmphasis
116120
}

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ target 'WooCommerce' do
4242
pod 'Gridicons', '~> 1.2.0'
4343

4444
# To allow pod to pick up beta versions use -beta. E.g., 1.1.7-beta.1
45-
pod 'WordPressAuthenticator', '~> 2.2.0-beta.3'
45+
pod 'WordPressAuthenticator', '~> 2.2.0-beta.4'
4646
# pod 'WordPressAuthenticator', :git => 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', :commit => ''
4747
# pod 'WordPressAuthenticator', :git => 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', :branch => ''
4848
# pod 'WordPressAuthenticator', :path => '../WordPressAuthenticator-iOS'

Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ PODS:
4242
- WordPress-Aztec-iOS (1.11.0)
4343
- WordPress-Editor-iOS (1.11.0):
4444
- WordPress-Aztec-iOS (= 1.11.0)
45-
- WordPressAuthenticator (2.2.0-beta.3):
45+
- WordPressAuthenticator (2.2.0-beta.4):
4646
- Alamofire (~> 4.8)
4747
- CocoaLumberjack (~> 3.5)
4848
- GoogleSignIn (~> 6.0.1)
@@ -92,7 +92,7 @@ DEPENDENCIES:
9292
- Sourcery (~> 1.0.3)
9393
- StripeTerminal (~> 2.7)
9494
- WordPress-Editor-iOS (~> 1.11.0)
95-
- WordPressAuthenticator (~> 2.2.0-beta.3)
95+
- WordPressAuthenticator (~> 2.2.0-beta.4)
9696
- WordPressKit (~> 4.49.0)
9797
- WordPressShared (~> 1.15)
9898
- WordPressUI (~> 1.12.5)
@@ -163,7 +163,7 @@ SPEC CHECKSUMS:
163163
UIDeviceIdentifier: af4e11e25a2ea670078e2bd677bb0e8144f9f063
164164
WordPress-Aztec-iOS: 050b34d4c3adfb7c60363849049b13d60683b348
165165
WordPress-Editor-iOS: 304098424f1051cb271546c99f906aac296b1b81
166-
WordPressAuthenticator: 9f8448772fe3d0576b84e2d20bdbe1ee9a601bb6
166+
WordPressAuthenticator: 815e29e0da0577fcc00ddec5295a2d508a659abf
167167
WordPressKit: 96deb6ba37ea5eaec4ddcaa53eca04d653246152
168168
WordPressShared: 5477f179c7fe03b5d574f91adda66f67d131827e
169169
WordPressUI: c5be816f6c7b3392224ac21de9e521e89fa108ac
@@ -179,6 +179,6 @@ SPEC CHECKSUMS:
179179
ZendeskSupportProvidersSDK: 2bdf8544f7cd0fd4c002546f5704b813845beb2a
180180
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
181181

182-
PODFILE CHECKSUM: cfd704bd22d40450f707bf2fe73ee95c44cd4005
182+
PODFILE CHECKSUM: 84fe62fbef29f20399ee95c320fab84bfc882e74
183183

184184
COCOAPODS: 1.11.2

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
-----
55
- [*] [Sign in with store credentials]: New screen added with instructions to verify Jetpack connected email. [https://github.com/woocommerce/woocommerce-ios/pull/7424]
66
- [*] [Sign in with store credentials]: Stop clearing username/password after an invalid attempt to enable users to fix typos. [https://github.com/woocommerce/woocommerce-ios/pull/7444]
7+
- [*] Login: after entering WP.com email, a magic link is automatically sent when it is enabled (magic links are disabled for A8C emails and WP.com accounts with recently changed password) and a new screen is shown with an option to log in with password. [https://github.com/woocommerce/woocommerce-ios/pull/7449]
78

89
9.8
910
-----

WooCommerce/Classes/AppDelegate.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
7171
// Yosemite Initialization
7272
synchronizeEntitiesIfPossible()
7373

74-
// Upgrade check...
75-
checkForUpgrades()
76-
7774
// Since we are using Injection for refreshing the content of the app in debug mode,
7875
// we are going to enable Inject.animation that will be used when
7976
// ever new source code is injected into our application.
@@ -86,6 +83,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
8683

8784
startABTesting()
8885

86+
// Upgrade check...
87+
// This has to be called after A/B testing setup in `startABTesting` if any of the Tracks events
88+
// in `checkForUpgrades` is used as an exposure event for an experiment.
89+
// For example, `application_installed` could be the exposure event for logged-out experiments.
90+
checkForUpgrades()
91+
8992
// Setup the Interface!
9093
setupMainWindow()
9194
setupComponentsAppearance()
@@ -368,9 +371,6 @@ private extension AppDelegate {
368371
/// Starts the AB testing platform
369372
///
370373
func startABTesting() {
371-
guard ServiceLocator.stores.isAuthenticated else {
372-
return
373-
}
374374
ABTest.start()
375375
}
376376
}

WooCommerce/Classes/Authentication/AuthenticationManager.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class AuthenticationManager: Authentication {
4343
/// Initializes the WordPress Authenticator.
4444
///
4545
func initialize() {
46+
let isWPComMagicLinkPreferredToPassword = ServiceLocator.featureFlagService.isFeatureFlagEnabled(.loginMagicLinkEmphasis)
4647
let configuration = WordPressAuthenticatorConfiguration(wpcomClientId: ApiCredentials.dotcomAppId,
4748
wpcomSecret: ApiCredentials.dotcomSecret,
4849
wpcomScheme: ApiCredentials.dotcomAuthScheme,
@@ -60,7 +61,8 @@ class AuthenticationManager: Authentication {
6061
enableUnifiedAuth: true,
6162
continueWithSiteAddressFirst: true,
6263
enableSiteCredentialsLoginForSelfHostedSites: true,
63-
isWPComLoginRequiredForSiteCredentialsLogin: true)
64+
isWPComLoginRequiredForSiteCredentialsLogin: true,
65+
isWPComMagicLinkPreferredToPassword: isWPComMagicLinkPreferredToPassword)
6466

6567
let systemGray3LightModeColor = UIColor(red: 199/255.0, green: 199/255.0, blue: 204/255.0, alpha: 1)
6668
let systemLabelLightModeColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
@@ -112,7 +114,7 @@ class AuthenticationManager: Authentication {
112114
textColor: .text,
113115
textSubtleColor: .textSubtle,
114116
textButtonColor: .accent,
115-
textButtonHighlightColor: .accent,
117+
textButtonHighlightColor: .accentDark,
116118
viewControllerBackgroundColor: .basicBackground,
117119
prologueButtonsBackgroundColor: .authPrologueBottomBackgroundColor,
118120
prologueViewBackgroundColor: .authPrologueBottomBackgroundColor,
@@ -196,9 +198,8 @@ class AuthenticationManager: Authentication {
196198
if let matchedSite = matcher.matchedSite(originalURL: siteURL),
197199
matchedSite.isWooCommerceActive == false {
198200
let viewModel = NoWooErrorViewModel(
199-
siteURL: siteURL,
201+
site: matchedSite,
200202
showsConnectedStores: matcher.hasConnectedStores,
201-
showsInstallButton: matchedSite.isJetpackConnected && matchedSite.isJetpackThePluginInstalled,
202203
onSetupCompletion: { [weak self] siteID in
203204
guard let self = self else { return }
204205
self.startStorePicker(with: siteID, in: navigationController, onDismiss: onStorePickerDismiss)

WooCommerce/Classes/Authentication/Epilogue/StorePickerViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,8 @@ private extension StorePickerViewController {
683683

684684
func showNoWooError(for site: Site) {
685685
let viewModel = NoWooErrorViewModel(
686-
siteURL: site.url,
686+
site: site,
687687
showsConnectedStores: false, // avoid looping from store picker > no woo > store picker
688-
showsInstallButton: site.isJetpackConnected && site.isJetpackThePluginInstalled,
689688
onSetupCompletion: { [weak self] siteID in
690689
guard let self = self else { return }
691690
self.navigationController?.popViewController(animated: true)

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

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,38 @@ import Yosemite
44
/// Configuration and actions for an ULErrorViewController,
55
/// modelling an error when WooCommerce is not installed or activated.
66
final class NoWooErrorViewModel: ULErrorViewModel {
7-
private let siteURL: String
7+
private let site: Site
88
private let showsConnectedStores: Bool
9-
private let showsInstallButton: Bool
109
private let analytics: Analytics
1110
private let stores: StoresManager
1211
private let setupCompletionHandler: (Int64) -> Void
1312

1413
private var storePickerCoordinator: StorePickerCoordinator?
1514

16-
init(siteURL: String?,
15+
init(site: Site,
1716
showsConnectedStores: Bool,
18-
showsInstallButton: Bool,
1917
analytics: Analytics = ServiceLocator.analytics,
2018
stores: StoresManager = ServiceLocator.stores,
2119
onSetupCompletion: @escaping (Int64) -> Void) {
22-
self.siteURL = siteURL ?? Localization.yourSite
20+
self.site = site
21+
self.title = site.name
2322
self.showsConnectedStores = showsConnectedStores
24-
self.showsInstallButton = showsInstallButton
2523
self.analytics = analytics
2624
self.stores = stores
2725
self.setupCompletionHandler = onSetupCompletion
2826
}
2927

3028
// MARK: - Data and configuration
29+
let title: String?
30+
3131
let image: UIImage = .noStoreImage
3232

3333
var text: NSAttributedString {
3434
let font: UIFont = .body
3535
let boldFont: UIFont = font.bold
3636

37-
let boldSiteAddress = NSAttributedString(string: siteURL.trimHTTPScheme(),
38-
attributes: [.font: boldFont])
37+
let boldSiteAddress = NSAttributedString(string: site.url.trimHTTPScheme(),
38+
attributes: [.font: boldFont])
3939
let message = NSMutableAttributedString(string: Localization.errorMessage)
4040

4141
message.replaceFirstOccurrence(of: "%@", with: boldSiteAddress)
@@ -49,7 +49,10 @@ final class NoWooErrorViewModel: ULErrorViewModel {
4949

5050
let primaryButtonTitle = Localization.primaryButtonTitle
5151

52-
var isPrimaryButtonHidden: Bool { !showsInstallButton }
52+
var isPrimaryButtonHidden: Bool {
53+
// Exclude simple sites and JCP sites - the web installation flow doesn't look great on these.
54+
!site.isJetpackConnected || !site.isJetpackThePluginInstalled
55+
}
5356

5457
let secondaryButtonTitle = Localization.secondaryButtonTitle
5558

@@ -59,10 +62,13 @@ final class NoWooErrorViewModel: ULErrorViewModel {
5962
guard let viewController = viewController else {
6063
return
6164
}
62-
let viewModel = WooSetupWebViewModel(siteURL: siteURL, onCompletion: { [weak self] in
65+
let viewModel = WooSetupWebViewModel(siteURL: site.url, onCompletion: { [weak self] in
6366
guard let self = self else { return }
6467
viewController.navigationController?.popViewController(animated: true)
68+
self.showInProgressView(in: viewController)
6569
self.handleSetupCompletion(in: viewController)
70+
}, onDismiss: {
71+
viewController.navigationController?.popViewController(animated: true)
6672
})
6773
let setupViewController = PluginSetupWebViewController(viewModel: viewModel)
6874
viewController.navigationController?.show(setupViewController, sender: nil)
@@ -91,24 +97,29 @@ final class NoWooErrorViewModel: ULErrorViewModel {
9197
// MARK: - Private helpers
9298
private extension NoWooErrorViewModel {
9399
func handleSetupCompletion(in viewController: UIViewController, retryCount: Int = 0) {
94-
showInProgressView(in: viewController)
95-
96-
ServiceLocator.stores.synchronizeEntities { [weak self] in
100+
let action = AccountAction.synchronizeSites(selectedSiteID: site.siteID, isJetpackConnectionPackageSupported: true) { [weak self] _ in
97101
guard let self = self else { return }
98-
// dismisses the in-progress view
99-
viewController.navigationController?.dismiss(animated: true)
100102

101103
let matcher = ULAccountMatcher()
102104
matcher.refreshStoredSites()
103-
guard let site = matcher.matchedSite(originalURL: self.siteURL),
105+
guard let site = matcher.matchedSite(originalURL: self.site.url),
104106
site.isWooCommerceActive else {
105107
if retryCount < 2 {
106-
return self.handleSetupCompletion(in: viewController, retryCount: retryCount + 1)
108+
// delays for 2 seconds to buy some time for the data to be synced
109+
DispatchQueue.main.asyncAfter(deadline: .now() + 2) { [weak self] in
110+
self?.handleSetupCompletion(in: viewController, retryCount: retryCount + 1)
111+
}
112+
return
107113
}
114+
// dismisses the in-progress view
115+
viewController.navigationController?.dismiss(animated: true)
108116
return self.showSetupErrorNotice(in: viewController)
109117
}
118+
// dismisses the in-progress view
119+
viewController.navigationController?.dismiss(animated: true)
110120
self.setupCompletionHandler(site.siteID)
111121
}
122+
stores.dispatch(action)
112123
}
113124

114125
func showInProgressView(in viewController: UIViewController) {
@@ -147,10 +158,6 @@ private extension NoWooErrorViewModel {
147158
comment: "Action button that will restart the login flow."
148159
+ "Presented when logging in with a site address that does not have WooCommerce")
149160

150-
static let yourSite = NSLocalizedString("your site",
151-
comment: "Placeholder for site url, if the url is unknown."
152-
+ "Presented when logging in with a site address that does not have WooCommerce."
153-
+ "The error would read: to use this app for your site you'll need...")
154161
static let verifyingInstallation = NSLocalizedString("Verifying installation...",
155162
comment: "Message displayed when checking whether a site has successfully installed WooCommerce")
156163
static let setupErrorMessage = NSLocalizedString("Cannot verify your site's WooCommerce installation.",

0 commit comments

Comments
 (0)