Skip to content

Commit 4ccb6e7

Browse files
authored
Merge pull request #741 from r1b2ns/feat/redirect-new-user-to-login
feat: improve user experience with a redirect window to sign-in
2 parents 00dcf38 + 22e4991 commit 4ccb6e7

4 files changed

Lines changed: 145 additions & 1 deletion

File tree

Xcodes/Backend/AppState.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,11 @@ class AppState: ObservableObject {
611611
self.installationPublishers[id] = nil
612612
if case let .failure(error) = completion {
613613
// Prevent setting the app state error if it is an invalid session, we will present the sign in view instead
614-
if error as? AuthenticationError != .invalidSession {
614+
if let error = error as? AuthenticationError, case .notAuthorized = error {
615+
self.error = error
616+
self.presentedAlert = .unauthenticated
617+
618+
} else if error as? AuthenticationError != .invalidSession {
615619
self.error = error
616620
self.presentedAlert = .generic(title: localizeString("Alert.Install.Error.Title"), message: error.legibleLocalizedDescription)
617621
}

Xcodes/Frontend/Common/XcodesAlert.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ enum XcodesAlert: Identifiable {
77
case privilegedHelper
88
case generic(title: String, message: String)
99
case checkMinSupportedVersion(xcode: AvailableXcode, macOS: String)
10+
case unauthenticated
1011

1112
var id: Int {
1213
switch self {
@@ -15,6 +16,7 @@ enum XcodesAlert: Identifiable {
1516
case .generic: return 3
1617
case .checkMinSupportedVersion: return 4
1718
case .cancelRuntimeInstall: return 5
19+
case .unauthenticated: return 6
1820
}
1921
}
2022
}

Xcodes/Frontend/MainWindow.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,20 @@ struct MainWindow: View {
190190
action: { appState.presentedAlert = nil }
191191
)
192192
)
193+
case .unauthenticated:
194+
return Alert(
195+
title: Text("Alert.Install.Error.Title"),
196+
message: Text("Alert.Install.AuthError.Message"),
197+
primaryButton: .default(
198+
Text("OK"),
199+
action: {
200+
appState.presentedSheet = .signIn
201+
}
202+
),
203+
secondaryButton: .cancel(
204+
Text("Cancel")
205+
)
206+
)
193207
case let .checkMinSupportedVersion(xcode, deviceVersion):
194208
return Alert(
195209
title: Text("Alert.MinSupported.Title"),

Xcodes/Resources/Localizable.xcstrings

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,6 +1958,130 @@
19581958
}
19591959
}
19601960
},
1961+
"Alert.Install.AuthError.Message" : {
1962+
"localizations" : {
1963+
"ar" : {
1964+
"stringUnit" : {
1965+
"state" : "translated",
1966+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
1967+
}
1968+
},
1969+
"ca" : {
1970+
"stringUnit" : {
1971+
"state" : "translated",
1972+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
1973+
}
1974+
},
1975+
"de" : {
1976+
"stringUnit" : {
1977+
"state" : "translated",
1978+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
1979+
}
1980+
},
1981+
"el" : {
1982+
"stringUnit" : {
1983+
"state" : "translated",
1984+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
1985+
}
1986+
},
1987+
"en" : {
1988+
"stringUnit" : {
1989+
"state" : "translated",
1990+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
1991+
}
1992+
},
1993+
"es" : {
1994+
"stringUnit" : {
1995+
"state" : "translated",
1996+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
1997+
}
1998+
},
1999+
"fi" : {
2000+
"stringUnit" : {
2001+
"state" : "translated",
2002+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2003+
}
2004+
},
2005+
"fr" : {
2006+
"stringUnit" : {
2007+
"state" : "translated",
2008+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2009+
}
2010+
},
2011+
"hi" : {
2012+
"stringUnit" : {
2013+
"state" : "translated",
2014+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2015+
}
2016+
},
2017+
"it" : {
2018+
"stringUnit" : {
2019+
"state" : "translated",
2020+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2021+
}
2022+
},
2023+
"ja" : {
2024+
"stringUnit" : {
2025+
"state" : "translated",
2026+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2027+
}
2028+
},
2029+
"ko" : {
2030+
"stringUnit" : {
2031+
"state" : "translated",
2032+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2033+
}
2034+
},
2035+
"nl" : {
2036+
"stringUnit" : {
2037+
"state" : "translated",
2038+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2039+
}
2040+
},
2041+
"pl" : {
2042+
"stringUnit" : {
2043+
"state" : "translated",
2044+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2045+
}
2046+
},
2047+
"pt-BR" : {
2048+
"stringUnit" : {
2049+
"state" : "translated",
2050+
"value" : "Você não está autorizado. Por favor, entre com o seu ID Apple primeiro."
2051+
}
2052+
},
2053+
"ru" : {
2054+
"stringUnit" : {
2055+
"state" : "translated",
2056+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2057+
}
2058+
},
2059+
"tr" : {
2060+
"stringUnit" : {
2061+
"state" : "translated",
2062+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2063+
}
2064+
},
2065+
"uk" : {
2066+
"stringUnit" : {
2067+
"state" : "translated",
2068+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2069+
}
2070+
},
2071+
"zh-Hans" : {
2072+
"stringUnit" : {
2073+
"state" : "translated",
2074+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2075+
}
2076+
},
2077+
"zh-Hant" : {
2078+
"stringUnit" : {
2079+
"state" : "translated",
2080+
"value" : "You are not authorized. Please Sign in with your Apple ID first."
2081+
}
2082+
}
2083+
}
2084+
},
19612085
"Alert.Install.Error.Need.Xcode16.1" : {
19622086
"extractionState" : "manual",
19632087
"localizations" : {

0 commit comments

Comments
 (0)