Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Merge release/21.4 into trunk" #14928

Closed
Closed
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
8 changes: 0 additions & 8 deletions Networking/Networking.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1120,8 +1120,6 @@
DEDA8DB52B187DE40076BF0F /* WordPressThemeMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEDA8DB42B187DE40076BF0F /* WordPressThemeMapper.swift */; };
DEDA8DB72B187E770076BF0F /* theme-mine-success.json in Resources */ = {isa = PBXBuildFile; fileRef = DEDA8DB62B187E770076BF0F /* theme-mine-success.json */; };
DEDA8DB92B187EC90076BF0F /* WordPressThemeMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEDA8DB82B187EC90076BF0F /* WordPressThemeMapperTests.swift */; };
DEE55CCC2D3A0551006D0251 /* site.json in Resources */ = {isa = PBXBuildFile; fileRef = DEE55CCB2D3A0551006D0251 /* site.json */; };
DEE55CCE2D3A069C006D0251 /* site-error.json in Resources */ = {isa = PBXBuildFile; fileRef = DEE55CCD2D3A069C006D0251 /* site-error.json */; };
DEEDA4442975003800F845AB /* settings-general-without-data.json in Resources */ = {isa = PBXBuildFile; fileRef = DEEDA4432975003800F845AB /* settings-general-without-data.json */; };
DEEF8E6529C832B500D47411 /* wordpress-site-info-with-auth-url.json in Resources */ = {isa = PBXBuildFile; fileRef = DEEF8E6429C832B500D47411 /* wordpress-site-info-with-auth-url.json */; };
DEEF8E6829C858AD00D47411 /* OneTimeApplicationPasswordUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEEF8E6729C858AD00D47411 /* OneTimeApplicationPasswordUseCase.swift */; };
Expand Down Expand Up @@ -2317,8 +2315,6 @@
DEDA8DB42B187DE40076BF0F /* WordPressThemeMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressThemeMapper.swift; sourceTree = "<group>"; };
DEDA8DB62B187E770076BF0F /* theme-mine-success.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "theme-mine-success.json"; sourceTree = "<group>"; };
DEDA8DB82B187EC90076BF0F /* WordPressThemeMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressThemeMapperTests.swift; sourceTree = "<group>"; };
DEE55CCB2D3A0551006D0251 /* site.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = site.json; sourceTree = "<group>"; };
DEE55CCD2D3A069C006D0251 /* site-error.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "site-error.json"; sourceTree = "<group>"; };
DEEDA4432975003800F845AB /* settings-general-without-data.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "settings-general-without-data.json"; sourceTree = "<group>"; };
DEEF8E6429C832B500D47411 /* wordpress-site-info-with-auth-url.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "wordpress-site-info-with-auth-url.json"; sourceTree = "<group>"; };
DEEF8E6729C858AD00D47411 /* OneTimeApplicationPasswordUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OneTimeApplicationPasswordUseCase.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3448,8 +3444,6 @@
CC0786622678F79500BA9AC1 /* shipping-label-purchase-success.json */,
CC0786C6267BB10700BA9AC1 /* shipping-label-status-success.json */,
CE606D8A2BE38B04001CB424 /* shipping-methods.json */,
DEE55CCB2D3A0551006D0251 /* site.json */,
DEE55CCD2D3A069C006D0251 /* site-error.json */,
B56C1EB920EA7D2C00D749F9 /* sites.json */,
2670C3FD270F4E6A002FE931 /* sites-malformed.json */,
7426CA1221AF34A3004E9FFC /* site-api.json */,
Expand Down Expand Up @@ -4565,7 +4559,6 @@
CEF2DD9D2B56E04F00A3DD0B /* jetpack-settings-invalid-module.json in Resources */,
45B79AC62C9355F800DCCB2C /* meta-data-products-and-orders_nested_in_data.json in Resources */,
DE9D6BCC270D769C00BA6562 /* shipping-label-address-without-name-validation-success.json in Resources */,
DEE55CCC2D3A0551006D0251 /* site.json in Resources */,
74A1D263211898F000931DFA /* site-visits-day.json in Resources */,
31054710262E2EE400C5C02B /* wcpay-payment-intent-succeeded.json in Resources */,
EE9826922B17569400A3F57E /* product-subscription-sync-renewals-day-month-format-int-values.json in Resources */,
Expand Down Expand Up @@ -4640,7 +4633,6 @@
2683D71024456EE4002A1589 /* categories-extra.json in Resources */,
A69FE19D2588D70E0059A96B /* order-with-deleted-refunds.json in Resources */,
E18152C228F85E0A0011A0EC /* iap-products.json in Resources */,
DEE55CCE2D3A069C006D0251 /* site-error.json in Resources */,
02B41A90296BC85800FE3311 /* site-domains.json in Resources */,
DE2004702BFB535500660A72 /* product-report.json in Resources */,
EE57C13E297FBEE200BC31E7 /* product-tags-created-without-data.json in Resources */,
Expand Down
19 changes: 0 additions & 19 deletions Networking/Networking/Remote/SiteRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public protocol SiteRemoteProtocol {
/// - Returns: The site that matches the site ID.
func loadSite(siteID: Int64) async throws -> Site

/// Loads a site.
/// - Parameter domain: Domain of the site to load.
/// - Returns: The site that matches the site ID.
func loadSite(domain: String) async throws -> Site

/// Update a site title.
/// - Parameters:
/// - siteID: Remote ID of the site to update
Expand Down Expand Up @@ -140,16 +135,6 @@ public class SiteRemote: Remote, SiteRemoteProtocol {
return try await enqueue(request)
}

public func loadSite(domain: String) async throws -> Site {
let path = Path.loadSite(domain: domain)
let parameters = [
SiteParameter.Fields.key: SiteParameter.Fields.value,
SiteParameter.Options.key: SiteParameter.Options.value
]
let request = DotcomRequest(wordpressApiVersion: .mark1_1, method: .get, path: path, parameters: parameters)
return try await enqueue(request)
}

public func updateSiteTitle(siteID: Int64, title: String) async throws {
let parameters = [
Fields.title: title
Expand Down Expand Up @@ -322,10 +307,6 @@ private extension SiteRemote {
"sites/\(siteID)"
}

static func loadSite(domain: String) -> String {
"sites/\(domain)"
}

static func siteSettings(siteID: Int64) -> String {
"sites/\(siteID)/settings"
}
Expand Down
30 changes: 0 additions & 30 deletions Networking/NetworkingTests/Remote/SiteRemoteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,34 +292,4 @@ final class SiteRemoteTests: XCTestCase {
(error as? DotcomError) == .unauthorized
})
}

// MARK: - `loadSite`

func test_loadSite_by_domain_returns_site_info_on_success() async throws {
// Given
let domain = "example.com"
network.simulateResponse(requestUrlSuffix: "sites/\(domain)", filename: "site")

// When
let response = try await remote.loadSite(domain: domain)

// Then
XCTAssertEqual(response.siteID, 1112233334444555)
XCTAssertEqual(response.name, "Testing Blog")
XCTAssertEqual(response.url, "https://some-testing-url.testing.blog")
}

func test_loadSite_by_domain_returns_error_upon_failure() async throws {
// Given
let domain = "example.com"
network.simulateResponse(requestUrlSuffix: "sites/\(domain)", filename: "site-error")

await assertThrowsError({
// When
_ = try await remote.loadSite(domain: domain)
}, errorAssert: { ($0 as? DotcomError) == .unknown(
code: "parse_error",
message: "The Jetpack site is inaccessible or returned an error: parse error (local). not well formed [-32710]"
)})
}
}
4 changes: 0 additions & 4 deletions Networking/NetworkingTests/Responses/site-error.json

