Skip to content

Commit dbc0fcd

Browse files
authored
Merge pull request #19194 from wordpress-mobile/task/19164-self-hosted-button
Jetpack Focus: Allow self-hosted sites to be added on the Jetpack app
2 parents 3119e75 + caa8e20 commit dbc0fcd

5 files changed

Lines changed: 2 additions & 110 deletions

File tree

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
-----
33
* [*] [Jetpack-only] Recommend App: you can now share the Jetpack app with your friends. [#19174]
44
* [*] [Jetpack-only] Feature Announcements: new features are highlighted via the What's New modals. [#19176]
5+
* [**] [Jetpack-only] Self-hosted sites: enables logging in via a self-hosted site / adding a self-hosted site [#19194]
56
* [*] Pages List: Fixed an issue where the app would freeze when opening the pages list if one of the featured images is a GIF. [#19184]
67
* [*] Stats: Fixed an issue where File Downloads section was being displayed for Jetpack sites even though it's not supported. [#19200]
78

WordPress/Classes/Utility/App Configuration/AuthenticationHandler.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
11
import WordPressAuthenticator
22

33
protocol AuthenticationHandler {
4-
func shouldPresentUsernamePasswordController(for siteInfo: WordPressComSiteInfo?, onCompletion: @escaping (WordPressAuthenticatorResult) -> Void)
5-
6-
/// Whether or not the AuthenticationHandler will override or handle the `presentLoginEpilogue` method.
7-
/// If this returns true, the `AuthenticationHandler.presentLoginEpilogue` method is called
8-
/// If not, then the default implementation will be called instead
9-
/// - Returns: Bool, true if we should override the functionality, false if we should not
10-
func willHandlePresentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials) -> Bool
11-
12-
func presentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, windowManager: WindowManager, onDismiss: @escaping () -> Void) -> Bool
13-
14-
/// Whether or not the AuthenticationHandler will override or handle the `presentSignupEpilogue` method.
15-
/// If this returns true, the `AuthenticationHandler.presentSignupEpilogue` method is called
16-
/// If not, then the default implementation will be called instead
17-
/// - Returns: Bool, true if we should override the functionality, false if we should not
18-
func willHandlePresentSignupEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, service: SocialService?) -> Bool
19-
20-
func presentSignupEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, service: SocialService?)
214

225
// WPAuthenticator style overrides
236
var statusBarStyle: UIStatusBarStyle { get }

