From 6187eb3e4eb776ae19b9040e2bcdd95443dc59e4 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Fri, 11 Feb 2022 14:19:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Communicate=20why=20Fix=20My=20V?= =?UTF-8?q?alet=20is=20disabled=20(#135)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A quick 5-minute fix. As raised in #135, it is not super obvious why Fix My Valet might be disabled. From now on, Fix My Valet is now always enabled, but it might throw up an alert if the required formula is missing. --- phpmon/Domain/Menu/MainMenu.swift | 5 +++++ phpmon/Domain/Menu/StatusMenu.swift | 17 ++++------------- phpmon/Localizable.strings | 4 ++++ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/phpmon/Domain/Menu/MainMenu.swift b/phpmon/Domain/Menu/MainMenu.swift index 55ec3c1..ec5d1d3 100644 --- a/phpmon/Domain/Menu/MainMenu.swift +++ b/phpmon/Domain/Menu/MainMenu.swift @@ -260,6 +260,11 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate } @objc func fixMyValet() { + if !PhpEnv.shared.availablePhpVersions.contains(PhpEnv.brewPhpVersion) { + Alert.notify(message: "alert.php_formula_missing.title".localized, info: "alert.php_formula_missing.info".localized, style: .warning) + return + } + if !Alert.present( messageText: "alert.fix_my_valet.title".localized, informativeText: "alert.fix_my_valet.info".localized(PhpEnv.brewPhpVersion), diff --git a/phpmon/Domain/Menu/StatusMenu.swift b/phpmon/Domain/Menu/StatusMenu.swift index 15ffb2f..326fdef 100644 --- a/phpmon/Domain/Menu/StatusMenu.swift +++ b/phpmon/Domain/Menu/StatusMenu.swift @@ -97,19 +97,10 @@ class StatusMenu : NSMenu { func addFirstAidAndServicesMenuItems() { let services = NSMenuItem(title: "mi_other".localized, action: nil, keyEquivalent: "") let servicesMenu = NSMenu() - servicesMenu.addItem(HeaderView.asMenuItem(text: "mi_first_aid".localized)) - - if !PhpEnv.shared.availablePhpVersions.contains(PhpEnv.brewPhpVersion) { - servicesMenu.addItem(NSMenuItem( - title: "mi_fix_my_valet_unavailable".localized(PhpEnv.brewPhpVersion), - action: nil, keyEquivalent: "f") - ) - } else { - servicesMenu.addItem(NSMenuItem( - title: "mi_fix_my_valet".localized(PhpEnv.brewPhpVersion), - action: #selector(MainMenu.fixMyValet), keyEquivalent: "") - ) - } + servicesMenu.addItem(NSMenuItem( + title: "mi_fix_my_valet".localized(PhpEnv.brewPhpVersion), + action: #selector(MainMenu.fixMyValet), keyEquivalent: "") + ) servicesMenu.addItem(NSMenuItem( title: "mi_fix_brew_permissions".localized(), diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index 3b1ec19..682a08a 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -208,6 +208,10 @@ problem manually, using your own Terminal app (this just shows you the output)." "alert.php_switch_failed.confirm" = "Yes, run \"Fix My Valet\""; "alert.php_switch_failed.cancel" = "Do Not Run"; +// PHP Formula Missing +"alert.php_formula_missing.title" = "Oops! The `php` formula must be installed for Fix My Valet..."; +"alert.php_formula_missing.info" = "It seems that you do not have the `php` formula installed, which prevents PHP Monitor from running Fix My Valet. Please install it using `brew install php`, restart PHP Monitor and try again."; + // Fix My Valet Started "alert.fix_my_valet.title" = "Having issues? Fix My Valet is ready to commence!"; "alert.fix_my_valet.info" = "This can take a while. Please be patient.\n\nWhen this is done, all other services will be halted and PHP %@ will be linked. You will be able to switch to your desired version of PHP once this operation has completed.\n\n(You'll get another alert once Fix My Valet is done.)";