Improve a few things about provider profile menus
- Add "Connect" item to connect to current server - Sort provider categories ("Default" should also come first) Reuse bundle from constants.
This commit is contained in:
parent
80f71507e3
commit
7a700408a8
|
@ -96,6 +96,7 @@ class DefaultLightProviderManager: LightProviderManager {
|
|||
fatalError("Unrecognized VPN protocol: \(vpnProtocol)")
|
||||
}
|
||||
return providerManager.categories(name, vpnProtocol: vpnProtocolType)
|
||||
.sorted()
|
||||
.map(DefaultLightProviderCategory.init)
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import Foundation
|
|||
|
||||
extension Constants {
|
||||
enum Mac {
|
||||
private static var bundle: Bundle {
|
||||
static var bundle: Bundle {
|
||||
Bundle(for: PassepartoutMac.self)
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,7 @@
|
|||
import Foundation
|
||||
import AppKit
|
||||
|
||||
private var bundle: Bundle {
|
||||
Bundle(for: PassepartoutMenu.StatusButton.self)
|
||||
}
|
||||
private let bundle = Constants.Mac.bundle
|
||||
|
||||
extension LightVPNStatus {
|
||||
var localizedDescription: String {
|
||||
|
|
|
@ -58,6 +58,10 @@ extension ProviderProfileItem {
|
|||
return category.name == profile.providerServer?.categoryName
|
||||
}
|
||||
|
||||
func connectTo() {
|
||||
vpnManager.connect(with: profile.id)
|
||||
}
|
||||
|
||||
func downloadIfNeeded() {
|
||||
providerManager.downloadIfNeeded(providerName, vpnProtocol: vpnProtocol)
|
||||
}
|
||||
|
|
|
@ -51,12 +51,21 @@ struct ProviderProfileItem: Item {
|
|||
private func submenu() -> NSMenu {
|
||||
let menu = NSMenu()
|
||||
let categories = viewModel.categories
|
||||
if categories.isEmpty {
|
||||
guard !categories.isEmpty else {
|
||||
let downloadItem = TextItem(L10n.Global.Strings.download) {
|
||||
viewModel.downloadIfNeeded()
|
||||
}
|
||||
menu.addItem(downloadItem.asMenuItem(withParent: menu))
|
||||
} else if categories.count > 1 {
|
||||
return menu
|
||||
}
|
||||
|
||||
let connectItem = TextItem(L10n.Global.Strings.connect) {
|
||||
viewModel.connectTo()
|
||||
}
|
||||
menu.addItem(connectItem.asMenuItem(withParent: menu))
|
||||
menu.addItem(.separator())
|
||||
|
||||
if categories.count > 1 {
|
||||
viewModel.categories.forEach {
|
||||
menu.addItem(categoryItem(with: $0, parent: menu))
|
||||
}
|
||||
|
@ -65,6 +74,7 @@ struct ProviderProfileItem: Item {
|
|||
menu.addItem(locationItem(with: $0, parent: menu))
|
||||
}
|
||||
}
|
||||
|
||||
return menu
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue