mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
✨ Allow toggling extensions via site list
This commit is contained in:
@ -110,6 +110,22 @@ extension DomainListVC {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func toggleExtension(sender: ExtensionMenuItem) {
|
||||||
|
Task {
|
||||||
|
self.setUIBusy()
|
||||||
|
|
||||||
|
await sender.phpExtension?.toggle()
|
||||||
|
|
||||||
|
if Preferences.isEnabled(.autoServiceRestartAfterExtensionToggle) {
|
||||||
|
await Actions.restartPhpFpm()
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadContextMenu()
|
||||||
|
|
||||||
|
self.setUINotBusy()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@objc func isolateSite(sender: PhpMenuItem) {
|
@objc func isolateSite(sender: PhpMenuItem) {
|
||||||
guard let site = selectedSite else {
|
guard let site = selectedSite else {
|
||||||
return
|
return
|
||||||
|
@ -42,7 +42,20 @@ extension DomainListVC {
|
|||||||
addDisabledIsolation(to: menu)
|
addDisabledIsolation(to: menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addSeparator(to: menu)
|
||||||
|
|
||||||
|
if let extensions = site.isolatedPhpVersion?.extensions ?? PhpEnvironments.phpInstall?.extensions,
|
||||||
|
let version = site.isolatedPhpVersion?.versionNumber.short ?? PhpEnvironments.phpInstall?.version.short {
|
||||||
|
menu.addItem(HeaderView.asMenuItem(text: "mi_detected_extensions".localized))
|
||||||
|
addMenuItemsForExtensions(
|
||||||
|
to: menu,
|
||||||
|
for: extensions,
|
||||||
|
version: version
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
menu.addItem(HeaderView.asMenuItem(text: "domain_list.actions".localized))
|
menu.addItem(HeaderView.asMenuItem(text: "domain_list.actions".localized))
|
||||||
|
|
||||||
addToggleSecure(to: menu, secured: site.secured)
|
addToggleSecure(to: menu, secured: site.secured)
|
||||||
addUnlink(to: menu, with: site)
|
addUnlink(to: menu, with: site)
|
||||||
|
|
||||||
@ -150,6 +163,28 @@ extension DomainListVC {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func addMenuItemsForExtensions(to menu: NSMenu, for extensions: [PhpExtension], version: String) {
|
||||||
|
var items: [NSMenuItem] = [
|
||||||
|
NSMenuItem(title: "domain_list.applies_to".localized(version))
|
||||||
|
]
|
||||||
|
|
||||||
|
for phpExtension in extensions {
|
||||||
|
let item = ExtensionMenuItem(
|
||||||
|
title: "\(phpExtension.name) (\(phpExtension.fileNameOnly))",
|
||||||
|
action: #selector(self.toggleExtension),
|
||||||
|
keyEquivalent: ""
|
||||||
|
)
|
||||||
|
|
||||||
|
item.state = phpExtension.enabled ? .on : .off
|
||||||
|
item.phpExtension = phpExtension
|
||||||
|
|
||||||
|
items.append(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.addItem(NSMenuItem(title: "domain_list.extensions".localized, submenu: items))
|
||||||
|
menu.addItem(NSMenuItem.separator())
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Menu Items for Proxy
|
// MARK: - Menu Items for Proxy
|
||||||
|
|
||||||
private func addMenuItemsForProxy(_ proxy: ValetProxy) {
|
private func addMenuItemsForProxy(_ proxy: ValetProxy) {
|
||||||
|
@ -264,6 +264,9 @@ You may be asked for your password during the uninstallation process if file per
|
|||||||
"domain_list.columns.kind" = "Kind";
|
"domain_list.columns.kind" = "Kind";
|
||||||
"domain_list.columns.project_type" = "Project Type";
|
"domain_list.columns.project_type" = "Project Type";
|
||||||
|
|
||||||
|
"domain_list.extensions" = "Toggle Extensions";
|
||||||
|
"domain_list.applies_to" = "Applies to PHP %@";
|
||||||
|
|
||||||
// CHOOSE WHAT TO ADD
|
// CHOOSE WHAT TO ADD
|
||||||
|
|
||||||
"selection.title" = "What kind of domain would you like to set up?";
|
"selection.title" = "What kind of domain would you like to set up?";
|
||||||
|
Reference in New Issue
Block a user