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 @@ -5,6 +5,7 @@ import WordPressShared
import WordPressSharedObjC
import WordPressUI
import Support
import SwiftUI

private struct Section {
let title: String?
Expand Down Expand Up @@ -507,14 +508,71 @@ private extension BlogDetailsTableViewModel {
func configureXMLRPCDisabledCell(tableView: UITableView) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(
withIdentifier: CellIdentifiers.xmlrpcDisabled
) as? XMLRPCDisabledCell,
let viewController else {
) as? XMLRPCDisabledCell else {
return UITableViewCell()
}

cell.configure(with: viewController)
cell.onTapped = { [weak self] in
self?.presentXMLRPCDisabledAlert()
}
return cell
}

private func presentXMLRPCDisabledAlert() {
guard let viewController else { return }

let alert = AlertView {
AlertHeaderView(
title: XMLRPCDisabledAlertStrings.title,
description: XMLRPCDisabledAlertStrings.description
)
} content: {
Image(systemName: "exclamationmark.triangle")
.font(.system(size: 50))
.foregroundStyle(.orange)
} actions: {
Button { [weak self, weak viewController] in
viewController?.dismiss(animated: true) {
self?.presentJetpackConnection()
}
} label: {
Text(XMLRPCDisabledAlertStrings.connectJetpack)
.font(.headline)
.frame(maxWidth: .infinity)
}
.buttonStyle(.borderedProminent)
.controlSize(.extraLarge)

Button { [weak viewController] in
let url = URL(string: "https://apps.wordpress.com/support/mobile/login-signup/inaccessible-xml-rpc-connection-error/")!
viewController?.dismiss(animated: true) {
UIApplication.shared.open(url)
}
} label: {
Text(XMLRPCDisabledAlertStrings.learnMore)
}
}

alert.present(in: viewController)
}

private func presentJetpackConnection() {
let controller = UIViewController.jetpackConnection(blog: blog)
controller.promptType = .bypassXMLRPC
controller.completionBlock = { [weak controller, weak self] in
controller?.dismiss(animated: true) {
self?.viewController?.refresh()
}
}
controller.navigationItem.leftBarButtonItem = UIBarButtonItem(
systemItem: .close,
primaryAction: UIAction { [weak controller] _ in
controller?.dismiss(animated: true)
}
)
let nav = UINavigationController(rootViewController: controller)
viewController?.present(nav, animated: true)
}
}