This file was deleted.

176 changes: 0 additions & 176 deletions Networking/NetworkingTests/Responses/site.json

This file was deleted.

2 changes: 1 addition & 1 deletion WooCommerce/Classes/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ private extension AppDelegate {
// MARK: - Magic link
private extension AppDelegate {
func handleAuthenticationUrl(_ url: URL, options: [UIApplication.OpenURLOptionsKey: Any], rootViewController: UIViewController) -> Bool {
return if ServiceLocator.stores.isAuthenticated {
return if ServiceLocator.stores.isAuthenticatedWithoutWPCom {
handleAuthenticationUrlForJetpackSetup(url, rootViewController: rootViewController)
} else {
ServiceLocator.authenticationManager.handleAuthenticationUrl(url, options: options, rootViewController: rootViewController)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ private extension EditStoreListView {
comment: "Header of the Other Stores section on the Edit Store List view"
)
static let otherStoresFooter = NSLocalizedString(
"editStoreListView.unselectedStoresNote",
value: "Unselected stores will be excluded from the store picker and won't receive push notifications for new orders or product.",
"editStoreListView.otherStoresFooter",
value: "Stores that are not selected will be excluded from the store picker",
comment: "Footer of the Other Stores section on the Edit Store List view"
)
static let retryButton = NSLocalizedString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,17 +251,15 @@ private extension JetpackSetupCoordinator {

func authenticateUserAndRefreshSite(with credentials: Credentials) {
analytics.track(.jetpackSetupCompleted)
let previousCredentials = stores.sessionManager.defaultCredentials
stores.sessionManager.deleteApplicationPassword()
stores.authenticate(credentials: credentials)

let progressView = InProgressViewController(viewProperties: .init(title: Localization.syncingData, message: ""))
rootViewController.topmostPresentedViewController.present(progressView, animated: true)

let action = SiteAction.syncSiteByDomain(domain: site.url.trimHTTPScheme()) { [weak self] result in
let action = AccountAction.synchronizeSitesAndReturnSelectedSiteInfo(siteAddress: site.url) { [weak self] result in
guard let self else { return }
switch result {
case .success(let site):
self.stores.sessionManager.deleteApplicationPassword()
self.stores.updateDefaultStore(storeID: site.siteID)
self.stores.synchronizeEntities { [weak self] in
self?.stores.updateDefaultStore(site)
Expand All @@ -279,11 +277,6 @@ private extension JetpackSetupCoordinator {
progressView.dismiss(animated: true, completion: { [weak self] in
self?.showAlert(message: Localization.errorFetchingSites, onRetry: {
self?.authenticateUserAndRefreshSite(with: credentials)
}, onCancel: {
// Revert the change to credentials
if let previousCredentials {
self?.stores.authenticate(credentials: previousCredentials)
}
})
})

Expand Down Expand Up @@ -443,8 +436,7 @@ private extension JetpackSetupCoordinator {
/// Shows an error alert with a button to retry the failed action.
///
func showAlert(message: String,
onRetry: (() -> Void)? = nil,
onCancel: (() -> Void)? = nil) {
onRetry: (() -> Void)? = nil) {
let alert = UIAlertController(title: message,
message: nil,
preferredStyle: .alert)
Expand All @@ -454,9 +446,7 @@ private extension JetpackSetupCoordinator {
}
alert.addAction(retryAction)
}
let cancelAction = UIAlertAction(title: Localization.cancelButton, style: .cancel) { _ in
onCancel?()
}
let cancelAction = UIAlertAction(title: Localization.cancelButton, style: .cancel)
alert.addAction(cancelAction)
rootViewController.topmostPresentedViewController.present(alert, animated: true)
}
Expand Down
Loading
Loading