WordPress/Classes/ViewRelated/NUX/WordPressAuthenticationManager.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,6 @@ extension WordPressAuthenticationManager: WordPressAuthenticatorDelegate {
309309
/// - onCompletion: Closure to be executed on completion.
310310
///
311311
func shouldPresentUsernamePasswordController(for siteInfo: WordPressComSiteInfo?, onCompletion: @escaping (WordPressAuthenticatorResult) -> Void) {
312-
if let authenticationHandler = authenticationHandler {
313-
authenticationHandler.shouldPresentUsernamePasswordController(for: siteInfo, onCompletion: onCompletion)
314-
return
315-
}
316312

317313
let result: WordPressAuthenticatorResult = .presentPasswordController(value: true)
318314
onCompletion(result)
@@ -321,11 +317,6 @@ extension WordPressAuthenticationManager: WordPressAuthenticatorDelegate {
321317
/// Presents the Login Epilogue, in the specified NavigationController.
322318
///
323319
func presentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, onDismiss: @escaping () -> Void) {
324-
if let authenticationHandler = authenticationHandler,
325-
authenticationHandler.willHandlePresentLoginEpilogue(in: navigationController, for: credentials),
326-
authenticationHandler.presentLoginEpilogue(in: navigationController, for: credentials, windowManager: windowManager, onDismiss: onDismiss) {
327-
return
328-
}
329320

330321
// If adding a self-hosted site, skip the Epilogue
331322
if let wporg = credentials.wporg,
@@ -392,11 +383,6 @@ extension WordPressAuthenticationManager: WordPressAuthenticatorDelegate {
392383
/// Presents the Signup Epilogue, in the specified NavigationController.
393384
///
394385
func presentSignupEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, service: SocialService?) {
395-
if let authenticationHandler = authenticationHandler,
396-
authenticationHandler.willHandlePresentSignupEpilogue(in: navigationController, for: credentials, service: service) {
397-
authenticationHandler.presentSignupEpilogue(in: navigationController, for: credentials, service: service)
398-
return
399-
}
400386

401387
let storyboard = UIStoryboard(name: "SignupEpilogue", bundle: .main)
402388
guard let epilogueViewController = storyboard.instantiateInitialViewController() as? SignupEpilogueViewController else {

WordPress/Jetpack/AppConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
@objc static let allowsDomainRegistration: Bool = true
1616
@objc static let showsReader: Bool = true
1717
@objc static let showsCreateButton: Bool = true
18-
@objc static let showAddSelfHostedSiteButton: Bool = false
18+
@objc static let showAddSelfHostedSiteButton: Bool = true
1919
@objc static let showsQuickActions: Bool = true
2020
@objc static let showsFollowedSitesSettings: Bool = true
2121
@objc static let showsWhatIsNew: Bool = true

WordPress/Jetpack/Classes/JetpackAuthenticationManager.swift

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -9,84 +9,6 @@ struct JetpackAuthenticationManager: AuthenticationHandler {
99
var prologuePrimaryButtonStyle: NUXButtonStyle? = JetpackPrologueStyleGuide.continueButtonStyle
1010
var prologueSecondaryButtonStyle: NUXButtonStyle? = JetpackPrologueStyleGuide.siteAddressButtonStyle
1111

12-
func shouldPresentUsernamePasswordController(for siteInfo: WordPressComSiteInfo?, onCompletion: @escaping (WordPressAuthenticatorResult) -> Void) {
13-
/// Jetpack is required. Present an error if we don't detect a valid installation.
14-
guard let site = siteInfo, isValidJetpack(for: site) else {
15-
let viewModel = JetpackNotFoundErrorViewModel(with: siteInfo?.url)
16-
let controller = errorViewController(with: viewModel)
17-
18-
let authenticationResult: WordPressAuthenticatorResult = .injectViewController(value: controller)
19-
onCompletion(authenticationResult)
20-
21-
return
22-
}
23-
24-
/// WordPress must be present.
25-
guard site.isWP else {
26-
let viewModel = JetpackNotWPErrorViewModel()
27-
let controller = errorViewController(with: viewModel)
28-
29-
let authenticationResult: WordPressAuthenticatorResult = .injectViewController(value: controller)
30-
onCompletion(authenticationResult)
31-
32-
return
33-
}
34-
35-
/// For self-hosted sites, navigate to enter the email address associated to the wp.com account:
36-
guard site.isWPCom else {
37-
let authenticationResult: WordPressAuthenticatorResult = .presentEmailController
38-
39-
onCompletion(authenticationResult)
40-
41-
return
42-
}
43-
44-
/// We should never reach this point, as WPAuthenticator won't call its delegate for this case.
45-
///
46-
DDLogWarn("⚠️ Present password controller for site: \(site.url)")
47-
let authenticationResult: WordPressAuthenticatorResult = .presentPasswordController(value: false)
48-
onCompletion(authenticationResult)
49-
}
50-
51-
func willHandlePresentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials) -> Bool {
52-
// Don't display the "no sites" epilogue if we allow site creation
53-
return !AppConfiguration.allowSiteCreation
54-
}
55-
56-
func presentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, windowManager: WindowManager, onDismiss: @escaping () -> Void) -> Bool {
57-
if AccountHelper.hasBlogs {
58-
return false
59-
}
60-
61-
// Exit out of the sign in process, if we don't do this we later can't
62-
// display the sign in again
63-
windowManager.dismissFullscreenSignIn()
64-
65-
// Display the no sites view
66-
let viewModel = JetpackNoSitesErrorViewModel()
67-
let controller = errorViewController(with: viewModel)
68-
windowManager.show(controller, completion: nil)
69-
70-
return true
71-
}
72-
73-
func willHandlePresentSignupEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, service: SocialService?) -> Bool {
74-
// Don't display the "no sites" epilogue if we allow site creation
75-
return !AppConfiguration.allowSiteCreation
76-
}
77-
78-
// If the user signs up using the Jetpack app (through SIWA, for example)
79-
// We show right away the screen explaining that they do not have Jetpack sites
80-
func presentSignupEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials, service: SocialService?) {
81-
let windowManager = WordPressAppDelegate.shared?.windowManager
82-
83-
windowManager?.dismissFullscreenSignIn()
84-
85-
let viewModel = JetpackNoSitesErrorViewModel()
86-
let controller = errorViewController(with: viewModel)
87-
windowManager?.show(controller, completion: nil)
88-
}
89-
9012
// MARK: - Private: Helpers
9113
private func isValidJetpack(for site: WordPressComSiteInfo) -> Bool {
9214
return site.hasJetpack &&

0 commit comments

Comments
 (0)