mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
👌 Improve initial alert
This commit is contained in:
@ -492,11 +492,11 @@
|
||||
<scene sceneID="y9E-bB-wIG">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="noticeVC" id="hkw-9V-NxP" customClass="BetterAlertVC" customModule="PHP_Monitor" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" misplaced="YES" id="UPH-hV-Naz">
|
||||
<view key="view" id="UPH-hV-Naz">
|
||||
<rect key="frame" x="0.0" y="0.0" width="520" height="212"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<visualEffectView blendingMode="behindWindow" material="underWindowBackground" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="JVG-5w-fPd">
|
||||
<visualEffectView blendingMode="behindWindow" material="popover" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="JVG-5w-fPd">
|
||||
<rect key="frame" x="0.0" y="0.0" width="520" height="212"/>
|
||||
</visualEffectView>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TCp-nS-HN2">
|
||||
@ -628,7 +628,7 @@ DQ
|
||||
</viewController>
|
||||
<customObject id="5Ts-EZ-bJh" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="38" y="1624.5"/>
|
||||
<point key="canvasLocation" x="38" y="1624"/>
|
||||
</scene>
|
||||
<!--Add SiteVC-->
|
||||
<scene sceneID="6JC-H6-u4K">
|
||||
|
@ -49,7 +49,7 @@ class Startup {
|
||||
private func showAlert(for check: EnvironmentCheck) {
|
||||
DispatchQueue.main.async {
|
||||
if check.requiresAppRestart {
|
||||
_ = BetterAlert.make()
|
||||
BetterAlert()
|
||||
.withInformation(
|
||||
title: check.titleText,
|
||||
subtitle: check.subtitleText,
|
||||
@ -57,14 +57,17 @@ class Startup {
|
||||
)
|
||||
.withPrimary(text: check.buttonText, action: { _ in
|
||||
exit(1)
|
||||
}).present()
|
||||
}).show()
|
||||
}
|
||||
|
||||
Alert.notify(
|
||||
message: check.titleText,
|
||||
info: check.descriptionText,
|
||||
style: .critical
|
||||
BetterAlert()
|
||||
.withInformation(
|
||||
title: check.titleText,
|
||||
subtitle: check.subtitleText,
|
||||
description: check.descriptionText
|
||||
)
|
||||
.withPrimary(text: "OK")
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,9 +103,8 @@ class Startup {
|
||||
command: { return !Filesystem.fileExists(Paths.php) },
|
||||
name: "`\(Paths.php)` exists",
|
||||
titleText: "startup.errors.php_binary.title".localized,
|
||||
descriptionText: "startup.errors.php_binary.desc".localized(
|
||||
Paths.php
|
||||
)
|
||||
subtitleText: "startup.errors.php_binary.subtitle".localized,
|
||||
descriptionText: "startup.errors.php_binary.desc".localized(Paths.php)
|
||||
),
|
||||
EnvironmentCheck(
|
||||
command: { return !Shell.pipe("ls \(Paths.optPath) | grep php").contains("php") },
|
||||
|
@ -102,16 +102,19 @@ extension MainMenu {
|
||||
*/
|
||||
private func onEnvironmentFail() {
|
||||
DispatchQueue.main.async { [self] in
|
||||
let close = Alert.present(
|
||||
messageText: "alert.cannot_start.title".localized,
|
||||
informativeText: "alert.cannot_start.info".localized,
|
||||
buttonTitle: "alert.cannot_start.close".localized,
|
||||
secondButtonTitle: "alert.cannot_start.retry".localized
|
||||
)
|
||||
|
||||
if (close) {
|
||||
BetterAlert()
|
||||
.withInformation(
|
||||
title: "alert.cannot_start.title".localized,
|
||||
subtitle: "alert.cannot_start.subtitle".localized,
|
||||
description: "alert.cannot_start.description".localized
|
||||
)
|
||||
.withPrimary(text: "alert.cannot_start.retry".localized)
|
||||
.withSecondary(text: "alert.cannot_start.close".localized, action: { vc in
|
||||
vc.close(with: .alertSecondButtonReturn)
|
||||
exit(1)
|
||||
}
|
||||
})
|
||||
.show()
|
||||
|
||||
Task { await startup() }
|
||||
}
|
||||
|
@ -17,15 +17,16 @@ class BetterAlert {
|
||||
return self.windowController.contentViewController as! BetterAlertVC
|
||||
}
|
||||
|
||||
public static func make() -> BetterAlert {
|
||||
init() {
|
||||
let storyboard = NSStoryboard(name: "Main" , bundle : nil)
|
||||
|
||||
let notice = BetterAlert()
|
||||
notice.windowController = storyboard.instantiateController(
|
||||
self.windowController = storyboard.instantiateController(
|
||||
withIdentifier: "noticeWindow"
|
||||
) as? NSWindowController
|
||||
}
|
||||
|
||||
return notice
|
||||
public static func make() -> BetterAlert {
|
||||
return BetterAlert()
|
||||
}
|
||||
|
||||
public func withPrimary(
|
||||
@ -74,9 +75,25 @@ class BetterAlert {
|
||||
return self
|
||||
}
|
||||
|
||||
public func present() -> NSApplication.ModalResponse {
|
||||
/**
|
||||
Shows the modal and returns a ModalResponse.
|
||||
If you wish to simply show the alert and disregard the outcome, use `show`.
|
||||
*/
|
||||
public func runModal() -> NSApplication.ModalResponse {
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
windowController.window?.makeKeyAndOrderFront(nil)
|
||||
return NSApplication.shared.runModal(for: windowController.window!)
|
||||
}
|
||||
|
||||
/** Shows the modal and returns true if the user pressed the primary button. */
|
||||
public func didSelectPrimary() -> Bool {
|
||||
return self.runModal() == .alertFirstButtonReturn
|
||||
}
|
||||
|
||||
/**
|
||||
Shows the modal and does not return anything.
|
||||
*/
|
||||
public func show() {
|
||||
_ = self.runModal()
|
||||
}
|
||||
}
|
||||
|
@ -234,9 +234,10 @@ problem manually, using your own Terminal app (this just shows you the output)."
|
||||
"alert.php_fpm_broken.info" = "PHP Monitor has determined that there are issues with your PHP-FPM config: it's not pointing to the Valet socket. This will result in 502 Bad Gateway if you visit websites linked via Valet.\n\nYou can usually fix this by running\n`valet install`, which updates your\n PHP-FPM configuration.";
|
||||
|
||||
// PHP Monitor Cannot Start
|
||||
"alert.cannot_start.title" = "PHP Monitor cannot start";
|
||||
"alert.cannot_start.info" = "The issue you were just notified about is keeping PHP Monitor from functioning correctly. Please fix the issue and restart PHP Monitor. After clicking on OK, PHP Monitor will close.\n\nIf you have fixed the issue (or don't remember what the exact issue is) you can click on Retry, which will have PHP Monitor retry the startup checks.";
|
||||
"alert.cannot_start.close" = "Close";
|
||||
"alert.cannot_start.title" = "PHP Monitor cannot start due to a configuration problem";
|
||||
"alert.cannot_start.subtitle" = "The issue you were just notified about is keeping PHP Monitor from functioning correctly.";
|
||||
"alert.cannot_start.description" = "You might not need to quit PHP Monitor and restart it. If you have fixed the issue (or don't remember what the exact issue is) you can click on Retry, which will have PHP Monitor retry the startup checks.";
|
||||
"alert.cannot_start.close" = "Quit";
|
||||
"alert.cannot_start.retry" = "Retry";
|
||||
|
||||
// PHP alias issue
|
||||
@ -262,7 +263,9 @@ You can do this by running `composer global update` in your terminal. After that
|
||||
|
||||
/// 1. PHP binary not found
|
||||
"startup.errors.php_binary.title" = "PHP is not correctly installed";
|
||||
"startup.errors.php_binary.desc" = "You must install PHP via brew. Try running `which php` in Terminal, it should return `%@`. The app will not work correctly until you resolve this issue. (Usually `brew link php` resolves this issue.)";
|
||||
"startup.errors.php_binary.subtitle" = "You must install PHP via Homebrew. The app will not work correctly until you resolve this issue.";
|
||||
"startup.errors.php_binary.desc" = "Usually running `brew link php` in your Terminal will resolve this issue.\n\nTo diagnose what is wrong, you can try running `which php` in your Terminal, it should return `%@`.";
|
||||
|
||||
|
||||
/// 2. PHP not found in /usr/local/opt or /opt/homebrew/opt
|
||||
"startup.errors.php_opt.title" = "PHP is not correctly installed";
|
||||
|
Reference in New Issue
Block a user