1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-08 04:20:07 +02:00

Allow opening of proxies in browser

This commit is contained in:
2022-04-21 19:18:05 +02:00
parent 932a0fe176
commit ba93ed93e4
6 changed files with 29 additions and 6 deletions

View File

@ -49,11 +49,11 @@ extension DomainListVC {
} }
@objc func openInBrowser() { @objc func openInBrowser() {
let prefix = selectedSite!.secured ? "https://" : "http://" guard let selected = self.selected else {
let url = URL(string: "\(prefix)\(selectedSite!.name).\(Valet.shared.config.tld)") return
if url != nil { }
NSWorkspace.shared.open(url!)
} else { guard let url = selected.getListableUrl() else {
BetterAlert() BetterAlert()
.withInformation( .withInformation(
title: "domain_list.alert.invalid_folder_name".localized, title: "domain_list.alert.invalid_folder_name".localized,
@ -61,7 +61,10 @@ extension DomainListVC {
) )
.withPrimary(text: "OK") .withPrimary(text: "OK")
.show() .show()
return
} }
NSWorkspace.shared.open(url)
} }
@objc func openInFinder() { @objc func openInFinder() {

View File

@ -140,10 +140,20 @@ extension DomainListVC {
private func addMenuItemsForProxy(_ proxy: ValetProxy) { private func addMenuItemsForProxy(_ proxy: ValetProxy) {
let menu = NSMenu() let menu = NSMenu()
addOpenProxyInBrowser(to: menu)
addSeparator(to: menu)
addRemoveProxy(to: menu) addRemoveProxy(to: menu)
tableView.menu = menu tableView.menu = menu
} }
private func addOpenProxyInBrowser(to menu: NSMenu) {
menu.addItem(
withTitle: "domain_list.open_in_browser".localized,
action: #selector(self.openInBrowser),
keyEquivalent: "B"
)
}
private func addRemoveProxy(to menu: NSMenu) { private func addRemoveProxy(to menu: NSMenu) {
menu.addItem( menu.addItem(
withTitle: "domain_list.unproxy".localized, withTitle: "domain_list.unproxy".localized,

View File

@ -251,7 +251,7 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
} }
@objc func doubleClicked(sender: Any) { @objc func doubleClicked(sender: Any) {
guard self.selectedSite != nil else { guard self.selected != nil else {
return return
} }

View File

@ -22,4 +22,6 @@ protocol DomainListable {
func getListableType() -> String func getListableType() -> String
func getListableUrl() -> URL?
} }

View File

@ -47,4 +47,8 @@ class ValetProxy: DomainListable
func getListableType() -> String { func getListableType() -> String {
return "proxy" return "proxy"
} }
func getListableUrl() -> URL? {
return URL(string: "\(self.secured ? "https://" : "http://")\(self.domain).\(self.tld)")
}
} }

View File

@ -257,4 +257,8 @@ class ValetSite: DomainListable {
func getListableType() -> String { func getListableType() -> String {
return self.driver ?? "ZZZ" return self.driver ?? "ZZZ"
} }
func getListableUrl() -> URL? {
return URL(string: "\(self.secured ? "https://" : "http://")\(self.name).\(Valet.shared.config.tld)")
}
} }