From 23c2cc426af63b1f31ab6b5da83f13c7ada01458 Mon Sep 17 00:00:00 2001 From: Tony Li Date: Thu, 2 Jul 2026 11:49:46 +1200 Subject: [PATCH 1/2] Format LoginWithUrlView.swift with swift-format --- WordPress/Classes/Login/LoginWithUrlView.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/Classes/Login/LoginWithUrlView.swift b/WordPress/Classes/Login/LoginWithUrlView.swift index 094eaf59f4cb..5574696ceb04 100644 --- a/WordPress/Classes/Login/LoginWithUrlView.swift +++ b/WordPress/Classes/Login/LoginWithUrlView.swift @@ -126,7 +126,8 @@ struct LoginWithUrlView: View { if Task.isCancelled { return } if case let .oAuth2(endpoints) = details.authentication, - endpoints.authorizationUrl.contains("public-api.wordpress.com") { + endpoints.authorizationUrl.contains("public-api.wordpress.com") + { presenter.dismiss(animated: true) { Notice(title: Strings.wpcomSiteRedirect).post() presentDotComLogin() @@ -171,6 +172,6 @@ private enum Strings { LoginWithUrlView( presenter: nil, loginCompleted: { _ in }, - presentDotComLogin: { } + presentDotComLogin: {} ) } From e0dfac629b78e250425ded7de522ec252c45eb57 Mon Sep 17 00:00:00 2001 From: Tony Li Date: Thu, 2 Jul 2026 12:52:00 +1200 Subject: [PATCH 2/2] Add Contact Support button to self-hosted site login errors When signing in to a self-hosted site fails, show a Contact Support link below the error message that presents the Help & Support screen from the topmost view controller. --- .../Classes/Login/LoginWithUrlView.swift | 67 ++++++++++++++++--- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/WordPress/Classes/Login/LoginWithUrlView.swift b/WordPress/Classes/Login/LoginWithUrlView.swift index 5574696ceb04..6d4ceb9a291c 100644 --- a/WordPress/Classes/Login/LoginWithUrlView.swift +++ b/WordPress/Classes/Login/LoginWithUrlView.swift @@ -5,6 +5,7 @@ import WordPressAPIInternal import WordPressData import DesignSystem import WordPressShared +import WordPressUI struct LoginWithUrlView: View { @@ -38,8 +39,7 @@ struct LoginWithUrlView: View { siteAdddressTextField() if let errorMessage { - Text(errorMessage) - .foregroundStyle(.red) + errorSection(errorMessage) } Spacer() @@ -73,6 +73,28 @@ struct LoginWithUrlView: View { .navigationBarTitleDisplayMode(.inline) } + private func errorSection(_ message: String) -> some View { + VStack(alignment: .leading, spacing: 8) { + Text(message) + .foregroundStyle(.red) + Button(Strings.contactSupport) { + contactSupportTapped() + } + .font(.subheadline.weight(.medium)) + } + } + + private func contactSupportTapped() { + guard let presenter else { + wpAssertionFailure("No presenter assigned") + return + } + // The `presenter` sits below the sheet hosting this view, so present + // the support screen from the topmost view controller instead. + let supportViewController = SupportTableViewController() + supportViewController.show(from: presenter.topmostPresentedViewController) + } + private func siteAdddressTextField() -> some View { HStack { TextField(text: $urlField) { @@ -164,14 +186,43 @@ private enum Strings { value: "This site is hosted on WordPress.com. Please log in with your WordPress.com account.", comment: "Notice message shown when a user tries to add a WordPress.com site as self-hosted" ) + + static let contactSupport = NSLocalizedString( + "addSite.selfHosted.contactSupport", + value: "Contact Support", + comment: "Button to contact support, shown when signing in to a self-hosted site fails" + ) } // MARK: - SwiftUI Preview -#Preview { - LoginWithUrlView( - presenter: nil, - loginCompleted: { _ in }, - presentDotComLogin: {} - ) +extension LoginWithUrlView { + /// Preview-only convenience to force the error state. + fileprivate init(errorMessage: String?, urlField: String) { + self.presenter = nil + self.loginCompleted = { _ in } + self.presentDotComLogin = {} + self._errorMessage = State(initialValue: errorMessage) + self._urlField = State(initialValue: urlField) + } +} + +#Preview("Default") { + NavigationStack { + LoginWithUrlView( + presenter: nil, + loginCompleted: { _ in }, + presentDotComLogin: {} + ) + } +} + +#Preview("Sign-in failed") { + NavigationStack { + LoginWithUrlView( + errorMessage: + "We couldn't log in to your site. The site at mysite.example.com doesn't appear to have the REST API enabled.", + urlField: "mysite.example.com" + ) + } }