mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 12:00:09 +02:00
👌 Cleanup dependencies for site isolation
This commit is contained in:
@ -41,25 +41,21 @@ struct VersionPopoverView: View {
|
||||
color: Color("AppColor")
|
||||
)
|
||||
if prefersIsolationSuggestions {
|
||||
// SITE ISOLATION (preferred)
|
||||
LazyVGrid(columns: self.rows, alignment: .leading, spacing: 5, content: {
|
||||
ForEach(validPhpVersions, id: \.self) { version in
|
||||
Button("site_link.isolate_php".localized(version.short), action: {
|
||||
Task {
|
||||
// Applies isolation
|
||||
App.shared.domainListWindowController?.contentVC.setUIBusy()
|
||||
try? await site.isolate(version: version.short)
|
||||
App.shared.domainListWindowController?.pressedReload(nil)
|
||||
App.shared.domainListWindowController?.contentVC.setUINotBusy()
|
||||
}
|
||||
App.shared.domainListWindowController?.contentVC
|
||||
.isolateSite(site: site, version: version.short)
|
||||
parent?.close()
|
||||
}).padding(EdgeInsets(top: 3, leading: 0, bottom: 3, trailing: 0))
|
||||
}
|
||||
}).padding(EdgeInsets(top: 5, leading: 0, bottom: 0, trailing: 0))
|
||||
} else {
|
||||
// GLOBAL SWITCHER
|
||||
LazyVGrid(columns: self.rows, alignment: .leading, spacing: 5, content: {
|
||||
ForEach(validPhpVersions, id: \.self) { version in
|
||||
Button("site_link.switch_to_php".localized(version.short), action: {
|
||||
// Uses the global switcher
|
||||
MainMenu.shared.switchToPhpVersion(version.short)
|
||||
parent?.close()
|
||||
}).padding(EdgeInsets(top: 3, leading: 0, bottom: 3, trailing: 0))
|
||||
|
@ -126,17 +126,17 @@ extension DomainListVC {
|
||||
}
|
||||
}
|
||||
|
||||
@objc func isolateSite(sender: PhpMenuItem) {
|
||||
guard let site = selectedSite else {
|
||||
return
|
||||
}
|
||||
|
||||
public func isolateSite(site: ValetSite, version: String) {
|
||||
waitAndExecute {
|
||||
do {
|
||||
// Instruct Valet to isolate a given PHP version
|
||||
try await site.isolate(version: sender.version)
|
||||
// Reload the UI
|
||||
self.reloadSelectedRow()
|
||||
try await site.isolate(version: version)
|
||||
// Reload the UI if it's the same site
|
||||
if self.selectedSite?.absolutePath == site.absolutePath {
|
||||
self.reloadSelectedRow()
|
||||
} else {
|
||||
await self.reloadDomains()
|
||||
}
|
||||
} catch {
|
||||
// Notify the user about a failed command
|
||||
let error = error as! ValetInteractionError
|
||||
@ -145,7 +145,15 @@ extension DomainListVC {
|
||||
}
|
||||
}
|
||||
|
||||
@objc func removeIsolatedSite() {
|
||||
@objc func isolateSiteViaMenuItem(sender: PhpMenuItem) {
|
||||
guard let site = selectedSite else {
|
||||
return
|
||||
}
|
||||
|
||||
self.isolateSite(site: site, version: sender.version)
|
||||
}
|
||||
|
||||
@objc func removeIsolatedSiteViaMenuItem() {
|
||||
guard let site = selectedSite else {
|
||||
return
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ extension DomainListVC {
|
||||
for version in PhpEnvironments.shared.availablePhpVersions.reversed() {
|
||||
let item = PhpMenuItem(
|
||||
title: "domain_list.always_use_php".localized(version),
|
||||
action: #selector(self.isolateSite),
|
||||
action: #selector(self.isolateSiteViaMenuItem),
|
||||
keyEquivalent: ""
|
||||
)
|
||||
if site.servingPhpVersion == version && site.isolatedPhpVersion != nil {
|
||||
@ -137,7 +137,7 @@ extension DomainListVC {
|
||||
items.append(NSMenuItem.separator())
|
||||
items.append(NSMenuItem(
|
||||
title: "domain_list.remove_isolation".localized,
|
||||
action: #selector(self.removeIsolatedSite)
|
||||
action: #selector(self.removeIsolatedSiteViaMenuItem)
|
||||
))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user