mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
👌 Improve BetterAlert performance notices
This commit is contained in:
@ -1162,6 +1162,7 @@
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 620;
|
||||
DEBUG = YES;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = phpmon/Info.plist;
|
||||
@ -1187,6 +1188,7 @@
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 620;
|
||||
DEBUG = NO;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = phpmon/Info.plist;
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
import Cocoa
|
||||
|
||||
@available(*, deprecated, message: "Use BetterAlert API instead for 5.1 and above")
|
||||
class Alert {
|
||||
|
||||
public static func present(
|
||||
|
@ -64,6 +64,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
||||
*/
|
||||
override init() {
|
||||
logger.verbosity = .info
|
||||
#if DEBUG
|
||||
logger.verbosity = .performance
|
||||
#endif
|
||||
Log.separator(as: .info)
|
||||
Log.info("PHP MONITOR by Nico Verbruggen")
|
||||
Log.info("Version \(App.version)")
|
||||
|
@ -53,11 +53,14 @@ extension MainMenu {
|
||||
}
|
||||
|
||||
@MainActor private func suggestFixMyValet(failed version: String) {
|
||||
let outcome = Alert.present(
|
||||
messageText: "alert.php_switch_failed.title".localized(version),
|
||||
informativeText: "alert.php_switch_failed.info".localized(version),
|
||||
buttonTitle: "alert.php_switch_failed.confirm".localized,
|
||||
secondButtonTitle: "alert.php_switch_failed.cancel".localized, style: .informational)
|
||||
let outcome = BetterAlert()
|
||||
.withInformation(
|
||||
title: "alert.php_switch_failed.title".localized(version),
|
||||
subtitle: "alert.php_switch_failed.info".localized(version)
|
||||
)
|
||||
.withPrimary(text: "alert.php_switch_failed.confirm".localized)
|
||||
.withSecondary(text: "alert.php_switch_failed.cancel".localized)
|
||||
.didSelectPrimary()
|
||||
if outcome {
|
||||
MainMenu.shared.fixMyValet()
|
||||
}
|
||||
|
@ -263,17 +263,28 @@ 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)
|
||||
BetterAlert()
|
||||
.withInformation(
|
||||
title: "alert.php_formula_missing.title".localized,
|
||||
subtitle: "alert.php_formula_missing.info".localized
|
||||
)
|
||||
.withPrimary(text: "OK")
|
||||
.show()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if !Alert.present(
|
||||
messageText: "alert.fix_my_valet.title".localized,
|
||||
informativeText: "alert.fix_my_valet.info".localized(PhpEnv.brewPhpVersion),
|
||||
buttonTitle: "alert.fix_my_valet.ok".localized,
|
||||
secondButtonTitle: "alert.fix_my_valet.cancel".localized,
|
||||
style: .warning
|
||||
) {
|
||||
|
||||
|
||||
if !BetterAlert()
|
||||
.withInformation(
|
||||
title: "alert.fix_my_valet.title".localized,
|
||||
subtitle: "alert.fix_my_valet.info".localized(PhpEnv.brewPhpVersion)
|
||||
)
|
||||
.withPrimary(text: "alert.fix_my_valet.ok".localized)
|
||||
.withSecondary(text: "alert.fix_my_valet.cancel".localized)
|
||||
.didSelectPrimary()
|
||||
{
|
||||
Log.info("The user has chosen to abort Fix My Valet")
|
||||
return
|
||||
}
|
||||
@ -281,10 +292,14 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
||||
asyncExecution {
|
||||
Actions.fixMyValet()
|
||||
} success: {
|
||||
Alert.notify(
|
||||
message: "alert.fix_my_valet_done.title".localized,
|
||||
info: "alert.fix_my_valet_done.info".localized
|
||||
BetterAlert()
|
||||
.withInformation(
|
||||
title: "alert.fix_my_valet_done.title".localized,
|
||||
subtitle: "alert.fix_my_valet_done.subtitle".localized,
|
||||
description: "alert.fix_my_valet_done.desc".localized
|
||||
)
|
||||
.withPrimary(text: "alert.fix_my_valet.ok".localized)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,4 +65,8 @@ class BetterAlertVC: NSViewController {
|
||||
NSApplication.shared.stopModal(withCode: code)
|
||||
}
|
||||
|
||||
deinit {
|
||||
Log.perf("A BetterAlert has been deinitialized.")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -218,7 +218,8 @@ problem manually, using your own Terminal app (this just shows you the output)."
|
||||
|
||||
// Fix My Valet Done
|
||||
"alert.fix_my_valet_done.title" = "Fix My Valet has completed its operations.";
|
||||
"alert.fix_my_valet_done.info" = "All appropriate services have been stopped and the correct ones restarted, and the latest version of PHP should now be active. You can now try switching to another version of PHP.\n\nIf visiting sites still does not work, you may try running `valet install` again, this can fix a 502 issue (Bad Gateway).\n\nIf Valet is broken and you cannot run `valet install`, you may need to run `composer global update`. Please consult the FAQ on GitHub if you have further issues.";
|
||||
"alert.fix_my_valet_done.subtitle" = "All appropriate services have been stopped and the correct ones restarted, and the latest version of PHP should now be active. You can now try switching to another version of PHP.";
|
||||
"alert.fix_my_valet_done.desc" = "If visiting sites still does not work, you may try running `valet install` again, this can fix a 502 issue (Bad Gateway).\n\nIf Valet is broken and you cannot run `valet install`, you may need to run `composer global update`. Please consult the FAQ on GitHub if you have further issues.";
|
||||
|
||||
// Restore Homebrew Permissions
|
||||
"alert.fix_homebrew_permissions.title" = "About \"Restore Homebrew Permissions\"";
|
||||
|
Reference in New Issue
Block a user