private extension BlogDetailsTableViewModel {
Expand Down Expand Up @@ -1515,3 +1573,26 @@ private enum CellIdentifiers {
static let extensiveLogging = "BlogDetailsExtensiveLoggingCellIdentifier"
static let xmlrpcDisabled = "BlogDetailsXMLRPCDisabledCellIdentifier"
}

private enum XMLRPCDisabledAlertStrings {
static let title = NSLocalizedString(
"blogDetails.xmlrpcDisabled.alert.title",
value: "XML-RPC Disabled",
comment: "Title for the XML-RPC disabled alert"
)
static let description = NSLocalizedString(
"blogDetails.xmlrpcDisabled.alert.description",
value: "XML-RPC is disabled on your site. Some features in the app currently require XML-RPC. Connect Jetpack or enable XML-RPC to access all features.",
comment: "Description explaining options to restore functionality when XML-RPC is disabled"
)
static let connectJetpack = NSLocalizedString(
"blogDetails.xmlrpcDisabled.alert.connectJetpack",
value: "Connect Jetpack",
comment: "Button title to connect Jetpack in XML-RPC disabled alert"
)
static let learnMore = NSLocalizedString(
"blogDetails.xmlrpcDisabled.alert.learnMore",
value: "Learn more",
comment: "Button title to learn more about XML-RPC being disabled"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public class BlogDetailsViewController: UIViewController {

public func pulledToRefresh(with refreshControl: UIRefreshControl, onCompletion completion: (() -> Void)?) {
let completionBlock = completion ?? {}
checkXMLRPCStatus()
updateTableView { [weak refreshControl] in
DispatchQueue.main.async {
refreshControl?.endRefreshing()
Expand All @@ -161,6 +162,15 @@ public class BlogDetailsViewController: UIViewController {
}
}

public func refresh() {
guard let refreshControl = tableView?.refreshControl else {
wpAssertionFailure("Can't get the UIRefreshControl instance")
return
}
refreshControl.beginRefreshing()
pulledToRefreshTriggered(refreshControl)
}

private func preloadBlogData() {
// only preload on wifi
guard ReachabilityUtils.internetReachability?.isReachableViaWiFi() == true else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
import WordPressUI

class XMLRPCDisabledCell: UITableViewCell {
private weak var presenterViewController: UIViewController?
var onTapped: (() -> Void)?

private lazy var cardView: UIView = {
let view = UIView()
Expand All @@ -18,7 +18,7 @@ class XMLRPCDisabledCell: UITableViewCell {
view.addSubview(content)
view.pinSubviewToAllEdges(content)

view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(showAlert)))
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(cardTapped)))
return view
}()

Expand All @@ -36,26 +36,8 @@ class XMLRPCDisabledCell: UITableViewCell {
contentView.pinSubviewToAllEdges(cardView)
}

func configure(with viewController: BlogDetailsViewController) {
presenterViewController = viewController
}

@objc private func showAlert() {
guard let presenter = presenterViewController else {
return
}

let alert = AlertView {
AlertHeaderView(title: Strings.alertTitle, description: Strings.alertMessage)
} content: {
Image(systemName: "exclamationmark.triangle")
.font(.system(size: 50))
.foregroundStyle(.orange)
} actions: {
AlertDismissButton()
}

alert.present(in: presenter)
@objc private func cardTapped() {
onTapped?()
}
}

Expand Down Expand Up @@ -96,16 +78,4 @@ private enum Strings {
value: "Some features may be limited",
comment: "Subtitle for the XML-RPC disabled card on blog details"
)

static let alertTitle = NSLocalizedString(
"blogDetails.xmlrpcDisabled.alert.title",
value: "XML-RPC Disabled",
comment: "Alert title for XML-RPC disabled"
)

static let alertMessage = NSLocalizedString(
"blogDetails.xmlrpcDisabled.alert.message",
value: "XML-RPC is currently unavailable on your site. The app is transitioning to WordPress REST API, but some features still require XML-RPC. You may experience limited functionality until this transition is complete.",
comment: "Alert message explaining that XML-RPC is disabled on the site and some features may be limited"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ public class JetpackLoginViewController: UIViewController {
properties["source"] = "stats"
case .notifications:
properties["source"] = "notifications"
case .bypassXMLRPC:
properties["source"] = "bypass_xmlrpc"
}

if let blog {
Expand Down Expand Up @@ -292,10 +294,11 @@ extension JetpackLoginViewController: JetpackRemoteInstallDelegate {
public enum JetpackLoginPromptType {
case stats
case notifications
case bypassXMLRPC

var image: UIImage? {
switch self {
case .stats:
case .stats, .bypassXMLRPC:
return UIImage(named: "wp-illustration-stats")
case .notifications:
return UIImage(named: "wp-illustration-notifications")
Expand All @@ -304,7 +307,7 @@ public enum JetpackLoginPromptType {

var imageName: String {
switch self {
case .stats:
case .stats, .bypassXMLRPC:
return "wp-illustration-stats"
case .notifications:
return "wp-illustration-notifications"
Expand All @@ -319,6 +322,12 @@ public enum JetpackLoginPromptType {
case .notifications:
return NSLocalizedString("To get helpful notifications on your phone from your WordPress site, you'll need to install the Jetpack plugin.",
comment: "Message asking the user if they want to set up Jetpack from notifications")
case .bypassXMLRPC:
return NSLocalizedString(
"jetpack.install.allFeatures.description",
value: "To unlock all app features, you'll need to install the Jetpack plugin.",
comment: "Message asking the user to install Jetpack to access all app features"
)
}
}

Expand All @@ -332,6 +341,12 @@ public enum JetpackLoginPromptType {
return NSLocalizedString("jetpack.install.connectUser.notifications.description",
value: "To get helpful notifications on your phone from your WordPress site, you'll need to connect to your user account.",
comment: "Message asking the user if they want to set up Jetpack from notifications")
case .bypassXMLRPC:
return NSLocalizedString(
"jetpack.install.connectUser.bypassXMLRPC.description",
value: "To unlock all app features, you'll need to connect the Jetpack plugin to your user account.",
comment: "Message asking the user to connect Jetpack to access all app features"
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private struct JetpackConnectionView: View {
viewModel.connect()
}
.buttonStyle(.borderedProminent)
.controlSize(.small)
.controlSize(.regular)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I assume it changes the button size in the Jetpack Connection screen.

.padding(.bottom, 12)
} else if viewModel.isCompleted {
CompletedAnimationView {
Expand Down