mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 12:00:09 +02:00
👌 Better alerts (WIP)
This commit is contained in:
@ -57,9 +57,11 @@ class InterApp {
|
||||
MainMenu.shared.switchToPhpVersion(version)
|
||||
} else {
|
||||
BetterAlert().withInformation(
|
||||
title: "Unsupported version",
|
||||
subtitle: "PHP Monitor can't switch to PHP \(version), as it may not be installed or available."
|
||||
).withPrimary(text: "OK").show()
|
||||
title: "alert.php_switch_unavailable.title".localized,
|
||||
subtitle: "alert.php_switch_unavailable.subtitle".localized(version)
|
||||
).withPrimary(
|
||||
text: "alert.php_switch_unavailable.ok".localized
|
||||
).show()
|
||||
}
|
||||
})
|
||||
]}
|
||||
|
@ -33,7 +33,11 @@ struct Preset: Codable {
|
||||
|
||||
// Apply the PHP version if is considered a valid version
|
||||
if self.version != nil {
|
||||
await switchToPhpVersionIfValid()
|
||||
if await !switchToPhpVersionIfValid() {
|
||||
PresetHelper.rollbackPreset = nil
|
||||
Actions.restartPhpFpm()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Apply the configuration changes first
|
||||
@ -61,30 +65,29 @@ struct Preset: Codable {
|
||||
|
||||
// MARK: - Apply Functionality
|
||||
|
||||
private func switchToPhpVersionIfValid() async {
|
||||
private func switchToPhpVersionIfValid() async -> Bool {
|
||||
if PhpEnv.shared.currentInstall.version.short == self.version! {
|
||||
Log.info("The version we are supposed to switch to is already active.")
|
||||
return
|
||||
return true
|
||||
}
|
||||
|
||||
if PhpEnv.shared.availablePhpVersions.first(where: { $0 == self.version }) != nil {
|
||||
await MainMenu.shared.switchToPhp(self.version!)
|
||||
return
|
||||
return true
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
BetterAlert()
|
||||
.withInformation(
|
||||
title: "PHP version unavailable",
|
||||
subtitle: "You have specified a PHP version (\(version!)) that is unavailable.",
|
||||
description: "Please make sure this version of PHP is installed "
|
||||
+ "and you can switch to it in the dropdown. "
|
||||
+ "Currently supported versions include: "
|
||||
+ "\(PhpEnv.shared.availablePhpVersions.joined(separator: ", "))."
|
||||
BetterAlert().withInformation(
|
||||
title: "alert.php_switch_unavailable.title".localized,
|
||||
subtitle: "alert.php_switch_unavailable.subtitle".localized(version!),
|
||||
description: "alert.php_switch_unavailable.info".localized(
|
||||
version!,
|
||||
PhpEnv.shared.availablePhpVersions.joined(separator: ", ")
|
||||
)
|
||||
.withPrimary(text: "OK")
|
||||
.show()
|
||||
).withPrimary(
|
||||
text: "alert.php_switch_unavailable.ok".localized
|
||||
).show()
|
||||
}
|
||||
return
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,6 +323,18 @@ For optimal support of the latest versions of PHP and proper version switching,
|
||||
|
||||
You can do this by running `composer global update` in your terminal. After that, run `valet install` again. For best results, restart PHP Monitor after that.";
|
||||
|
||||
// PHP version unavailable
|
||||
"alert.php_switch_unavailable.title" = "Unsupported PHP version";
|
||||
"alert.php_switch_unavailable.subtitle" = "PHP Monitor can't switch to PHP %@, as it may not be installed or available. Applying this preset has been cancelled.";
|
||||
"alert.php_switch_unavailable.info" = "Please make sure PHP %@ is installed and you can switch to it in the dropdown. Currently supported versions include PHP: %@.";
|
||||
"alert.php_switch_unavailable.ok" = "OK";
|
||||
|
||||
// Revert
|
||||
"alert.revert_description.title" = "Revert Configuration?";
|
||||
"alert.revert_description.subtitle" = "PHP Monitor can revert to the previous configuration that was active. Here's what will be applied: \n\n%@";
|
||||
"alert.revert_description.ok" = "Revert";
|
||||
"alert.revert_description.cancel" = "Cancel";
|
||||
|
||||
// STARTUP
|
||||
|
||||
/// 0. Architecture mismatch
|
||||
|
Reference in New Issue
Block a user