mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
👌 Cleanup, ensure all tests pass
This commit is contained in:
@ -184,6 +184,7 @@
|
||||
C4F30B09278E1A0E00755FCE /* CustomPrefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C3ED4227834C5200AB15D8 /* CustomPrefs.swift */; };
|
||||
C4F30B0A278E1A1A00755FCE /* ComposerJson.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D89BC52783C99400A02B68 /* ComposerJson.swift */; };
|
||||
C4F30B0B278E203C00755FCE /* MainMenu+Startup.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C3ED402783497000AB15D8 /* MainMenu+Startup.swift */; };
|
||||
C4F319C927B034A500AFF46F /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DEB7D327A5D60B00834718 /* Stats.swift */; };
|
||||
C4F7809C25D80344000DBC97 /* CommandTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F7809B25D80344000DBC97 /* CommandTest.swift */; };
|
||||
C4F780A825D80AE8000DBC97 /* php.ini in Resources */ = {isa = PBXBuildFile; fileRef = C4F780A725D80AE8000DBC97 /* php.ini */; };
|
||||
C4F780AE25D80B37000DBC97 /* ExtensionParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F780AD25D80B37000DBC97 /* ExtensionParserTest.swift */; };
|
||||
@ -1011,6 +1012,7 @@
|
||||
C43A8A2425D9D20D00591B77 /* BrewJsonParserTest.swift in Sources */,
|
||||
C4F780CA25D80B75000DBC97 /* HomebrewPackage.swift in Sources */,
|
||||
C4C8E81C276F54E5003AC782 /* PhpConfigWatcher.swift in Sources */,
|
||||
C4F319C927B034A500AFF46F /* Stats.swift in Sources */,
|
||||
C4F30B04278E16BA00755FCE /* HomebrewService.swift in Sources */,
|
||||
C4AF9F7B2754499000D44ED0 /* Valet.swift in Sources */,
|
||||
C4F780C025D80B6E000DBC97 /* Startup.swift in Sources */,
|
||||
@ -1250,7 +1252,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 590;
|
||||
CURRENT_PROJECT_VERSION = 600;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = phpmon/Info.plist;
|
||||
@ -1275,7 +1277,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 590;
|
||||
CURRENT_PROJECT_VERSION = 600;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = phpmon/Info.plist;
|
||||
|
@ -51,6 +51,9 @@ class Alert {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Notify the user about something by showing an alert.
|
||||
*/
|
||||
public static func notify(message: String, info: String, style: NSAlert.Style = .informational) {
|
||||
_ = present(
|
||||
messageText: message,
|
||||
@ -61,7 +64,11 @@ class Alert {
|
||||
)
|
||||
}
|
||||
|
||||
public static func notifyAbout(error: Error&AlertableError) {
|
||||
/**
|
||||
Notify the user about a particular error (which must be `Alertable`)
|
||||
by showing an alert.
|
||||
*/
|
||||
public static func notify(about error: Error & AlertableError) {
|
||||
let key = error.getErrorMessageKey()
|
||||
_ = present(
|
||||
messageText: "\(key).title".localized,
|
||||
|
@ -20,13 +20,19 @@ extension MainMenu {
|
||||
}
|
||||
|
||||
/**
|
||||
Attempts asynchronous execution of a callback that may throw an Error.
|
||||
Attempts asynchronous execution of a callback that may throw an `Error`.
|
||||
While the callback is being executed, the UI will be marked as busy.
|
||||
|
||||
- Parameter execute: Callback of the work that needs to happen.
|
||||
- Parameter success: Callback that is fired when all was OK.
|
||||
- Parameter failure: Callback that is fired when an Error was thrown.
|
||||
(Preferably, if an `Error` is thrown, it should also be an `AlertableError`,
|
||||
which will make presenting errors easier.)
|
||||
|
||||
- Parameter execute: Required callback of the work that needs to happen.
|
||||
|
||||
- Parameter success: Optional callback that is fired when all was OK.
|
||||
- Parameter failure: Optional callback that is fired when an `Error` was thrown.
|
||||
- Parameter behaviours: Various behaviours that can be tweaked, but usually best left to the default.
|
||||
The default will set the UI to busy, reload PHP info, update the menu bar,
|
||||
and broadcast to the services view that the list has been updated.
|
||||
*/
|
||||
func asyncExecution(
|
||||
_ execute: @escaping () throws -> Void,
|
||||
@ -42,9 +48,11 @@ extension MainMenu {
|
||||
if behaviours.contains(.reloadsPhpInstallation) {
|
||||
PhpEnv.shared.isBusy = true
|
||||
}
|
||||
|
||||
if behaviours.contains(.setsBusyUI) {
|
||||
setBusyImage()
|
||||
}
|
||||
|
||||
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
|
||||
var error: Error? = nil
|
||||
|
||||
@ -60,13 +68,9 @@ extension MainMenu {
|
||||
}
|
||||
|
||||
if behaviours.contains(.updatesMenuBarContents) {
|
||||
// Refresh the entire menu bar menu's contents
|
||||
updatePhpVersionInStatusBar()
|
||||
} else {
|
||||
// We do still need to refresh the icon based on the busy state
|
||||
if behaviours.contains(.setsBusyUI) {
|
||||
refreshIcon()
|
||||
}
|
||||
} else if behaviours.contains(.setsBusyUI) {
|
||||
refreshIcon()
|
||||
}
|
||||
|
||||
if behaviours.contains(.broadcastServicesUpdate) {
|
||||
|
@ -160,9 +160,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
|
||||
style: .warning
|
||||
)
|
||||
} failure: { error in
|
||||
let error = error as! HomebrewPermissionError
|
||||
Alert.notifyAbout(error: error)
|
||||
|
||||
Alert.notify(about: error as! HomebrewPermissionError)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user