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)")
|
fatalError("Unrecognized VPN protocol: \(vpnProtocol)")
|
||||||
}
|
}
|
||||||
return providerManager.categories(name, vpnProtocol: vpnProtocolType)
|
return providerManager.categories(name, vpnProtocol: vpnProtocolType)
|
||||||
|
.sorted()
|
||||||
.map(DefaultLightProviderCategory.init)
|
.map(DefaultLightProviderCategory.init)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ import Foundation
|
||||||
|
|
||||||
extension Constants {
|
extension Constants {
|
||||||
enum Mac {
|
enum Mac {
|
||||||
private static var bundle: Bundle {
|
static var bundle: Bundle {
|
||||||
Bundle(for: PassepartoutMac.self)
|
Bundle(for: PassepartoutMac.self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,7 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import AppKit
|
import AppKit
|
||||||
|
|
||||||
private var bundle: Bundle {
|
private let bundle = Constants.Mac.bundle
|
||||||
Bundle(for: PassepartoutMenu.StatusButton.self)
|
|
||||||
}
|
|
||||||
|
|
||||||
extension LightVPNStatus {
|
extension LightVPNStatus {
|
||||||
var localizedDescription: String {
|
var localizedDescription: String {
|
||||||
|
|
|
@ -58,6 +58,10 @@ extension ProviderProfileItem {
|
||||||
return category.name == profile.providerServer?.categoryName
|
return category.name == profile.providerServer?.categoryName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func connectTo() {
|
||||||
|
vpnManager.connect(with: profile.id)
|
||||||
|
}
|
||||||
|
|
||||||
func downloadIfNeeded() {
|
func downloadIfNeeded() {
|
||||||
providerManager.downloadIfNeeded(providerName, vpnProtocol: vpnProtocol)
|
providerManager.downloadIfNeeded(providerName, vpnProtocol: vpnProtocol)
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,21 @@ struct ProviderProfileItem: Item {
|
||||||
private func submenu() -> NSMenu {
|
private func submenu() -> NSMenu {
|
||||||
let menu = NSMenu()
|
let menu = NSMenu()
|
||||||
let categories = viewModel.categories
|
let categories = viewModel.categories
|
||||||
if categories.isEmpty {
|
guard !categories.isEmpty else {
|
||||||
let downloadItem = TextItem(L10n.Global.Strings.download) {
|
let downloadItem = TextItem(L10n.Global.Strings.download) {
|
||||||
viewModel.downloadIfNeeded()
|
viewModel.downloadIfNeeded()
|
||||||
}
|
}
|
||||||
menu.addItem(downloadItem.asMenuItem(withParent: menu))
|
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 {
|
viewModel.categories.forEach {
|
||||||
menu.addItem(categoryItem(with: $0, parent: menu))
|
menu.addItem(categoryItem(with: $0, parent: menu))
|
||||||
}
|
}
|
||||||
|
@ -65,6 +74,7 @@ struct ProviderProfileItem: Item {
|
||||||
menu.addItem(locationItem(with: $0, parent: menu))
|
menu.addItem(locationItem(with: $0, parent: menu))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return menu
|
return menu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue