Share guidance metadata in Core
This commit is contained in:
parent
494f0d0322
commit
35a149435e
|
@ -208,15 +208,6 @@ extension Infrastructure.Metadata {
|
|||
}
|
||||
return image
|
||||
}
|
||||
|
||||
var guidanceString: String? {
|
||||
let key = "account.sections.guidance.footer.infrastructure.\(name)"
|
||||
let format = NSLocalizedString(key, tableName: "Core", bundle: Bundle(for: AppDelegate.self), comment: "")
|
||||
guard format != key else {
|
||||
return nil
|
||||
}
|
||||
return String(format: format, locale: .current, description)
|
||||
}
|
||||
}
|
||||
|
||||
extension PoolGroup {
|
||||
|
|
|
@ -57,27 +57,6 @@ class AccountViewController: UIViewController, StrongTableHost {
|
|||
return Credentials(username, password).trimmed()
|
||||
}
|
||||
|
||||
private var guidanceString: String? {
|
||||
guard let name = infrastructureName, let metadata = InfrastructureFactory.shared.metadata(forName: name) else {
|
||||
return nil
|
||||
}
|
||||
return metadata.guidanceString
|
||||
}
|
||||
|
||||
private var guidanceURL: String? {
|
||||
guard let name = infrastructureName else {
|
||||
return nil
|
||||
}
|
||||
return AppConstants.URLs.guidances[name]
|
||||
}
|
||||
|
||||
private var referralURL: String? {
|
||||
guard let name = infrastructureName else {
|
||||
return nil
|
||||
}
|
||||
return AppConstants.URLs.referrals[name]
|
||||
}
|
||||
|
||||
weak var delegate: AccountViewControllerDelegate?
|
||||
|
||||
// MARK: StrongTableHost
|
||||
|
@ -144,17 +123,17 @@ class AccountViewController: UIViewController, StrongTableHost {
|
|||
}
|
||||
|
||||
private func openGuidanceURL() {
|
||||
guard let urlString = guidanceURL else {
|
||||
guard let url = guidanceURL else {
|
||||
return
|
||||
}
|
||||
UIApplication.shared.open(URL(string: urlString)!, options: [:], completionHandler: nil)
|
||||
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||
}
|
||||
|
||||
private func openReferralURL() {
|
||||
guard let urlString = referralURL else {
|
||||
guard let url = referralURL else {
|
||||
return
|
||||
}
|
||||
UIApplication.shared.open(URL(string: urlString)!, options: [:], completionHandler: nil)
|
||||
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||
}
|
||||
|
||||
@IBAction private func done() {
|
||||
|
@ -286,3 +265,24 @@ extension AccountViewController: UITableViewDataSource, UITableViewDelegate, Fie
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension AccountViewController {
|
||||
private var guidanceString: String? {
|
||||
return metadata?.guidanceString
|
||||
}
|
||||
|
||||
private var guidanceURL: URL? {
|
||||
return metadata?.guidanceURL
|
||||
}
|
||||
|
||||
private var referralURL: URL? {
|
||||
return metadata?.referralURL
|
||||
}
|
||||
|
||||
private var metadata: Infrastructure.Metadata? {
|
||||
guard let name = infrastructureName else {
|
||||
return nil
|
||||
}
|
||||
return InfrastructureFactory.shared.metadata(forName: name)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -805,7 +805,7 @@ DQ
|
|||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="openGuidance:" target="9cc-44-7Ec" id="YJy-EF-tl2"/>
|
||||
<action selector="openGuidanceURL:" target="9cc-44-7Ec" id="tsU-Ot-gPe"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
|
|
|
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Changed
|
||||
|
||||
- Improved debug log appearance.
|
||||
- Show information from provider metadata in account.
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -88,7 +88,9 @@ class AccountViewController: NSViewController {
|
|||
}
|
||||
}
|
||||
|
||||
@IBAction private func openGuidance(_ sender: Any?) {
|
||||
// MARK: Actions
|
||||
|
||||
@IBAction private func openGuidanceURL(_ sender: Any?) {
|
||||
guard let url = guidanceURL else {
|
||||
return
|
||||
}
|
||||
|
@ -126,27 +128,22 @@ class AccountViewController: NSViewController {
|
|||
}
|
||||
|
||||
extension AccountViewController {
|
||||
private var infrastructureName: Infrastructure.Name? {
|
||||
guard let providerProfile = profile as? ProviderConnectionProfile else {
|
||||
return nil
|
||||
}
|
||||
return providerProfile.name
|
||||
}
|
||||
|
||||
private var guidanceString: String? {
|
||||
guard let name = infrastructureName, let metadata = InfrastructureFactory.shared.metadata(forName: name) else {
|
||||
return nil
|
||||
}
|
||||
return metadata.guidanceString
|
||||
return metadata?.guidanceString
|
||||
}
|
||||
|
||||
private var guidanceURL: URL? {
|
||||
guard let name = infrastructureName else {
|
||||
return metadata?.guidanceURL
|
||||
}
|
||||
|
||||
private var referralURL: URL? {
|
||||
return metadata?.referralURL
|
||||
}
|
||||
|
||||
private var metadata: Infrastructure.Metadata? {
|
||||
guard let providerProfile = profile as? ProviderConnectionProfile else {
|
||||
return nil
|
||||
}
|
||||
guard let string = AppConstants.URLs.guidances[name] else {
|
||||
return nil
|
||||
}
|
||||
return URL(string: string)
|
||||
return InfrastructureFactory.shared.metadata(forName: providerProfile.name)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,3 +198,28 @@ public extension Array where Element: CustomStringConvertible {
|
|||
return sorted { $0.description.lowercased() < $1.description.lowercased() }
|
||||
}
|
||||
}
|
||||
|
||||
public extension Infrastructure.Metadata {
|
||||
var guidanceString: String? {
|
||||
let key = "account.sections.guidance.footer.infrastructure.\(name)"
|
||||
let format = NSLocalizedString(key, tableName: "Core", bundle: .main, comment: "")
|
||||
guard format != key else {
|
||||
return nil
|
||||
}
|
||||
return String(format: format, locale: .current, description)
|
||||
}
|
||||
|
||||
var guidanceURL: URL? {
|
||||
guard let string = AppConstants.URLs.guidances[name] else {
|
||||
return nil
|
||||
}
|
||||
return URL(string: string)
|
||||
}
|
||||
|
||||
var referralURL: URL? {
|
||||
guard let string = AppConstants.URLs.referrals[name] else {
|
||||
return nil
|
||||
}
|
||||
return URL(string: string)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue